/* ==========================================
   GAME OF TEARS — Retro Teal Grid Aesthetic
   ========================================== */

:root {
    --teal: #9DD4C8;
    --teal-dark: #7BBFB2;
    --purple: #B89AD4;
    --purple-dark: #9478B8;
    --pink: #E8A0B4;
    --lime: #D4E157;
    --black: #1a1a1a;
    --cream: #FFF8F0;
    --grid-line: rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    background: var(--teal);
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--black);
}

canvas { display: block; }

/* --- Teal Grid Background --- */
.bg-blobs {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    background-color: var(--teal);
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Decorative shapes */
.blob { position: absolute; pointer-events: none; }
.blob-1 {
    width: 120px; height: 120px;
    top: 10%; right: 8%;
    background: var(--pink);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: spinSlow 20s linear infinite;
}
.blob-2 {
    width: 80px; height: 80px;
    bottom: 15%; left: 6%;
    background: var(--black);
    clip-path: polygon(50% 0%, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0% 50%, 35% 35%);
}
.blob-3 {
    width: 60px; height: 60px;
    top: 70%; right: 12%;
    background: var(--black);
    clip-path: polygon(50% 0%, 65% 35%, 100% 50%, 65% 65%, 50% 100%, 35% 65%, 0% 50%, 35% 35%);
}

/* Floating number decoration */
.blob-1::after {
    content: '01.';
    position: absolute;
    top: -180px; left: -200px;
    font-size: 140px; font-weight: 800;
    color: transparent;
    -webkit-text-stroke: 2px rgba(255,255,255,0.4);
    pointer-events: none;
}

@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ==========================================
   AUTH SCREEN
   ========================================== */
#auth-screen {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.auth-box {
    text-align: center;
    padding: 40px 44px;
    background: var(--cream);
    border-radius: 24px;
    border: 3px solid var(--black);
    width: 420px;
    box-shadow: 8px 8px 0px var(--black);
    position: relative;
}

.auth-logo {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--purple);
    border: 3px solid var(--black);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: var(--black);
}

.auth-box h1 {
    font-size: 34px; font-weight: 800; margin-bottom: 4px;
    color: var(--black);
}

.auth-subtitle { color: #888; font-size: 14px; margin-bottom: 28px; }

.auth-tabs {
    display: flex; gap: 0;
    margin-bottom: 24px;
    border-radius: 14px; overflow: hidden;
    border: 3px solid var(--black);
}

.auth-tab {
    flex: 1; padding: 12px;
    font-size: 14px; font-weight: 700;
    border: none; background: var(--cream);
    color: #888; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
}

.auth-tab.active {
    background: var(--purple);
    color: var(--black);
}

.input-group { position: relative; margin-bottom: 14px; }

.input-icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: var(--purple-dark); font-size: 16px; font-weight: bold;
}

.auth-form input {
    display: block; width: 100%;
    padding: 14px 16px 14px 42px;
    font-size: 15px; font-family: inherit;
    border: 3px solid var(--black);
    border-radius: 14px;
    background: #fff; color: var(--black); outline: none;
    transition: all 0.2s;
}

.auth-form input:focus {
    border-color: var(--purple);
    box-shadow: 4px 4px 0px var(--purple);
}

.auth-submit {
    display: block; width: 100%;
    padding: 14px; margin-top: 8px;
    font-size: 16px; font-weight: 800;
    font-family: inherit;
    border: 3px solid var(--black);
    border-radius: 14px;
    background: var(--lime);
    color: var(--black); cursor: pointer;
    transition: all 0.15s;
    box-shadow: 4px 4px 0px var(--black);
}

.auth-submit:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--black);
}

.auth-submit:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px var(--black);
}

.auth-back {
    display: block; width: 100%;
    padding: 10px; margin-top: 10px;
    font-size: 14px; font-family: inherit;
    border: 2px solid var(--black);
    border-radius: 10px;
    background: transparent; color: #666;
    cursor: pointer;
}
.auth-back:hover { background: rgba(0,0,0,0.05); }

