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

html, body {
    touch-action: none; /* prevent browser-level pinch/zoom and pull-to-refresh by default */
    overscroll-behavior: none; /* prevent pull-to-refresh / navigation gestures */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none; /* prevent text selection globally (except inputs) */
    -webkit-touch-callout: none; /* disable long-press callout on iOS */
}

/* Allow normal interactions (scroll/selection) inside explicit interactive controls */
input, textarea, select {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    touch-action: manipulation;
}

/* Make the game board scrollable on touch (permit vertical/horizontal pan) */
.game-board {
    /* ...existing styles... */
    touch-action: pan-y pan-x; /* allow panning inside the board */
    overflow: auto; /* ensure content can scroll when needed */
}

/* Ensure debug panel and overlays remain operable for touch */
.debug-panel, .gameover-overlay, .gameover-animation, .clippy-content {
    touch-action: manipulation;
}

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

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #c0c0c0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-container {
    text-align: center;
    background-color: #c0c0c0;
    padding: 20px;
    border: 3px solid #808080;
    border-top-color: #ffffff;
    border-left-color: #ffffff;
}

.progress-bar {
    width: 300px;
    height: 20px;
    background-color: #808080;
    border: 2px solid #ffffff;
    border-right-color: #808080;
    border-bottom-color: #808080;
    margin: 10px auto;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background-color: #008000;
    transition: width 0.3s;
    position: relative;
    overflow: hidden;
}

#progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: progressShine 1.5s linear infinite;
}

@keyframes progressShine {
    to {
        left: 200%;
    }
}

#loading-text {
    font-weight: bold;
    margin-top: 5px;
}

#loaded-assets-container {
    width: 300px;
    height: 80px;
    margin-top: 15px;
    overflow: hidden;
    position: relative;
    border: 2px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    background-color: #333;
}

#loaded-assets-track {
    display: flex;
    position: relative;
    height: 100%;
    align-items: center;
    padding: 0 10px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #666 #333;
}

#loaded-assets-track::-webkit-scrollbar {
    height: 6px;
}

#loaded-assets-track::-webkit-scrollbar-track {
    background: #333;
}

#loaded-assets-track::-webkit-scrollbar-thumb {
    background-color: #666;
    border-radius: 3px;
}

.loaded-asset {
    min-width: 40px;
    height: 40px;
    margin: 0 5px;
    object-fit: contain;
    position: relative;
    transform: translateX(300px);
    opacity: 0;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    background-color: #666;
    padding: 5px;
    border-radius: 5px;
    flex-shrink: 0;
}

.loaded-asset.sound-asset {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    background-color: #4a4a80;
}

.loaded-asset.sound-asset::before {
    content: '♪';
    font-size: 20px;
    margin-right: 5px;
}

.asset-enter {
    animation: assetEnterAnimation 1s forwards;
}

@keyframes assetEnterAnimation {
    0% {
        transform: translateX(300px) rotate(0deg) scale(0);
        opacity: 0;
    }
    30% {
        transform: translateX(100px) rotate(180deg) scale(1.5);
        opacity: 0.7;
    }
    60% {
        transform: translateX(50px) rotate(360deg) scale(0.8);
        opacity: 0.9;
    }
    100% {
        transform: translateX(0) rotate(720deg) scale(1);
        opacity: 1;
    }
}

.asset-pulse {
    animation: assetPulseAnimation 1.5s infinite;
}

@keyframes assetPulseAnimation {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.2);
        filter: brightness(1.5) hue-rotate(180deg);
    }
}

.game-container {
    background-color: #c0c0c0;
    border: 3px solid #808080;
    border-top-color: #ffffff;
    border-left-color: #ffffff;
    padding: 10px;
    transform-origin: center;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #c0c0c0;
    border: 3px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    padding: 6px;
    margin-bottom: 10px;
}

.bomb-counter, .timer {
    display: flex;
    height: 32px;
    position: relative;
}

.bomb-counter img, .timer img {
    height: 100%;
    transition: transform 0.2s;
}

