/* ============================================
   WALDUR ESCAPE ROOM - DARK TERMINAL THEME
   ============================================ */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --text-primary: #00ff00;
    --text-secondary: #00cc00;
    --text-dim: #008800;
    --text-bright: #33ff33;
    --accent-red: #ff3333;
    --accent-yellow: #ffcc00;
    --accent-blue: #00ccff;
    --accent-purple: #cc66ff;
    --border-color: #00ff0033;
    --glow-color: rgba(0, 255, 0, 0.3);
}

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

body {
    font-family: 'Fira Code', 'Courier New', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 9999;
}

/* CRT flicker effect */
@keyframes flicker {
    0% { opacity: 0.97; }
    50% { opacity: 1; }
    100% { opacity: 0.98; }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.3) 100%);
    z-index: 9998;
    animation: flicker 0.15s infinite;
}

/* Glow text effect */
.glow {
    text-shadow: 0 0 5px var(--text-primary), 0 0 10px var(--text-primary), 0 0 20px var(--text-dim);
}

.glow-red {
    color: var(--accent-red);
    text-shadow: 0 0 5px var(--accent-red), 0 0 10px var(--accent-red);
}

.glow-yellow {
    color: var(--accent-yellow);
    text-shadow: 0 0 5px var(--accent-yellow), 0 0 10px var(--accent-yellow);
}

.glow-blue {
    color: var(--accent-blue);
    text-shadow: 0 0 5px var(--accent-blue), 0 0 10px var(--accent-blue);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    position: relative;
    z-index: 1;
}

/* ASCII Art Header */
.ascii-header {
    font-size: 10px;
    line-height: 1.2;
    white-space: pre;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .ascii-header {
        font-size: 6px;
    }
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Title Screen */
#title-screen {
    text-align: center;
    padding: 40px 20px;
}

.title-box {
    margin-bottom: 30px;
    padding: 20px;
    border: 2px solid var(--text-primary);
    background: rgba(0, 255, 0, 0.05);
}

.main-title {
    font-size: 5em;
    letter-spacing: 15px;
    margin: 0;
    font-weight: 700;
}

.sub-title {
    font-size: 2em;
    letter-spacing: 10px;
    color: var(--text-secondary);
    margin: 10px 0 0 0;
    font-weight: 400;
}

.title-text {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle-text {
    font-size: 1.2em;
    color: var(--text-dim);
    margin-bottom: 30px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 300px;
    margin: 40px auto;
}

/* Buttons */
.btn {
    font-family: 'Fira Code', monospace;
    font-size: 1em;
    padding: 15px 30px;
    background: transparent;
    border: 2px solid var(--text-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn:hover {
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 0 20px var(--glow-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-hint {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
}

.btn-hint:hover {
    background: var(--accent-yellow);
    color: var(--bg-primary);
}

.btn-submit {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-submit:hover {
    background: var(--accent-blue);
    color: var(--bg-primary);
}

/* Game Layout */
.game-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    min-height: calc(100vh - 100px);
}

@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-title {
    font-size: 0.9em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Room Map */
.room-map {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border-color);
    opacity: 0.5;
    transition: all 0.3s;
}

.room-indicator.current {
    opacity: 1;
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.1);
}

.room-indicator.completed {
    opacity: 0.8;
    border-color: var(--text-dim);
}

.room-indicator.completed::after {
    content: '✓';
    margin-left: auto;
    color: var(--text-primary);
}

.room-number {
    width: 24px;
    height: 24px;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
}

.room-name {
    font-size: 0.8em;
}

/* Stats */
.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.stat-value {
    color: var(--text-bright);
}

/* Collected Digits */
.digits-display {
    display: flex;
    gap: 5px;
    font-size: 1.5em;
    font-weight: bold;
}

.digit-slot {
    width: 35px;
    height: 40px;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.digit-slot.filled {
    border-style: solid;
    border-color: var(--text-primary);
    color: var(--text-bright);
}

/* Main Content */
.main-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 30px;
}

/* Room Display */
.room-header {
    margin-bottom: 30px;
}

.room-title {
    font-size: 1.5em;
    margin-bottom: 10px;
}

.room-description {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.room-ascii {
    font-size: 8px;
    line-height: 1.1;
    white-space: pre;
    color: var(--text-dim);
    margin: 20px 0;
    text-align: center;
}

/* Puzzle List */
.puzzle-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.puzzle-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.puzzle-card:hover {
    border-color: var(--text-primary);
    box-shadow: 0 0 10px var(--glow-color);
}

.puzzle-card.completed {
    opacity: 0.7;
    border-color: var(--text-dim);
}

.puzzle-card.completed::before {
    content: '[SOLVED] ';
    color: var(--text-primary);
}

.puzzle-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.puzzle-number {
    color: var(--text-dim);
    font-size: 0.8em;
}

.puzzle-title {
    font-size: 1.1em;
    margin: 5px 0;
}

.puzzle-type {
    font-size: 0.8em;
    color: var(--accent-blue);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 2px solid var(--text-primary);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: 0 0 30px var(--glow-color);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--accent-red);
}

/* Puzzle Content */
.puzzle-content {
    margin: 20px 0;
}

.puzzle-question {
    font-size: 1.1em;
    margin-bottom: 20px;
    line-height: 1.8;
}

.code-block {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 15px;
    margin: 15px 0;
    overflow-x: auto;
    font-size: 0.9em;
}

/* Multiple Choice */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
}

.option-item:hover {
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.05);
}

.option-item.selected {
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.1);
}

.option-item.correct {
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.2);
}

