/* ============================================================
   WIKA — Family Language Learning App
   Main Stylesheet — Duolingo-inspired, dark mode default
   Built for kids ages 7–10, phones → 55" TV
   ============================================================ */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
    --primary:        #58CC02;
    --primary-dark:   #46A302;
    --primary-light:  #89E219;
    --secondary:      #1CB0F6;
    --secondary-dark: #0A91D8;
    --warning:        #FF9600;
    --warning-dark:   #E07800;
    --danger:         #FF4B4B;
    --danger-dark:    #D63030;
    --success:        #58CC02;
    --purple:         #CE82FF;
    --purple-dark:    #A855E0;
    --pink:           #FF86D0;
    --yellow:         #FFC800;
    --teal:           #00E5CC;

    --bg:             #131F24;
    --bg-secondary:   #1A2E35;
    --card:           #1A2E35;
    --card-hover:     #213640;
    --text:           #FFFFFF;
    --text-secondary: #A0B4BE;
    --text-muted:     #607080;
    --border:         #2A3F48;
    --border-light:   #354D58;

    --radius:         16px;
    --radius-sm:      8px;
    --radius-lg:      24px;
    --radius-full:    9999px;

    --shadow:         0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.4);
    --shadow-glow:    0 0 20px rgba(88,204,2,0.3);

    --font:           'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;

    --transition:     all 0.2s ease;
    --transition-slow: all 0.4s ease;

    --bottom-nav-h:   70px;
    --header-h:       60px;
    --top-nav-h:      72px;
}

/* Light mode */
body.light-mode {
    --bg:             #F0F4F8;
    --bg-secondary:   #FFFFFF;
    --card:           #FFFFFF;
    --card-hover:     #F5F5F5;
    --text:           #1A1A2E;
    --text-secondary: #555;
    --text-muted:     #999;
    --border:         #E0E0E0;
    --border-light:   #EAEAEA;
    --shadow:         0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.15);
}


/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--secondary);
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.2rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 600; }

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}


/* ============================================================
   LAYOUT — PAGES
   ============================================================ */
.main-content {
    padding-top: var(--header-h);
    min-height: 100vh;
}

.page {
    display: none;
    padding: 16px 16px 90px;
    max-width: 600px;
    margin: 0 auto;
    min-height: calc(100vh - var(--header-h));
    animation: fadeIn 0.25s ease;
}

.page.active {
    display: block;
}

.section-block {
    margin-bottom: 20px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    flex: 1;
}


/* ============================================================
   APP HEADER (sticky top bar — mobile/tablet)
   ============================================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-brand {
    font-size: 1.4rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.profile-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 14px 6px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    transition: var(--transition);
}

.profile-chip:hover {
    border-color: var(--primary);
    background: var(--card-hover);
}

.profile-chip span:first-child {
    font-size: 1.2rem;
}


/* ============================================================
   TOP NAV — TV / Wide screen only
   ============================================================ */
.nav-top {
    display: none; /* shown via responsive.css */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-nav-h);
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

.nav-top-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 2rem;
}

.brand-icon-img {
    width: 36px;
    height: 36px;
    vertical-align: middle;
}

.brand-name {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-top-links {
    display: flex;
    gap: 8px;
}

.nav-top-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: var(--transition);
    text-decoration: none;
    border: 2px solid transparent;
}

.nav-top-link:hover,
.nav-top-link.active {
    background: rgba(88, 204, 2, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

.nav-top-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
}

.nav-top-profile .profile-avatar {
    font-size: 1.6rem;
}


/* ============================================================
   BOTTOM NAV — Mobile / Tablet
   ============================================================ */
.nav-bottom {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-secondary);
    border-top: 2px solid var(--border);
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
    text-decoration: none;
}