.digit-change {
    animation: digitPulse 0.3s ease-out;
}

@keyframes digitPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.face {
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.face img {
    width: 32px;
    height: 32px;
    transition: transform 0.3s;
}

.face:hover img {
    transform: scale(1.05);
    z-index: 10;
}

.face-clicked img {
    animation: faceClick 0.3s ease;
}

@keyframes faceClick {
    0% { transform: scale(1); }
    40% { transform: scale(0.85); }
    60% { transform: scale(0.95); }
    80% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.win-animation {
    animation: winGameAnimation 2s ease-in-out;
}

@keyframes winGameAnimation {
    0%, 100% { transform: scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-2deg) scale(1.02); }
    20%, 40%, 60%, 80% { transform: rotate(2deg) scale(1.02); }
}

.lose-animation {
    animation: loseGameAnimation 0.5s ease-in-out;
}

@keyframes loseGameAnimation {
    0%, 100% { transform: scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.game-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-gap: 0;
    border: 3px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    position: relative;
    flex-grow: 1;
    touch-action: pan-y pan-x; /* allow panning inside the board */
    overflow: auto; /* ensure content can scroll when needed */
}

.cell {
    width: 32px;
    height: 32px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    position: relative;
    transform-origin: center;
    transition: transform 0.05s;
}

.cell:hover {
    transform: scale(1.05);
    z-index: 10;
}

.cell img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.2s;
}

.reveal-animation {
    animation: revealCell 0.4s ease-out;
}

@keyframes revealCell {
    0% { transform: rotateY(90deg) scale(0.5); }
    50% { transform: rotateY(45deg) scale(1.2); }
    100% { transform: rotateY(0) scale(1); }
}

.flag-animation {
    animation: flagPlant 0.5s ease-out;
}

@keyframes flagPlant {
    0% { transform: translateY(-10px) scale(1.2); }
    40% { transform: translateY(3px) scale(0.9); }
    60% { transform: translateY(-2px) scale(1.1); }
    100% { transform: translateY(0) scale(1); }
}

.explosion-animation {
    animation: explodeCell 0.6s ease-out;
}

@keyframes explodeCell {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); filter: brightness(2); }
    100% { transform: scale(1); filter: brightness(1); }
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
}

@keyframes particleFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; }
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(0); opacity: 0; }
}

.number-particle {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    color: rgba(0, 0, 255, 0.8);
    pointer-events: none;
    z-index: 100;
    animation: floatUp 1s ease-out forwards;
}

.shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid rgba(255, 0, 0, 0.8);
    opacity: 0;
    z-index: 999;
}

@keyframes shockwaveEffect {
    0% { width: 0; height: 0; opacity: 1; }
    100% { width: 100px; height: 100px; opacity: 0; }
}

#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--color);
    opacity: 0.8;
    z-index: 10000;
}

@keyframes confettiFall {
    0% { transform: translateY(-10vh) rotate(0deg); }
    100% { transform: translateY(100vh) rotate(720deg); }
}

.idle-pulse {
    animation: idlePulse 0.8s ease-in-out;
}

@keyframes idlePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.idle-shake {
    animation: idleShake 0.5s ease-in-out;
}

@keyframes idleShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.idle-glow {
    animation: idleGlow 1s ease-in-out;
}

@keyframes idleGlow {
    0%, 100% { filter: brightness(1); box-shadow: none; }
    50% { filter: brightness(1.5); box-shadow: 0 0 8px rgba(255, 200, 0, 0.8); }
}

.idle-wiggle {
    animation: idleWiggle 0.6s ease-in-out;
}

@keyframes idleWiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-5deg); }
    50% { transform: rotate(0); }
    75% { transform: rotate(5deg); }
}

.idle-bounce {
    animation: idleBounce 0.5s ease-in-out;
}

@keyframes idleBounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(3px); }
    80% { transform: translateY(-2px); }
}

.board-pulse {
    animation: boardPulse 1s ease-in-out;
}

@keyframes boardPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.02); filter: brightness(1.1); }
}

