:root {
    /* Futuristic Cyberpunk Palette */
    --bg-body: #050510;
    --bg-surface: rgba(255, 255, 255, 0.03);
    --bg-surface-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --primary: #00f3ff;
    /* Neon Cyan */
    --primary-hover: #00c2cc;
    --secondary: #bc13fe;
    /* Neon Purple */
    --accent: #ff0055;
    /* Neon Pink */

    --border-light: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(0, 243, 255, 0.5);

    --success: #00ff9d;
    --danger: #ff0055;

    --shadow-sm: 0 0 10px rgba(0, 243, 255, 0.1);
    --shadow-md: 0 0 20px rgba(188, 19, 254, 0.2);
    --shadow-glow: 0 0 15px var(--primary);

    --radius-md: 12px;
    --radius-lg: 16px;

    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Exo 2', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-body);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(188, 19, 254, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(0, 243, 255, 0.1) 0%, transparent 20%);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Remove old effects */
.background-fx,
.orb {
    display: none;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    /* Wider for 5x5 grid */
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    /* Scroll inside container */
    scrollbar-width: thin;
    scrollbar-color: var(--secondary) var(--bg-body);
}

/* Typography */
header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    padding-top: 1rem;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

/* Layout */
main {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.hidden {
    display: none !important;
}

.view,
.sub-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeScale 0.2s ease-out;
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.99);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Menu Cards */
.game-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
}

@media (min-width: 640px) {
    .game-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .game-list {
        grid-template-columns: repeat(5, 1fr);
    }
}

.game-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    /* Vertical layout for cooler look */
    align-items: center;
    text-align: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.game-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-glow), var(--shadow-md);
    background: var(--bg-surface-hover);
}

.game-card:hover::before {
    transform: scaleX(1);
}

.card-icon {
    font-size: 2.5rem;
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--primary);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.game-card:hover .card-icon {
    color: var(--bg-body);
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary);
}

.game-info h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.game-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}



/* Game Header */
.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.game-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.btn-back:hover {
    color: var(--text-primary);
    background: #f3f4f6;
}

/* Buttons */
/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: transparent;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    /* center glow */
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.btn:hover {
    border-color: transparent;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
    color: #fff;
}

.btn:hover::before {
    opacity: 1;
}

.btn.primary {
    background: rgba(0, 243, 255, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.btn.primary:hover {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 20px var(--primary);
}

.btn.primary:hover::before {
    opacity: 0;
    /* remove gradient for solid color effect on primary */
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
}

.btn.secondary:hover {
    border-color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    width: auto;
}

.btn-main-page {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    background: rgba(255, 0, 85, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    z-index: 100;
}

.btn-main-page:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 15px var(--danger);
}

/* Reaction Duel */
.circle {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    border: 4px solid var(--border-light);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 2rem;
    box-shadow: var(--shadow-sm);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.circle.waiting {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
}

.circle.go {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(16, 185, 129, 0.4);
}

.circle.too-early {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-tertiary);
    color: var(--text-tertiary);
}

#instruction-text {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-heading);
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

#mp-controls-hint {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 2rem 1rem;
}

.key-hint {
    width: 56px;
    height: 56px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

/* Tile Flip */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 340px;
    margin-bottom: 1.5rem;
}

.stat {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat span {
    color: var(--text-primary);
    font-weight: 600;
}

.grid-4x4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.tile {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.tile.active {
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary);
}

.tile:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Endless Dodger */
.canvas-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    background: #000;
}

canvas {
    background: #050510;
    display: block;
}

.overlay {
    background: rgba(5, 5, 16, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-light);
}

.overlay h2 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-family: var(--font-heading);
    text-shadow: 0 0 10px var(--primary);
}

.overlay p {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Results */
.result-content {
    text-align: center;
    padding-top: 2rem;
}

.time-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
    margin: 1rem 0;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
    font-family: var(--font-heading);
}

#result-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.125rem;
}

