* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a1628;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

.game-container {
    position: relative;
    width: 400px;
    height: 700px;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 400 / 700;
}

@media (max-width: 420px), (max-height: 720px) {
    .game-container {
        width: 100vw;
        height: calc(100vw * 700 / 400);
        max-height: 100vh;
    }
    .game-container:has(#gameCanvas) {
        width: min(100vw, calc(100vh * 400 / 700));
        height: min(100vh, calc(100vw * 700 / 400));
    }
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 8px;
    cursor: crosshair;
    box-shadow: 0 0 40px rgba(52, 152, 219, 0.3);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== Overlays ===== */

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    display: none;
}

/* ===== Menu Overlay ===== */

#menuOverlay {
    /* Transparent so canvas menu background shows through */
    background: transparent;
    pointer-events: none;
}

#menuOverlay > * {
    pointer-events: auto;
}

.menu-title {
    color: #FFF;
    font-size: 36px;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    margin-bottom: 4px;
}

.menu-subtitle {
    color: #7FB3D5;
    font-size: 16px;
    margin-bottom: 20px;
}

.menu-stone-icon {
    width: 50px;
    height: 50px;
    background: #E74C3C;
    border-radius: 50%;
    position: relative;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.menu-stone-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 10px;
    background: #333;
    border-radius: 2px;
}

.menu-btn {
    display: block;
    width: 180px;
    height: 50px;
    border: none;
    border-radius: 10px;
    color: #FFF;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 15px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.menu-btn:hover {
    transform: scale(1.05);
}

.menu-btn:active {
    transform: scale(0.97);
}

#startBtn {
    background: #27AE60;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

#tutorialBtn {
    background: #3498DB;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.menu-high-score {
    color: #F1C40F;
    font-size: 14px;
    margin-top: 20px;
}

/* ===== Game Over Overlay ===== */

#gameoverOverlay {
    background: rgba(0, 0, 0, 0.85);
}

.gameover-title {
    color: #FFF;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 15px;
}

.gameover-score {
    color: #F1C40F;
    font-size: 52px;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.4);
}

.gameover-new-record {
    color: #2ECC71;
    font-size: 16px;
    margin-bottom: 15px;
}

.gameover-high-score {
    color: #BDC3C7;
    font-size: 14px;
    margin-bottom: 30px;
}

.gameover-btn {
    display: block;
    width: 180px;
    height: 46px;
    border: none;
    border-radius: 10px;
    color: #FFF;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.15s ease;
}

.gameover-btn:hover {
    transform: scale(1.05);
}

.gameover-btn:active {
    transform: scale(0.97);
}

#playAgainBtn {
    background: #27AE60;
    box-shadow: 0 3px 12px rgba(39, 174, 96, 0.4);
}

#backToMenuBtn {
    background: #7F8C8D;
    box-shadow: 0 3px 12px rgba(127, 140, 141, 0.3);
}

/* ===== Difficulty Overlay ===== */

#difficultyOverlay {
    background: rgba(0, 0, 0, 0.75);
    pointer-events: auto;
}

.difficulty-title {
    color: #FFF;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    margin-bottom: 24px;
}

.difficulty-btn {
    display: block;
    width: 180px;
    height: 50px;
    border: none;
    border-radius: 10px;
    color: #FFF;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.difficulty-btn:hover {
    transform: scale(1.05);
}

.difficulty-btn:active {
    transform: scale(0.97);
}

.difficulty-easy {
    background: #27AE60;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.difficulty-medium {
    background: #F39C12;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.difficulty-hard {
    background: #E74C3C;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.difficulty-back-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: #AAA;
    font-size: 13px;
    padding: 8px 20px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.difficulty-back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #FFF;
}

/* ===== Tutorial Overlay ===== */

#tutorialOverlay {
    background: transparent;
    pointer-events: none;
    justify-content: space-between;
}

#tutorialOverlay > * {
    pointer-events: auto;
}

.tutorial-top {
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px 20px;
    text-align: center;
    border-radius: 8px 8px 0 0;
}

.tutorial-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.tutorial-dots .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

.tutorial-dots .dot.active {
    background: #3498DB;
}

.tutorial-top h2 {
    color: #FFF;
    font-size: 20px;
    margin-bottom: 8px;
}

.tutorial-top p {
    color: #BDC3C7;
    font-size: 14px;
    line-height: 1.5;
}

.tutorial-bottom {
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    text-align: center;
    border-radius: 0 0 8px 8px;
}

.tutorial-bottom .hint {
    color: #FFF;
    font-size: 14px;
}

.tutorial-bottom .hint.success {
    color: #2ECC71;
}

.tutorial-bottom .hint.warning {
    color: #F1C40F;
}

.tutorial-bottom .hint.error {
    color: #E74C3C;
}

.tutorial-skip {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: #AAA;
    font-size: 12px;
    padding: 6px 14px;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s;
}

.tutorial-skip:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #FFF;
}

.hidden {
    display: none !important;
}