/* Game over animation overlays */
.gameover-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001; /* raised above debug panel (which is 9999) */
    display: none;
    opacity: 0;
    transition: opacity 0.5s;
}

.gameover-overlay.active {
    display: block;
    opacity: 1;
}

.gameover-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    cursor: pointer;
}

.gameover-animation.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* BSOD Screen */
.bsod-screen {
    background-color: #0078d7;
    color: white;
    font-family: 'Segoe UI', sans-serif;
    flex-direction: column;
}

.bsod-content {
    max-width: 80%;
    text-align: center;
}

.bsod-content h1 {
    font-size: 48px;
    margin-bottom: 20px;
}

.bsod-content p {
    font-size: 18px;
    margin: 10px 0;
}

.bsod-content a {
    color: white;
    text-decoration: underline;
}

.bsod-continue {
    margin-top: 30px;
    opacity: 0;
    animation: blinkText 1.5s infinite alternate;
}

@keyframes blinkText {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

/* Fake Browser Screen */
.browser-screen {
    background-color: #f5f5f5;
    color: #333;
    font-family: Arial, sans-serif;
    flex-direction: column;
}

.browser-bar {
    width: 80%;
    height: 40px;
    background-color: #e1e1e1;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.browser-buttons {
    display: flex;
    gap: 5px;
}

.browser-buttons span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ccc;
}

