/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

:root {
    --primary-color: #6aaa64;
    --secondary-color: #c9b458;
    --background: #0a0a0a;
    --surface: #1a1a1b;
    --text-primary: #ffffff;
    --text-secondary: #818384;
    --border: #3a3a3c;
    --error: #dc3545;
    --tile-size: 64px;
    --grid-gap: 4px;
    --transition-speed: 0.2s;
    --retro-font: 'Press Start 2P', monospace;
}

body {
    font-family: var(--retro-font);
    background-color: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    overflow-x: hidden;
    overflow-y: scroll; /* Changed from auto to scroll to force scrollbar */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: contain;
    /* iOS-specific scroll fixes */
    -webkit-overflow-scrolling: touch;
    /* Prevent text selection during gameplay */
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

/* Retro CRT scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
}

/* CRT screen curvature effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    z-index: 9998;
}

#app {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* Header */
header {
    text-align: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Game Container */
#game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-height: 100vh;
    padding-bottom: 4rem;
}

/* General hidden class */
.hidden {
    display: none !important;
}

#game-container.hidden {
    display: none !important;
}

header.hidden {
    display: none !important;
}

#main-menu.hidden {
    display: none !important;
}

.game-info {
    display: flex;
    justify-content: space-evenly;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 500px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.info-item .label {
    font-size: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-item span:last-child {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Controls Hint */
#controls-hint {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#controls-hint .desktop {
    display: block;
}

#controls-hint .mobile {
    display: none;
}

/* Utility Bar - Above Grid */
.utility-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    background: rgba(30, 30, 30, 0.6);
    padding: 0.4rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.utility-btn {
    flex: 1;
    padding: 0.4rem 0.6rem;
    background: rgba(45, 45, 45, 0.8);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 500;
    white-space: nowrap;
}

.utility-btn:hover {
    border-color: var(--text-secondary);
    background: rgba(60, 60, 60, 0.9);
    transform: translateY(-1px);
}

.utility-btn:active {
    transform: translateY(0);
}

/* Ability Controls Row - Below Grid */
.ability-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
}

/* Ability button styling - larger and more prominent */
.ability-btn {
    min-width: 140px;
    height: 56px;
    padding: 0 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(106, 170, 100, 0.3) 0%, rgba(90, 150, 85, 0.3) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

/* Make lightning emoji bigger */
.ability-emoji {
    font-size: 24px;
    vertical-align: middle;
}

.ability-btn:hover {
    border-color: var(--primary-color);
    background: rgba(106, 170, 100, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 170, 100, 0.3);
}

.ability-btn:active {
    transform: translateY(0);
}

/* Ability Button States */
.ability-btn.active {
    background: linear-gradient(135deg, #8b4789 0%, #6a3a68 100%);
    border-color: #a65ea3;
    animation: abilityPulse 1s ease-in-out infinite;
}

.ability-btn.used {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--surface);
}

.ability-btn.used:hover {
    transform: none;
    border-color: var(--border);
    background: var(--surface);
    box-shadow: none;
}

.ability-btn.knight-shield {
    background: linear-gradient(135deg, #4a7dae 0%, #2e5682 100%);
    border-color: #6cb3f8;
    animation: shieldPulse 1.5s ease-in-out infinite;
}

@keyframes abilityPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(139, 71, 137, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(139, 71, 137, 0.8);
    }
}

@keyframes shieldPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(74, 125, 174, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(74, 125, 174, 0.8);
    }
}

/* Switch Character Button */
.switch-char-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    background: rgba(128, 126, 126, 0.8);
    border: 2px solid #adabab;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 28px;
    line-height: 1;
}

.switch-char-btn:hover {
    border-color: #8a8a8a;
    background: rgba(90, 90, 90, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 100, 100, 0.3);
}

.switch-char-btn:active {
    transform: translateY(0);
}