.auth-error { color: #D32F2F; font-size: 13px; margin-top: 14px; min-height: 18px; font-weight: 600; }

/* ==========================================
   MAIN MENU
   ========================================== */
#main-menu {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 1000;
}

.menu-header {
    position: absolute; top: 24px; left: 30px; right: 30px;
    display: flex; justify-content: space-between; align-items: center;
}

.menu-user { display: flex; align-items: center; gap: 12px; }

.user-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--purple);
    border: 3px solid var(--black);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; color: var(--black);
}

#menu-welcome { font-size: 15px; color: var(--black); font-weight: 600; }

#logout-btn {
    padding: 8px 18px; font-size: 13px; font-family: inherit; font-weight: 600;
    border: 2px solid var(--black); border-radius: 10px;
    background: var(--cream); color: var(--black); cursor: pointer;
    transition: all 0.15s;
}
#logout-btn:hover { background: var(--pink); }

.menu-title {
    font-size: 56px; font-weight: 800; margin-bottom: 6px;
    color: var(--black);
    text-shadow: 3px 3px 0 var(--purple);
}

.menu-subtitle { color: #555; font-size: 16px; margin-bottom: 40px; font-weight: 500; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 250px);
    gap: 18px;
}

.menu-card {
    position: relative;
    padding: 30px 24px;
    background: var(--cream);
    border-radius: 20px;
    border: 3px solid var(--black);
    cursor: pointer; text-align: center;
    transition: all 0.15s;
    box-shadow: 6px 6px 0px var(--black);
    overflow: hidden;
}

.card-glow { display: none; }

.menu-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0px var(--black);
}

.menu-card:active {
    transform: translate(2px, 2px);
    box-shadow: 3px 3px 0px var(--black);
}

.menu-icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px; border-radius: 50%;
    border: 3px solid var(--black);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 800; color: var(--black);
}

.card-uconnect .menu-icon { background: var(--purple); }
.card-games .menu-icon { background: var(--pink); }
.card-practice .menu-icon { background: var(--lime); }
.card-quiz .menu-icon { background: var(--teal-dark); }

.card-uconnect { border-top: 6px solid var(--purple); }
.card-games { border-top: 6px solid var(--pink); }
.card-practice { border-top: 6px solid var(--lime); }
.card-quiz { border-top: 6px solid var(--teal-dark); }

.menu-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; color: var(--black); }
.menu-card p { font-size: 13px; color: #777; }

/* Leaderboard */
.leaderboard {
    margin-top: 36px;
    width: 520px;
    max-width: 90vw;
}

.lb-title {
    font-size: 18px; font-weight: 700;
    color: var(--black); margin-bottom: 12px;
    text-align: center;
}

.lb-list {
    background: var(--cream);
    border: 3px solid var(--black);
    border-radius: 16px;
    box-shadow: 5px 5px 0 var(--black);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
}

.lb-row {
    display: flex; align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-size: 14px;
}

.lb-row:last-child { border-bottom: none; }

.lb-me { background: rgba(212,225,87,0.25); }

.lb-rank {
    width: 36px; font-weight: 700; font-size: 16px;
}

.lb-name {
    flex: 1; font-weight: 600; color: var(--black);
}

.lb-pts {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700; font-size: 15px;
    color: var(--purple-dark);
}

/* ==========================================
   CHARACTER SELECT
   ========================================== */
#uconnect-select {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.select-box {
    text-align: center;
    padding: 36px 44px;
    background: var(--cream);
    border-radius: 24px;
    border: 3px solid var(--black);
    box-shadow: 8px 8px 0px var(--black);
}

.select-box h2 { font-size: 28px; font-weight: 700; margin-bottom: 20px; color: var(--black); }

#character-select, #character-select-row2 {
    display: flex; gap: 10px;
    justify-content: center; margin: 8px 0;
    flex-wrap: wrap;
}

.char-option {
    cursor: pointer; text-align: center;
    padding: 10px 12px; border-radius: 14px;
    border: 3px solid transparent;
    background: #fff;
    transition: all 0.2s; color: #666; font-size: 12px; font-weight: 600;
}
.char-option:hover { border-color: var(--black); transform: translateY(-2px); }
.char-option.selected { border-color: var(--black); background: var(--purple); color: var(--black); box-shadow: 3px 3px 0 var(--black); }

