/* AYHEM MATH ARENA - Polished Arcade Game-Show CSS */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Outfit:wght@600;800;900&display=swap');

:root {
    --bg-dark: #0a0a16;
    --bg-card: rgba(255, 255, 255, 0.07);
    --bg-card-border: rgba(255, 255, 255, 0.15);
    --gold: #ffb703;
    --gold-glow: rgba(255, 183, 3, 0.4);
    
    /* Teams */
    --team-blue: #3a86ef;
    --team-blue-glow: rgba(58, 134, 239, 0.5);
    --team-red: #ff0054;
    --team-red-glow: rgba(255, 0, 84, 0.5);
    --team-green: #38b000;
    --team-green-glow: rgba(56, 176, 0, 0.5);
    
    --text-light: #ffffff;
    --text-muted: #a0a5c0;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Fredoka', sans-serif;
}

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

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at center, #1b1035 0%, #0a0a16 100%);
    font-family: var(--font-body);
    color: var(--text-light);
}

/* App Container */
#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header & Scoreboard */
header {
    height: 70px;
    min-height: 70px;
    background: rgba(10, 10, 22, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 2px solid var(--bg-card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 50;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.app-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffb703, #fb8500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 1px;
    filter: drop-shadow(0 2px 8px var(--gold-glow));
}

.round-badge {
    background: linear-gradient(135deg, #7209b7, #4361ee);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(67, 97, 238, 0.4);
}

/* Scoreboard */
.scoreboard {
    display: flex;
    gap: 1rem;
}

.team-score-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    border: 2.5px solid transparent;
    font-size: 1.1rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.team-score-card.t1 {
    border-color: var(--team-blue);
    box-shadow: 0 0 12px var(--team-blue-glow);
}

.team-score-card.t2 {
    border-color: var(--team-red);
    box-shadow: 0 0 12px var(--team-red-glow);
}

.team-score-card.t3 {
    border-color: var(--team-green);
    box-shadow: 0 0 12px var(--team-green-glow);
}

.score-num {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--gold);
}

/* Header Controls */
.header-actions {
    display: flex;
    gap: 0.6rem;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--bg-card-border);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:active {
    transform: scale(0.9);
    background: var(--gold);
    color: #000;
}

/* Screens Container */
main {
    flex: 1;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 70px);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Headings */
.screen-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.screen-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    text-align: center;
}

/* Game Selection Cards */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 1350px;
}

.game-card {
    background: var(--bg-card);
    border: 2.5px solid var(--bg-card-border);
    border-radius: 20px;
    padding: 1.2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    height: 160px;
    justify-content: center;
}

.game-card:active {
    transform: scale(0.96);
    border-color: var(--gold);
    box-shadow: 0 0 25px var(--gold-glow);
}

.game-icon {
    font-size: 2.5rem;
    margin-bottom: 0.4rem;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
}

.game-card-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    color: #fff;
}

.game-card-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Difficulty Buttons */
.difficulty-options {
    display: flex;
    gap: 1.8rem;
    margin-bottom: 2rem;
}

.diff-btn {
    width: 240px;
    height: 120px;
    border-radius: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
}

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

