@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;600;700;800&family=Prompt:wght@400;600;700;800&display=swap');

:root {
    --primary-color: #00F0FF;
    --secondary-color: #FF007A;
    --accent-yellow: #FFD700;
    --bg-dark: #0F172A;
    --glass-bg: rgba(15, 23, 42, 0.78);
    --glass-border: rgba(255, 255, 255, 0.22);
    --text-light: #F8FAFC;
    --success-green: #00FF66;
    --danger-red: #FF3366;
    --card-bg: rgba(30, 41, 59, 0.92);
    --surface: rgba(10, 18, 36, 0.88);
    --muted: #A8B4C7;
    --radius-lg: 28px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Kanit', sans-serif;
    color: var(--text-light);
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button:focus-visible, input:focus-visible {
    outline: 3px solid rgba(0, 240, 255, 0.75);
    outline-offset: 3px;
}

/* App Layout Container */
#app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background:
        linear-gradient(rgba(4, 9, 24, .16), rgba(4, 9, 24, .58)),
        url('assets/neon-bubble-arena.webp') center / cover no-repeat,
        #07101f;
}

#app-container::after {
    content: '';
    position: absolute;
    inset: -8%;
    z-index: 0;
    pointer-events: none;
    background: conic-gradient(from 180deg at 50% 50%, transparent, rgba(0,240,255,.11), transparent 32%, rgba(255,0,122,.1), transparent 65%);
    animation: arenaAurora 16s linear infinite;
}

.ambient-orb {
    position: absolute;
    z-index: 0;
    width: 42vw;
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .18;
    pointer-events: none;
}
.orb-one { background: #00F0FF; top: -25%; left: -10%; }
.orb-two { background: #FF007A; right: -15%; bottom: -30%; }

.visual-fx-layer {
    position: absolute;
    inset: 0;
    z-index: 101;
    overflow: hidden;
    pointer-events: none;
    opacity: .72;
    transition: opacity .5s ease;
}
#app-container.is-playing .visual-fx-layer { opacity: .16; }
.world-bubble {
    position: absolute;
    width: var(--bubble-size, 80px);
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.52);
    background: radial-gradient(circle at 28% 24%, rgba(255,255,255,.92) 0 3%, transparent 12%), radial-gradient(circle at 66% 72%, rgba(255,0,180,.22), transparent 54%), linear-gradient(135deg, rgba(0,240,255,.2), rgba(132,68,255,.08));
    box-shadow: inset -12px -14px 28px rgba(255,0,180,.13), inset 8px 8px 20px rgba(255,255,255,.12), 0 0 30px rgba(0,240,255,.2);
    backdrop-filter: blur(2px);
    animation: worldBubbleFloat var(--float-time, 10s) ease-in-out infinite alternate;
}
.bubble-a { --bubble-size: 92px; --float-time: 11s; left: 5%; top: 14%; }
.bubble-b { --bubble-size: 48px; --float-time: 8s; left: 15%; bottom: 10%; animation-delay: -3s; }
.bubble-c { --bubble-size: 110px; --float-time: 13s; right: 4%; top: 19%; animation-delay: -6s; }
.bubble-d { --bubble-size: 58px; --float-time: 9s; right: 15%; bottom: 9%; animation-delay: -2s; }
.world-spark {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 8px #fff, 0 0 20px #00F0FF;
    animation: sparkTwinkle 2.2s ease-in-out infinite;
}
.spark-a { left: 11%; top: 42%; }
.spark-b { right: 9%; top: 56%; animation-delay: -.8s; }
.spark-c { left: 50%; top: 8%; animation-delay: -1.5s; }

@keyframes arenaAurora { to { transform: rotate(360deg) scale(1.05); } }
@keyframes worldBubbleFloat {
    0% { transform: translate3d(0, 18px, 0) rotate(-5deg) scale(.96); }
    55% { transform: translate3d(18px, -16px, 0) rotate(5deg) scale(1.04); }
    100% { transform: translate3d(-8px, -36px, 0) rotate(-2deg) scale(1); }
}
@keyframes sparkTwinkle { 0%,100% { opacity:.2; transform:scale(.6); } 50% { opacity:1; transform:scale(1.7); } }

/* AR Camera Feed & Canvas Overlay */
#webcam-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 1;
}

#ar-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: auto;
}

/* Top Action Control Buttons Bar */
.top-action-bar {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 101;
    display: flex;
    gap: 12px;
}