.char-preview {
    width: 44px; height: 44px;
    border-radius: 10px; margin: 0 auto 6px;
    border: 2px solid rgba(0,0,0,0.15);
}

.controls-info { margin-top: 20px; }
.controls-info p { color: #888; font-size: 12px; }
.controls-info b { color: var(--black); }

/* ==========================================
   PRACTICE SECTION
   ========================================== */
#practice-section {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--cream);
    background-image:
        linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 1000; overflow-y: auto; padding: 24px 30px;
}

.practice-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 30px; padding-bottom: 18px;
    border-bottom: 3px solid var(--black);
}

.practice-header h2 { font-size: 28px; font-weight: 800; color: var(--black); }
.header-sub { color: #888; font-size: 14px; }

.back-btn {
    padding: 8px 18px; font-size: 13px; font-weight: 700; font-family: inherit;
    border: 2px solid var(--black); border-radius: 10px;
    background: var(--cream); color: var(--black); cursor: pointer;
    transition: all 0.15s; box-shadow: 3px 3px 0 var(--black);
}
.back-btn:hover { background: var(--purple); transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--black); }

/* Topic Cards */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; max-width: 1000px; margin: 0 auto;
}

.topic-card {
    position: relative;
    padding: 32px 28px;
    background: #fff;
    border-radius: 20px;
    border: 3px solid var(--black);
    cursor: pointer; text-align: center;
    transition: all 0.15s;
    box-shadow: 5px 5px 0px var(--black);
}

.topic-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 8px 8px 0px var(--black);
}

.topic-icon {
    width: 64px; height: 64px;
    margin: 0 auto 18px; border-radius: 50%;
    border: 3px solid var(--black);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800; color: var(--black);
}

.topic-card h3 { font-size: 22px; font-weight: 700; margin-bottom: 8px; color: var(--black); }
.topic-card p { font-size: 14px; color: #777; margin-bottom: 14px; }
.topic-count {
    font-size: 12px; font-weight: 700; color: var(--black);
    background: var(--lime); padding: 4px 14px;
    border-radius: 20px; border: 2px solid var(--black);
    display: inline-block;
}

/* Question Cards */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px; max-width: 1200px; margin: 0 auto;
}

.question-card {
    padding: 20px;
    background: #fff;
    border-radius: 14px;
    border: 2px solid var(--black);
    border-left: 6px solid var(--black);
    cursor: pointer; transition: all 0.15s;
    box-shadow: 3px 3px 0px var(--black);
}

.question-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px var(--black);
}

.question-card { position: relative; }

.delete-q-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    border: 2px solid #BE123C;
    border-radius: 8px;
    background: #FECDD3;
    color: #BE123C;
    font-size: 18px; font-weight: 800;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}