.browser-buttons span:nth-child(1) { background-color: #ff5f57; }
.browser-buttons span:nth-child(2) { background-color: #ffbd2e; }
.browser-buttons span:nth-child(3) { background-color: #28ca41; }

.browser-address {
    flex-grow: 1;
    background-color: white;
    border-radius: 4px;
    margin-left: 10px;
    padding: 5px 10px;
    font-size: 14px;
}

.browser-content {
    width: 80%;
    height: 60%;
    background-color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search-box {
    width: 80%;
    display: flex;
    margin-bottom: 20px;
}

.search-box input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 16px;
}

.search-box button {
    padding: 10px 20px;
    background-color: #0078d7;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.search-results {
    width: 80%;
    text-align: left;
}

.too-late {
    font-size: 48px;
    color: red;
    text-align: center;
    margin-top: 50px;
    font-weight: bold;
    opacity: 0;
    animation: jumpscareText 0.5s forwards 1s;
}

@keyframes jumpscareText {
    0% { transform: scale(0.1); opacity: 0; }
    50% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Obituary Screen */
.obituary-screen {
    background-color: rgba(0, 0, 0, 0.8);
    filter: grayscale(100%);
}

.tombstone {
    width: 300px;
    height: 400px;
    background-color: #aaa;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.tombstone h2 {
    margin-top: 0;
    color: #333;
}

.tombstone h1 {
    font-size: 36px;
    margin: 10px 0;
    color: #333;
}

.tombstone p {
    color: #333;
}

.tombstone .dates {
    margin-top: 30px;
    font-style: italic;
}

/* Power-off Prank */
.poweroff-screen {
    background-color: black;
}

.poweroff-content {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.crt-lines:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 1;
    opacity: 0;
    animation: crtEffect 0.2s forwards 0.5s;
}

@keyframes crtEffect {
    0% { opacity: 0; transform: scale(1); }
    50% { opacity: 1; transform: scale(0.98); }
    100% { opacity: 0; transform: scale(0); }
}

.poweroff-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    color: white;
    text-align: center;
    opacity: 0;
    animation: revealMessage 0.5s forwards 1.5s;
}

@keyframes revealMessage {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Windows XP Error Meltdown */
.xp-error-screen {
    background-color: #235e99;
    background-image: linear-gradient(to bottom, #235e99, #4aa4ff);
    overflow: hidden;
}

.error-windows {
    width: 100%;
    height: 100%;
    position: relative;
}

.error-window {
    position: absolute;
    width: 300px;
    background-color: #ece9d8;
    border: 1px solid #0055ea;
    border-radius: 7px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
    padding-bottom: 10px;
    animation: errorSlide 1s forwards;
}

.error-title {
    background: linear-gradient(to right, #0055ea, #3d94ff);
    color: white;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 7px 7px 0 0;
    display: flex;
    justify-content: space-between;
}

.error-content {
    padding: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.error-icon {
    width: 32px;
    height: 32px;
    margin-right: 10px;
    background-color: red;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.error-buttons {
    text-align: center;
}

.error-button {
    padding: 5px 15px;
    background-color: #ece9d8;
    border: 1px solid #888;
    border-radius: 3px;
    cursor: pointer;
}

@keyframes errorSlide {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* Judge Judy Screen */
.judge-screen {
    background-color: black;
}

.judge-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.judge-image {
    width: 300px;
    height: 300px;
    background-color: #333;
    border-radius: 50%;
    margin-bottom: 20px;
    background-image: url('https://placekitten.com/300/300'); /* Placeholder */
    background-size: cover;
}

.judge-text {
    color: white;
    font-size: 24px;
    text-align: center;
    margin-bottom: 30px;
}

.gavel {
    width: 100px;
    height: 40px;
    background-color: #8b4513;
    position: relative;
    animation: gavelBang 0.5s forwards 2s;
}

.gavel:before {
    content: "";
    position: absolute;
    top: -20px;
    left: 40px;
    width: 20px;
    height: 60px;
    background-color: #8b4513;
}

@keyframes gavelBang {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-45deg); }
    100% { transform: rotate(0deg); }
}

/* Clippy Roast Session */
.clippy-screen {
    background-color: #f0f0f0;
    font-family: 'Segoe UI', sans-serif;
}

.clippy-content {
    width: 80%;
    height: 80%;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.clippy-image {
    width: 120px;
    height: 120px;
    align-self: flex-end;
}

.clippy-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.clippy-bubble {
    background-color: #fffbd6;
    border: 1px solid #e6e098;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    position: relative;
}

.clippy-bubble:after {
    content: "";
    position: absolute;
    top: -10px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #fffbd6;
}

.replay-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.replay-board {
    flex-grow: 1;
    background-color: #c0c0c0;
}

.replay-commentary {
    background-color: #333;
    color: white;
    padding: 10px;
    font-size: 14px;
}

/* Debug Panel Styles */
.debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 380px;
    background-color: rgba(0, 0, 0, 0.85);
    color: #00ff00;
    font-family: 'Courier New', monospace;
    border: 2px solid #00ff00;
    border-radius: 5px;
    padding: 10px;
    z-index: 9999;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
    display: none;
    max-height: 80vh;
    overflow-y: auto;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #00ff00;
}

.debug-header h3 {
    color: #ff9900;
    margin: 0;
}

.debug-header button {
    background-color: #ff3300;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
}

.debug-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #00aa00;
}

.debug-section h4 {
    color: #ffff00;
    margin-bottom: 5px;
}

.debug-section pre {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 3px;
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

.debug-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.debug-buttons button {
    background-color: #333;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    transition: all 0.2s;
}

.debug-buttons button:hover {
    background-color: #555;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.8);
}

#debug-mine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20px, 1fr));
    gap: 2px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 3px;
    max-height: 150px;
    overflow-y: auto;
}

.debug-cell {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.debug-mine {
    background-color: #ff0000;
    color: white;
}

.debug-empty {
    background-color: #222;
    color: #aaa;
}

.debug-revealed {
    background-color: #006400; /* solid dark green to clearly indicate revealed */
    color: white;
    border: none; /* remove border-only cues */
}

.debug-flagged {
    background-color: #8b4000; /* solid brown/orange to indicate a flag */
    color: white;
    border: none;
}

.debug-active {
    background-color: #ff3b3b; /* make active clicked mine clearly red */
    color: white;
    box-shadow: 0 0 12px #ff0000;
    animation: debug-pulse 1s infinite alternate;
}

@keyframes debug-pulse {
    from { box-shadow: 0 0 5px rgba(255, 0, 0, 0.5); }
    to { box-shadow: 0 0 10px rgba(255, 0, 0, 1); }
}

/* For the debug code sequence */
.debug-code-active {
    position: fixed;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #00ff00;
    padding: 5px 10px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 9999;
}

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

/* Win animation screens */
/* Credits roll screen */
.credits-screen {
    background-color: black;
    color: white;
}

.credits-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.credits-title {
    font-size: 60px;
    font-weight: bold;
    margin-bottom: 40px;
    font-family: 'Times New Roman', serif;
    color: gold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    margin-top: 30px;
}

.credits-scroll {
    animation: creditsScroll 30s linear forwards;
    text-align: center;
    width: 80%;
}

@keyframes creditsScroll {
    from { transform: translateY(100vh); }
    to { transform: translateY(-300vh); }
}

.credits-header {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #cccccc;
}

.credits-name {
    font-size: 36px;
    margin-bottom: 30px;
}

.credits-disclaimer {
    font-size: 16px;
    font-style: italic;
    color: #888888;
    margin-top: 40px;
}

.credits-copyright {
    font-size: 18px;
    margin-top: 50px;
    color: #aaaaaa;
}

/* NASA congratulation screen */
.nasa-screen {
    background-color: #0b3d91;
    color: white;
}

.nasa-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nasa-logo {
    font-size: 80px;
    font-weight: bold;
    font-family: 'Arial', sans-serif;
    margin-bottom: 40px;
    color: white;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.nasa-broadcast {
    width: 80%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border: 2px solid #ff0000;
    border-radius: 10px;
    position: relative;
}

.nasa-headline {
    font-size: 36px;
    font-weight: bold;
    color: #ff0000;
    margin-bottom: 20px;
    text-align: center;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.nasa-news {
    font-size: 24px;
    text-align: center;
}

.nasa-rocket {
    font-size: 80px;
    position: absolute;
    bottom: 20px;
    right: 20px;
    animation: rocketLaunch 3s forwards 2s;
}

@keyframes rocketLaunch {
    from { transform: translateY(0) rotate(0deg); }
    to { transform: translateY(-500px) rotate(15deg); }
}

/* Slow-mo replay screen */
.slowmo-screen {
    background-color: #1a1a1a;
    color: white;
}

.slowmo-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.slowmo-title {
    font-size: 48px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    letter-spacing: 5px;
}

.slowmo-replay {
    width: 80%;
    height: 60%;
    background-color: rgba(50, 50, 50, 0.7);
    border: 3px solid #444;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.slowmo-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5));
    animation: slowmoEffect 5s infinite;
}

@keyframes slowmoEffect {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}

.slowmo-narration {
    font-size: 28px;
    font-style: italic;
    text-align: center;
    max-width: 80%;
    animation: fadeInOut 4s infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Statue reveal screen */
.statue-screen {
    background: linear-gradient(to bottom, #87CEEB, #4682B4);
    color: white;
}

.statue-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.statue-scene {
    position: relative;
    width: 300px;
    height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.statue-figure {
    width: 100px;
    height: 300px;
    background-color: #ffd700;
    position: relative;
    animation: statueReveal 3s forwards;
    transform: scale(0);
}

@keyframes statueReveal {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.statue-plaque {
    background-color: #8b4513;
    color: #ffd700;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 18px;
    margin-top: 20px;
    opacity: 0;
    animation: fadeIn 2s forwards 1.5s;
}

.statue-crowd {
    font-size: 36px;
    margin-top: 40px;
    animation: crowd 2s infinite 2s;
}

@keyframes crowd {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Scared errors screen */
.scared-errors-screen {
    background-color: #235e99;
    background-image: linear-gradient(to bottom, #235e99, #4aa4ff);
    overflow: hidden;
}

.scared-errors-content {
    width: 100%;
    height: 100%;
    position: relative;
}

.scared-error-window {
    position: absolute;
    width: 300px;
    background-color: #ece9d8;
    border: 1px solid #0055ea;
    border-radius: 7px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
    padding-bottom: 10px;
}

.scared-error-title {
    background: linear-gradient(to right, #0055ea, #3d94ff);
    color: white;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 7px 7px 0 0;
    display: flex;
    justify-content: space-between;
}

.scared-error-content {
    padding: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.scared-error-icon {
    width: 32px;
    height: 32px;
    margin-right: 10px;
    background-color: #ffd800;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Friendless celebration screen */
.friendless-screen {
    background-color: #111;
    color: white;
}

.friendless-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.friendless-message {
    font-size: 36px;
    text-align: center;
    max-width: 80%;
    color: #aaa;
    font-family: 'Courier New', monospace;
    margin-bottom: 50px;
}

.friendless-crickets {
    font-size: 24px;
    animation: crickets 2s infinite;
    color: #666;
}

@keyframes crickets {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Minecraft end credits screen */
.minecraft-screen {
    background-color: #000;
    color: #aaa;
    font-family: 'Courier New', monospace;
}

.minecraft-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.minecraft-poem {
    width: 70%;
    text-align: center;
    animation: minecraftScroll 45s linear forwards;
}

@keyframes minecraftScroll {
    from { transform: translateY(100vh); }
    to { transform: translateY(-300vh); }
}

.minecraft-text {
    font-size: 20px;
    margin-bottom: 20px;
    color: #5a5;
}

.minecraft-crash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #111;
    padding: 20px;
    border: 2px solid #333;
    width: 80%;
    max-width: 600px;
    display: none;
    font-family: 'Courier New', monospace;
    color: #f00;
    text-align: left;
    animation: crashAppear 1s forwards 20s;
}

@keyframes crashAppear {
    from { display: none; opacity: 0; }
    1% { display: block; opacity: 0; }
    to { display: block; opacity: 1; }
}

/* Footer style */
.footer {
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: #555;
}

.footer a {
    color: #555;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Visual mark for footer long-press reveal (non-destructive) */
.debug-mark-mine {
    position: relative;
    z-index: 50; /* ensure it sits above normal cells */
    box-shadow: 0 0 12px 4px rgba(255, 0, 0, 0.9) inset, 0 0 8px 2px rgba(255, 0, 0, 0.6);
    animation: debugMarkPulse 0.8s ease-in-out infinite;
}

@keyframes debugMarkPulse {
    0% { transform: scale(1); filter: saturate(1); }
    50% { transform: scale(1.03); filter: saturate(1.2); }
    100% { transform: scale(1); filter: saturate(1); }
}

.debug-mark-mine::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 0, 0, 0.25);
    pointer-events: none;
    border-radius: 2px;
}

/* Help icon and modal */
#help-icon {
    position: fixed;
    right: 12px;
    bottom: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #808080;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    font-family: 'Cal Sans', 'Noto Sans', Arial, sans-serif;
    font-weight: bold;
    z-index: 10002;
    cursor: pointer;
}

.help-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px); /* new: subtle blur behind modal */
    z-index: 10003;
    padding: 20px;
}

.help-modal[aria-hidden="false"] { display: flex; }

.help-modal-content {
    background: #ffffff;
    color: #111;
    max-width: 760px; /* increased width for readability */
    width: 100%;
    border-radius: 12px; /* softer corners */
    padding: 28px 32px; /* more breathing room */
    box-shadow: 0 20px 60px rgba(0,0,0,0.35); /* stronger elevated card */
    transform: translateY(-8px) scale(0.98);
    opacity: 0;
    animation: helpModalEnter 260ms cubic-bezier(.2,.9,.3,1) forwards;
    font-family: 'Cal Sans', 'Noto Sans', Arial, sans-serif; /* nicer default font */
    line-height: 1.45;
}

@keyframes helpModalEnter {
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.help-close {
    position: absolute;
    right: 18px;
    top: 16px;
    background: transparent;
    border: 0;
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 150ms, transform 150ms;
}
.help-close:hover { background: rgba(0,0,0,0.06); transform: translateY(-1px); }

.help-modal h2 { margin-bottom: 10px; }

.help-modal ul { margin-left: 18px; margin-bottom: 10px; }

.help-footnote { margin-top: 12px; font-size: 12px; color: #666; }