.btn-toggle, .btn-record {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px 20px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.btn-toggle:hover, .btn-record:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-3px) scale(1.03);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.35);
}

.btn-record.recording {
    background: linear-gradient(135deg, #FF3366, #FF007A);
    border-color: #FF3366;
    animation: pulseRecord 1.5s infinite;
}

@keyframes pulseRecord {
    0% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.7); }
    70% { box-shadow: 0 0 0 14px rgba(255, 51, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0); }
}

/* Recording Status Badge */
.record-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    right: auto;
    z-index: 101;
    background: rgba(255, 51, 102, 0.95);
    border: 2px solid #FF3366;
    color: white;
    padding: 7px 16px;
    border-radius: 22px;
    font-size: 0.95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(255, 51, 102, 0.5);
}

.rec-dot {
    animation: blinkDot 1s infinite;
}

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

/* Top HUD Bar */
#hud-container {
    position: absolute;
    /* เว้นพื้นที่แถวบนสำหรับปุ่มควบคุม ไม่ให้ทับคอมโบและเวลา */
    top: 84px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 980px;
    display: none;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

#app-container.is-playing #hud-container { animation: hudDrop .55s cubic-bezier(.2,.8,.2,1) both; }
@keyframes hudDrop {
    from { opacity: 0; transform: translate(-50%, -24px) scale(.96); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.hud-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid var(--glass-border);
    padding: 10px 22px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
}

.hud-label {
    font-size: 0.95rem;
    color: #94A3B8;
    text-transform: uppercase;
    font-weight: 600;
}

.hud-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--primary-color);
}

#score-val {
    color: var(--accent-yellow);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

#combo-val {
    color: var(--secondary-color);
    text-shadow: 0 0 12px rgba(255, 0, 122, 0.5);
}

#timer-val {
    color: var(--primary-color);
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.target-badge {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 2px solid var(--primary-color);
    padding: 12px 28px;
    border-radius: 24px;
    font-size: 1.25rem;
    font-weight: 800;
    color: #FFFFFF;
    box-shadow: 0 10px 35px rgba(0, 240, 255, 0.3);
    animation: pulseBadgeGlow 2s infinite alternate;
}