.question-card:hover .delete-q-btn,
.topic-card:hover .delete-q-btn { opacity: 1; }
.delete-q-btn:hover { background: #BE123C; color: #fff; }

.question-card h4 {
    font-size: 16px; font-family: 'JetBrains Mono', monospace;
    color: var(--black); margin: 10px 0 8px; font-weight: 700;
}

.question-card p { font-size: 13px; color: #777; line-height: 1.4; }

/* Difficulty Badges */
.diff-badge {
    display: inline-block; padding: 3px 12px;
    font-size: 10px; font-weight: 800;
    border-radius: 6px; letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 2px solid;
}

.diff-badge.easy { background: #C8F7C5; color: #1B7A1B; border-color: #1B7A1B; }
.diff-badge.medium { background: #FFF3C4; color: #8B6914; border-color: #8B6914; }
.diff-badge.hard { background: #FECDD3; color: #BE123C; border-color: #BE123C; }

/* Challenge Page */
.challenge-body {
    display: grid; grid-template-columns: 1fr 1.5fr;
    gap: 24px; max-width: 1400px; margin: 0 auto;
    height: calc(100vh - 120px);
}

.challenge-left { padding: 20px; overflow-y: auto; }
.challenge-desc { font-size: 16px; color: #444; margin-bottom: 18px; line-height: 1.7; }
.challenge-sig {
    font-size: 14px; color: var(--purple-dark);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 18px; font-weight: 600;
}
.challenge-topic-label { font-size: 13px; color: #888; }

.struct-box {
    background: #F0FFF0;
    border: 3px solid #2E7D32;
    border-radius: 14px; padding: 16px; margin-top: 16px;
    box-shadow: 3px 3px 0 #2E7D32;
}

.struct-box code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px; color: #2E7D32; white-space: pre;
}

.challenge-right { display: flex; flex-direction: column; gap: 10px; }
.editor-label { font-size: 13px; color: #888; font-family: 'JetBrains Mono', monospace; }

.code-editor {
    flex: 1; min-height: 250px;
    background: #1a1a2e;
    border: 3px solid var(--black);
    border-radius: 14px; padding: 18px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px; color: #e0e0e0;
    resize: vertical; outline: none;
    tab-size: 4; line-height: 1.6;
    box-shadow: 4px 4px 0 var(--black);
    transition: all 0.2s;
}

.code-editor:focus {
    border-color: var(--purple);
    box-shadow: 4px 4px 0 var(--purple);
}

.answer-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 18px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    background: #fff;
    border: 3px solid var(--black);
    border-radius: 14px;
    color: var(--black);
    outline: none;
    box-shadow: 4px 4px 0 var(--black);
    transition: all 0.2s;
}

.answer-input:focus {
    border-color: var(--purple);
    box-shadow: 4px 4px 0 var(--purple);
}

.answer-input::placeholder { color: #aaa; font-weight: 400; }

.answer-preview {
    margin-top: 8px;
    padding: 12px 16px;
    min-height: 40px;
    background: #fff;
    border: 2px dashed var(--purple);
    border-radius: 12px;
    font-size: 18px;
    text-align: center;
    color: var(--black);
}

/* Add Question Card + Form */
.add-question-card {
    border: 3px dashed var(--purple) !important;
    background: rgba(184,154,212,0.08) !important;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--purple-dark);
    border-left-width: 3px !important;
}

.add-question-card:hover {
    background: rgba(184,154,212,0.15) !important;
    border-color: var(--purple-dark) !important;
}

.add-question-card h4 { color: var(--purple-dark) !important; }

.add-form {
    max-width: 600px;
    margin: 20px auto;
    padding: 24px;
    background: #fff;
    border: 3px solid var(--black);
    border-radius: 16px;
    box-shadow: 5px 5px 0 var(--black);
}

.add-form h3 { font-size: 20px; margin-bottom: 16px; color: var(--black); }

.aq-input {
    display: block; width: 100%;
    padding: 10px 14px; margin-bottom: 10px;
    font-size: 14px; font-family: 'JetBrains Mono', monospace;
    border: 2px solid var(--black); border-radius: 10px;
    background: #fff; color: var(--black); outline: none;
}

.aq-input:focus { border-color: var(--purple); box-shadow: 3px 3px 0 var(--purple); }

select.aq-input { font-family: inherit; cursor: pointer; }

.challenge-buttons { display: flex; gap: 10px; }

.btn-check {
    padding: 11px 28px; font-size: 14px; font-weight: 800; font-family: inherit;
    border: 3px solid var(--black); border-radius: 12px;
    background: var(--lime); color: var(--black); cursor: pointer;
    box-shadow: 3px 3px 0 var(--black); transition: all 0.15s;
}
.btn-check:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--black); }

.btn-hint {
    padding: 11px 22px; font-size: 14px; font-weight: 700; font-family: inherit;
    border: 3px solid var(--black); border-radius: 12px;
    background: #FFF3C4; color: var(--black); cursor: pointer;
    box-shadow: 3px 3px 0 var(--black); transition: all 0.15s;
}
.btn-hint:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--black); }

.btn-solution {
    padding: 11px 22px; font-size: 14px; font-weight: 700; font-family: inherit;
    border: 3px solid var(--black); border-radius: 12px;
    background: var(--purple); color: var(--black); cursor: pointer;
    box-shadow: 3px 3px 0 var(--black); transition: all 0.15s;
}
.btn-solution:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--black); }