.option-item.incorrect {
    border-color: var(--accent-red);
    background: rgba(255, 0, 0, 0.1);
}

.option-letter {
    width: 30px;
    height: 30px;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-weight: bold;
}

/* Matching Puzzle */
.matching-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.matching-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.matching-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
}

.matching-item:hover {
    border-color: var(--text-primary);
}

.matching-item.selected {
    border-color: var(--accent-blue);
    background: rgba(0, 204, 255, 0.1);
}

.matching-item.matched {
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.1);
    opacity: 0.7;
}

/* Sequence Puzzle */
.sequence-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sequence-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    cursor: grab;
    transition: all 0.3s;
    position: relative;
}

.sequence-item::before {
    content: '⋮⋮';
    position: absolute;
    right: 12px;
    color: var(--text-dim);
    font-size: 1.2em;
    letter-spacing: -3px;
    opacity: 0.5;
}

.sequence-item:hover {
    border-color: var(--text-primary);
}

.sequence-item:hover::before {
    opacity: 1;
    color: var(--text-primary);
}

.sequence-item.dragging {
    opacity: 0.5;
    border-color: var(--accent-blue);
}

.sequence-number {
    width: 30px;
    height: 30px;
    border: 1px solid var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 0.9em;
    color: var(--text-dim);
}

.sequence-text {
    flex: 1;
    padding-right: 30px;
}

/* Code Input */
.code-input-container {
    margin: 20px 0;
}

.code-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.95em;
    padding: 15px;
    min-height: 150px;
    resize: vertical;
}

.code-input:focus {
    outline: none;
    border-color: var(--text-primary);
}

/* Hints */
.hints-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.hints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.hint-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-yellow);
    padding: 15px;
    margin-top: 10px;
    color: var(--accent-yellow);
    font-size: 0.95em;
}

/* Puzzle Actions */
.puzzle-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

/* Feedback */
.feedback-message {
    padding: 15px;
    margin-top: 20px;
    border: 1px solid;
    font-size: 0.95em;
}

.feedback-message.success {
    border-color: var(--text-primary);
    background: rgba(0, 255, 0, 0.1);
}

.feedback-message.error {
    border-color: var(--accent-red);
    background: rgba(255, 0, 0, 0.1);
    color: var(--accent-red);
}

/* Room Complete */
.room-complete {
    text-align: center;
    padding: 40px;
    border: 2px solid var(--text-primary);
    margin-top: 30px;
}