.nav-item .nav-icon {
    font-size: 1.4rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.nav-item .nav-label {
    font-size: 0.6rem;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: scale(1.2);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

.nav-item:hover:not(.active) {
    color: var(--text-secondary);
}

.nav-item:hover .nav-icon {
    transform: scale(1.1);
}


/* ============================================================
   BUTTONS
   ============================================================ */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.btn-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-danger:active,
.btn-success:active,
.btn-warning:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

/* Primary — Green */
.btn-primary {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--primary-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-primary:hover {
    background: linear-gradient(180deg, #9AEA30 0%, var(--primary-light) 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 0 var(--primary-dark);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--primary-dark); }

/* Secondary — Blue */
.btn-secondary {
    background: linear-gradient(180deg, #3EC4FF 0%, var(--secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--secondary-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-secondary:hover {
    background: linear-gradient(180deg, #5CCFFF 0%, #3EC4FF 100%);
    transform: translateY(-1px);
}
.btn-secondary:active { box-shadow: 0 1px 0 var(--secondary-dark); }

/* Danger — Red */
.btn-danger {
    background: linear-gradient(180deg, #FF7070 0%, var(--danger) 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--danger-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-danger:hover {
    background: linear-gradient(180deg, #FF8080 0%, #FF6060 100%);
    transform: translateY(-1px);
}
.btn-danger:active { box-shadow: 0 1px 0 var(--danger-dark); }

/* Success — same as primary */
.btn-success {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--primary-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-success:hover { transform: translateY(-1px); }

/* Warning — Orange */
.btn-warning {
    background: linear-gradient(180deg, #FFB030 0%, var(--warning) 100%);
    color: #fff;
    box-shadow: 0 4px 0 var(--warning-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-warning:hover {
    background: linear-gradient(180deg, #FFC040 0%, #FFB030 100%);
    transform: translateY(-1px);
}

/* Ghost / Outline */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: none;
    min-height: 44px;
}
.btn-outline:hover {
    background: rgba(88,204,2,0.1);
}

/* Small */
.btn-sm {
    min-height: 36px;
    padding: 6px 16px;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

/* Full width */
.full-width,
.btn.full-width,
.btn-primary.full-width,
.btn-secondary.full-width {
    width: 100%;
}

/* Icon button */
.btn-icon {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--card);
    color: var(--text);
    border: 2px solid var(--border);
    font-size: 1rem;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background: var(--card-hover);
    border-color: var(--primary);
    color: var(--primary);
}

/* Back button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--card);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    min-height: 40px;
    box-shadow: none;
    transition: var(--transition);
}
.btn-back:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(88,204,2,0.08);
}

/* Disabled state */
button:disabled,
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}


/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-action-link {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.card-action-link:hover {
    background: rgba(28,176,246,0.1);
}


/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A0B4BE' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(88,204,2,0.15);
    background: var(--bg-secondary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.editable-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: transparent;
    border-color: var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.sticky-actions {
    position: sticky;
    bottom: 80px;
    background: var(--bg);
    padding: 12px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

textarea.form-input {
    height: auto;
    min-height: 120px;
    padding: 14px 16px;
    resize: vertical;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: var(--radius-full);
    transition: var(--transition);
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 4px;
    top: 4px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-label {
    font-size: 1rem;
    font-weight: 600;
}

.setting-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}


/* ============================================================
   PROFILE SELECTOR / PILLS (Home page)
   ============================================================ */
.profile-selector-bar {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}

.profile-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.profile-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    min-width: 72px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.profile-pill:hover {
    border-color: var(--secondary);
    background: rgba(28,176,246,0.08);
}

.profile-pill.active {
    border-color: var(--primary);
    background: rgba(88,204,2,0.12);
    box-shadow: 0 0 0 2px rgba(88,204,2,0.2);
}

.pill-avatar {
    font-size: 1.8rem;
    line-height: 1;
}

.pill-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
}

.add-profile-pill {
    border-style: dashed;
    color: var(--text-muted);
}


/* ============================================================
   QUICK ACTIONS (Home)
   ============================================================ */
.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--radius);
    padding: 14px 8px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    border: none;
    cursor: pointer;
    min-height: 72px;
    transition: var(--transition);
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.2);
}

.quick-action-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.qa-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.qa-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-create { background: linear-gradient(135deg, var(--purple), var(--purple-dark)); box-shadow: 0 4px 0 #8B3FBF; }
.btn-study  { background: linear-gradient(135deg, var(--secondary), var(--secondary-dark)); box-shadow: 0 4px 0 var(--secondary-dark); }
.btn-play   { background: linear-gradient(135deg, var(--primary-light), var(--primary)); box-shadow: 0 4px 0 var(--primary-dark); }
.btn-bonus  { background: linear-gradient(135deg, #FFD700, var(--warning)); box-shadow: 0 4px 0 var(--warning-dark); }


/* ============================================================
   STREAK BANNER
   ============================================================ */
.streak-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #2A1A00, #3D2500);
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    padding: 14px 20px;
}

.streak-fire {
    font-size: 2rem;
    animation: streakFire 1.5s ease infinite;
}

.streak-count {
    font-size: 2rem;
    font-weight: 900;
    color: var(--warning);
    line-height: 1;
}

.streak-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--warning);
}


/* ============================================================
   LEADERBOARD
   ============================================================ */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.leaderboard-item:hover {
    border-color: var(--border-light);
    transform: translateX(4px);
}

/* Podium colors for top 3 */
.leaderboard-item:nth-child(1) {
    background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(255,215,0,0.04));
    border-color: rgba(255,215,0,0.4);
}
.leaderboard-item:nth-child(2) {
    background: linear-gradient(135deg, rgba(192,192,192,0.12), rgba(192,192,192,0.04));
    border-color: rgba(192,192,192,0.4);
}
.leaderboard-item:nth-child(3) {
    background: linear-gradient(135deg, rgba(205,127,50,0.12), rgba(205,127,50,0.04));
    border-color: rgba(205,127,50,0.4);
}

.lb-rank {
    font-size: 1rem;
    font-weight: 900;
    width: 28px;
    text-align: center;
    color: var(--text-muted);
}

.leaderboard-item:nth-child(1) .lb-rank { color: #FFD700; font-size: 1.2rem; }
.leaderboard-item:nth-child(2) .lb-rank { color: #C0C0C0; }
.leaderboard-item:nth-child(3) .lb-rank { color: #CD7F32; }

.lb-avatar {
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    border: 2px solid var(--border);
}

.lb-name {
    flex: 1;
    font-weight: 700;
    font-size: 0.95rem;
}

.lb-xp {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(88,204,2,0.1);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

/* Full leaderboard page */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}


/* ============================================================
   LESSONS LIST (Home)
   ============================================================ */
.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lesson-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.lesson-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 4px 0 0 4px;
}

.lesson-card:hover {
    border-color: var(--primary);
    background: var(--card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.lesson-icon {
    font-size: 2rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.lesson-info {
    flex: 1;
    min-width: 0;
}

.lesson-title {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lesson-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.lesson-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}


/* ============================================================
   STATS GRID (Profile)
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card:nth-child(1)::after { background: var(--primary); }
.stat-card:nth-child(2)::after { background: var(--secondary); }
.stat-card:nth-child(3)::after { background: var(--warning); }
.stat-card:nth-child(4)::after { background: var(--purple); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-icon {
    font-size: 1.4rem;
    margin-bottom: 6px;
    display: block;
}


/* ============================================================
   PROFILE CARD
   ============================================================ */
.profile-card {
    background: linear-gradient(135deg, var(--bg-secondary), var(--card));
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.profile-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--purple));
}

.profile-avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg);
    border: 4px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 12px;
    box-shadow: 0 0 0 4px rgba(88,204,2,0.2);
}

.profile-name-lg {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.profile-level {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.profile-xp-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(88,204,2,0.15);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 4px 14px;
    font-size: 0.85rem;
    font-weight: 800;
    margin-top: 8px;
}


/* ============================================================
   AVATAR GRID (Settings/Profile)
   ============================================================ */
.avatar-grid,
.avatar-selector-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
    max-width: 500px;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    line-height: 1;
}

.avatar-option:hover {
    border-color: var(--secondary);
    background: rgba(28,176,246,0.1);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary);
    background: rgba(88,204,2,0.12);
    box-shadow: 0 0 0 3px rgba(88,204,2,0.25);
    transform: scale(1.12);
}


/* ============================================================
   GAME MODE CARDS
   ============================================================ */
.game-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.game-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text);
    min-height: 110px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.game-mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.04), transparent);
    pointer-events: none;
}

.game-mode-card:hover {
    border-color: var(--primary);
    background: var(--card-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.game-mode-card.selected {
    border-color: var(--primary);
    background: rgba(88,204,2,0.1);
    box-shadow: 0 0 0 2px rgba(88,204,2,0.3), var(--shadow);
}

.gm-icon {
    font-size: 2.4rem;
    line-height: 1;
}

.gm-name {
    font-size: 0.95rem;
    font-weight: 800;
}

.gm-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

/* Game options panel */
.game-options-panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    margin-top: 8px;
}

.mode-toggle-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.mode-toggle-btn {
    flex: 1;
    min-height: 46px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.mode-toggle-btn.active {
    background: rgba(88,204,2,0.12);
    border-color: var(--primary);
    color: var(--primary);
}

.mode-toggle-btn:hover:not(.active) {
    border-color: var(--border-light);
    color: var(--text);
}


/* ============================================================
   FLASHCARD
   ============================================================ */
.flashcard-scene {
    perspective: 1200px;
    margin: 16px 0;
}

.flashcard {
    position: relative;
    width: 100%;
    min-height: 300px;
    cursor: pointer;
    border-radius: var(--radius-lg);
    user-select: none;
}

/* Front visible by default, back hidden */
.flashcard .flashcard-front {
    opacity: 1;
    z-index: 2;
}
.flashcard .flashcard-back {
    opacity: 0;
    z-index: 1;
}

/* Flipped: hide front, show back */
.flashcard.flipped .flashcard-front {
    opacity: 0;
    z-index: 1;
}
.flashcard.flipped .flashcard-back {
    opacity: 1;
    z-index: 2;
}

/* Flip animation using scaleX */
.flashcard.flipping {
    animation: cardFlip 0.5s ease;
}

@keyframes cardFlip {
    0%   { transform: scaleX(1); }
    50%  { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

.flashcard-face {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px 24px;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-lg);
    text-align: center;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.flashcard-front {
    background: linear-gradient(135deg, #1A3A4A, #1A2E35);
    border-color: var(--secondary);
}

.flashcard-front::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(28,176,246,0.08);
    pointer-events: none;
}

.flashcard-back {
    background: linear-gradient(135deg, #1A3A1A, #1F3520);
    border-color: var(--primary);
}

.flashcard-back::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(88,204,2,0.08);
    pointer-events: none;
}

.fc-lang-tag {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.1);
    color: var(--text-secondary);
}

.flashcard-front .fc-lang-tag {
    color: var(--secondary);
    background: rgba(28,176,246,0.15);
}

.flashcard-back .fc-lang-tag {
    color: var(--primary);
    background: rgba(88,204,2,0.15);
}

.fc-word {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.2;
    color: var(--text);
    word-break: break-word;
    max-width: 100%;
}

.fc-tap-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.flashcard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.btn-fc {
    min-height: 52px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.btn-practice {
    background: linear-gradient(180deg, #FF9E9E, var(--danger));
    color: #fff;
    box-shadow: 0 4px 0 var(--danger-dark);
}

.btn-got-it {
    background: linear-gradient(180deg, var(--primary-light), var(--primary));
    color: #fff;
    box-shadow: 0 4px 0 var(--primary-dark);
}

.btn-fc:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

/* Completion screen */
.fc-completion,
.quiz-complete {
    text-align: center;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.completion-emoji,
.complete-emoji {
    font-size: 4rem;
    display: block;
    animation: bounce 0.5s ease;
}

.fc-completion h2,
.quiz-complete h2 {
    font-size: 1.8rem;
    font-weight: 900;
}

.complete-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Language selector row */
.language-selector-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 10px;
}

.lang-selector-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
    padding-bottom: 14px;
    text-align: center;
}

.lang-selector-group {
    min-width: 0;
}

/* Progress bar */
.progress-bar-track {
    height: 8px;
    background: var(--bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 12px 0 4px;
    border: 1px solid var(--border);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}


/* ============================================================
   QUIZ PAGE
   ============================================================ */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.quiz-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.quiz-counter {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.quiz-score-display {
    font-size: 1rem;
    font-weight: 800;
    color: var(--warning);
}

/* Timer bar */
.timer-track {
    height: 10px;
    background: var(--bg);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--danger), var(--warning), var(--primary));
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
    width: 100%;
}

.timer-fill.urgent {
    background: linear-gradient(90deg, var(--danger-dark), var(--danger));
    animation: pulse 0.5s ease infinite;
}

/* Question area */
.question-area {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    border: 2px solid var(--border);
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.question-lang-tag {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary);
    background: rgba(28,176,246,0.12);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.question-text {
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1.2;
    word-break: break-word;
}

.question-image {
    max-height: 150px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* Answer grid */
.answer-grid,
.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.answer-btn,
.quiz-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-align: center;
    padding: 12px;
    line-height: 1.3;
    word-break: break-word;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25);
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}

.answer-btn::before,
.quiz-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.answer-btn:hover:not(:disabled),
.quiz-option:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 0 rgba(0,0,0,0.25);
}

.answer-btn:active:not(:disabled),
.quiz-option:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.answer-btn:disabled,
.quiz-option:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

/* Color variants */
.answer-red    { background: linear-gradient(180deg, #FF7070, var(--danger)); box-shadow: 0 4px 0 var(--danger-dark); }
.answer-blue   { background: linear-gradient(180deg, #3EC4FF, var(--secondary)); box-shadow: 0 4px 0 var(--secondary-dark); }
.answer-yellow { background: linear-gradient(180deg, #FFD840, var(--yellow)); box-shadow: 0 4px 0 #B08C00; }
.answer-yellow { color: #2A2000; text-shadow: none; }
.answer-green  { background: linear-gradient(180deg, var(--primary-light), var(--primary)); box-shadow: 0 4px 0 var(--primary-dark); }

/* Feedback overlay */
.answer-feedback {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    left: 16px;
    right: 16px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--border);
    z-index: 50;
    animation: slideUp 0.25s ease;
}

.feedback-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.feedback-text {
    font-size: 1.1rem;
    font-weight: 800;
}

.feedback-correct {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.answer-feedback.correct {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(88,204,2,0.12), var(--card));
}

.answer-feedback.wrong {
    border-color: var(--danger);
    background: linear-gradient(135deg, rgba(255,75,75,0.12), var(--card));
}

/* Score summary */
.score-summary {
    text-align: center;
}

.score-big {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    margin: 8px 0;
}


/* ============================================================
   TV HOST PAGE
   ============================================================ */
.tv-title {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 8px;
}

.tv-sub {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.tv-big-btn {
    width: 100%;
    min-height: 60px;
    font-size: 1.2rem;
}

.tv-state {
    animation: fadeIn 0.3s ease;
}

.tv-setup-options {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.tv-room-code {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    color: var(--primary);
    text-align: center;
    font-family: 'Courier New', monospace;
    background: var(--bg);
    border: 3px dashed var(--primary);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

/* ============================================================
   ROOMS PAGE
   ============================================================ */

.room-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.room-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.room-code-badge {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: .15em;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

.room-status-badge {
    font-size: .8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.room-waiting .room-status-badge {
    background: rgba(88, 204, 2, .15);
    color: var(--primary);
}

.room-playing .room-status-badge {
    background: rgba(255, 200, 0, .15);
    color: #FFC800;
}

.room-finished .room-status-badge {
    background: rgba(255, 75, 75, .15);
    color: #FF4B4B;
}

.room-card-body {
    margin-bottom: 10px;
    color: var(--text-dim);
}

.room-card-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 16px;
    font-size: .85rem;
}

.qr-code-display {
    display: flex;
    justify-content: center;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius);
    margin: 8px auto;
    width: fit-content;
}

.qr-code-display svg {
    display: block;
}

.qr-url-display {
    text-align: center;
    margin-top: 8px;
}

.qr-label {
    font-size: .85rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.qr-url-text {
    font-size: .9rem;
    color: var(--primary);
    word-break: break-all;
    font-family: 'Courier New', monospace;
}

.tv-lobby-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 768px) {
    .tv-lobby-layout {
        grid-template-columns: 1fr;
    }
}

.tv-qr-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.tv-players-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tv-player-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-full);
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 700;
    animation: slideUp 0.3s ease;
}

.tv-player-chip .player-emoji {
    font-size: 1.2rem;
}

/* Player Grid in Lobby */
#tv-player-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    padding: 8px 0;
}

/* 3D Player Cards in Lobby */
.tv-player-card-3d {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px 14px;
    background: linear-gradient(145deg, var(--card), rgba(255,255,255,0.03));
    border: 2px solid var(--primary);
    border-radius: 16px;
    box-shadow:
        0 6px 0 rgba(0,0,0,0.25),
        0 10px 20px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.1);
    animation: playerPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
    transition: transform 0.2s;
}

.tv-player-card-3d:hover {
    transform: translateY(-4px);
}

.player-avatar-3d {
    font-size: 3rem;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(88,204,2,0.15), rgba(88,204,2,0.05));
    border-radius: 50%;
    box-shadow:
        0 4px 0 rgba(0,0,0,0.15),
        0 6px 12px rgba(0,0,0,0.15),
        inset 0 -2px 4px rgba(0,0,0,0.1),
        inset 0 2px 4px rgba(255,255,255,0.15);
}

.player-name-3d {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

@keyframes playerPop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Game History Cards */
.game-history-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-round {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--primary);
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.history-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
}

.history-medal {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.history-avatar {
    font-size: 1.2rem;
}

.history-name {
    flex: 1;
    font-weight: 700;
    font-size: 0.9rem;
}

.history-pts {
    font-weight: 800;
    color: var(--primary);
    font-size: 0.9rem;
}

/* TV question display */
.tv-question-display {
    text-align: center;
    padding: 24px 16px;
}

.tv-question-big {
    font-size: 2rem;
    font-weight: 900;
    margin: 16px 0 24px;
    color: var(--text);
}

.tv-answers-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* TV Answer Blocks (Kahoot-style on host screen) */
.tv-answer-blocks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 900px;
    margin: 24px auto;
    padding: 0 16px;
}

.tv-answer-block {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    min-height: 70px;
}

.tv-ans-shape {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.tv-ans-text {
    flex: 1;
}

.tv-answer-count-row {
    text-align: center;
    margin-top: 16px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.tv-play-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
}

.tv-q-counter {
    font-size: 1.2rem;
    font-weight: 800;
    white-space: nowrap;
}

.tv-timer-track {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.tv-timer-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 5px;
    transition: width 0.3s linear;
    width: 100%;
}

.btn-quit-game {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.btn-quit-game:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.tv-question-text {
    font-size: 2rem;
    font-weight: 900;
    text-align: center;
    margin: 16px 0 24px;
    color: var(--text);
}

/* ============================================================
   BUZZER PHONE UI
   ============================================================ */

.buzzer-question-strip {
    text-align: center;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.buzzer-button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px;
    height: calc(100vh - 160px);
    max-height: 600px;
}

.buzzer-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s, opacity 0.2s;
    min-height: 120px;
}

.buzzer-btn:active {
    transform: scale(0.95);
}

.buzzer-btn:disabled {
    cursor: not-allowed;
}

.buzzer-red    { background: linear-gradient(180deg, #FF7070, #E53E3E); }
.buzzer-blue   { background: linear-gradient(180deg, #3EC4FF, #3498DB); }
.buzzer-yellow { background: linear-gradient(180deg, #FFD840, #F0B429); color: #2A2000; text-shadow: none; }
.buzzer-green  { background: linear-gradient(180deg, #7CFC00, #58CC02); }

.buz-shape {
    font-size: 3rem;
}

.buz-label {
    font-size: 2rem;
}

/* Buzzer result card */
.buzzer-result-card {
    text-align: center;
    padding: 40px 24px;
    margin: 24px 16px;
    border-radius: 20px;
    background: var(--card);
    border: 2px solid var(--border);
}

.buzzer-result-card.result-correct {
    border-color: var(--primary);
    background: linear-gradient(180deg, rgba(88,204,2,0.1), var(--card));
}

.buzzer-result-card.result-wrong {
    border-color: var(--danger);
    background: linear-gradient(180deg, rgba(229,62,62,0.1), var(--card));
}

.buzzer-result-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 12px;
}

.buzzer-result-text {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.buzzer-points-gained {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 700;
}

.buzzer-total-score {
    font-size: 3rem;
    font-weight: 900;
    display: block;
    margin-top: 12px;
    color: var(--text);
}

.buzzer-home-btn {
    margin-top: 20px;
}

/* Buzzer Play Header (timer + counter) */
.buzzer-play-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.buzzer-q-counter {
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    color: var(--text);
}

.buzzer-timer-track {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.buzzer-timer-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    width: 100%;
}

.buzzer-timer-text {
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
}

/* Buzzer Join Card */
.buzzer-join-card {
    max-width: 400px;
    margin: 0 auto;
    padding: 24px 20px;
    background: var(--card);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.buzzer-brand {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 4px;
}

.buzzer-heading {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 20px;
}

.buzzer-profile-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.buzzer-join-btn {
    margin-top: 8px;
    font-size: 1.1rem;
    padding: 14px;
}

.large-input {
    font-size: 1.4rem;
    letter-spacing: 8px;
    font-weight: 800;
    padding: 14px;
}

/* Buzzer Waiting Card */
.buzzer-waiting-card {
    text-align: center;
    padding: 48px 24px;
}

.buzzer-player-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.buzzer-avatar {
    font-size: 4rem;
}

.buzzer-player-name {
    font-size: 1.5rem;
    font-weight: 900;
}

.waiting-animation {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.dot-pulse {
    font-size: 2rem;
    color: var(--primary);
    animation: dotPulse 1.2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50%      { opacity: 1;   transform: scale(1.2); }
}

.waiting-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.waiting-room-code {
    font-size: 1rem;
    color: var(--text-dim);
}

/* Buzzer State visibility */
.buzzer-state {
    min-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Podium */
.tv-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    margin: 24px auto;
    max-width: 600px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    text-align: center;
}

.podium-crown {
    font-size: 2rem;
}

.podium-avatar {
    font-size: 2.5rem;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.podium-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.podium-score {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
}

.podium-bar {
    width: 100%;
    border-radius: 8px 8px 0 0;
    margin-top: 8px;
}

.podium-bar.bar-1 {
    height: 100px;
    background: linear-gradient(180deg, #FFD700, #B8860B);
}

.podium-bar.bar-2 {
    height: 70px;
    background: linear-gradient(180deg, #C0C0C0, #808080);
}

.podium-bar.bar-3 {
    height: 50px;
    background: linear-gradient(180deg, #CD7F32, #8B5A2B);
}

.tv-score-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tv-score-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 16px;
    border: 1px solid var(--border);
}

.tv-score-pos {
    font-size: 1.2rem;
    font-weight: 900;
    width: 32px;
    color: var(--text-muted);
}

.tv-score-pos.gold   { color: #FFD700; }
.tv-score-pos.silver { color: #C0C0C0; }
.tv-score-pos.bronze { color: #CD7F32; }

.tv-score-name { flex: 1; font-weight: 700; }

.tv-score-pts {
    font-weight: 900;
    color: var(--primary);
}


/* ============================================================
   PHRASE TABLE
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    background: var(--card);
}

.phrase-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.phrase-table th {
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.phrase-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

.phrase-table tbody tr:nth-child(odd) {
    background: rgba(255,255,255,0.02);
}

.phrase-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.005);
}

.phrase-table tbody tr:hover {
    background: rgba(28,176,246,0.06);
}

.phrase-table tbody tr:last-child td {
    border-bottom: none;
}

.phrase-table td input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.phrase-table td input:focus {
    outline: none;
    background: var(--bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(88,204,2,0.15);
}

.col-english  { color: var(--secondary) !important; }
.col-tagalog  { color: var(--primary) !important; }
.col-visaya   { color: var(--purple) !important; }
.col-ilocano  { color: var(--warning) !important; }

.col-actions { width: 80px; text-align: center; }

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 24px;
}

.inline-phrase-form {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.add-phrase-bar {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px dashed var(--border);
}


/* ============================================================
   TAB BAR
   ============================================================ */
.tab-bar {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-align: center;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-btn:hover:not(.active) {
    color: var(--text-secondary);
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

.tab-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 14px;
}


/* ============================================================
   CAMERA / UPLOAD AREA
   ============================================================ */
.camera-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
    min-height: 160px;
}

.camera-upload-area:hover {
    border-color: var(--secondary);
    background: rgba(28,176,246,0.04);
}

.upload-icon {
    font-size: 3rem;
    display: block;
}

.upload-hint {
    font-weight: 700;
    color: var(--text);
}

.upload-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.image-preview-container {
    position: relative;
    margin-top: 12px;
}

.camera-preview {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--border);
}

.ai-suggestion-card {
    background: linear-gradient(135deg, rgba(206,130,255,0.08), rgba(28,176,246,0.08));
    border: 2px solid rgba(206,130,255,0.3);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ai-icon {
    font-size: 2.5rem;
    display: block;
}

/* Generated phrases preview */
.generated-preview {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}

.phrases-preview-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 14px;
}

.phrase-preview-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 8px;
    align-items: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.8rem;
}

.phrase-cell {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.phrase-cell:nth-child(1) { color: var(--secondary); }
.phrase-cell:nth-child(2) { color: var(--primary); }
.phrase-cell:nth-child(3) { color: var(--purple); }
.phrase-cell:nth-child(4) { color: var(--warning); }


/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-green   { background: rgba(88,204,2,0.15);   color: var(--primary); }
.badge-blue    { background: rgba(28,176,246,0.15);  color: var(--secondary); }
.badge-orange  { background: rgba(255,150,0,0.15);   color: var(--warning); }
.badge-red     { background: rgba(255,75,75,0.15);   color: var(--danger); }
.badge-purple  { background: rgba(206,130,255,0.15); color: var(--purple); }
.badge-yellow  { background: rgba(255,200,0,0.15);   color: var(--yellow); }


/* ============================================================
   BONUS GAMES PAGE
   ============================================================ */
.bonus-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.bonus-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    color: var(--text);
    min-height: 120px;
    box-shadow: var(--shadow);
}

.bonus-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.bonus-card:nth-child(1) { border-color: rgba(255,200,0,0.4); background: linear-gradient(135deg, rgba(255,200,0,0.06), var(--card)); }
.bonus-card:nth-child(2) { border-color: rgba(206,130,255,0.4); background: linear-gradient(135deg, rgba(206,130,255,0.06), var(--card)); }
.bonus-card:nth-child(3) { border-color: rgba(88,204,2,0.4); background: linear-gradient(135deg, rgba(88,204,2,0.06), var(--card)); }
.bonus-card:nth-child(4) { border-color: rgba(255,134,208,0.4); background: linear-gradient(135deg, rgba(255,134,208,0.06), var(--card)); }

.bonus-icon { font-size: 2.4rem; }
.bonus-name { font-size: 0.95rem; font-weight: 800; }
.bonus-desc { font-size: 0.72rem; color: var(--text-muted); }

/* Bonus game play header */
.bonus-play-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.bonus-game-title {
    font-size: 1.2rem;
    font-weight: 800;
    flex: 1;
}
.bonus-game-score {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Progress indicator */
.bonus-progress {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 600;
}

/* Bonus game panels */
.bonus-game-panel {
    text-align: center;
}

/* Options grid (shared by all game types) */
.bonus-options-grid,
.flag-answer-grid,
.picture-answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Individual option button */
.bonus-option {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}
.bonus-option:hover:not(:disabled) {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.bonus-option:disabled {
    cursor: default;
    opacity: 0.85;
}
.bonus-option.animate-correct {
    background: rgba(88, 204, 2, 0.2);
    border-color: #58cc02;
    color: #58cc02;
}
.bonus-option.animate-wrong {
    background: rgba(255, 75, 75, 0.2);
    border-color: #ff4b4b;
    color: #ff4b4b;
}

/* Rebus display */
.rebus-pre {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.4;
    margin: 20px auto;
    white-space: pre-wrap;
}
.rebus-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 16px;
}
.rebus-answer-area {
    max-width: 400px;
    margin: 0 auto;
}
.rebus-feedback {
    margin-top: 10px;
    font-weight: 700;
    font-size: 1rem;
}
.feedback-correct { color: #58cc02; }
.feedback-wrong   { color: #ff4b4b; }

/* Flag display */
.flag-display {
    margin: 20px auto;
    text-align: center;
}
.flag-image {
    max-width: 280px;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    display: block;
    margin: 0 auto;
}

/* Picture display */
.picture-image {
    max-width: 280px;
    max-height: 200px;
    border-radius: var(--radius);
    margin: 16px auto;
    display: block;
    object-fit: cover;
}

/* 4 Pics grid */
.four-pics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-width: 320px;
    margin: 16px auto;
}
.four-pics-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface);
}

/* Results screen */
.bonus-results {
    text-align: center;
    padding: 30px 20px;
}
.results-medal {
    font-size: 4rem;
    margin-bottom: 12px;
}
.results-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.results-score {
    font-size: 1.2rem;
    color: var(--text-muted);
}
.results-pct {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 8px 0 20px;
}
.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Empty state */
.bonus-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* Content manager */
.content-manager {
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}
.cm-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 16px;
}
.cm-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.cm-status {
    margin-top: 12px;
    font-weight: 600;
    font-size: 0.9rem;
}
.bonus-manage-btn {
    margin-top: 16px;
}


/* ============================================================
   CUSTOM QUIZ BUILDER
   ============================================================ */
.builder-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.builder-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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


/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    opacity: 0.7;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 260px;
}


/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--card) !important;
    color: transparent !important;
    border-color: var(--border) !important;
    pointer-events: none;
    user-select: none;
}

.skeleton * {
    visibility: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255,255,255,0.06),
        transparent
    );
    animation: shimmer 1.5s ease infinite;
}

@keyframes shimmer {
    to { left: 150%; }
}


/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
}

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 20px;
    color: var(--text-secondary);
    font-weight: 600;
}


/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
#toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #2D4A56;
    color: var(--text);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--border);
    max-width: calc(100vw - 40px);
    text-align: center;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#toast.toast-success {
    background: linear-gradient(135deg, #1A3A1A, #223A22);
    border-color: var(--primary);
    color: var(--primary);
}

#toast.toast-error {
    background: linear-gradient(135deg, #3A1A1A, #3A2222);
    border-color: var(--danger);
    color: var(--danger);
}

#toast.toast-info {
    background: linear-gradient(135deg, #1A2A3A, #1A2E40);
    border-color: var(--secondary);
    color: var(--secondary);
}

#toast.toast-warning {
    background: linear-gradient(135deg, #3A2A10, #3A2E1A);
    border-color: var(--warning);
    color: var(--warning);
}

/* On TV (large), toast moves to top */
@media (min-width: 1200px) {
    #toast {
        bottom: auto;
        top: calc(var(--top-nav-h) + 16px);
    }
}


/* ============================================================
   MODAL OVERLAY
   ============================================================ */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

#modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: var(--transition);
    flex-shrink: 0;
    font-family: inherit;
}

.modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.modal-body {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Confirm dialog */
.confirm-icon {
    font-size: 3rem;
    text-align: center;
    display: block;
    margin-bottom: 12px;
}


/* ============================================================
   CONFETTI CONTAINER
   ============================================================ */
#confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 12px;
    height: 12px;
    top: -20px;
    border-radius: 2px;
}


/* ============================================================
   SCORE POPUP (floating +XP)
   ============================================================ */
.score-popup {
    position: fixed;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    pointer-events: none;
    z-index: 9990;
    animation: scorePopup 0.8s ease forwards;
}


/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.profile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.profile-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    border: 1px solid var(--border);
}

.profile-list-avatar {
    font-size: 1.6rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.profile-list-info {
    flex: 1;
}

.profile-list-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.profile-list-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-list-actions {
    display: flex;
    gap: 6px;
}

/* New profile form */
.new-profile-form {
    background: linear-gradient(135deg, rgba(88,204,2,0.06), var(--bg));
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 8px;
}

.new-profile-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}


/* ============================================================
   MATCHING GAME
   ============================================================ */
.match-instruction {
    text-align: center;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.95rem;
    margin: 0 0 12px;
    opacity: 0.85;
}

.match-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.match-card {
    min-height: 70px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text);
    word-break: break-word;
}

.match-card:hover {
    border-color: var(--secondary);
    background: rgba(28,176,246,0.06);
}

.match-card.selected {
    border-color: var(--secondary);
    background: rgba(28,176,246,0.15);
    box-shadow: 0 0 0 2px rgba(28,176,246,0.3);
}

.match-card.matched {
    border-color: var(--primary);
    background: rgba(88,204,2,0.1);
    opacity: 0.6;
    pointer-events: none;
}

.match-card.wrong {
    border-color: var(--danger);
    background: rgba(255,75,75,0.1);
    animation: shake 0.3s ease;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden    { display: none !important; }
.invisible { visibility: hidden; }

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

.text-primary   { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-danger    { color: var(--danger); }
.text-muted     { color: var(--text-muted); }
.text-warning   { color: var(--warning); }
.text-purple    { color: var(--purple); }

.font-bold   { font-weight: 700; }
.font-black  { font-weight: 900; }

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }

.w-full { width: 100%; }

.rounded    { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-full { border-radius: var(--radius-full); }

.large-select {
    font-size: 1.1rem;
    height: 60px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}


/* ============================================================
   SPEED ROUND
   ============================================================ */

/* Full-height flex views inside the speed page */
.sr-view {
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0 16px 24px;
    gap: 12px;
}

/* Loading */
.sr-loading-text {
    margin-top: 40%;
    font-size: 1.4rem;
    color: var(--text-secondary);
    animation: pulse 1.2s ease infinite;
}

/* ---- Timer bar ---- */
.sr-timer-track {
    width: 100%;
    height: 10px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
    flex-shrink: 0;
}

.sr-timer-fill {
    height: 100%;
    width: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.05s linear, background-color 0.3s ease;
}

/* ---- Progress ---- */
.sr-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.sr-progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Progress dots strip */
.sr-progress-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    width: 100%;
    padding: 4px 0;
}

.sr-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s;
}

.sr-dot-done {
    background: var(--primary);
}

.sr-dot-current {
    background: var(--secondary);
    box-shadow: 0 0 6px rgba(28,176,246,0.6);
}

/* ---- Statement card ---- */
.sr-statement-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    width: 100%;
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
}

.sr-statement-text {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
}

/* ---- Feedback overlay ---- */
.sr-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    border-radius: var(--radius-lg);
    padding: 12px 28px;
    font-size: 1.4rem;
    font-weight: 800;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.15s;
}

.sr-feedback-hidden {
    opacity: 0;
    pointer-events: none;
}

.sr-feedback-correct {
    color: var(--primary);
    opacity: 1;
    animation: bounce 0.35s ease;
}

.sr-feedback-wrong {
    color: var(--danger);
    opacity: 1;
    animation: shake 0.35s ease;
}

.sr-feedback-text {
    white-space: nowrap;
}

/* ---- TRUE / FALSE buttons ---- */
.sr-answer-row {
    display: flex;
    gap: 16px;
    width: 100%;
    flex: 1;
    align-items: stretch;
    min-height: 100px;
}

.sr-answer-btn {
    flex: 1;
    border: none;
    border-radius: var(--radius-lg);
    font-size: clamp(1.3rem, 5vw, 2rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 6px 0 rgba(0,0,0,0.3);
    padding: 20px 12px;
    min-height: 100px;
    touch-action: manipulation;
}

.sr-answer-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

.sr-btn-true {
    background: linear-gradient(180deg, #89E219, var(--primary));
    color: #fff;
}

.sr-btn-true:hover:not(:disabled) {
    background: linear-gradient(180deg, #9EF020, #68D402);
}

.sr-btn-false {
    background: linear-gradient(180deg, #FF7070, var(--danger));
    color: #fff;
}

.sr-btn-false:hover:not(:disabled) {
    background: linear-gradient(180deg, #FF8080, #E03030);
}

/* Correct answer highlight */
.sr-btn-correct {
    animation: bounce 0.35s ease;
    box-shadow: 0 0 18px rgba(88,204,2,0.6), 0 4px 0 var(--primary-dark) !important;
    background: linear-gradient(180deg, var(--primary-light), var(--primary)) !important;
}

/* Wrong answer highlight */
.sr-btn-wrong {
    animation: shake 0.35s ease;
    box-shadow: 0 0 18px rgba(255,75,75,0.6), 0 4px 0 var(--danger-dark) !important;
    background: linear-gradient(180deg, #FF7070, var(--danger)) !important;
    opacity: 0.7;
}

/* Timeout — correct answer shown */
.sr-btn-timeout {
    box-shadow: 0 0 12px rgba(255,150,0,0.5) !important;
    background: linear-gradient(180deg, #FFBE33, var(--warning)) !important;
    animation: pulse 0.5s ease;
}

.sr-answer-btn:disabled {
    cursor: not-allowed;
}

/* ---- Results view ---- */
.sr-results-view {
    justify-content: flex-start;
    padding-top: 12px;
}

.sr-results-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.sr-results-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 8px;
}

.sr-stars {
    font-size: 2rem;
    margin-bottom: 16px;
}

.sr-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.sr-stat-cell {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sr-stat-full {
    grid-column: 1 / -1;
}

.sr-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.sr-speed-rating {
    font-size: 1.1rem;
    color: var(--yellow);
}

.sr-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sr-max-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 20px;
}

.sr-result-actions {
    display: flex;
    gap: 12px;
    flex-direction: column;
}

.sr-result-actions .btn,
.sr-result-actions .btn-primary,
.sr-result-actions .btn-secondary {
    width: 100%;
}


/* ============================================================
   LESSON CARDS (Home Screen)
   ============================================================ */

.lesson-card {
    display: flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.lesson-card:hover {
    background: var(--card-hover);
    transform: translateY(-1px);
}

.lesson-card-left {
    font-size: 1.5rem;
    margin-right: 12px;
}

.lesson-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lesson-card-title {
    font-weight: 700;
    color: var(--text);
    font-size: 1rem;
}

.lesson-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lesson-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-card-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.lesson-card-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
}


/* ============================================================
   SCORE ROWS (Profile Screen)
   ============================================================ */

.score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

.score-icon {
    font-size: 1.2rem;
}

.score-type {
    flex: 1;
    color: var(--text);
    text-transform: capitalize;
    font-weight: 600;
}

.score-result {
    color: var(--text-secondary);
}

.score-points {
    color: var(--primary);
    font-weight: 700;
}

.score-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}


/* ============================================================
   LEADERBOARD ENHANCEMENTS
   ============================================================ */

.lb-top3 {
    background: var(--card-hover);
}

.lb-streak {
    font-size: 0.8rem;
    color: var(--warning);
    margin-left: 4px;
}

.lb-champion {
    margin-left: 4px;
}

.lb-challenge-btn {
    font-size: 0.7rem;
    padding: 2px 8px;
    margin-left: auto;
}

.btn-xs {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}


/* ============================================================
   DARK MODE TOGGLE
   ============================================================ */

.dark-mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    cursor: pointer;
    user-select: none;
}

.dm-label {
    font-size: 1rem;
    color: var(--text);
}

.dm-toggle {
    width: 52px;
    height: 28px;
    background: var(--border);
    border-radius: var(--radius-full);
    position: relative;
    transition: var(--transition);
}

.dm-toggle.dm-active {
    background: var(--primary);
}

.dm-toggle-knob {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: var(--transition);
}

.dm-toggle.dm-active .dm-toggle-knob {
    left: 27px;
}


/* ============================================================
   GENERATED PHRASES PREVIEW
   ============================================================ */

.phrases-table-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.phrases-table-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.phrases-table-row:nth-child(even) {
    background: var(--bg-secondary);
}

.ai-suggestion-content {
    text-align: center;
    padding: 16px;
}

.ai-topic-name {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.ai-topic-desc {
    color: var(--text-secondary);
    margin-bottom: 16px;
}


/* ============================================================
   STREAK BANNER
   ============================================================ */

.streak-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #FF6B00, #FF9600);
    border-radius: var(--radius);
    color: white;
    font-weight: 700;
}

.streak-fire {
    font-size: 1.5rem;
}

.streak-count {
    font-size: 2rem;
    line-height: 1;
}

.streak-label {
    font-size: 0.9rem;
    opacity: 0.9;
}


/* ============================================================
   LIGHT MODE OVERRIDES
   ============================================================ */

body.light-mode {
    --bg:             #F7F7F7;
    --bg-secondary:   #FFFFFF;
    --card:           #FFFFFF;
    --card-hover:     #F0F0F0;
    --text:           #1A1A1A;
    --text-secondary: #555555;
    --text-muted:     #888888;
    --border:         #E0E0E0;
    --border-light:   #D0D0D0;
    --shadow:         0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.12);
}

body.light-mode .app-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
}

body.light-mode .nav-bottom {
    background: #FFFFFF;
    border-top: 1px solid var(--border);
}

body.light-mode .nav-top {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   STUDY MODE
   ============================================================ */

/* Wider layout for study page */
#page-study {
    max-width: 900px;
}

/* Grid of country cards */
.study-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.study-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}
.study-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.study-card-flag {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    display: block;
    margin: 0 auto 6px;
}

.study-card-name {
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 2px;
}

.study-card-capital {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Modal overlay */
.study-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.study-modal-content {
    background: var(--card);
    border-radius: 20px;
    max-width: 540px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.study-modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
}
.study-modal-close:hover { color: var(--text); }

/* Nav bar (prev/next) */
.study-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.study-nav-bottom {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-bottom: 0;
}
.study-nav-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: inherit;
}
.study-nav-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.study-nav-counter {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

/* Map — small preview */
.study-map {
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    position: relative;
}
.study-map::after {
    content: '🔍 Click to expand';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    z-index: 500;
    pointer-events: none;
}

/* Fullscreen map overlay */
.study-map-fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}
.study-map-fs-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}
.study-map-fs-close {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}
.study-map-fs-close:hover { background: #ff4b4b; color: #fff; border-color: #ff4b4b; }
.study-map-fs-title {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}
.study-map-fs-zoom {
    display: flex;
    gap: 8px;
}
.study-map-fs-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}
.study-map-fs-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.study-map-fs-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Style switcher bar */
.study-map-fs-styles {
    display: flex;
    gap: 6px;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: center;
}

/* Two-column layout container — single col on mobile, side-by-side on desktop */
.study-detail-columns {
    display: block;
}
.study-detail-left,
.study-detail-right {
    /* no special styling on mobile — just stacked */
}

/* Detail header */
.study-detail-header {
    text-align: center;
    margin-bottom: 20px;
}

.study-detail-flag {
    max-width: 220px;
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
    display: block;
    margin: 0 auto 14px;
}

.study-detail-name {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 4px;
}

.study-detail-capital {
    font-size: 1rem;
    color: var(--primary);
    margin: 0 0 4px;
}

.study-detail-region {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* Sections */
.study-detail-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.study-detail-section h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 10px;
}

/* Tips */
.study-tip {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
}
.tip-label {
    font-weight: 700;
    margin-right: 4px;
}

/* Community notes */
.study-note {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.study-note-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.78rem;
}

.study-note-type { font-size: 1rem; }
.study-note-author { font-weight: 700; color: var(--primary); }
.study-note-date { color: var(--text-muted); margin-left: auto; }

.study-note-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
}
.study-note-delete:hover { color: #ff4b4b; }

.study-note-content {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
}

/* Info pills */
.study-info-pills {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}
.study-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Fun fact cards */
.study-fact-card {
    background: var(--surface);
    border-left: 3px solid var(--primary);
    border-radius: 0 10px 10px 0;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 0.88rem;
    line-height: 1.5;
}

/* Trivia list */
.study-trivia-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.88rem;
    line-height: 1.8;
    color: var(--text);
}
.study-trivia-list li {
    margin-bottom: 4px;
}

/* Culture cards */
.study-culture-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ============================================================
   FULLSCREEN MODE — hide all navigation, use full viewport
   ============================================================ */
:fullscreen .nav-top,
:fullscreen .nav-bottom,
:fullscreen .app-header {
    display: none !important;
}

:fullscreen .main-content {
    padding-top: 0 !important;
}

:fullscreen .page {
    max-width: 100%;
    padding-top: 24px;
    padding-bottom: 0;
    min-height: 100vh;
}

:fullscreen #page-buzzer {
    padding: 0;
    max-width: 100%;
}

:fullscreen #page-tv-host {
    padding: 12px 24px;
    max-width: 100%;
}

:fullscreen #page-bonus {
    display: flex !important;
    flex-direction: column;
    min-height: 100vh;
    justify-content: center;
}

:fullscreen #bonus-play-container {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
}

/* ── Flag / Capitals game — center content in fullscreen ── */
:fullscreen #bonus-flags-panel,
:fullscreen #bonus-capitals-panel {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

:fullscreen #flags-game-area,
:fullscreen #capitals-game-area {
    width: 100%;
    max-width: 800px;
}

/* ── TV Host playing — center question + answers ── */
:fullscreen .tv-state[style*="block"] {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 60px);
}

/* ── Buzzer playing state — fill viewport, no scroll ── */
:fullscreen #buzzer-state-playing {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
:fullscreen .buzzer-button-grid {
    flex: 1;
    max-height: none;
    height: auto;
}
:fullscreen .buzzer-question-strip {
    flex-shrink: 0;
}
:fullscreen .buzzer-play-header {
    flex-shrink: 0;
}

/* Webkit (Chrome, Edge, Samsung TV browser) */
:-webkit-full-screen .nav-top,
:-webkit-full-screen .nav-bottom,
:-webkit-full-screen .app-header {
    display: none !important;
}

:-webkit-full-screen .main-content {
    padding-top: 0 !important;
}

:-webkit-full-screen .page {
    max-width: 100%;
    padding-top: 24px;
    padding-bottom: 0;
    min-height: 100vh;
}

:-webkit-full-screen #page-buzzer {
    padding: 0;
    max-width: 100%;
}

:-webkit-full-screen #page-tv-host {
    padding: 12px 24px;
    max-width: 100%;
}

:-webkit-full-screen #page-bonus {
    display: flex !important;
    flex-direction: column;
    min-height: 100vh;
    justify-content: center;
}

:-webkit-full-screen #bonus-play-container {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
}

:-webkit-full-screen #bonus-flags-panel,
:-webkit-full-screen #bonus-capitals-panel {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

:-webkit-full-screen #flags-game-area,
:-webkit-full-screen #capitals-game-area {
    width: 100%;
    max-width: 800px;
}

:-webkit-full-screen .tv-state[style*="block"] {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 60px);
}

:-webkit-full-screen #buzzer-state-playing {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
:-webkit-full-screen .buzzer-button-grid {
    flex: 1;
    max-height: none;
    height: auto;
}
:-webkit-full-screen .buzzer-question-strip {
    flex-shrink: 0;
}
:-webkit-full-screen .buzzer-play-header {
    flex-shrink: 0;
}