.result-badge {
    display: inline-block; padding: 8px 24px;
    font-size: 15px; font-weight: 800;
    border-radius: 10px; margin-bottom: 12px;
    letter-spacing: 2px; border: 3px solid;
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.result-badge.correct { background: #C8F7C5; color: #1B7A1B; border-color: #1B7A1B; box-shadow: 3px 3px 0 #1B7A1B; }
.result-badge.wrong { background: #FECDD3; color: #BE123C; border-color: #BE123C; box-shadow: 3px 3px 0 #BE123C; }

.ai-result {
    background: #fff; border: 2px solid var(--black);
    border-radius: 14px; padding: 16px;
    max-height: 200px; overflow-y: auto;
    box-shadow: 3px 3px 0 var(--black);
}

.ai-loading { color: #888; font-style: italic; }
.ai-response { color: #444; font-size: 14px; line-height: 1.7; }
.ai-response code { background: #F3E8FF; padding: 2px 7px; border-radius: 4px; color: var(--purple-dark); font-family: 'JetBrains Mono', monospace; }
.ai-response strong { color: var(--black); }
.ai-error { color: #BE123C; font-weight: 600; }

.hint-box {
    background: #FFF3C4; border: 2px solid #8B6914;
    border-radius: 14px; padding: 14px; color: #5D4E00; font-size: 14px;
    box-shadow: 3px 3px 0 #8B6914;
}

.solution-box {
    background: #F0FFF0; border: 2px solid #2E7D32;
    border-radius: 14px; padding: 14px; max-height: 200px; overflow-y: auto;
    box-shadow: 3px 3px 0 #2E7D32;
}

.solution-box code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px; color: #2E7D32; white-space: pre;
}

/* ==========================================
   PLACEHOLDER PAGE
   ========================================== */
#placeholder-page {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.placeholder-content { text-align: center; }
.placeholder-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-content h2 { font-size: 32px; font-weight: 800; margin-bottom: 12px; color: var(--black); }
.placeholder-content p { color: #777; margin-bottom: 28px; }
.placeholder-content .auth-submit { width: 220px; margin: 0 auto; }

/* ==========================================
   CHESS
   ========================================== */
#games-section {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--cream);
    background-image:
        linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 1000; overflow-y: auto; padding: 24px 30px;
}

.chess-header {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 520px; margin: 0 auto 10px;
}

.chess-turn { font-size: 16px; font-weight: 700; }

.chess-player-bar {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 520px; margin: 0 auto;
    padding: 10px 16px;
    background: #fff; border: 3px solid var(--black);
    border-radius: 12px; box-shadow: 3px 3px 0 var(--black);
    font-weight: 600; font-size: 15px;
}

.chess-player-bar.opp { margin-bottom: 10px; }
.chess-player-bar.mine { margin-top: 10px; }

.chess-timer-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px; font-weight: 800;
    padding: 4px 14px; border-radius: 8px;
    background: rgba(0,0,0,0.06);
    border: 2px solid var(--black);
}

.timer-active {
    background: var(--lime) !important;
    border-color: var(--black) !important;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    max-width: 520px; margin: 0 auto;
    border: 3px solid var(--black);
    border-radius: 4px;
    box-shadow: 5px 5px 0 var(--black);
    overflow: hidden;
}

.chess-sq {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
}

.sq-light { background: #F0D9B5; }
.sq-dark { background: #B58863; }

.sq-selected { background: #7FC97F !important; }

.sq-valid::after {
    content: '';
    position: absolute;
    width: 30%; height: 30%;
    border-radius: 50%;
    background: rgba(0,0,0,0.2);
}

.chess-piece {
    font-size: clamp(24px, 5vw, 48px);
    user-select: none;
    line-height: 1;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.piece-white { color: #fff; -webkit-text-stroke: 1px #333; }
.piece-black { color: #333; }

/* ==========================================
   QUIZ
   ========================================== */
#quiz-section {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--cream);
    background-image:
        linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 1000; overflow-y: auto; padding: 24px 30px;
}

.quiz-top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; margin-bottom: 20px;
    background: #fff; border: 3px solid var(--black);
    border-radius: 14px; box-shadow: 4px 4px 0 var(--black);
}

.quiz-quit-btn {
    padding: 8px 18px; font-size: 13px; font-weight: 700; font-family: inherit;
    border: 2px solid #BE123C; border-radius: 10px;
    background: #FECDD3; color: #BE123C; cursor: pointer;
    transition: all 0.15s;
}
.quiz-quit-btn:hover { background: #BE123C; color: #fff; }

.quiz-timer {
    font-size: 28px; font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--black);
    background: var(--lime);
    padding: 4px 16px; border-radius: 10px;
    border: 2px solid var(--black);
}

.quiz-opponent-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; margin-bottom: 20px;
    background: var(--purple); border: 3px solid var(--black);
    border-radius: 14px; box-shadow: 3px 3px 0 var(--black);
    font-weight: 700;
}

.quiz-question-area {
    max-width: 800px; margin: 0 auto;
    padding: 28px;
    background: #fff; border: 3px solid var(--black);
    border-radius: 20px; box-shadow: 5px 5px 0 var(--black);
}

.quiz-question-area h3 {
    font-size: 22px; font-weight: 700;
    margin: 10px 0 14px; color: var(--black);
}

.quiz-result-grid {
    display: flex; flex-direction: column; gap: 12px;
    margin: 24px auto; max-width: 400px;
}

.quiz-stat {
    display: flex; justify-content: space-between;
    padding: 14px 20px;
    background: #fff; border: 3px solid var(--black);
    border-radius: 12px; box-shadow: 3px 3px 0 var(--black);
    font-size: 16px;
}

.quiz-stat.correct { border-color: #1B7A1B; }
.quiz-stat.wrong { border-color: #BE123C; }
.quiz-stat strong { font-size: 20px; }

.quiz-solution-card {
    padding: 16px;
    background: #fff;
    border: 2px solid var(--black);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 3px 3px 0 var(--black);
}

.quiz-solution-card code {
    background: rgba(184,154,212,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

/* ==========================================
   GAME HUD
   ========================================== */
#game-hud { pointer-events: none; }
#game-hud input, #game-hud button { pointer-events: auto; }

#quit-game-btn {
    position: fixed; top: 16px; left: 20px;
    padding: 8px 18px; font-size: 13px; font-weight: 700; font-family: inherit;
    border: 2px solid #BE123C; border-radius: 10px;
    background: #FECDD3; color: #BE123C; cursor: pointer;
    z-index: 10; pointer-events: auto;
    transition: all 0.15s;
}
#quit-game-btn:hover { background: #BE123C; color: #fff; }

#crosshair {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(255,255,255,0.8);
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
    pointer-events: none; z-index: 10;
}

#player-count {
    position: fixed; top: 16px; right: 20px;
    font-size: 13px; font-weight: 600; color: #fff;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    padding: 6px 16px; border-radius: 10px;
    z-index: 10;
}

#chat-container {
    position: fixed; bottom: 80px; left: 20px;
    width: 380px; z-index: 10;
}

#chat-messages {
    max-height: 200px; overflow-y: auto;
    padding: 8px; display: flex;
    flex-direction: column; gap: 3px;
}

.chat-msg {
    font-size: 13px; padding: 5px 10px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    border-radius: 6px; word-wrap: break-word; color: #fff;
}

.chat-msg .chat-name { font-weight: 600; margin-right: 6px; }

#chat-input {
    display: none; width: 100%;
    padding: 10px 16px; font-size: 14px; font-family: inherit;
    border: 2px solid rgba(255,255,255,0.3); border-radius: 10px;
    background: rgba(0,0,0,0.6); color: #fff; outline: none;
    margin-top: 6px;
}
#chat-input:focus { border-color: var(--purple); }
#chat-input.visible { display: block; }

/* Proximity Voice */
#prox-voice-hud {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    padding: 6px 18px; border-radius: 10px;
    z-index: 30; pointer-events: none;
    display: flex; align-items: center; gap: 8px;
}

#prox-mic-icon { font-size: 11px; font-weight: 700; color: #43e97b; padding: 2px 8px; border-radius: 5px; background: rgba(67,233,123,0.2); }
#prox-mic-icon.muted { color: #f5576c; background: rgba(245,87,108,0.2); }
#prox-voice-status { font-size: 13px; color: #aaa; }

#prox-mic-toggle {
    position: fixed; bottom: 30px; right: 20px;
    padding: 8px 18px; font-size: 13px; font-weight: 700; font-family: inherit;
    border: 2px solid var(--black); border-radius: 10px;
    background: var(--lime); color: var(--black); cursor: pointer;
    z-index: 30; pointer-events: auto;
}
#prox-mic-toggle.muted { background: var(--pink); }

/* Meeting Button */
#meeting-btn {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    padding: 14px 36px; font-size: 17px; font-weight: 800; font-family: inherit;
    border: 3px solid var(--black); border-radius: 14px;
    background: var(--lime); color: var(--black); cursor: pointer;
    z-index: 30; pointer-events: auto;
    box-shadow: 4px 4px 0 var(--black);
    animation: meetPulse 2s infinite;
}
#meeting-btn:hover { transform: translateX(-50%) translate(-2px,-2px); box-shadow: 6px 6px 0 var(--black); }

@keyframes meetPulse {
    0%, 100% { box-shadow: 4px 4px 0 var(--black); }
    50% { box-shadow: 6px 6px 0 var(--black); }
}

/* Meeting Overlay */
#meeting-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: #1a1a2e;
    z-index: 100; display: flex; flex-direction: column;
    pointer-events: auto;
}

#meeting-header {
    display: flex; align-items: center;
    padding: 14px 24px; gap: 16px;
    background: #111;
    border-bottom: 3px solid #333;
}

#meeting-title { font-size: 18px; font-weight: 700; color: #fff; }
#meeting-count { font-size: 13px; color: #888; flex: 1; }

#meeting-leave-btn {
    padding: 8px 22px; font-size: 14px; font-weight: 800; font-family: inherit;
    border: 2px solid #BE123C; border-radius: 10px;
    background: #FECDD3; color: #BE123C; cursor: pointer;
}