.game-progress {
    position: absolute;
    z-index: 11;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    display: none;
    background: rgba(255,255,255,.12);
}
.game-progress-fill {
    width: 100%;
    height: 100%;
    transform-origin: left;
    background: linear-gradient(90deg, #00F0FF, #FFD700, #FF007A);
    box-shadow: 0 0 18px rgba(0,240,255,.7);
    transition: width .35s linear;
    background-size: 220% 100%;
    animation: progressEnergy 2.2s linear infinite;
}
@keyframes progressEnergy { to { background-position: -220% 0; } }

.countdown-overlay {
    position: absolute;
    inset: 0;
    z-index: 95;
    display: grid;
    place-content: center;
    text-align: center;
    background: rgba(5, 10, 24, .36);
    backdrop-filter: blur(4px);
    pointer-events: none;
}
.countdown-value {
    font: 800 clamp(6rem, 16vw, 12rem)/.9 'Prompt', sans-serif;
    color: #fff;
    text-shadow: 0 0 55px rgba(0,240,255,.85);
    animation: countdownPop .8s ease both;
}
.countdown-caption { margin-top: 20px; color: #DCE7F5; font-size: 1.15rem; font-weight: 700; }
@keyframes countdownPop { from { opacity: 0; transform: scale(.6); } 45% { opacity: 1; transform: scale(1.08); } to { opacity: 1; transform: scale(1); } }

@keyframes pulseBadgeGlow {
    0% { transform: scale(1); }
    100% { transform: scale(1.03); }
}

/* Gesture & Color Selectors in Menu */
.gesture-selector, .target-selector {
    margin-bottom: 18px;
    background: rgba(15, 23, 42, 0.65);
    padding: 16px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.selector-label {
    font-size: 1rem;
    font-weight: 700;
    color: #CBD5E1;
    display: block;
    margin-bottom: 12px;
}

.selector-btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.btn-color-select {
    font-size: 0.9rem !important;
    padding: 10px 16px !important;
    border-radius: 14px !important;
}

.btn-select {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
    padding: 11px 18px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-select:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.btn-select.active {
    background: linear-gradient(135deg, #00F0FF, #0072FF);
    color: #0F172A;
    border-color: #00F0FF;
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.45);
    transform: translateY(-2px) scale(1.04);
    animation: selectedGlow 2.4s ease-in-out infinite;
}

@keyframes selectedGlow {
    0%,100% { box-shadow: 0 6px 20px rgba(0,240,255,.35); }
    50% { box-shadow: 0 6px 30px rgba(0,240,255,.75), 0 0 0 4px rgba(0,240,255,.08); }
}

/* Hand Tracker Status Bar */
#hand-status-bar {
    position: absolute;
    bottom: 24px;
    left: 24px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hand-status {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 10px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.hand-status.found {
    border-color: var(--success-green);
    color: var(--success-green);
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.3);
}

.hand-status.searching {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
}

.camera-status.warning {
    color: var(--accent-yellow);
}

/* Modals & Screens Overlay */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 50% 0%, rgba(13, 34, 66, .7), rgba(3, 7, 20, .88) 68%),
        url('assets/neon-bubble-arena.webp') center / cover no-repeat;
    background-attachment: fixed;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-card {
    position: relative;
    background: linear-gradient(145deg, rgba(28, 41, 65, .96), rgba(12, 20, 38, .96));
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-lg);
    padding: 34px 38px;
    max-width: 720px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    animation: popIn 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    isolation: isolate;
}

.modal-card::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(115deg, transparent 12%, rgba(0,240,255,.72), transparent 42%, rgba(255,0,122,.66), transparent 78%);
    background-size: 220% 100%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: cardBorderFlow 6s linear infinite;
    pointer-events: none;
}
@keyframes cardBorderFlow { to { background-position: -220% 0; } }

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #DDE8F7;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .04em;
    margin-bottom: 18px;
}
.brand-mark {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: #07101F;
    border-radius: 9px;
    background: linear-gradient(135deg, #00F0FF, #82FFCC);
    box-shadow: 0 0 20px rgba(0,240,255,.35);
}
.eyebrow {
    color: #80ECF5;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.title-main {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, #FFD700 50%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    filter: drop-shadow(0 4px 15px rgba(0, 240, 255, 0.3));
    background-size: 200% auto;
    animation: titleSpectrum 5s linear infinite;
}
@keyframes titleSpectrum { to { background-position: 200% center; } }

.subtitle {
    font-size: 1.1rem;
    color: #94A3B8;
    margin-bottom: 22px;
}

.step-number {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    margin-right: 7px;
    border-radius: 8px;
    color: #06111D;
    background: #77EAF2;
    font-size: .8rem;
}

/* Privacy note — เครื่องห้องคอมใช้ร่วมกัน ครู/ผู้ปกครองต้องเห็นก่อนกดเริ่มว่า
   กล้องและภาพถ่ายไม่ได้ออกจากเครื่องนี้ และล้างได้จากตรงนี้เลย */
.privacy-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    background: rgba(0, 240, 255, 0.06);
    border: 1px solid rgba(0, 240, 255, 0.28);
    border-radius: 18px;
    padding: 11px 16px;
    margin-bottom: 18px;
    text-align: left;
}

.privacy-note .privacy-icon { font-size: 1.15rem; line-height: 1.2; }
.privacy-note p { flex: 1 1 220px; min-width: 0; }
.privacy-note b { display: block; font-size: .92rem; color: var(--primary-color); }
.privacy-note small { display: block; margin-top: 2px; color: var(--muted); font-size: .82rem; line-height: 1.5; }

.btn-clear-local {
    flex-shrink: 0;
    white-space: nowrap;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    padding: 7px 14px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.btn-clear-local:hover {
    color: var(--danger-red);
    border-color: rgba(255, 51, 102, 0.5);
}

.privacy-note .btn-clear-local { margin-left: auto; }

@media (min-width: 821px) {
    #menu-modal .modal-card {
        max-width: 980px;
        display: grid;
        grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
        column-gap: 16px;
    }
    #menu-modal .modal-card > .brand-lockup,
    #menu-modal .modal-card > .eyebrow,
    #menu-modal .modal-card > .title-main,
    #menu-modal .modal-card > .subtitle,
    #menu-modal .modal-card > .instruction-box,
    #menu-modal .modal-card > .privacy-note,
    #menu-modal .modal-card > .btn-group {
        grid-column: 1 / -1;
    }
    #menu-modal .gesture-selector,
    #menu-modal .target-selector { margin-bottom: 14px; }
    #menu-modal .instruction-box { padding: 14px 18px; margin-bottom: 18px; }
    #menu-modal .instruction-box ul { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
    #menu-modal .instruction-box li { align-items: flex-start; margin: 0; }
    #menu-modal .subtitle { margin-bottom: 16px; }
}

