:root {
    --bg-color: #1a1a1a;
    --game-bg: #2d2d2d;
    --accent-color: #4a90e2;
    --text-color: #ffffff;
    --cell-closed: #3d3d3d;
    --cell-closed-hover: #4d4d4d;
    --cell-revealed: #252525;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);

    /* Number Colors */
    --c1: #3b82f6;
    --c2: #10b981;
    --c3: #ef4444;
    --c4: #a855f7;
    --c5: #f59e0b;
    --c6: #06b6d4;
    --c7: #ffffff;
    --c8: #94a3b8;
}

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

.row-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.icon {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: radial-gradient(circle at 50% 50%, #2a2a2a 0%, #1a1a1a 100%);
    overflow: hidden;
    overscroll-behavior: none;
}

.game-container {
    background: rgba(45, 45, 45, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s;
}

.app-section {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Title Screen Specifics */
.title-screen {
    min-width: 300px;
    padding: 40px;
}

.main-title {
    font-size: 3rem;
    margin-bottom: 20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.menu-label {
    font-size: 1.2rem;
    color: #ccc;
    margin-bottom: 8px;
    text-align: center;
}

.menu-btn {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.difficulty-btn {
    background: #4b5563;
    /* Gray */
    color: white;
}

.difficulty-btn:hover {
    background: #6b7280;
    transform: translateY(-2px);
}

.difficulty-btn[data-diff="easy"] {
    background: #10b981;
}

.difficulty-btn[data-diff="easy"]:hover {
    background: #059669;
}

.difficulty-btn[data-diff="normal"] {
    background: #3b82f6;
}

.difficulty-btn[data-diff="normal"]:hover {
    background: #2563eb;
}

.difficulty-btn[data-diff="hard"] {
    background: #ef4444;
}

.difficulty-btn[data-diff="hard"]:hover {
    background: #dc2626;
}

.secondary-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffd700;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.game-select-btn {
    background: #4b5563;
    color: white;
    height: 80px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.game-select-btn:hover {
    background: #60a5fa;
    /* Blue */
    transform: translateY(-2px);
}

.game-select-btn[data-game="minesweeper"]:hover {
    background: #10b981;
    /* Green */
}

/* Hit and Blow Specifics - Clubhouse Games Style */
.hb-board {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 480px;
    /* Wider for table feel */
}

/* History Log - Scorepad Style */
.hb-history {
    background: #fdf6e3;
    /* Paper color */
    border-radius: 4px;
    padding: 0;
    height: 300px;
    overflow-y: auto;
    border: 1px solid #d1d5db;
    font-family: 'Courier New', monospace;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.05);
    position: relative;
}

/* Notebook lines */
.hb-history::before {
    content: '';
    position: absolute;
    top: 0;
    left: 40px;
    width: 2px;
    height: 100%;
    background: rgba(255, 0, 0, 0.2);
    z-index: 0;
    pointer-events: none;
}

.hb-history-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    /* Notebook line */
    position: relative;
    z-index: 1;
    color: #374151;
}

.hb-history-row.header {
    font-weight: bold;
    color: #fff;
    background: #4b5563;
    /* Clip header */
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hb-num-col {
    flex: 2;
    text-align: center;
    font-size: 1.4rem;
    letter-spacing: 6px;
    font-weight: bold;
    font-family: 'Inter', sans-serif;
}

.hb-result-col {
    flex: 1;
    text-align: center;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pegs for Hit/Blow */
.hb-peg {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 2px;
    box-shadow: inset -1px -1px 2px rgba(0, 0, 0, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.hb-peg.hit {
    background: #ef4444;
    border: 1px solid #991b1b;
}

.hb-peg.blow {
    background: #fbbf24;
    border: 1px solid #b45309;
}

.hb-input-area {
    background: rgba(0, 0, 0, 0.2);
    /* Darker area for controls */
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hb-current-input {
    display: flex;
    justify-content: center;
    gap: 16px;
    height: 70px;
    background: #2d2d2d;
    padding: 10px;
    border-radius: 50px;
    /* Capsule shape */
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
}

.hb-input-box {
    width: 48px;
    height: 48px;
    background: #1a1a1a;
    /* Hole */
    border: none;
    border-radius: 50%;
    /* Circle holes */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.8), inset -1px -1px 2px rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.hb-input-box.filled {
    background: #e5e5e5;
    /* Marble/Plastic piece */
    color: #1a1a1a;
    box-shadow: 2px 4px 6px rgba(0, 0, 0, 0.4), inset 2px 2px 5px rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    border: 1px solid #999;
}

.hb-keypad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 0 10px;
}

.hb-key {
    aspect-ratio: 1;
    background: #e5e5e5;
    /* Physical button look */
    border: none;
    border-radius: 50%;
    color: #333;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #999, 0 5px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
    font-family: 'Inter', sans-serif;
}

.hb-key:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #999, 0 8px 15px rgba(0, 0, 0, 0.3);
}

.hb-key:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #999, 0 2px 5px rgba(0, 0, 0, 0.3);
}

.hb-key:disabled {
    background: #555;
    color: #888;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.hb-key.action {
    background: #4b5563;
    color: #fbbf24;
    border-radius: 12px;
    aspect-ratio: auto;
    /* Rectangular for action buttons */
    height: 50px;
    box-shadow: 0 4px 0 #1f2937, 0 5px 10px rgba(0, 0, 0, 0.3);
}

.hb-key.action:hover {
    background: #6b7280;
    box-shadow: 0 6px 0 #1f2937, 0 8px 15px rgba(0, 0, 0, 0.3);
}

.hb-key.action:active {
    box-shadow: 0 2px 0 #1f2937;
}

.hb-key.enter {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 0 #1e40af, 0 5px 10px rgba(0, 0, 0, 0.3);
}

.hb-key.enter:hover {
    background: #3b82f6;
    box-shadow: 0 6px 0 #1e40af, 0 8px 15px rgba(0, 0, 0, 0.3);
}

.hb-key.enter:active {
    box-shadow: 0 2px 0 #1e40af;
}

/* HB Settings */
.hb-settings {
    display: flex;
    justify-content: center;
    width: 100%;
}

.hb-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: #e5e7eb;
    font-size: 0.9rem;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    transition: background 0.2s;
}

.hb-checkbox:hover {
    background: rgba(255, 255, 255, 0.15);
}

.hb-checkbox input[type="checkbox"] {
    accent-color: #60a5fa;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Color Mode Styles */
.hb-key.color-key,
.hb-ball {
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hb-key.color-key.selected {
    border-color: #fff;
    transform: scale(0.95);
}

.color-red {
    background: #ef4444;
}

.color-blue {
    background: #3b82f6;
}

.color-green {
    background: #10b981;
}

/* Gomoku Styles */
.gomoku-turn-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: bold;
}

.gomoku-turn-indicator .turn-stone {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.gomoku-board-container {
    padding: 20px;
    background: #e2b069;
    /* Wood color */
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
}

.gomoku-board {
    display: grid;
    grid-template-columns: repeat(15, 30px);
    grid-template-rows: repeat(15, 30px);
    background: #eab308;
    /* Inner wood */
    border: 1px solid #78350f;
    position: relative;
}

.gomoku-cell {
    width: 30px;
    height: 30px;
    position: relative;
    cursor: pointer;
}

/* Grid lines */
.gomoku-cell::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #78350f;
    transform: translateY(-50%);
    z-index: 0;
}

.gomoku-cell::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: #78350f;
    transform: translateX(-50%);
    z-index: 0;
}

/* Stone */
.gomoku-stone {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.gomoku-stone.black {
    background: radial-gradient(circle at 30% 30%, #555, #000);
}

.gomoku-stone.white {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
}

/* Quantum Mode - Uncertain Stones */
.gomoku-stone.uncertain-black-p90 {
    background: radial-gradient(circle at 30% 30%, #666, #333);
    opacity: 0.9;
}

.gomoku-stone.uncertain-black-p70 {
    background: radial-gradient(circle at 30% 30%, #888, #555);
    opacity: 0.7;
}

.gomoku-stone.uncertain-white-p90 {
    background: radial-gradient(circle at 30% 30%, #ccc, #999);
    opacity: 0.9;
}

.gomoku-stone.uncertain-white-p70 {
    background: radial-gradient(circle at 30% 30%, #aaa, #777);
    opacity: 0.7;
}

/* Observation animation */
.gomoku-stone.observing {
    animation: quantumPulse 0.6s ease-in-out;
}

@keyframes quantumPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

/* UFO Escape Styles */
#ufo-game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background-color: #0f172a;
    /* Dark blue specific to UFO game */
}

#ufo-game-container .game-header {
    margin: 10px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 60;
}

#ufo-game-container .score-container {
    text-align: center;
    color: #00ffff;
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    flex: 1;
}

#ufo-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 600px;
    /* Limit width for playable area */
    margin: 0 auto;
    /* Center horizontally */
    display: flex;
    justify-content: center;
    align-items: center;
    border-left: 1px solid #334155;
    border-right: 1px solid #334155;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

canvas#ufo-canvas {
    background: radial-gradient(circle at bottom, #1e293b 0%, #0f172a 100%);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.1);
    border-top: 1px solid #334155;
}

.ufo-start-btn {
    background: linear-gradient(45deg, #06b6d4, #3b82f6);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: 'Orbitron', 'Noto Sans JP', sans-serif;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.ufo-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.8);
}

/* Quantum HUD */
.quantum-hud {
    display: flex;
    gap: 20px;
    align-items: center;
    background: rgba(99, 102, 241, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid rgba(139, 92, 246, 0.5);
    flex-wrap: wrap;
    justify-content: center;
}

.quantum-info {
    display: flex;
    gap: 8px;
    align-items: center;
    color: #e0e7ff;
    font-size: 0.9rem;
}

.quantum-prob-value {
    font-weight: bold;
    font-size: 1.1rem;
    color: #a5b4fc;
}

.quantum-observe-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.quantum-observe-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.5);
}

.quantum-observe-btn:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Quantum Observation Result Banner */
.quantum-observe-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
    z-index: 1000;
    font-weight: 500;
}

.quantum-observe-banner button {
    background: white;
    color: #6366f1;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.quantum-observe-banner button:hover {
    transform: scale(1.05);
}

/* Hover effect */
.gomoku-cell:not(.has-stone):hover::before,
.gomoku-cell:not(.has-stone):hover::after {
    background: rgba(0, 0, 0, 0.5);
    /* Highlight grid on hover */
}

/* Star points (Hoshi) - Optional but nice */
.gomoku-cell.hoshi .hoshi-dot {
    width: 6px;
    height: 6px;
    background: #78350f;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.color-purple {
    background: #8b5cf6;
}

.color-orange {
    background: #f97316;
}

/* Small layout adjustment for modal ans in color mode */
.hb-ans-row {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.hb-ans-ball {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

.home-btn {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    transition: all 0.2s;
}

.home-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Ranking Tabs */
.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
}

.rank-tab {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.rank-tab.active {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
}


/* Tile Speed Styles */
.tile-board-wrapper {
    position: relative;
    width: 100%;
    max-width: 320px;
    height: 480px;
    /* Fixed height for 4 rows visible (120px * 4) */
    overflow: hidden;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 2px solid #333;
}

.tile-board {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    /* No fixed height, controlled by content and transform */
    display: flex;
    flex-direction: column-reverse;
    /* Row 0 at bottom */
}

.tile-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: 120px;
    /* Taller tiles for ease of tapping */
    width: 100%;
    border-bottom: 1px solid #ddd;
}

.tile-cell {
    border-right: 1px solid #eee;
    background: #fff;
    /* White tile */
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
}

.tile-cell:last-child {
    border-right: none;
}

.tile-cell.black {
    background: #111;
    /* Black tile */
}

.tile-cell.black:active {
    background: #333;
    /* Feedback */
}

.tile-cell.tapped {
    background: rgba(0, 0, 0, 0.4) !important;
    /* Greyed out after tapping */
}

.tile-cell.success {
    background: #4ade80 !important;
    /* Green flash on win step if desired */
}

.tile-cell.wrong {
    background: #ef4444 !important;
    /* Red flash on error */
    animation: shake 0.4s;
}

.tile-cell.start-cell::after {
    content: 'Start';
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tile-start-overlay {
    position: absolute;
    bottom: 150px;
    width: 100%;
    text-align: center;
    pointer-events: none;
    color: #ef4444;
    font-weight: bold;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
    animation: pulse 1s infinite;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.game-title {
    text-align: center;
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: #ffd700;
    /* Gold color */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    gap: 12px;
    /* Added gap */
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    min-width: 60px;
    justify-content: center;
}

.stat-box.best-score {
    color: #fcd34d;
    /* Amber/Gold */
    font-size: 1.2rem;
    min-width: 50px;
}

.stat-box .icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.reset-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    background: rgba(255, 255, 255, 0.1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.reset-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.15);
}

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

.game-board {
    display: grid;
    grid-template-columns: repeat(10, 40px);
    grid-template-rows: repeat(10, 40px);
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cell {
    width: 40px;
    height: 40px;
    background-color: var(--cell-closed);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1.2rem;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.cell:hover:not(.revealed):not(.flagged) {
    background-color: var(--cell-closed-hover);
    transform: translateY(-1px);
}

.cell.revealed {
    background-color: var(--cell-revealed);
    cursor: default;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: none;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.cell.mine {
    background-color: #ef4444;
    animation: boom 0.3s ease-out;
}

@keyframes boom {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.cell.flagged {
    color: #f59e0b;
}

.cell.flagged::after {
    content: "🚩";
    font-size: 1.2rem;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}

/* Number colors */
.cell[data-num="1"] {
    color: var(--c1);
}

.cell[data-num="2"] {
    color: var(--c2);
}

.cell[data-num="3"] {
    color: var(--c3);
}

.cell[data-num="4"] {
    color: var(--c4);
}

.cell[data-num="5"] {
    color: var(--c5);
}

.cell[data-num="6"] {
    color: var(--c6);
}

.cell[data-num="7"] {
    color: var(--c7);
}

.cell[data-num="8"] {
    color: var(--c8);
}

/* Win animation bits */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f00;
    animation: fall 3s linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: rgba(45, 45, 45, 0.95);
    padding: 30px 40px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 320px;
}

.ranking-btn {
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0);
    transition: all 0.2s;
}

.ranking-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.ranking-list {
    margin: 20px 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    font-size: 1.1rem;
    color: #e5e7eb;
}

.ranking-item .rank {
    font-weight: bold;
    color: #ffd700;
    width: 30px;
}

.ranking-item .time {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #10b981;
}

.ranking-item .date {
    font-size: 0.8rem;
    color: #9ca3af;
}

.ranking-item.empty {
    justify-content: center;
    color: #6b7280;
    font-style: italic;
}

#ranking-close-btn {
    background: #4b5563;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

#ranking-close-btn:hover {
    background: #6b7280;
}

.modal.hidden .modal-content {
    transform: scale(0.8);
}

.modal h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.modal p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #ccc;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.modal-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    width: 100%;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.modal-btn.primary-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.modal-btn.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.modal-btn.primary-btn:active {
    transform: translateY(0);
}

.modal-btn.secondary-btn {
    background: transparent;
    color: #9ca3af;
    border: 1px solid #4b5563;
}

.modal-btn.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

/* Tile Speed Goal Line */
.tile-row.goal-line {
    background-image: repeating-linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%, #ccc), repeating-linear-gradient(45deg, #ccc 25%, #fff 25%, #fff 75%, #ccc 75%, #ccc);
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
}

.tile-row.goal-line .tile-cell {
    background: transparent;
    /* Show texture */
}

.tile-row.goal-line .tile-cell.black {
    background: #ef4444;
    /* Red finish line tile */
    border: 2px solid #fff;
    box-shadow: 0 0 10px #fbbf24;
}

.tile-row.goal-line::after {
    content: 'GOAL';
    position: absolute;
    width: 100%;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 10;
}

/* Block Breaker */
.bb-canvas-container {
    width: 600px;
    height: 700px;
    max-width: 100%;
    /* Fixed logic to avoid calc issues when scaling */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #111827;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, #1f2937 0%, #111827 100%);
}

canvas#bb-canvas {
    background: transparent;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 50px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Shake Animation Class */
.shake {
    animation: shake 0.3s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}