.digit-reveal {
    font-size: 4em;
    font-weight: bold;
    margin: 20px 0;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Victory Screen */
#victory-screen {
    text-align: center;
    padding: 40px 20px;
}

.victory-code {
    font-size: 3em;
    letter-spacing: 10px;
    margin: 30px 0;
}

.final-stats {
    max-width: 400px;
    margin: 30px auto;
    text-align: left;
}

.rank-display {
    font-size: 1.5em;
    margin: 20px 0;
    padding: 20px;
    border: 2px solid var(--accent-purple);
    color: var(--accent-purple);
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.achievement-badge {
    padding: 15px;
    border: 1px solid var(--border-color);
    text-align: center;
    opacity: 0.4;
}

.achievement-badge.unlocked {
    opacity: 1;
    border-color: var(--accent-yellow);
    background: rgba(255, 204, 0, 0.1);
}

.achievement-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.achievement-name {
    font-size: 0.85em;
    color: var(--accent-yellow);
}

/* Intro Screen */
#intro-screen {
    padding: 40px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.typewriter {
    overflow: hidden;
    white-space: pre-wrap;
    margin-bottom: 20px;
    line-height: 1.8;
}

.terminal-prompt {
    color: var(--text-dim);
}

.terminal-prompt::before {
    content: '> ';
    color: var(--text-primary);
}

.blink-cursor::after {
    content: '█';
    animation: blink 1s infinite;
}

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

/* Leaderboard */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.leaderboard-table th {
    background: var(--bg-tertiary);
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 0.85em;
}

/* Final Code Entry */
.final-code-entry {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 30px 0;
}

.code-digit-input {
    width: 60px;
    height: 70px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 2em;
    text-align: center;
}

.code-digit-input:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: 0 0 10px var(--glow-color);
}

/* Timer */
.timer-display {
    font-size: 1.2em;
    color: var(--accent-yellow);
}

/* Music Toggle Button */
.music-toggle {
    position: fixed;
    top: max(15px, env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 2px solid var(--text-primary);
    color: var(--text-primary);
    font-size: 1.4em;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: inherit;
}

.music-toggle:hover {
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 0 15px var(--glow-color);
}

.music-toggle.muted {
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.music-toggle.muted:hover {
    background: var(--text-dim);
    color: var(--bg-primary);
}

.music-icon {
    line-height: 1;
    position: relative;
}

.music-toggle.muted .music-icon::after {
    content: '✕';
    font-size: 0.5em;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-red);
    font-weight: bold;
}

/* Achievement Toast Notification */
.achievement-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-yellow);
    padding: 15px 20px;
    z-index: 10001;
    animation: slideIn 0.5s ease-out, fadeOut 0.5s ease-in 2.5s forwards;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
    max-width: 300px;
}