/* Hint Button */
.hint-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    background: rgba(255, 193, 7, 0.2);
    border: 2px solid rgba(255, 193, 7, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

.hint-btn:hover {
    border-color: rgba(255, 193, 7, 0.8);
    background: rgba(255, 193, 7, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.hint-btn:active {
    transform: translateY(0);
}

/* Retry Button */
.retry-btn {
    width: 56px;
    height: 56px;
    padding: 0;
    background: rgba(100, 140, 220, 0.2);
    border: 2px solid rgba(100, 140, 220, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

.retry-btn:hover {
    border-color: rgba(100, 140, 220, 0.8);
    background: rgba(100, 140, 220, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 140, 220, 0.3);
}

.retry-btn:active {
    transform: translateY(0);
}

/* Hint Modal Sections */
.hint-section {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.hint-toggle {
    width: 100%;
    padding: 0.75rem;
    background: rgba(40, 40, 40, 0.8);
    border: none;
    color: var(--text-primary);
    font-family: var(--retro-font);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.hint-toggle:hover {
    background: rgba(50, 50, 50, 0.9);
}

.hint-label {
    flex: 1;
    text-align: left;
}

.hint-arrow {
    transition: transform 0.2s;
    font-size: 0.6rem;
}

.hint-toggle.expanded .hint-arrow {
    transform: rotate(180deg);
}

.hint-content {
    padding: 0.75rem;
    background: rgba(30, 30, 30, 0.6);
    font-size: 0.65rem;
    line-height: 1.4;
}

.hint-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hint-content li {
    padding: 0.3rem 0;
    line-height: 1.6;
}

.hint-content li strong {
    display: inline-block;
}

/* Pause Button - Legacy class for compatibility */
.pause-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(45, 45, 45, 0.9);
    border: 2px solid #4a4a4a;
    border-radius: 8px;
    color: #ffd700;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
}

.pause-btn:hover {
    border-color: #ffd700;
    background: rgba(90, 90, 42, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.pause-btn:active {
    transform: translateY(0);
}

.char-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.char-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.char-btn {
    width: 48px;
    height: 48px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.char-btn:hover {
    background: var(--border);
    transform: translateY(-2px);
}

.char-btn.active {
    border-color: var(--primary-color);
    background: rgba(106, 170, 100, 0.2);
    box-shadow: 0 0 12px rgba(106, 170, 100, 0.3);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
    font-size: 0.7rem;
}

/* Stats Display */
.stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    min-width: 100px;
}

.stat-label {
    font-size: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Buttons */
.primary-button {
    background: var(--primary-color);
    color: var(--text-primary);
    border: none;
    padding: 0.875rem 2rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
    width: 100%;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.primary-button:hover {
    background: #5a9a54;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 170, 100, 0.3);
}

.primary-button:active {
    transform: translateY(0);
}

.secondary-button {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.secondary-button:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.secondary-button:active {
    transform: translateY(0);
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

/* Instructions */
.instruction-list {
    text-align: left;
    margin-bottom: 2rem;
    list-style: none;
    padding: 0;
}

.instruction-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    line-height: 1.5;
}

.instruction-list li:last-child {
    border-bottom: none;
}

.instruction-list li::before {
    content: "→ ";
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* Next Puzzle Countdown */
.next-puzzle {
    margin-top: 1.5rem;
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-family: var(--retro-font);
}

.next-puzzle span {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--retro-font);
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

/* Loading state */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ===== MAIN MENU - DUNGEON THEME ===== */
.screen {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
    background: var(--background);
}

.screen.hidden {
    display: none !important;
}

.menu-container {
    max-width: 600px;
    width: 100%;
    background: linear-gradient(135deg, #1a1a1b 0%, #0d0d0e 100%);
    border: 3px solid #3a3a3a;
    border-radius: 8px;
    padding: 2rem;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.game-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    color: #ffd700;
    text-shadow:
        3px 3px 0px #000,
        4px 4px 0px rgba(255, 215, 0, 0.5);
    font-family: var(--retro-font);
    font-weight: 400;
    letter-spacing: 0.05em;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 5px #ffd700);
    }
    to {
        filter: drop-shadow(0 0 15px #ffd700);
    }
}

.game-subtitle {
    text-align: center;
    color: #888;
    font-size: 0.6rem;
    margin-bottom: 2rem;
    font-family: var(--retro-font);
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Game Info Box */
.game-info-box {
    background: rgba(45, 45, 45, 0.5);
    border: 2px solid #4a4a4a;
    border-radius: 6px;
    padding: 1.5rem;
}

.game-info-box h3 {
    color: #ffd700;
    font-size: 0.8rem;
    margin-bottom: 1rem;
    text-align: center;
    font-family: var(--retro-font);
    text-shadow: 2px 2px 0px #000;
}

.instructions {
    list-style: none;
    padding: 0;
    margin: 0;
}

.instructions li {
    padding: 0.5rem 0;
    color: #ccc;
    font-size: 0.6rem;
    line-height: 1.8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--retro-font);
}

.instructions li:last-child {
    border-bottom: none;
}

/* Menu Character Selection */
.menu-character-select {
    background: rgba(45, 45, 45, 0.5);
    border: 2px solid #4a4a4a;
    border-radius: 6px;
    padding: 1.5rem;
}

.menu-character-select h3 {
    color: #ffd700;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
    font-family: 'Courier New', monospace;
}

.menu-char-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.menu-char-btn {
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 2px solid #3a3a3a;
    border-radius: 6px;
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #999;
    font-size: 0.8rem;
}

.menu-char-btn:hover {
    border-color: #6a6a6a;
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    transform: translateY(-2px);
}

.menu-char-btn.active {
    border-color: #ffd700;
    background: linear-gradient(135deg, #4a4a2a 0%, #3a3a1a 100%);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

.char-preview {
    width: 48px;
    height: 48px;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Character sprites in preview */
.char-preview::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
}

.char-preview[data-character="hero"]::before {
    box-shadow:
        -8px -8px 0 0 #4ecdc4,
        0px -8px 0 0 #4ecdc4,
        8px -8px 0 0 #4ecdc4,
        -8px 0px 0 0 #4ecdc4,
        -4px 0px 0 0 #2d2d2d,
        0px 0px 0 0 #4ecdc4,
        4px 0px 0 0 #2d2d2d,
        8px 0px 0 0 #4ecdc4,
        -8px 8px 0 0 #44a7a0,
        -4px 8px 0 0 #44a7a0,
        0px 8px 0 0 #6ee7df,
        4px 8px 0 0 #44a7a0,
        8px 8px 0 0 #44a7a0,
        -4px 16px 0 0 #38817c,
        4px 16px 0 0 #38817c;
}

.char-preview[data-character="knight"]::before {
    box-shadow:
        -8px -8px 0 0 #dc3545,
        0px -8px 0 0 #dc3545,
        8px -8px 0 0 #dc3545,
        -8px 0px 0 0 #dc3545,
        -4px 0px 0 0 #2d2d2d,
        0px 0px 0 0 #2d2d2d,
        4px 0px 0 0 #2d2d2d,
        8px 0px 0 0 #dc3545,
        -8px 8px 0 0 #c82333,
        -4px 8px 0 0 #ff6b6b,
        0px 8px 0 0 #c82333,
        4px 8px 0 0 #ff6b6b,
        8px 8px 0 0 #c82333,
        -4px 16px 0 0 #8b2d2d,
        4px 16px 0 0 #8b2d2d;
}

.char-preview[data-character="ranger"]::before {
    box-shadow:
        -8px -8px 0 0 #6aaa64,
        0px -8px 0 0 #6aaa64,
        8px -8px 0 0 #6aaa64,
        -8px 0px 0 0 #6aaa64,
        -4px 0px 0 0 #2d2d2d,
        0px 0px 0 0 #f5deb3,
        4px 0px 0 0 #2d2d2d,
        8px 0px 0 0 #6aaa64,
        -8px 8px 0 0 #7cc576,
        -4px 8px 0 0 #6aaa64,
        0px 8px 0 0 #9bcd76,
        4px 8px 0 0 #6aaa64,
        8px 8px 0 0 #7cc576,
        -4px 16px 0 0 #5a8a54,
        4px 16px 0 0 #5a8a54;
}

.char-preview[data-character="mage"]::before {
    box-shadow:
        0px -12px 0 0 #8b3a8b,
        -4px -8px 0 0 #8b3a8b,
        0px -8px 0 0 #8b3a8b,
        4px -8px 0 0 #8b3a8b,
        -8px 0px 0 0 #8b3a8b,
        -4px 0px 0 0 #2d2d2d,
        0px 0px 0 0 #f5deb3,
        4px 0px 0 0 #2d2d2d,
        8px 0px 0 0 #8b3a8b,
        -8px 8px 0 0 #a855a8,
        -4px 8px 0 0 #8b3a8b,
        0px 8px 0 0 #c77cc7,
        4px 8px 0 0 #8b3a8b,
        8px 8px 0 0 #a855a8,
        -4px 16px 0 0 #6b2a6b,
        4px 16px 0 0 #6b2a6b;
}

.char-preview[data-character="challenge"]::before {
    box-shadow:
        -8px -8px 0 0 #d4d4d4,
        0px -8px 0 0 #ffffff,
        8px -8px 0 0 #d4d4d4,
        -8px 0px 0 0 #e0e0e0,
        -4px 0px 0 0 #505050,
        0px 0px 0 0 #ffffff,
        4px 0px 0 0 #505050,
        8px 0px 0 0 #e0e0e0,
        -8px 8px 0 0 #b0b0b0,
        -4px 8px 0 0 #c8c8c8,
        0px 8px 0 0 #e8e8e8,
        4px 8px 0 0 #c8c8c8,
        8px 8px 0 0 #b0b0b0,
        -4px 16px 0 0 #909090,
        4px 16px 0 0 #909090;
}

/* Menu Play Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-play-btn {
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    border: 4px solid #4a4a4a;
    border-radius: 0px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 400;
    font-family: var(--retro-font);
    text-shadow: 2px 2px 0px #000;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
}

.menu-play-btn:hover {
    border-color: #6a6a6a;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
}

.menu-play-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.menu-play-btn.primary {
    border-color: #ffd700;
    background: linear-gradient(135deg, #5a5a2a 0%, #4a4a1a 100%);
    color: #ffd700;
}

.menu-play-btn.primary:hover {
    border-color: #ffed4e;
    box-shadow: 6px 6px 0px rgba(255, 215, 0, 0.3);
}

.menu-play-btn.danger {
    border-color: #ff4444;
    background: linear-gradient(135deg, #5a2a2a 0%, #4a1a1a 100%);
    color: #ff6666;
}

.menu-play-btn.danger:hover {
    border-color: #ff6666;
    box-shadow: 6px 6px 0px rgba(255, 68, 68, 0.3);
}

.btn-subtitle {
    font-size: 0.5rem;
    font-weight: 400;
    color: #999;
    font-family: var(--retro-font);
    text-shadow: 1px 1px 0px #000;
}

/* Submenu Header (Character Selection & Help) */
.submenu-header {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 1rem;
    background: rgba(20, 20, 20, 0.95);
    border-bottom: 2px solid #3a3a3a;
    position: sticky;
    top: -2rem;
    z-index: 100;
    gap: 1.5rem;
    margin: -2rem -1rem 0 -1rem;
}

.back-button {
    background: transparent;
    border: 2px solid #4a4a4a;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: var(--retro-font);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.back-button:hover {
    border-color: var(--primary-color);
    background: rgba(106, 170, 100, 0.2);
}

.submenu-title {
    font-family: var(--retro-font);
    font-size: 0.9rem;
    color: #ffd700;
    text-shadow: 2px 2px 0px #000;
    margin: 0;
    text-align: center;
}

/* Character Selection Screen - Larger Cards */
.char-selection-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.char-card {
    position: relative; /* For absolute positioning of skin button */
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 3px solid #3a3a3a;
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.char-card:hover {
    border-color: #6a6a6a;
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.char-card.active {
    border-color: #ffd700;
    background: linear-gradient(135deg, #4a4a2a 0%, #3a3a1a 100%);
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.4);
}

.char-card-preview {
    width: 80px;
    height: 80px;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Character sprites in card preview - scaled up */
.char-card-preview::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1.5);
    background: transparent;
}

/* Character preview sprites moved to individual character CSS files */
/* See: styles/characters/hero.css, knight.css, ranger.css, mage.css, champion.css */

.char-card-info {
    text-align: center;
}

.char-card-info h3 {
    color: #ffd700;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    font-family: var(--retro-font);
    text-shadow: 2px 2px 0px #000;
}

.char-card-info p {
    color: #999;
    font-size: 0.55rem;
    margin: 0;
    font-family: var(--retro-font);
}

.char-card-info .char-subtitle {
    margin-bottom: 0.5rem;
    color: #888;
}

.char-card-info .char-ability {
    font-size: 0.6rem;
    line-height: 1.3;
    color: #aaa;
    margin-top: 0.5rem;
}

.char-card.active .char-card-info h3 {
    color: #ffed4e;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.char-card.active .char-card-info .char-ability {
    color: #ccc;
}

/* Responsive adjustments for menu */
@media (max-width: 480px) {
    .game-title {
        font-size: 1.8rem;
    }

    .game-subtitle {
        font-size: 0.65rem;
    }

    .menu-char-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .char-selection-grid {
        grid-template-columns: 1fr;
    }

    .menu-container {
        padding: 1.5rem;
    }

    .instructions li {
        font-size: 0.65rem;
    }

    .menu-play-btn {
        font-size: 0.9rem;
    }

    /* Adjust utility bar for mobile */
    .utility-bar {
        gap: 0.3rem;
        padding: 0.3rem;
    }

    .utility-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Adjust game info spacing on mobile */
    .game-info {
        gap: 0.75rem !important;
    }
}

/* Level Complete Notification (Challenge Mode) */
.level-complete-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #ffd700;
    border-radius: 12px;
    padding: 2rem;
    z-index: 10000;
    max-width: 400px;
    width: 90%;
    text-align: center;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.3);
}

.level-complete-notification.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.level-complete-notification h2 {
    font-family: var(--retro-font);
    font-size: 1rem;
    color: #ffd700;
    margin: 0 0 1.5rem 0;
    text-shadow: 2px 2px 0px #000;
    animation: glow 1s ease-in-out infinite alternate;
}

.notification-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.notification-stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification-label {
    font-family: var(--retro-font);
    font-size: 0.5rem;
    color: #888;
    text-transform: uppercase;
}

.notification-value {
    font-family: var(--retro-font);
    font-size: 1rem;
    color: #fff;
    text-shadow: 2px 2px 0px #000;
}

.notification-next {
    font-family: var(--retro-font);
    font-size: 0.6rem;
    color: #ffd700;
    margin: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Developer Menu Styles */
.dev-level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.dev-level-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: var(--retro-font);
    font-size: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.dev-level-btn:hover {
    border-color: var(--primary-color);
    background: rgba(106, 170, 100, 0.1);
    transform: translateY(-2px);
}

.dev-level-btn .level-id {
    color: var(--primary-color);
    font-size: 0.7rem;
}

.dev-level-btn .level-desc {
    color: var(--text-secondary);
    font-size: 0.55rem;
    line-height: 1.3;
}

.dev-level-btn .level-difficulty {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.5rem;
    margin-top: 0.2rem;
}

.dev-level-btn .level-difficulty.super_easy {
    background: #67b347;
    color: #000;
}

.dev-level-btn .level-difficulty.easy {
    background: #e6c547;
    color: #000;
}

.dev-level-btn .level-difficulty.medium {
    background: #d97938;
    color: #fff;
}

.dev-level-btn .level-difficulty.medium_hard {
    background: #c74440;
    color: #fff;
}

.dev-level-btn .level-difficulty.hard {
    background: #8b4789;
    color: #fff;
}

/* Ad Container */
.ad-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(20, 20, 20, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.25rem;
    text-align: center;
    z-index: 1000;
    max-height: 100px;
    overflow: hidden;
    display: none; /* Hidden until ready for production */
}

.ad-container ins {
    display: block;
    max-width: 728px;
    margin: 0 auto;
    min-height: 50px;
    max-height: 90px;
    height: auto !important;
}

/* Add padding to body to prevent content being hidden by fixed ad */
/* Note: padding-bottom is set to 100px earlier for iOS scrolling */

@media (max-width: 768px) {
    .ad-container {
        padding: 0.1rem 0.2rem;
        max-height: 80px;
    }

    .ad-container ins {
        min-height: 40px;
        max-height: 60px;
    }
}