/* Save Score Form Card */
.save-score-card {
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--accent-yellow);
    border-radius: 22px;
    padding: 18px 22px;
    margin-bottom: 22px;
    text-align: left;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.2);
}

.save-score-card h4 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent-yellow);
    margin-bottom: 14px;
}

.auto-save-card {
    border-color: rgba(0, 255, 102, .55);
    box-shadow: 0 8px 25px rgba(0, 255, 102, .14);
}
.auto-save-card h4 { color: var(--success-green); }
.auto-save-flex { justify-content: center; text-align: left; }
.auto-save-copy { display: flex; flex-direction: column; gap: 3px; }
.auto-save-copy strong { color: #F8FAFC; font-size: 1rem; }
.auto-save-copy span { color: var(--muted); font-size: .88rem; }

.save-score-flex {
    display: flex;
    align-items: center;
    gap: 18px;
}

.avatar-preview-box {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
    flex-shrink: 0;
}

.avatar-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.save-input-group {
    display: flex;
    gap: 12px;
    flex-grow: 1;
}

.save-input-group input {
    flex-grow: 1;
    background: rgba(30, 41, 59, 0.95);
    border: 2px solid var(--glass-border);
    border-radius: 14px;
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: all 0.2s;
}

.save-input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

/* Leaderboard High Score List */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 6px;
    margin-bottom: 10px;
}

.leaderboard-item {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    transition: transform 0.25s, box-shadow 0.25s;
}

.leaderboard-item:hover {
    transform: translateX(6px);
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.2);
}

.leaderboard-item.rank-1 {
    border: 2px solid var(--accent-yellow);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(15, 23, 42, 0.9));
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
}

.leaderboard-item.rank-2 {
    border: 2px solid #CBD5E1;
    background: linear-gradient(135deg, rgba(203, 213, 225, 0.2), rgba(15, 23, 42, 0.9));
}

.leaderboard-item.rank-3 {
    border: 2px solid #CD7F32;
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(15, 23, 42, 0.9));
}

.rank-num {
    font-size: 1.6rem;
    font-weight: 800;
    min-width: 36px;
    text-align: center;
    color: var(--accent-yellow);
}

.avatar-wrap {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
    flex-shrink: 0;
}

.player-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    flex-grow: 1;
}

.player-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-tag {
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.12);
    padding: 3px 8px;
    border-radius: 8px;
}

.player-meta {
    font-size: 0.85rem;
    color: #94A3B8;
    margin-top: 3px;
}

.player-score {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-yellow);
    text-align: right;
    flex-shrink: 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.score-unit {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94A3B8;
    display: block;
}

.empty-leaderboard {
    padding: 35px;
    color: #94A3B8;
    font-size: 1.05rem;
}

.empty-leaderboard span {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-color);
    display: block;
    margin-bottom: 8px;
}

/* Rules / Instructions Box */
.instruction-box {
    background: rgba(15, 23, 42, 0.65);
    border: 1px dashed rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    padding: 20px 22px;
    margin-bottom: 26px;
    text-align: left;
}

.instruction-box h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.instruction-box ul {
    list-style: none;
}

.instruction-box li {
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.instruction-box li > span { width: 34px; font-size: 1.35rem; flex: 0 0 34px; text-align: center; }
.instruction-box li div { display: flex; flex-direction: column; gap: 1px; }
.instruction-box li small { color: var(--muted); font-size: .82rem; font-weight: 400; }

/* Action Buttons */
.btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, #00F0FF 0%, #0072FF 100%);
    color: #0F172A;
    font-size: 1.2rem;
    font-weight: 800;
    padding: 15px 32px;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: -60% auto -60% -35%;
    width: 22%;
    transform: rotate(18deg);
    background: rgba(255,255,255,.6);
    filter: blur(8px);
    animation: buttonShine 3.8s ease-in-out infinite;
}
@keyframes buttonShine { 0%,38% { left:-35%; } 62%,100% { left:125%; } }
.btn-primary, .btn-secondary, .btn-select, .btn-toggle, .btn-record { min-height: 44px; }
.btn-primary:active, .btn-secondary:active, .btn-select:active, .btn-toggle:active, .btn-record:active { transform: translateY(1px) scale(.99); }

.btn-primary:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0, 240, 255, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-light);
    font-size: 1.2rem;
    font-weight: 700;
    padding: 15px 32px;
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-3px) scale(1.02);
}