.achievement-toast-header {
    font-size: 0.8em;
    color: var(--accent-yellow);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement-toast-icon {
    font-size: 2em;
}

.achievement-toast-name {
    color: var(--text-primary);
    font-weight: bold;
}

.achievement-toast-desc {
    font-size: 0.85em;
    color: var(--text-dim);
    margin-top: 4px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* Utility Classes */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none !important; }

/* Loading animation */
.loading {
    display: inline-block;
}

.loading::after {
    content: '';
    animation: loading 1s infinite;
}

@keyframes loading {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .modal {
        padding: 20px;
    }

    .title-text {
        font-size: 1.5em;
    }

    .main-title {
        font-size: 2.5em;
        letter-spacing: 8px;
    }

    .sub-title {
        font-size: 1.2em;
        letter-spacing: 5px;
    }

    .matching-container {
        grid-template-columns: 1fr;
    }

    .puzzle-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* ============================================
   MOBILE/TOUCH DEVICE IMPROVEMENTS
   ============================================ */

/* Prevent text selection during drag operations */
.sequence-container {
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS momentum scrolling inside modal */
    .modal {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent iOS zoom on double-tap */
    .btn,
    .option-item,
    .matching-item,
    .sequence-item,
    .puzzle-card {
        touch-action: manipulation;
    }
}

/* Touch-friendly sizes for all interactive elements */
@media (max-width: 768px) {
    /* Increase button touch targets */
    .btn {
        min-height: 48px;
        padding: 14px 24px;
    }

    .btn-small {
        min-height: 44px;
        padding: 12px 16px;
    }

    /* Larger touch targets for options */
    .option-item {
        min-height: 54px;
        padding: 16px;
    }

    .option-letter {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    /* Larger touch targets for matching items */
    .matching-item {
        min-height: 54px;
        padding: 16px;
        font-size: 0.95em;
    }

    /* Larger touch targets for sequence items */
    .sequence-item {
        min-height: 54px;
        padding: 16px;
        cursor: grab;
    }

    .sequence-item.dragging {
        opacity: 0.8;
        background: rgba(0, 204, 255, 0.15);
        border-color: var(--accent-blue);
        box-shadow: 0 4px 12px rgba(0, 204, 255, 0.3);
    }

    .sequence-number {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    /* Larger puzzle cards for easier tapping */
    .puzzle-card {
        min-height: 80px;
        padding: 20px;
    }

    /* Improve modal for mobile */
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .modal {
        max-height: calc(100vh - 40px);
        max-height: calc(100dvh - 40px);
        padding: 20px 15px;
        border-radius: 0;
    }

    .modal-close {
        top: 8px;
        right: 12px;
        font-size: 2em;
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hints section mobile adjustments */
    .hints-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .hints-header .btn-hint {
        width: 100%;
    }

    /* Puzzle question readable on mobile */
    .puzzle-question {
        font-size: 1em;
        line-height: 1.7;
    }

    .code-block {
        font-size: 0.8em;
        padding: 12px;
    }

    /* Sidebar mobile adjustments */
    .sidebar {
        position: relative;
        top: 0;
        padding: 15px;
    }

    .sidebar-section {
        margin-bottom: 15px;
    }

    /* Room map horizontal on mobile */
    .room-map {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
    }

    .room-indicator {
        flex: 1;
        min-width: calc(50% - 5px);
        padding: 6px;
    }

    .room-name {
        font-size: 0.7em;
    }

    /* Digits display */
    .digits-display {
        justify-content: center;
    }

    .digit-slot {
        width: 30px;
        height: 35px;
        font-size: 1.2em;
    }

    /* Main content mobile */
    .main-content {
        padding: 20px 15px;
    }

    .room-title {
        font-size: 1.2em;
    }

    .room-description {
        font-size: 0.9em;
    }

    .room-ascii {
        font-size: 5px;
        line-height: 1;
    }

    /* Final code entry mobile */
    .code-digit-input {
        width: 45px;
        height: 55px;
        font-size: 1.5em;
    }

    /* Victory screen mobile */
    .victory-code {
        font-size: 2em;
        letter-spacing: 5px;
    }

    .ascii-header {
        font-size: 4px;
        overflow: hidden;
    }

    /* Leaderboard mobile */
    .leaderboard-table {
        font-size: 0.85em;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 6px;
    }

    /* Achievement badges mobile */
    .achievements-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }

    .achievement-badge {
        padding: 10px;
    }

    .achievement-icon {
        font-size: 1.5em;
    }

    .achievement-name {
        font-size: 0.75em;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .main-title {
        font-size: 2em;
        letter-spacing: 5px;
    }

    .sub-title {
        font-size: 1em;
        letter-spacing: 3px;
    }

    .title-text {
        font-size: 1.2em;
    }

    .modal {
        padding: 15px 10px;
    }

    .puzzle-question {
        font-size: 0.95em;
    }

    .option-item,
    .matching-item,
    .sequence-item {
        font-size: 0.9em;
    }
}

/* Landscape mobile */
@media (max-width: 900px) and (orientation: landscape) {
    .modal {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
    }

    .modal-overlay {
        padding: 10px;
    }

    #intro-screen {
        padding: 20px;
    }

    .ascii-header {
        display: none;
    }
}