.diff-btn.easy { background: linear-gradient(135deg, #2b9348, #55a630); }
.diff-btn.medium { background: linear-gradient(135deg, #ee9b00, #ca6702); }
.diff-btn.hard { background: linear-gradient(135deg, #ae2012, #9b2226); }

/* Primary Action Buttons */
.btn-primary {
    padding: 1rem 2.8rem;
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, var(--gold), #fb8500);
    color: #0a0a16;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--gold-glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.btn-secondary {
    padding: 0.8rem 2rem;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 50px;
    border: 2px solid var(--bg-card-border);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
}

.btn-secondary:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

/* Game Playing Arena Styling */
.game-play-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0.5rem;
}

.question-box {
    background: rgba(255, 255, 255, 0.08);
    border: 3px solid var(--gold);
    box-shadow: 0 0 20px var(--gold-glow);
    border-radius: 24px;
    padding: 1.5rem 2.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    width: 85%;
    max-width: 1050px;
}

.question-text {
    font-family: var(--font-heading);
    font-size: 3.2rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 1px;
}

/* Answer Cards Grid */
.answers-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem;
    width: 85%;
    max-width: 1050px;
}

.answers-grid.four-col {
    grid-template-columns: repeat(4, 1fr);
}

.answer-btn {
    background: var(--bg-card);
    border: 3px solid var(--bg-card-border);
    border-radius: 22px;
    padding: 1.4rem 1rem;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    cursor: pointer;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
    min-height: 95px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-btn:active {
    transform: scale(0.94);
    border-color: var(--gold);
}

.answer-btn.correct {
    background: rgba(56, 176, 0, 0.4) !important;
    border-color: var(--team-green) !important;
    box-shadow: 0 0 25px var(--team-green-glow);
}

.answer-btn.wrong {
    background: rgba(255, 0, 84, 0.4) !important;
    border-color: var(--team-red) !important;
    box-shadow: 0 0 25px var(--team-red-glow);
}

.answer-btn.trap {
    border-color: #9d4edd;
    box-shadow: 0 0 12px rgba(157, 78, 221, 0.4);
}

/* Game 2: Number Race Styling */
.race-container {
    width: 90%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.race-lane {
    height: 75px;
    background: rgba(255,255,255,0.06);
    border: 2.5px solid var(--bg-card-border);
    border-radius: 40px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.race-lane.t1 { border-color: var(--team-blue); }
.race-lane.t2 { border-color: var(--team-red); }
.race-lane.t3 { border-color: var(--team-green); }

.lane-label {
    position: absolute;
    left: 15px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    z-index: 2;
    background: rgba(0,0,0,0.6);
    padding: 0.3rem 0.8rem;
    border-radius: 16px;
}

.race-character {
    font-size: 2.8rem;
    position: absolute;
    left: 100px;
    transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 3;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
}

.finish-line {
    position: absolute;
    right: 15px;
    top: 0;
    bottom: 0;
    width: 20px;
    background: repeating-linear-gradient(45deg, #fff, #fff 8px, #000 8px, #000 16px);
    z-index: 1;
    border-radius: 4px;
}

/* Game 4: Number Target Grid */
.target-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 70%;
    max-width: 800px;
}

.target-num-btn {
    background: var(--bg-card);
    border: 3px solid var(--bg-card-border);
    border-radius: 20px;
    height: 85px;
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 900;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.target-num-btn.selected {
    border-color: var(--gold);
    background: rgba(255, 183, 3, 0.25);
    box-shadow: 0 0 20px var(--gold-glow);
    transform: scale(1.04);
}

/* Game 5: Memory Match Grid */
.memory-grid {
    display: grid;
    gap: 0.8rem;
    width: 85%;
    max-width: 950px;
}

.memory-card {
    height: 90px;
    background: linear-gradient(135deg, #1d1b38, #2a2656);
    border: 2.5px solid var(--gold);
    border-radius: 16px;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
    text-align: center;
    padding: 0.4rem;
}

.memory-card.flipped {
    background: rgba(255, 255, 255, 0.12);
    border-color: #4cc9f0;
}

.memory-card.matched {
    background: rgba(56, 176, 0, 0.3);
    border-color: var(--team-green);
    opacity: 0.75;
}

/* Game 6: Build The Number */
.build-slots {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.build-slot {
    min-width: 90px;
    height: 70px;
    border: 3px dashed var(--gold);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    background: rgba(255,255,255,0.04);
    padding: 0 0.8rem;
}

.build-pieces-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    max-width: 950px;
}

.build-piece-btn {
    background: var(--bg-card);
    border: 2.5px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 0.9rem 1.6rem;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
}

.build-piece-btn.used {
    opacity: 0.3;
    pointer-events: none;
}

/* Game 7: Mega Tic-Tac-Toe 5x5 */
.ttt-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    width: 460px;
    height: 460px;
}

.ttt-cell {
    background: var(--bg-card);
    border: 2.5px solid var(--bg-card-border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
}

.ttt-cell:active {
    transform: scale(0.95);
}

.ttt-cell.t1-mark { color: var(--team-blue); border-color: var(--team-blue); background: rgba(58, 134, 239, 0.2); }
.ttt-cell.t2-mark { color: var(--team-red); border-color: var(--team-red); background: rgba(255, 0, 84, 0.2); }
.ttt-cell.t3-mark { color: var(--team-green); border-color: var(--team-green); background: rgba(56, 176, 0, 0.2); }

/* Overlays (Scoring Popup, Countdown, Results, Winner) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 12, 0.88);
    backdrop-filter: blur(15px);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.overlay.active {
    display: flex;
    opacity: 1;
}

/* Scoring Popup */
.scoring-modal {
    background: #151428;
    border: 4px solid var(--gold);
    border-radius: 32px;
    padding: 2rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 40px var(--gold-glow);
    width: 90%;
    max-width: 800px;
}

.scoring-title {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--gold);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

.scoring-teams {
    display: flex;
    gap: 1.2rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

.score-team-btn {
    flex: 1;
    height: 110px;
    border-radius: 22px;
    border: 3px solid transparent;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: transform 0.2s ease;
}

.score-team-btn:active { transform: scale(0.94); }

.score-team-btn.t1 { background: linear-gradient(135deg, #1d4ed8, #3b82f6); border-color: var(--team-blue); }
.score-team-btn.t2 { background: linear-gradient(135deg, #be123c, #f43f5e); border-color: var(--team-red); }
.score-team-btn.t3 { background: linear-gradient(135deg, #15803d, #22c55e); border-color: var(--team-green); }

.score-team-btn.nopoint {
    background: rgba(255,255,255,0.1);
    border-color: var(--bg-card-border);
    color: var(--text-muted);
}

/* Countdown Overlay */
.countdown-num {
    font-family: var(--font-heading);
    font-size: 10rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 40px var(--gold-glow);
    animation: popScale 0.8s ease infinite;
}

@keyframes popScale {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Floating Teacher Button */
.teacher-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7209b7, #4361ee);
    border: 3px solid #fff;
    color: #fff;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    z-index: 90;
    transition: transform 0.2s ease;
}

.teacher-floating-btn:active {
    transform: scale(0.9);
}

/* Teacher Menu Panel */
.teacher-panel {
    background: #121124;
    border: 4px solid #4361ee;
    border-radius: 28px;
    padding: 2rem;
    width: 90%;
    max-width: 550px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.teacher-panel-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
    color: #4361ee;
    margin-bottom: 0.8rem;
}

.teacher-action-btn {
    width: 100%;
    height: 60px;
    border-radius: 16px;
    border: 2px solid var(--bg-card-border);
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.teacher-action-btn:active {
    background: rgba(255,255,255,0.2);
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 120;
}

/* BUILD THE NUMBER: Countdown number smooth scale */
#build-countdown-num {
    transition: color 0.3s ease, transform 0.2s ease;
    display: inline-block;
}

/* 3-game grid layout */
.games-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    max-width: 900px !important;
}

/* DYNAMIC RED BACKGROUND ALERT FOR LOW TIMER */
#game-play-container {
    transition: background 0.4s ease, box-shadow 0.4s ease;
    border-radius: 24px;
}

#game-play-container.time-alert {
    background: radial-gradient(circle at center, rgba(255, 0, 84, 0.35) 0%, rgba(10, 10, 22, 0.95) 75%) !important;
    animation: pulseRedBg 0.5s infinite alternate ease-in-out;
}

@keyframes pulseRedBg {
    from {
        box-shadow: inset 0 0 30px rgba(255, 0, 84, 0.3), 0 0 25px rgba(255, 0, 84, 0.4);
    }
    to {
        box-shadow: inset 0 0 120px rgba(255, 0, 84, 0.85), 0 0 50px rgba(255, 0, 84, 0.9);
    }
}