#meeting-grid {
    flex: 1; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px; padding: 16px;
    overflow-y: auto; align-content: center;
}

.meeting-tile {
    position: relative; background: #222;
    border-radius: 14px; overflow: hidden;
    aspect-ratio: 16/9; border: 2px solid #444;
}

.meeting-tile video { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }

.meeting-tile .tile-name {
    position: absolute; bottom: 10px; left: 12px;
    font-size: 13px; color: #fff;
    background: rgba(0,0,0,0.6);
    padding: 4px 12px; border-radius: 8px;
}

#meeting-controls {
    display: flex; justify-content: center; gap: 12px;
    padding: 16px; background: #111;
    border-top: 3px solid #333;
}

.meeting-ctrl-btn {
    padding: 11px 28px; font-size: 14px; font-weight: 700; font-family: inherit;
    border: 2px solid var(--black); border-radius: 12px; cursor: pointer; color: var(--black);
    transition: all 0.2s;
}

.meeting-ctrl-btn.on { background: var(--lime); }
.meeting-ctrl-btn.off { background: #555; color: #aaa; border-color: #555; }

/* Pointer Lock Message */
#pointer-lock-msg {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; display: none;
    z-index: 50; cursor: pointer;
    background: rgba(0,0,0,0.2); pointer-events: auto;
}

#pointer-lock-msg span {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px; font-weight: 700;
    color: var(--black);
    background: var(--cream);
    border: 3px solid var(--black);
    padding: 18px 40px; border-radius: 16px;
    box-shadow: 5px 5px 0 var(--black);
}