footer {
    margin-top: auto;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    text-align: center;
    padding-top: 2rem;
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: monospace;
    font-size: 0.8em;
    color: var(--primary);
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

/* ============================
   BATCH 1 GAMES STYLES
   ============================ */

/* Generic Grids */
.grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* Memory Match */
.memory-grid .tile {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: transparent;
    transition: transform 0.4s, background 0.4s, box-shadow 0.4s;
    transform-style: preserve-3d;
}

.memory-grid .tile.revealed,
.memory-grid .tile.matched {
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    color: var(--text-primary);
    transform: rotateY(180deg);
    box-shadow: 0 0 10px var(--primary);
}

.memory-grid .tile.matched {
    border-color: var(--success);
    color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Tic-Tac-Toe */
.tictactoe-grid .cell {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-primary);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.tictactoe-grid .cell:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.tictactoe-grid .cell.x {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
}

.tictactoe-grid .cell.o {
    color: var(--danger);
    text-shadow: 0 0 10px var(--danger);
}

/* Whack-a-Mole */
.whack-grid .hole {
    width: 80px;
    height: 80px;
    background: #3f2e22;
    /* Darker dirt */
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 4px solid #634331;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.whack-grid .mole {
    width: 60px;
    height: 60px;
    background: var(--accent);
    /* Neon mole */
    border-radius: 50%;
    position: absolute;
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    transition: bottom 0.1s;
    box-shadow: 0 0 10px var(--accent);
}

.whack-grid .hole.up .mole {
    bottom: 0;
}

.whack-grid .hole.whacked .mole {
    background: var(--danger);
    transform: translateX(-50%) scale(0.9);
}

/* ============================
   BATCH 2 GAMES STYLES
   ============================ */

/* Simon Says */
.simon-board {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    background: #111;
    border: 8px solid #222;
    display: flex;
    flex-wrap: wrap;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    margin: 1rem auto;
}

.simon-btn {
    width: 50%;
    height: 50%;
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.1s, transform 0.1s, box-shadow 0.1s;
}

.simon-btn.active,
.simon-btn:active {
    opacity: 1;
    transform: scale(0.98);
}

.simon-btn.top-left {
    background: #ff0055;
    border-top-left-radius: 100%;
}

.simon-btn.top-left.active {
    box-shadow: 0 0 20px #ff0055;
    z-index: 2;
}

.simon-btn.top-right {
    background: #00f3ff;
    border-top-right-radius: 100%;
}

.simon-btn.top-right.active {
    box-shadow: 0 0 20px #00f3ff;
    z-index: 2;
}

.simon-btn.bottom-left {
    background: #ffcc00;
    border-bottom-left-radius: 100%;
}

.simon-btn.bottom-left.active {
    box-shadow: 0 0 20px #ffcc00;
    z-index: 2;
}

.simon-btn.bottom-right {
    background: #00ff9d;
    border-bottom-right-radius: 100%;
}

.simon-btn.bottom-right.active {
    box-shadow: 0 0 20px #00ff9d;
    z-index: 2;
}

.center-circle {
    width: 80px;
    height: 80px;
    background: #111;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid #333;
    z-index: 10;
}

/* RPS */
.rps-choice {
    font-size: 3.5rem;
    margin-top: 1rem;
    height: 80px;
    width: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border: 2px solid var(--border-light);
}

.rps-vs {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    font-family: var(--font-heading);
}

/* Guess Number & Scramble Inputs */
.input-lg {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-family: var(--font-heading);
    background: rgba(0, 0, 0, 0.3);
    color: var(--success);
}

.input-lg:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

/* ============================
   BATCH 3 GAMES STYLES
   ============================ */

/* Math Dash */
.math-problem {
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 0 10px var(--secondary);
    font-family: var(--font-heading);
}

.math-option {
    font-size: 1.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-light);
    color: var(--text-primary);
    border-radius: var(--radius-md);
}

.math-option:hover {
    border-color: var(--primary);
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 10px var(--primary);
}

/* Color Shade */
.color-grid {
    display: grid;
    gap: 8px;
    padding: 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 300px;
    height: 300px;
    margin: 0 auto;
    border: 1px solid var(--border-light);
}

.color-tile {
    border-radius: 4px;
    cursor: pointer;
    background: #ccc;
    /* overwritten by JS */
}

/* Stopwatch */
.sw-result.perfect {
    color: var(--success);
    text-shadow: 0 0 10px var(--success);
}

.sw-result.good {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
}

.sw-result.bad {
    color: var(--danger);
    text-shadow: 0 0 10px var(--danger);
}

/* ============================
   BATCH 4 GAMES STYLES
   ============================ */

/* Type Racer */
.text-display span.correct {
    color: var(--success);
    text-shadow: 0 0 5px var(--success);
}

.text-display span.wrong {
    color: var(--danger);
    text-decoration: underline;
    text-decoration-color: var(--danger);
    text-shadow: 0 0 5px var(--danger);
}

.text-display span.current {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* 2048 - Dark Theme */
.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
    background: #1e293b;
    border-radius: 6px;
    width: 300px;
    height: 300px;
    margin: 0 auto;
    border: 1px solid var(--border-light);
}

.tile-2048 {
    background: #334155;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #94a3b8;
}

.tile-2048.val-2 {
    background: #475569;
    color: #f8fafc;
}

.tile-2048.val-4 {
    background: #64748b;
    color: #f8fafc;
}

.tile-2048.val-8 {
    background: rgba(0, 243, 255, 0.2);
    color: #00f3ff;
    border: 1px solid #00f3ff;
}

.tile-2048.val-16 {
    background: rgba(0, 243, 255, 0.4);
    color: #fff;
    border: 1px solid #00f3ff;
}

.tile-2048.val-32 {
    background: rgba(188, 19, 254, 0.4);
    color: #fff;
    border: 1px solid #bc13fe;
}

.tile-2048.val-64 {
    background: rgba(188, 19, 254, 0.6);
    color: #fff;
    border: 1px solid #bc13fe;
}

.tile-2048.val-128 {
    background: rgba(255, 0, 85, 0.5);
    color: #fff;
    border: 1px solid #ff0055;
}

.tile-2048.val-256 {
    background: rgba(255, 0, 85, 0.7);
    color: #fff;
    border: 1px solid #ff0055;
}

.tile-2048.val-1024 {
    background: #ffd700;
    color: #000;
    box-shadow: 0 0 10px #ffd700;
}

.tile-2048.val-2048 {
    background: #fff;
    color: #000;
    box-shadow: 0 0 20px #fff;
}

/* Mine Field */
.mine-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 4px;
    background: #334155;
    border-radius: 4px;
    width: 300px;
    height: 300px;
    margin: 0 auto;
}

.mine-tile {
    background: #475569;
    border: 1px solid #64748b;
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
}

.mine-tile.revealed {
    border: 1px solid #1e293b;
    background: #0f172a;
}

/* Hangman */
.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    max-width: 400px;
    margin: 0 auto;
}

.key-btn {
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s;
}

.key-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 5px var(--primary);
}

.key-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.key-btn.wrong {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border-color: var(--danger);
}

.key-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 5px var(--success);
}