/* 영어 단어 놀이터 메인 사이트·Word Hunt 교사용과 같은 톤: 밝은 바탕, 흰 카드, 보라 그라데이션, 선 아이콘 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #667eea; --secondary: #764ba2;
    --text: #2d3748; --text-light: #718096; --line: #e2e8f0;
    --bg: #f7fafc; --white: #ffffff;
    --ok: #10b981; --ok-dark: #059669; --bad: #ef4444;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.07); --radius: 20px;
}
body {
    font-family: "Segoe UI", "Malgun Gothic", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh;
    background-image: radial-gradient(circle at 12% 0%, rgba(102, 126, 234, .10), transparent 40%),
                      radial-gradient(circle at 92% 8%, rgba(118, 75, 162, .08), transparent 38%);
    background-attachment: fixed;
}
button, input { font-family: inherit; }
[hidden] { display: none !important; }
.ic { width: 1.1em; height: 1.1em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; }

/* ── 상단 바 ── */
.topbar {
    position: sticky; top: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 64px; padding: 0 24px; background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #1a1a2e; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 4px 12px rgba(102, 126, 234, .35); }
.brand-mark .ic { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-title { font-size: 1.12em; font-weight: 800; letter-spacing: -.3px; }
.brand-title em { font-style: normal; font-size: .72em; font-weight: 800; color: #fff; background: var(--secondary); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.brand-sub { font-size: .76em; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #f1f3fb; border: 1px solid var(--line); color: #4c51bf; text-decoration: none; }
.home-btn:hover { background: #e6e9fb; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 20px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ── 상태 요약 ── */
.status { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.status-item { background: var(--white); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid rgba(226, 232, 240, .8); min-width: 0; }
.status-label { display: flex; align-items: center; gap: 6px; font-size: .78em; font-weight: 700; color: var(--text-light); margin-bottom: 4px; }
.status-value { font-size: 1.15em; font-weight: 800; color: #1a1a2e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-value.connected { color: var(--ok-dark); display: inline-flex; align-items: center; gap: 7px; }
.status-value.connected::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); flex-shrink: 0; }
.status-value.disconnected { color: #dc2626; }
#currentRoom.on { font-family: Consolas, monospace; letter-spacing: .12em; color: var(--primary); }

/* ── 단계 카드 ── */
.section { background: var(--white); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); border: 1px solid rgba(226, 232, 240, .8); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.step { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 4px 12px rgba(102, 126, 234, .3); }
.card-head h2 { font-size: 1.15em; font-weight: 800; color: #1a1a2e; letter-spacing: -.3px; }
.card-head p { font-size: .85em; color: var(--text-light); margin-top: 1px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 42px; padding: 0 18px; border-radius: 12px;
    border: 1.5px solid transparent; cursor: pointer; font-size: .92em; font-weight: 800; white-space: nowrap;
    transition: transform .15s, box-shadow .15s, filter .15s, background .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .remove-btn:focus-visible { outline: 3px solid rgba(102, 126, 234, .45); outline-offset: 2px; }
.btn-go { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: 0 4px 14px rgba(102, 126, 234, .32); }
.btn-green { background: linear-gradient(135deg, #34d399, var(--ok-dark)); color: #fff; box-shadow: 0 4px 14px rgba(5, 150, 105, .32); }
.btn-ghost { background: #fff; border-color: #d6dcf5; color: #4c5fc7; }
.btn-ghost:hover:not(:disabled) { background: #f2f4ff; }
.btn-ghost.danger { border-color: #fecaca; color: #dc2626; }
.btn-ghost.danger:hover:not(:disabled) { background: #fef2f2; }
.btn-lg { height: 56px; padding: 0 30px; border-radius: 99px; font-size: 1.08em; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.info-box { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 14px; background: #f5f7ff; color: #4a5568; font-size: .9em; line-height: 1.6; margin-bottom: 14px; }
.info-box .ic { color: var(--primary); margin-top: 2px; }
.info-box--mt { margin: 14px 0 0; }

/* ── 게임방 ── */
.room-info-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; align-items: start; }
.code-label { font-size: .85em; font-weight: 700; color: var(--text-light); }
.room-code-display {
    margin: 6px 0 14px; padding: 18px 10px; border-radius: 18px; text-align: center;
    background: linear-gradient(135deg, #f5f7ff, #f3efff); border: 2px dashed #c3cbf5;
    font-family: Consolas, monospace; font-size: 3.1em; font-weight: 800; letter-spacing: .22em; color: #4c51bf;
}
.game-info-display { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.game-info-display span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: .85em; font-weight: 700; background: #fff7ed; color: #c2410c; }
.game-info-display span + span { background: #f0fdf4; color: #15803d; }
.student-steps { list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.student-steps li { counter-increment: s; display: flex; align-items: center; gap: 10px; font-size: .93em; color: var(--text); }
.student-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: .82em; font-weight: 800; color: var(--primary); background: #eef0ff; }
.room-code-highlight { font-family: Consolas, monospace; font-weight: 800; letter-spacing: .1em; color: var(--primary); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: #fbfcff; }
.qr-title { display: flex; align-items: center; gap: 6px; font-size: .88em; font-weight: 800; color: var(--text-light); }
#qrCode { width: 184px; height: 184px; padding: 8px; background: #fff; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); display: grid; place-items: center; }
#qrCode img, #qrCode canvas { display: block; width: 168px !important; height: 168px !important; }
#qrCode .qr-fallback { font-size: .8em; color: var(--text-light); text-align: center; line-height: 1.5; }
.url-display { width: 100%; padding: 9px 12px; border-radius: 10px; background: #f1f3f9; font-family: Consolas, monospace; font-size: .8em; color: #4a5568; word-break: break-all; text-align: center; }
.qr-box .btn-row { width: 100%; }
.qr-box .btn-row .btn { flex: 1; }

/* ── 단어 ── */
.word-input-section { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 10px; }
input[type="text"] {
    height: 46px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: #f8faff;
    font-size: 1em; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; min-width: 0;
}
input[type="text"]:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(102, 126, 234, .15); }
#wordInput { text-transform: uppercase; }
#wordInput::placeholder { text-transform: none; }
#wordList { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 360px; overflow-y: auto; padding: 2px; }
.word-no-data { grid-column: 1 / -1; padding: 26px 10px; text-align: center; color: var(--text-light); font-size: .9em; background: #f8faff; border: 1.5px dashed var(--line); border-radius: 14px; }
.word-item { display: flex; align-items: center; gap: 9px; padding: 9px 8px 9px 10px; border-radius: 12px; background: #f8faff; border: 1px solid var(--line); min-width: 0; }
.word-item .no { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; font-size: .75em; font-weight: 800; color: var(--primary); background: #eef0ff; }
.word-item .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.word-text { font-weight: 800; color: #1a1a2e; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-meaning { font-size: .82em; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-letter-count { font-size: .72em; font-weight: 800; color: var(--text-light); background: #eceff6; border-radius: 99px; padding: 1px 7px; flex-shrink: 0; }
.remove-btn { width: 28px; height: 28px; display: grid; place-items: center; flex-shrink: 0; border: 0; border-radius: 8px; background: transparent; color: #a0aec0; cursor: pointer; }
.remove-btn:hover { background: #fef2f2; color: #dc2626; }
.word-head-count { margin: 16px 0 10px; font-weight: 800; color: #1a1a2e; }

/* ── 모둠 모니터링 ── */
.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.team-card {
    --tc: #667eea; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 8px; min-width: 0;
    padding: 16px 14px 14px 18px; border-radius: 16px; background: #f8faff; border: 1.5px solid var(--line);
    transition: border-color .3s, background .3s, box-shadow .3s, opacity .3s;
}
.team-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--tc); opacity: .85; }
.team-card[data-team="1"] { --tc: #e11d48; } .team-card[data-team="2"] { --tc: #0d9488; } .team-card[data-team="3"] { --tc: #ea580c; }
.team-card[data-team="4"] { --tc: #4f46e5; } .team-card[data-team="5"] { --tc: #16a34a; } .team-card[data-team="6"] { --tc: #c026d3; }
.team-card[data-team="7"] { --tc: #0891b2; } .team-card[data-team="8"] { --tc: #ca8a04; }
.tc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.team-name { font-size: 1.1em; font-weight: 800; color: var(--tc); }
.tc-status { font-size: .74em; font-weight: 800; color: var(--text-light); background: #eceff6; border-radius: 99px; padding: 2px 9px; white-space: nowrap; }
.tc-score { display: flex; align-items: baseline; gap: 3px; }
.tc-score b { font-family: Consolas, monospace; font-size: 1.8em; font-weight: 800; color: #1a1a2e; line-height: 1; }
.tc-score small { font-size: .85em; font-weight: 700; color: var(--text-light); }
.team-members { display: flex; flex-direction: column; gap: 4px; }
.team-empty-msg { font-size: .84em; color: #a0aec0; }
.member-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 9px; background: rgba(255, 255, 255, .8); border: 1px solid #edf0f6; font-size: .86em; font-weight: 700; min-width: 0; }
.member-item .mn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-item .ms { flex-shrink: 0; font-size: .9em; color: var(--text-light); }
.member-ready { color: var(--ok-dark) !important; }
.member-playing { color: #ea580c !important; }
.member-done { color: #4f46e5 !important; }
.team-card.empty { opacity: .6; }
.team-card.waiting { background: #fff; }
.team-card.waiting .tc-status { background: #fef9c3; color: #a16207; }
.team-card.playing { background: #fff; border-color: var(--tc); box-shadow: 0 8px 22px rgba(0, 0, 0, .07); animation: pulse 2s ease-in-out infinite; }
.team-card.playing .tc-status { background: #fff7ed; color: #ea580c; }
.team-card.completed { background: #f0fdf4; border-color: #86efac; }
.team-card.completed .tc-status { background: #dcfce7; color: var(--ok-dark); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.015); } }

/* ── 결과 ── */
#resultsSection { background: linear-gradient(160deg, #fffbeb, #fff); border-color: #fde68a; }
#resultsSection .step { background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 4px 12px rgba(245, 158, 11, .35); }
.ranking-list { display: flex; flex-direction: column; gap: 8px; }
.ranking-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); font-weight: 800; color: #1a1a2e; }
.ranking-position { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #a0aec0; flex-shrink: 0; }
.ranking-team { flex: 1; font-size: 1.05em; }
.ranking-score { font-family: Consolas, monospace; font-size: 1.1em; color: var(--ok-dark); }
.ranking-item.rank-1 { border-color: #fcd34d; background: #fffbeb; box-shadow: 0 8px 20px rgba(245, 158, 11, .18); }
.rank-1 .ranking-position { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.rank-2 .ranking-position { background: linear-gradient(135deg, #cbd5e1, #94a3b8); }
.rank-3 .ranking-position { background: linear-gradient(135deg, #f0a46b, #c2703d); }

/* ── 확인 모달 · 알림 ── */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; padding: 20px; background: rgba(20, 22, 40, .55); }
.modal-overlay.active { display: flex; }
.modal-content { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 24px 70px rgba(0, 0, 0, .35); animation: pop .25s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-content h3 { padding: 18px 22px 14px; font-size: 1.1em; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.modal-content p { padding: 20px 22px 8px; font-size: .95em; line-height: 1.7; color: var(--text); white-space: pre-line; word-break: keep-all; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1.5px solid #eef0f6; }
.modal-btn-confirm.danger { background: linear-gradient(135deg, #f87171, #dc2626); box-shadow: 0 4px 14px rgba(220, 38, 38, .3); }
.notification {
    position: fixed; top: 80px; right: 20px; z-index: 1000; display: flex; align-items: center; gap: 10px; max-width: min(380px, calc(100vw - 40px));
    padding: 13px 18px; border-radius: 14px; background: #fff; border: 1px solid #a7f3d0; color: var(--text); font-size: .92em; font-weight: 700;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .12); animation: slideIn .3s ease;
}
.notification .ic { color: var(--ok-dark); }
.notification--error { border-color: #fecaca; }
.notification--error .ic { color: #dc2626; }
.notification--warning { border-color: #fde68a; }
.notification--warning .ic { color: #d97706; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

@media (max-width: 960px) {
    .team-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
    .status { grid-template-columns: repeat(2, 1fr); }
    .room-info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .topbar { padding: 0 14px; }
    .brand-sub { display: none; }
    .section { padding: 18px 16px; }
    .word-input-section { grid-template-columns: 1fr 1fr; }
    .word-input-section .btn { grid-column: 1 / -1; }
    .room-code-display { font-size: 2.3em; }
    .team-grid { grid-template-columns: 1fr; }
}