/* Score Summary Modal */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.summary-card {
    background: rgba(15, 23, 42, 0.75);
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.summary-card .val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-yellow);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.badge-banner {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--success-green);
    margin-bottom: 22px;
    padding: 12px;
    background: rgba(0, 255, 102, 0.12);
    border: 1px solid rgba(0, 255, 102, 0.3);
    border-radius: 16px;
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.2);
}

/* Review History List */
.history-section {
    text-align: left;
    margin-bottom: 24px;
}

.history-section h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #94A3B8;
    margin-bottom: 14px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 6px;
}

.history-item {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 14px;
    padding: 14px 18px;
    border-left: 5px solid #CBD5E1;
}

.history-item.correct {
    border-left-color: var(--success-green);
}

.history-item.wrong {
    border-left-color: var(--danger-red);
}

.item-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1.05rem;
}

.item-trivia {
    font-size: 0.9rem;
    color: #94A3B8;
    margin-top: 5px;
}

.badge.bg-success {
    color: var(--success-green);
}

.badge.bg-danger {
    color: var(--danger-red);
}

::-webkit-scrollbar {
    width: 7px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

.btn-camera-retry {
    align-self: flex-start;
    border: 1px solid rgba(255,215,0,.45);
    border-radius: 12px;
    padding: 8px 14px;
    background: rgba(15,23,42,.86);
    color: #FFD75A;
    cursor: pointer;
}
.pause-overlay { z-index: 120; }
.pause-card { max-width: 460px; }
.pause-icon {
    width: 70px;
    height: 70px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 22px;
    color: #07111E;
    background: linear-gradient(135deg, #00F0FF, #FFD700);
    font-size: 1.9rem;
    box-shadow: 0 12px 40px rgba(0,240,255,.3);
}
.toast {
    position: absolute;
    z-index: 200;
    left: 50%;
    bottom: 28px;
    max-width: min(90vw, 520px);
    padding: 12px 18px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 14px;
    background: rgba(8,15,29,.92);
    color: #fff;
    box-shadow: 0 16px 40px rgba(0,0,0,.4);
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
    .top-action-bar { top: 12px; right: 12px; gap: 7px; }
    .record-badge { top: 12px; left: 12px; right: auto; }
    .btn-toggle, .btn-record { padding: 9px 11px; border-radius: 13px; }
    .btn-toggle span, .btn-record span { display: none; }
    #hud-container { top: 68px; width: calc(100% - 24px); gap: 7px; }
    .hud-card { padding: 7px 11px; border-radius: 15px; gap: 6px; }
    .hud-label { font-size: .68rem; }
    .hud-value { font-size: 1.25rem; }
    .target-badge { order: 3; position: absolute; top: 59px; left: 50%; transform: translateX(-50%); width: calc(100vw - 24px); max-width: none; padding: 8px 14px; font-size: .86rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: none; }
    #hand-status-bar { left: 12px; bottom: 12px; max-width: calc(100% - 24px); }
    .hand-status { padding: 8px 12px; border-radius: 12px; font-size: .78rem; }
    .modal-overlay { align-items: flex-start; padding: 12px; overflow-y: auto; }
    .modal-card { margin: auto 0; padding: 26px 18px; max-height: none; border-radius: 22px; }
    #menu-modal .modal-card { padding-top: 70px; }
    .gesture-selector, .target-selector { padding: 14px; }
    .selector-btn-group { gap: 8px; }
    .btn-select { flex: 1 1 180px; }
    .btn-color-select { flex: 1 1 105px; }
    .instruction-box { padding: 16px; }
    .btn-group { gap: 10px; }
    .btn-primary, .btn-secondary { width: 100%; padding: 13px 18px; font-size: 1rem; }
    .summary-grid { gap: 8px; }
    .summary-card { padding: 12px 6px; }
    .summary-card .val { font-size: 1.45rem; }
    .save-score-flex, .save-input-group { flex-direction: column; }
    .save-input-group, .save-input-group input { width: 100%; }
    .leaderboard-item { padding: 11px; gap: 9px; }
    .avatar-wrap { width: 44px; height: 44px; }
    .player-meta { font-size: .72rem; }
    .player-score { font-size: 1.15rem; }
}

@media (max-height: 700px) and (min-width: 821px) {
    .modal-card { padding: 24px 32px; }
    .brand-lockup { margin-bottom: 8px; }
    .gesture-selector, .target-selector { margin-bottom: 10px; padding: 10px 16px; }
    .instruction-box { padding: 12px 18px; margin-bottom: 14px; }
    .instruction-box li { margin-bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
