/* CSS Variables for Level Themes */
:root {
    /* Default theme (classic) */
    --theme-primary: #00ff88;
    --theme-secondary: #ffaa00;
    --theme-background: #0a0a0a;
    --theme-board-bg: #1a1a2e;
    --theme-cell-border: #2a2a3e;
    --theme-hud-bg: #1a1a2e;
    --theme-hud-text: #ffffff;
    --theme-bonus-dl: #4a9eff;
    --theme-bonus-tl: #2563eb;
    --theme-bonus-dw: #f472b6;
    --theme-bonus-tw: #dc2626;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: var(--theme-background);
    color: #ffffff;
    overflow: hidden;
    user-select: none;
    transition: background 0.5s ease;
}

/* Pixel Art Text */
.pixel-text {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0px #000;
}

/* Screens */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.screen.active {
    display: flex;
}

.content {
    text-align: center;
    z-index: 2;
    max-width: 90%;
}

/* Animated Background */
.pixel-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    animation: bgPulse 5s ease-in-out infinite;
    z-index: 0;
}

/* Disable background animation on character screen */
#character-screen .pixel-bg {
    animation: none;
    opacity: 1;
}

/* Disable background animation on arcade title screen */
.arcade-title-screen .pixel-bg {
    animation: none;
}

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

/* Landing Screen */
.title {
    font-size: 72px;
    color: #00ff88;
    margin-bottom: 20px;
    animation: titleGlow 2s ease-in-out infinite;
}

/* Password Screen Logo */
.password-logo {
    max-width: 500px;
    width: 85%;
    height: auto;
    margin-bottom: 0;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 10px #00ff88, 0 0 20px #00ff88, 3px 3px 0px #000; }
    50% { text-shadow: 0 0 20px #00ff88, 0 0 30px #00ff88, 3px 3px 0px #000; }
}

.tagline {
    font-size: 18px;
    color: #ffaa00;
    margin-bottom: 40px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* Arcade Title Screen Styles */
.arcade-title-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.landing-content-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.landing-bg-rect {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 360px;
    background-color: rgba(15, 20, 30, 0.9);
    z-index: 0;
    overflow: hidden;
}

.landing-bg-rect::before {
    content: '';
    position: absolute;
    top: 0;
    left: -160px;
    width: calc(100% + 320px);
    height: 100%;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 79px,
            rgba(100, 120, 140, 0.15) 79px,
            rgba(100, 120, 140, 0.15) 80px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 79px,
            rgba(100, 120, 140, 0.15) 79px,
            rgba(100, 120, 140, 0.15) 80px
        );
    animation: gridScrollLeft 1.5s linear infinite;
}

@keyframes gridScrollLeft {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-80px);
    }
}

.arcade-title-container {
    margin-top: 0;
    margin-bottom: 0;
    text-align: center;
    position: relative;
    z-index: 1;
}

.arcade-title {
    font-size: 120px;
    font-weight: bold;
    line-height: 0.9;
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #ffeb3b 0%, #ff9800 30%, #f44336 60%, #d32f2f 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow:
        4px 4px 0px rgba(0, 0, 0, 0.8),
        6px 6px 0px rgba(0, 0, 0, 0.5),
        8px 8px 0px rgba(0, 0, 0, 0.3);
    filter: drop-shadow(0 0 20px rgba(255, 152, 0, 0.8));
    letter-spacing: -4px;
    animation: arcadeTitlePulse 2s ease-in-out infinite;
}

/* Safari fallback for text gradient */
@supports not (-webkit-background-clip: text) {
    .arcade-title {
        color: #ff9800;
        text-shadow:
            0 0 10px #ffeb3b,
            0 0 20px #ff9800,
            4px 4px 0px rgba(0, 0, 0, 0.8),
            6px 6px 0px rgba(0, 0, 0, 0.5);
    }
}

@keyframes arcadeTitlePulse {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(255, 152, 0, 0.8));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(255, 152, 0, 1));
        transform: scale(1.02);
    }
}

/* Logo Image */
.arcade-logo {
    max-width: 540px;
    width: 81%;
    height: auto;
    animation: logoFloat 3s ease-in-out infinite;
}

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

.arcade-subtitle {
    font-size: 32px;
    font-weight: bold;
    color: #42a5f5;
    margin-top: 10px;
    text-shadow:
        0 0 10px #42a5f5,
        0 0 20px #1976d2,
        2px 2px 0px #000;
    letter-spacing: 8px;
    animation: subtitleFlicker 3s ease-in-out infinite;
}

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

.insert-coin {
    display: none;
}

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

.arcade-primary-actions {
    display: flex;
    flex-direction: row;
    gap: 30px;
    margin-bottom: 40px;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.arcade-button-large {
    background: linear-gradient(180deg, #00ff88 0%, #00cc66 100%);
    border: 4px solid #fff;
    color: #000;
    padding: 13px 50px;
    font-size: 28px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    min-width: 280px;
    box-shadow:
        0 0 20px rgba(0, 255, 136, 0.5),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        6px 6px 0px rgba(0, 0, 0, 0.4);
    transition: all 0.1s;
    position: relative;
}

.arcade-button-large:hover,
.arcade-button-large:focus,
.arcade-button-large.keyboard-focused {
    background: linear-gradient(180deg, #00ffaa 0%, #00dd77 100%);
    box-shadow:
        0 0 30px rgba(0, 255, 136, 0.8),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        6px 6px 0px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    outline: none;
}

.arcade-button-large:active {
    transform: translateY(2px);
    box-shadow:
        0 0 15px rgba(0, 255, 136, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.2),
        3px 3px 0px rgba(0, 0, 0, 0.4);
}

.arcade-quick-actions {
    display: flex;
    flex-direction: row;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.arcade-button-medium {
    background: linear-gradient(180deg, #ffaa00 0%, #ff8800 100%);
    border: 3px solid #fff;
    color: #000;
    padding: 15px 35px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.3);
    box-shadow:
        0 0 20px rgba(255, 170, 0, 0.6),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        5px 5px 0px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    letter-spacing: 1px;
    opacity: 1;
    animation: none;
    text-align: center;
    display: inline-block;
}

.arcade-button-medium:hover,
.arcade-button-medium:focus,
.arcade-button-medium.keyboard-focused {
    background: linear-gradient(180deg, #ffcc00 0%, #ffaa00 100%);
    box-shadow:
        0 0 30px rgba(255, 170, 0, 0.8),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        5px 5px 0px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
    outline: none;
}

.arcade-button-medium:active {
    transform: translateY(2px);
    box-shadow:
        0 0 15px rgba(255, 170, 0, 0.5),
        inset 0 -2px 0 rgba(0, 0, 0, 0.2),
        3px 3px 0px rgba(0, 0, 0, 0.4);
}

.arcade-button-medium:disabled {
    background: linear-gradient(180deg, #666 0%, #555 100%);
    border-color: #444;
    color: #888;
    cursor: not-allowed;
    box-shadow:
        0 0 10px rgba(100, 100, 100, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        5px 5px 0px rgba(0, 0, 0, 0.3);
}

.arcade-button-medium:disabled:hover {
    background: linear-gradient(180deg, #666 0%, #555 100%);
    transform: none;
    box-shadow:
        0 0 10px rgba(100, 100, 100, 0.3),
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        5px 5px 0px rgba(0, 0, 0, 0.3);
}

.arcade-secondary-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.arcade-button-small {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 20px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.arcade-button-small:hover,
.arcade-button-small:focus,
.arcade-button-small.keyboard-focused {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    outline: none;
}

.arcade-button-small:active {
    transform: scale(0.95);
}

/* Keyboard shortcut underlines in buttons */
.arcade-button-large u,
.arcade-button-medium u,
.arcade-button-small u {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
}

/* Pixel Inputs */
.pixel-input {
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    color: var(--theme-hud-text);
    padding: 12px 20px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    outline: none;
    min-width: 300px;
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

.pixel-input:focus {
    border-color: var(--theme-secondary);
    box-shadow: 0 0 10px var(--theme-secondary);
}

.pixel-select {
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    color: var(--theme-hud-text);
    padding: 12px 20px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    outline: none;
    cursor: pointer;
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

.pixel-select:hover {
    border-color: var(--theme-secondary);
}

.pixel-select option {
    background: var(--theme-hud-bg);
    color: var(--theme-hud-text);
}

/* Pixel Buttons */
.pixel-button {
    background: #00ff88;
    border: 3px solid #00cc66;
    color: #000;
    padding: 12px 30px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 4px 4px 0px #00aa55;
    min-width: 300px;
}

.pixel-button:hover,
.pixel-button:focus,
.pixel-button.keyboard-focused {
    background: #00ffaa;
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #00aa55;
    outline: none;
}

.pixel-button:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.pixel-button.small {
    min-width: auto;
    padding: 8px 20px;
    font-size: 14px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pixel-button:disabled {
    background: #444;
    border-color: #333;
    color: #666;
    cursor: not-allowed;
    box-shadow: 4px 4px 0px #222;
}

.pixel-button:disabled:hover {
    background: #444;
    transform: none;
    box-shadow: 4px 4px 0px #222;
}

/* Theme-aware buttons for game screen */
#game-screen .pixel-button,
#menu-btn {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-hud-bg);
    box-shadow: 4px 4px 0px var(--theme-secondary);
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease, box-shadow 0.5s ease;
}

#game-screen .pixel-button:hover,
#menu-btn:hover {
    background: var(--theme-secondary);
    border-color: var(--theme-secondary);
    box-shadow: 2px 2px 0px var(--theme-primary);
}

#game-screen .pixel-button:active,
#menu-btn:active {
    box-shadow: none;
}

.quickstart-button {
    background: #ffaa00 !important;
    border-color: #ff9500 !important;
    box-shadow: 4px 4px 0px #cc7700 !important;
}

.quickstart-button:hover {
    background: #ffbb22 !important;
    box-shadow: 2px 2px 0px #cc7700 !important;
}

.quickstart-button:active {
    box-shadow: none !important;
}

/* Circular Back Button */
.back-circle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(20, 30, 40, 0.8) 100%);
    border: 3px solid #00ff88;
    color: #00ff88;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
    font-family: Arial, sans-serif;
    padding: 0;
    line-height: 1;
}

.back-circle-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.2) 0%, rgba(20, 40, 30, 0.9) 100%);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.6);
    transform: scale(1.1);
}

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

/* Character Selection - Fighting Game Style */
.character-select-container {
    width: 95%;
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 2;
    padding: 0 20px;
}

.character-select-title {
    color: var(--theme-primary);
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 15px;
    text-transform: uppercase;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.character-select-subtitle {
    color: var(--theme-secondary);
    font-size: 14px;
    margin-bottom: 25px;
    font-style: italic;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
    white-space: nowrap;
}

/* Character Preview Box - Above Grid */
.character-preview-box {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(10, 20, 30, 0.85) 100%);
    border: 3px solid #00ff88;
    padding: 30px 35px;
    margin: 0 auto 25px auto;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    width: fit-content;
    height: 300px;
}

.character-preview-content {
    display: flex;
    gap: 25px;
    align-items: stretch;
    justify-content: flex-start;
    width: 700px;
    height: 100%;
}

/* When no character selected, center the text */
.character-preview-content.no-selection {
    justify-content: center;
    align-items: center;
}

.character-preview-content.no-selection .character-preview-left {
    min-width: auto;
}

.character-preview-content.no-selection .character-preview-right {
    display: none;
}

.character-preview-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    flex-shrink: 0;
}

.character-preview-right {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(7, 90px);
    grid-template-rows: repeat(2, 90px);
    gap: 10px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(20, 30, 50, 0.6) 100%);
    margin: 0 auto 25px auto;
    width: fit-content;
    border-radius: 8px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.character-grid:hover,
.character-grid.keyboard-focus-active {
    border-color: #ffaa00;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(255, 170, 0, 0.6);
    background: linear-gradient(135deg, rgba(50, 40, 0, 0.6) 0%, rgba(40, 30, 20, 0.6) 100%);
}

.character-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    border: 3px solid #333;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

/* Hover state - only on devices with hover capability (excludes touch devices) */
@media (hover: hover) and (pointer: fine) {
    .character-grid:not(.keyboard-focus-active) .character-card:not(.selected):hover {
        border-color: #00ff88;
        background: linear-gradient(135deg, #252540 0%, #1a1a35 100%);
        transform: translateY(-3px);
        box-shadow: 0 5px 20px rgba(0, 255, 136, 0.6);
    }
}

/* Keyboard navigation focus (works on all devices) */
.character-card.keyboard-focused {
    border-color: #00ff88;
    background: linear-gradient(135deg, #252540 0%, #1a1a35 100%);
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.6);
}

/* Selected state - orange border (takes precedence over hover) */
.character-card.selected {
    border-color: #ffaa00;
    background: linear-gradient(135deg, #3a3a1e 0%, #2a2a1e 100%);
    box-shadow: 0 0 25px #ffaa00, inset 0 0 25px rgba(255, 170, 0, 0.3);
    transform: scale(1.05);
}

@keyframes pulseSelected {
    0%, 100% { box-shadow: 0 0 20px #ffaa00, inset 0 0 20px rgba(255, 170, 0, 0.2); }
    50% { box-shadow: 0 0 30px #ffaa00, inset 0 0 30px rgba(255, 170, 0, 0.3); }
}

.character-icon {
    font-size: 45px;
    line-height: 1;
    margin-bottom: 4px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.character-card h3 {
    color: #00ff88;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.character-card.selected h3 {
    color: #ffaa00;
}

/* Character Input Fields Container */
.character-inputs {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.character-inputs .name-input {
    min-width: 300px;
    flex: 1;
    max-width: 400px;
}

.character-preview-icon {
    font-size: 120px;
    line-height: 1;
    filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.6));
    animation: floatIcon 3s ease-in-out infinite;
}

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

.spell-list-title {
    color: #ffaa00;
    font-size: 14px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #ffaa00;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
}

#spell-words-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 8px;
}

#spell-words-list::-webkit-scrollbar {
    width: 10px;
}

#spell-words-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

#spell-words-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

#spell-words-list::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
    background-clip: padding-box;
}

.spell-item {
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 8px;
    font-family: 'Courier New', monospace;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.spell-word {
    color: var(--theme-primary);
    font-size: 13px;
    font-weight: bold;
    min-width: 100px;
    flex-shrink: 0;
}

.spell-desc {
    color: var(--theme-hud-text);
    opacity: 0.9;
    font-size: 12px;
    flex: 1;
    min-width: 250px;
}

/* Character Intro Overlay */
.character-intro-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.character-intro-overlay.active {
    display: flex;
    opacity: 1;
}

.intro-bg-rect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 20, 30, 0.5);
    z-index: 0;
    overflow: hidden;
}

.intro-bg-rect::before {
    content: '';
    position: absolute;
    top: 0;
    left: -160px;
    width: calc(100% + 320px);
    height: 100%;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 79px,
            rgba(100, 120, 140, 0.15) 79px,
            rgba(100, 120, 140, 0.15) 80px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 79px,
            rgba(100, 120, 140, 0.15) 79px,
            rgba(100, 120, 140, 0.15) 80px
        );
    animation: gridScrollLeft 1.5s linear infinite;
}

.character-intro-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 80px;
    animation: none;
    padding-top: 50px;
    position: relative;
    z-index: 1;
}

.character-intro-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    position: relative;
}

.character-intro-icon {
    font-size: 280px;
    animation: introIconDramaticEntrance 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
               introIconPulse 2s ease-in-out 1.2s infinite;
    filter: drop-shadow(0 0 40px rgba(255, 170, 0, 0));
    opacity: 0;
    transform: scale(0) rotate(-180deg);
}

@keyframes introIconDramaticEntrance {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
        filter: drop-shadow(0 0 0px rgba(255, 170, 0, 0));
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 40px rgba(255, 170, 0, 0.8));
    }
}

@keyframes introIconPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 40px rgba(255, 170, 0, 0.8));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 60px rgba(255, 170, 0, 1));
    }
}

.character-intro-icon.exit {
    animation: introIconDramaticExit 0.8s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes introIconDramaticExit {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 40px rgba(255, 170, 0, 0.8));
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(180deg);
        filter: drop-shadow(0 0 0px rgba(255, 170, 0, 0));
    }
}

.character-intro-name {
    display: flex;
    gap: 6px;
    justify-content: center;
    min-height: 80px;
}

.character-intro-tile {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #f5e6d3 0%, #d4b896 100%);
    border: 3px solid #8b6f47;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: #2c1810;
    box-shadow:
        0 4px 0 #6b5639,
        0 6px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    opacity: 0;
    transform: translateY(-150px) rotate(15deg);
    animation: tileDrop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.character-intro-tile .value {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: grid;
    grid-template-columns: 4px 4px;
    grid-template-rows: 4px 4px;
    gap: 2px;
    width: 10px;
    height: 10px;
}

.character-intro-tile .point-dot {
    width: 4px;
    height: 4px;
    background: #2c1810;
    border-radius: 50%;
    opacity: 0.8;
}

/* Position dots for character intro tiles */
.character-intro-tile .value .point-dot:only-child {
    grid-column: 2;
    grid-row: 2;
}

.character-intro-tile .value .point-dot:first-child:nth-last-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.character-intro-tile .value .point-dot:first-child:nth-last-child(2) ~ .point-dot {
    grid-column: 2;
    grid-row: 2;
}

.character-intro-tile .value .point-dot:first-child:nth-last-child(3) {
    grid-column: 2;
    grid-row: 1;
}

.character-intro-tile .value .point-dot:first-child:nth-last-child(3) ~ .point-dot:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.character-intro-tile .value .point-dot:first-child:nth-last-child(3) ~ .point-dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

@keyframes tileDrop {
    0% {
        opacity: 0;
        transform: translateY(-150px) rotate(15deg);
    }
    60% {
        transform: translateY(8px) rotate(-5deg);
    }
    75% {
        transform: translateY(-4px) rotate(2deg);
    }
    90% {
        transform: translateY(2px) rotate(-1deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
}

.character-intro-taunt {
    opacity: 0;
    transform: translateX(50px);
    animation: bubbleSlideIn 0.8s ease-out 0.8s forwards,
               bubbleFloat 3s ease-in-out 1.6s infinite;
    margin-top: 60px;
}

@keyframes bubbleSlideIn {
    0% {
        opacity: 0;
        transform: translateX(50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.speech-bubble {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 3px solid #00ff88;
    border-radius: 20px;
    padding: 30px 45px;
    max-width: 500px;
    box-shadow:
        0 0 30px rgba(0, 255, 136, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
}

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

.speech-bubble::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -20px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 20px solid #00ff88;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -14px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 17px solid rgba(255, 255, 255, 0.1);
}

.speech-text {
    font-size: 24px;
    color: #fff;
    text-align: center;
    font-style: italic;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    line-height: 1.4;
}

.skip-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    opacity: 0;
    animation: fadeInHint 0.5s ease 2s forwards;
}

@keyframes fadeInHint {
    to {
        opacity: 1;
    }
}

/* Password Screen */
.password-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
}

.password-container #password-input {
    flex: 1;
    max-width: 300px;
}

.password-container #password-submit-btn {
    flex-shrink: 0;
    min-width: 120px;
}

.password-error {
    color: #ff6b6b;
    font-size: 14px;
    min-height: 20px;
    text-shadow: 1px 1px 0px #000;
    position: absolute;
    margin-top: 70px;
}

/* Character Dialog */
.character-dialog-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 15px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.75);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.character-dialog-container.has-dialog {
    opacity: 1;
    pointer-events: auto;
}

.character-dialog {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 101;
}

.character-dialog.active {
    opacity: 1;
    transform: translateY(0);
}

/* Player dialog */
.character-dialog.player {
    flex-direction: row-reverse;
}

/* Other players' dialog */
.character-dialog.other {
}

.character-dialog-icon {
    font-size: 44px;
    filter: drop-shadow(0 0 10px rgba(255, 170, 0, 0.6));
    animation: dialogIconFloat 2s ease-in-out infinite;
}

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

.character-dialog-bubble {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 2px solid #00ff88;
    border-radius: 14px;
    padding: 10px 18px;
    max-width: 380px;
    box-shadow: 0 0 18px rgba(0, 255, 136, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.character-dialog-bubble::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -10px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 10px solid #00ff88;
}

.character-dialog-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -7px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid rgba(255, 255, 255, 0.1);
}

/* Player bubble tail points to the right */
.character-dialog.player .character-dialog-bubble::before {
    left: auto;
    right: -10px;
    border-right: none;
    border-left: 10px solid #00ff88;
}

.character-dialog.player .character-dialog-bubble::after {
    left: auto;
    right: -7px;
    border-right: none;
    border-left: 8px solid rgba(255, 255, 255, 0.1);
}

.character-dialog-text {
    font-size: 15px;
    color: #fff;
    text-align: left;
    font-style: italic;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    line-height: 1.3;
}

/* Setup Screen */
.setup-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px auto;
    max-width: 400px;
}

.option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
}

.option label {
    color: #00ff88;
}

/* Level Selection */
#setup-screen {
    background: var(--theme-background);
    transition: background 0.5s ease;
}

#setup-screen .content {
    background: var(--theme-hud-bg);
    border: 4px solid var(--theme-primary);
    padding: 30px;
    border-radius: 8px;
    transition: background 0.5s ease, border-color 0.5s ease;
}

#setup-screen h2, #setup-screen h3 {
    color: var(--theme-primary) !important;
    transition: color 0.5s ease;
}

/* Level Selection Layout */
.level-selection-layout {
    display: flex;
    gap: 25px;
    justify-content: center;
    align-items: stretch;
    margin: 25px auto;
    max-width: 900px;
}

.level-grid-container {
    flex-shrink: 0;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 140px);
    grid-template-rows: repeat(3, 110px);
    gap: 12px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(20, 30, 50, 0.6) 100%);
    border-radius: 8px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 0 30px transparent;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    height: 410px;
}

.level-grid:hover,
.level-grid.keyboard-focus-active {
    border-color: #ffaa00;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(255, 170, 0, 0.6);
    background: linear-gradient(135deg, rgba(50, 40, 0, 0.6) 0%, rgba(40, 30, 20, 0.6) 100%);
}

.level-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    border: 3px solid #333;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

/* Hover state - only on devices with hover capability (excludes touch devices) */
@media (hover: hover) and (pointer: fine) {
    .level-grid:not(.keyboard-focus-active) .level-card:not(.selected):hover {
        border-color: #00ff88;
        background: linear-gradient(135deg, #252540 0%, #1a1a35 100%);
        box-shadow: 0 5px 20px rgba(0, 255, 136, 0.6);
    }
}

/* Keyboard navigation focus (works on all devices) */
.level-card.keyboard-focused {
    border-color: #00ff88;
    background: linear-gradient(135deg, #252540 0%, #1a1a35 100%);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.6);
}

/* Selected state - orange (takes precedence over hover) */
.level-card.selected {
    border-color: #ffaa00;
    background: linear-gradient(135deg, #3a3a1e 0%, #2a2a1e 100%);
    box-shadow: 0 0 25px #ffaa00, inset 0 0 25px rgba(255, 170, 0, 0.3);
}

.level-icon {
    font-size: 50px;
    line-height: 1;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Make octagon emoji appear white/light in level selection cards */
.level-card[data-level="octagon"] .level-icon {
    filter: grayscale(100%) brightness(2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Make octagon emoji appear white/light in preview panel */
.level-preview-panel:has(.level-preview-name:contains("OCTAGON")) .level-preview-icon,
.level-preview-icon:first-child {
    /* This will be applied via JavaScript for dynamic content */
}

/* General octagon emoji styling - applied globally */
span.octagon-icon,
#hud-level-name.octagon-level {
    filter: grayscale(100%) brightness(2);
}

.level-card h3 {
    color: #00ff88;
    font-size: 11px;
    margin: 0;
    text-align: center;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Level Preview Panel */
.level-preview-panel {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(10, 20, 30, 0.85) 100%);
    border: 3px solid #00ff88;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5);
    width: 480px;
    height: 390px;
    overflow-y: auto;
    flex-shrink: 0;
}

.level-preview-icon {
    font-size: 80px;
    text-align: center;
    margin-bottom: 15px;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.7));
}

.level-preview-name {
    color: #00ff88;
    font-size: 22px;
    text-align: center;
    margin: 0 0 15px 0;
    font-family: 'Courier New', monospace;
    letter-spacing: 1.5px;
    font-weight: bold;
}

.level-preview-description {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
    opacity: 0.9;
}

.level-preview-section {
    margin-bottom: 20px;
}

.level-preview-section h4 {
    color: #ffaa00;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    margin: 0 0 8px 0;
    font-weight: bold;
}

.level-preview-section p {
    color: #ffffff;
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    opacity: 0.85;
}

.level-thematic-words {
    word-wrap: break-word;
}

.level-board-size,
.level-mechanics,
.level-bonus-multiplier {
    font-weight: bold;
}

.option label {
    color: var(--theme-primary);
    transition: color 0.5s ease;
}

/* Options Layout - Form on Left, Explanation on Right */
.options-layout {
    display: flex;
    gap: 30px;
    margin: 30px auto;
    max-width: 1000px;
}

/* Form Section */
.options-form-section {
    flex: 0 0 480px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(20, 30, 50, 0.7) 100%);
    border: 3px solid rgba(0, 255, 136, 0.4);
    border-radius: 8px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 255, 136, 0.3);
}

.form-group {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 2px solid rgba(0, 255, 136, 0.2);
}

.form-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-group-label {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #00ff88;
    display: block;
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.form-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-label-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.inline-label-group .form-group-label {
    margin-bottom: 0;
}

.inline-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-label {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #ccc;
    min-width: 130px;
}

.form-options .pixel-select {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    padding: 8px 12px;
}

.form-options .pixel-select.compact {
    flex: 0 0 auto;
    width: 70px;
}

.form-options .pixel-input {
    flex: 0 0 auto;
    min-width: 0;
    width: 90px;
    font-size: 14px;
    padding: 8px 12px;
}

.form-options .pixel-input.compact {
    width: 70px;
}

/* Explanation Section */
.options-explanation-section {
    flex: 1;
    padding: 30px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(10, 20, 30, 0.6) 100%);
    border: 3px solid rgba(255, 170, 0, 0.4);
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 170, 0, 0.2);
    overflow-y: auto;
    max-height: 500px;
}

.explanation-title {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: #ffaa00;
    text-align: center;
    margin: 0 0 25px 0;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

.explanation-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 170, 0, 0.2);
}

.explanation-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.explanation-item h4 {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    color: #00ff88;
    margin: 0 0 10px 0;
    letter-spacing: 0.5px;
}

.explanation-item p {
    font-family: 'Arial', sans-serif;
    font-size: 13px;
    line-height: 1.6;
    color: #ccc;
    margin: 0;
}

.explanation-item p strong {
    color: #ffaa00;
    font-weight: bold;
}

/* Options Bottom Buttons */
.options-bottom-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

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

.modal-content {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(10, 20, 30, 0.95) 100%);
    border: 3px solid rgba(255, 170, 0, 0.6);
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(255, 170, 0, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid rgba(255, 170, 0, 0.3);
}

.modal-title {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: #ffaa00;
    margin: 0;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

.modal-close {
    background: none;
    border: none;
    color: #ffaa00;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
}

.modal-close:hover {
    color: #fff;
    transform: scale(1.2);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

/* Game Screen */
#game-screen {
    flex-direction: column;
    padding: 10px;
}

.board-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
    padding-top: 10px;
}

/* Mobile-only elements hidden on desktop */
.mobile-only {
    display: none;
}

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

.board-player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.board-player-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.level-title {
    font-family: 'Courier New', monospace;
    font-size: 28px;
    font-weight: bold;
    color: var(--theme-primary);
    text-align: left;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: color 0.5s ease;
}

.hud-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.hud-item {
    font-size: 16px;
    color: var(--theme-hud-text);
    transition: color 0.5s ease;
}

.hud-item .label {
    color: var(--theme-primary);
    margin-right: 5px;
    transition: color 0.5s ease;
}

.hud-item span:last-child {
    color: var(--theme-secondary);
    font-weight: bold;
    transition: color 0.5s ease;
}

.player-hud-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    overflow: visible;
}

.player-section-divider {
    border: none;
    border-top: 2px solid #444;
    margin: 15px 0 5px 0;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#hud-character-icon {
    font-size: 32px;
}

#hud-player {
    color: var(--theme-secondary);
    font-weight: bold;
    font-size: 20px;
    line-height: 1;
    transition: color 0.5s ease;
}

#hud-level-name {
    color: var(--theme-primary);
    font-size: 20px;
    line-height: 1;
    opacity: 0.8;
    transition: color 0.5s ease;
}

.player-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.menu-container {
    position: relative;
}

.menu-dropdown {
    display: none;
    position: fixed;
    top: 50px;
    right: 10px;
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    min-width: 250px;
    z-index: 10000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.5s ease, border-color 0.5s ease;
}

.menu-dropdown.active {
    display: block;
}

.menu-item {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--theme-primary);
    color: var(--theme-primary);
    padding: 12px 15px;
    text-align: left;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
}

.menu-item.menu-info {
    cursor: default;
    background: rgba(0, 0, 0, 0.1);
}

.menu-item.menu-info .label {
    color: var(--theme-primary);
    margin-right: 8px;
}

.menu-item.menu-info #hud-room-code {
    color: var(--theme-secondary);
    font-weight: bold;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-divider {
    height: 1px;
    background: var(--theme-primary);
    margin: 5px 0;
    opacity: 0.3;
}

.menu-section-label {
    padding: 8px 15px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--theme-primary);
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-item:hover:not(.menu-info) {
    background: rgba(0, 0, 0, 0.1);
    color: var(--theme-secondary);
}

.menu-item.menu-info:hover {
    background: rgba(0, 0, 0, 0.1);
}

.game-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
    flex: 1;
    overflow: auto;
    padding: 10px;
}

/* Board */
.board {
    display: grid;
    grid-template-columns: repeat(15, 40px);
    grid-template-rows: repeat(15, 40px);
    gap: 2px;
    background: var(--theme-background);
    border: none;
    padding: 0;
    overflow: visible;
}

.board-cell {
    width: 40px;
    height: 40px;
    background: var(--theme-board-bg);
    border: 2px solid var(--theme-cell-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* Disabled cells for shaped boards (hexagon, etc) */
.board-cell.disabled {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
    opacity: 0;
}

.board-cell.bonus-2x {
    background: var(--theme-bonus-dl);
    border-color: var(--theme-bonus-dl);
    filter: brightness(0.9);
    font-size: 16px;
}

.board-cell.bonus-3x {
    background: var(--theme-bonus-tl);
    border-color: var(--theme-bonus-tl);
    filter: brightness(0.9);
}

.board-cell.bonus-4x {
    background: var(--theme-bonus-dw);
    border-color: var(--theme-bonus-dw);
    filter: brightness(0.9);
}

.board-cell.bonus-5x {
    background: var(--theme-bonus-tw);
    border-color: var(--theme-bonus-tw);
    filter: brightness(0.9);
}

.board-cell.bonus-6x {
    background: var(--theme-bonus-tw);
    border-color: var(--theme-bonus-tw);
    filter: brightness(1.1);
    font-size: 16px;
}

.board-cell.bonus-7x {
    background: var(--theme-bonus-tw);
    border-color: var(--theme-bonus-tw);
    filter: brightness(0.8);
    font-size: 16px;
}

.board-cell.center {
    background: var(--theme-secondary);
    border-color: var(--theme-center-border);
    border-width: 2px;
}

/* Bonus tile hover tooltip */
.board-cell[data-bonus-name]:hover::after {
    content: attr(data-bonus-name);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: var(--theme-primary);
    color: var(--theme-hud-bg);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.board-cell[data-bonus-name]:hover {
    z-index: 10000;
    overflow: visible;
}

/* Space level floating animation */
@keyframes floatCell {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Apply floating to all board cells when space level is active */
.board.space-level .board-cell {
    animation-name: floatCell;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-fill-mode: both;
    animation-play-state: running;
}

/* Randomized animation timing for independent floating */
.board.space-level .board-cell:nth-child(1) { animation-delay: 0.3s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(2) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(3) { animation-delay: 0.9s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(4) { animation-delay: 2.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(5) { animation-delay: 0.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(6) { animation-delay: 1.2s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(7) { animation-delay: 2.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(8) { animation-delay: 0.4s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(9) { animation-delay: 1.9s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(10) { animation-delay: 0.7s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(11) { animation-delay: 2.1s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(12) { animation-delay: 1.4s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(13) { animation-delay: 0.2s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(14) { animation-delay: 2.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(15) { animation-delay: 1.1s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(16) { animation-delay: 0.8s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(17) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(18) { animation-delay: 1.5s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(19) { animation-delay: 0.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(20) { animation-delay: 2.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(21) { animation-delay: 1.3s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(22) { animation-delay: 0.5s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(23) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(24) { animation-delay: 1.8s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(25) { animation-delay: 0.9s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(26) { animation-delay: 2.4s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(27) { animation-delay: 1.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(28) { animation-delay: 0.3s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(29) { animation-delay: 2.7s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(30) { animation-delay: 1.0s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(31) { animation-delay: 0.6s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(32) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(33) { animation-delay: 1.4s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(34) { animation-delay: 0.2s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(35) { animation-delay: 2.9s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(36) { animation-delay: 1.7s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(37) { animation-delay: 0.8s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(38) { animation-delay: 2.3s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(39) { animation-delay: 1.2s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(40) { animation-delay: 0.4s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(41) { animation-delay: 2.8s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(42) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(43) { animation-delay: 0.7s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(44) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(45) { animation-delay: 1.9s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(46) { animation-delay: 0.1s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(47) { animation-delay: 2.5s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(48) { animation-delay: 1.1s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(49) { animation-delay: 0.9s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(50) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(51) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(52) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(53) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(54) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(55) { animation-delay: 0.3s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(56) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(57) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(58) { animation-delay: 0.6s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(59) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(60) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(61) { animation-delay: 0.2s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(62) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(63) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(64) { animation-delay: 0.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(65) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(66) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(67) { animation-delay: 0.4s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(68) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(69) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(70) { animation-delay: 0.7s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(71) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(72) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(73) { animation-delay: 0.1s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(74) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(75) { animation-delay: 1.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(76) { animation-delay: 0.9s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(77) { animation-delay: 2.5s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(78) { animation-delay: 1.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(79) { animation-delay: 0.6s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(80) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(81) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(82) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(83) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(84) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(85) { animation-delay: 0.3s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(86) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(87) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(88) { animation-delay: 0.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(89) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(90) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(91) { animation-delay: 0.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(92) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(93) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(94) { animation-delay: 0.4s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(95) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(96) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(97) { animation-delay: 0.7s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(98) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(99) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(100) { animation-delay: 0.1s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(101) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(102) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(103) { animation-delay: 0.9s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(104) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(105) { animation-delay: 1.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(106) { animation-delay: 0.3s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(107) { animation-delay: 2.5s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(108) { animation-delay: 1.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(109) { animation-delay: 0.6s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(110) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(111) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(112) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(113) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(114) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(115) { animation-delay: 0.2s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(116) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(117) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(118) { animation-delay: 0.8s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(119) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(120) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(121) { animation-delay: 0.4s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(122) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(123) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(124) { animation-delay: 0.7s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(125) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(126) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(127) { animation-delay: 0.1s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(128) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(129) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(130) { animation-delay: 0.9s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(131) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(132) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(133) { animation-delay: 0.3s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(134) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(135) { animation-delay: 1.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(136) { animation-delay: 0.6s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(137) { animation-delay: 2.5s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(138) { animation-delay: 1.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(139) { animation-delay: 0.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(140) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(141) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(142) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(143) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(144) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(145) { animation-delay: 0.8s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(146) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(147) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(148) { animation-delay: 0.4s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(149) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(150) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(151) { animation-delay: 0.7s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(152) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(153) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(154) { animation-delay: 0.1s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(155) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(156) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(157) { animation-delay: 0.9s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(158) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(159) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(160) { animation-delay: 0.3s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(161) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(162) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(163) { animation-delay: 0.6s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(164) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(165) { animation-delay: 1.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(166) { animation-delay: 0.2s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(167) { animation-delay: 2.5s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(168) { animation-delay: 1.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(169) { animation-delay: 0.8s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(170) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(171) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(172) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(173) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(174) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(175) { animation-delay: 0.4s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(176) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(177) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(178) { animation-delay: 0.1s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(179) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(180) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(181) { animation-delay: 0.7s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(182) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(183) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(184) { animation-delay: 0.9s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(185) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(186) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(187) { animation-delay: 0.3s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(188) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(189) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(190) { animation-delay: 0.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(191) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(192) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(193) { animation-delay: 0.2s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(194) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(195) { animation-delay: 1.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(196) { animation-delay: 0.8s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(197) { animation-delay: 2.5s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(198) { animation-delay: 1.1s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(199) { animation-delay: 0.4s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(200) { animation-delay: 2.6s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(201) { animation-delay: 1.3s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(202) { animation-delay: 0.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(203) { animation-delay: 2.0s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(204) { animation-delay: 1.8s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(205) { animation-delay: 0.1s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(206) { animation-delay: 2.4s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(207) { animation-delay: 1.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(208) { animation-delay: 0.7s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(209) { animation-delay: 2.7s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(210) { animation-delay: 1.0s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(211) { animation-delay: 0.9s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(212) { animation-delay: 2.1s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(213) { animation-delay: 1.4s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(214) { animation-delay: 0.3s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(215) { animation-delay: 2.9s; animation-duration: 3.5s; }
.board.space-level .board-cell:nth-child(216) { animation-delay: 1.7s; animation-duration: 2.8s; }
.board.space-level .board-cell:nth-child(217) { animation-delay: 0.6s; animation-duration: 3.2s; }
.board.space-level .board-cell:nth-child(218) { animation-delay: 2.3s; animation-duration: 3.0s; }
.board.space-level .board-cell:nth-child(219) { animation-delay: 1.2s; animation-duration: 2.6s; }
.board.space-level .board-cell:nth-child(220) { animation-delay: 0.2s; animation-duration: 3.4s; }
.board.space-level .board-cell:nth-child(221) { animation-delay: 2.8s; animation-duration: 2.9s; }
.board.space-level .board-cell:nth-child(222) { animation-delay: 1.5s; animation-duration: 3.1s; }
.board.space-level .board-cell:nth-child(223) { animation-delay: 0.8s; animation-duration: 2.7s; }
.board.space-level .board-cell:nth-child(224) { animation-delay: 2.2s; animation-duration: 3.3s; }
.board.space-level .board-cell:nth-child(225) { animation-delay: 1.9s; animation-duration: 3.5s; }

.board-cell.filled {
    background: var(--theme-filled-cell-bg);
    color: var(--theme-primary);
    font-weight: bold;
    transition: color 0.5s ease;
}

.board-cell.filled.special-letter {
    background: #3a3a2e;
    color: #ffdd00;
    box-shadow: 0 0 8px rgba(255, 221, 0, 0.3);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 221, 0, 0.5);
}

.board-cell.used {
    background: #3a3a4e;
}

.board-cell.preview {
    background: #4a4a6e;
    color: #ffaa00;
    opacity: 0.85;
    box-shadow: 0 0 8px rgba(255, 170, 0, 0.5);
}

.status.special ~ .board .board-cell.preview {
    background: #6a5a3e;
    color: #ffdd00;
    box-shadow: 0 0 15px rgba(255, 221, 0, 0.6);
}

.board-cell.preview-intersection {
    box-shadow: 0 0 12px #ffaa00;
}

.board-cell.other-player-preview {
    outline: 2px dashed rgba(255, 107, 107, 0.7);
    outline-offset: -2px;
}

@keyframes otherPlayerPulse {
    0%, 100% {
        outline-color: rgba(255, 107, 107, 0.4);
    }
    50% {
        outline-color: rgba(255, 107, 107, 0.8);
    }
}

.board-cell.word-placed-animation {
    position: relative;
    box-shadow: 0 0 20px var(--player-color);
    animation: wordPlacedGlow 0.4s ease-out forwards;
}

.board-cell.word-placed-animation::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid var(--player-color);
    border-radius: 2px;
    pointer-events: none;
    opacity: 1;
    animation: borderAppear 0.3s ease-out forwards;
}

.board-cell.word-placed-fading {
    animation: wordPlacedFadeOut 0.8s ease-in-out forwards;
}

.board-cell.word-placed-fading::after {
    animation: borderFadeOut 0.8s ease-in-out forwards;
}

@keyframes wordPlacedGlow {
    0% {
        box-shadow: 0 0 25px var(--player-color);
    }
    100% {
        box-shadow: 0 0 18px var(--player-color);
    }
}

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

@keyframes wordPlacedFadeOut {
    0% {
        box-shadow: 0 0 18px var(--player-color);
    }
    100% {
        box-shadow: 0 0 0px transparent;
    }
}

@keyframes borderFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

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

@keyframes specialPreviewPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes intersectionGlow {
    0%, 100% { box-shadow: 0 0 5px #ffaa00; }
    50% { box-shadow: 0 0 15px #ffaa00; }
}

/* Special word effects */
.special-shake {
    animation: boardShake 0.6s ease-in-out;
}

@keyframes boardShake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-5px, -5px) rotate(-1deg); }
    20% { transform: translate(5px, 5px) rotate(1deg); }
    30% { transform: translate(-5px, 5px) rotate(-1deg); }
    40% { transform: translate(5px, -5px) rotate(1deg); }
    50% { transform: translate(-5px, -5px) rotate(-1deg); }
    60% { transform: translate(5px, 5px) rotate(1deg); }
    70% { transform: translate(-5px, 5px) rotate(-1deg); }
    80% { transform: translate(5px, -5px) rotate(1deg); }
    90% { transform: translate(-3px, -3px) rotate(-0.5deg); }
}

.levelbreaking-to-hell-1 {
    /* No board-level animation, just container for cells */
}

/* More specific selector to override any lingering animation properties */
.board .board-cell.cell-breaking-hell-1 {
    animation-name: cellFallApart;
    animation-duration: 0.8s;
    animation-delay: 0s;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
    animation-iteration-count: 1;
    animation-play-state: running;
}

@keyframes cellFallApart {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
        filter: brightness(1);
    }
    15% {
        opacity: 1;
        transform: translateY(-5px) rotate(-3deg) scale(1.05);
        filter: brightness(1.5) saturate(1.5);
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    }
    30% {
        opacity: 0.95;
        transform: translateY(10px) rotate(5deg) scale(0.98);
        filter: brightness(1.3);
    }
    50% {
        opacity: 0.7;
        transform: translateY(80px) rotate(15deg) scale(0.85);
        filter: brightness(0.8);
    }
    70% {
        opacity: 0.4;
        transform: translateY(200px) rotate(30deg) scale(0.6);
        filter: brightness(0.4);
    }
    85% {
        opacity: 0.15;
        transform: translateY(350px) rotate(50deg) scale(0.3);
        filter: brightness(0.2);
    }
    100% {
        opacity: 0;
        transform: translateY(500px) rotate(70deg) scale(0.1);
        filter: brightness(0);
    }
}

.letter-dropping {
    animation: letterDrop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes letterDrop {
    0% {
        opacity: 0;
        transform: translateY(-400px) scale(0.3) rotate(0deg);
        filter: brightness(2) saturate(2);
    }
    10% {
        opacity: 1;
    }
    60% {
        transform: translateY(0) scale(1.1) rotate(5deg);
        filter: brightness(1.5) saturate(1.5);
    }
    75% {
        transform: translateY(-15px) scale(0.95) rotate(-2deg);
        filter: brightness(1.2);
    }
    85% {
        transform: translateY(0) scale(1.05) rotate(1deg);
        filter: brightness(1.1);
    }
    95% {
        transform: translateY(-5px) scale(0.98) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        filter: brightness(1);
    }
}

/* Level break candle fade in */
.board-cell.candle-fade-hidden {
    opacity: 0 !important;
}

.board-cell.candle-preview {
    background: #0a0a0a !important;
    border-color: #0a0a0a !important;
    filter: brightness(1) !important;
}

.board-cell.devil-preview {
    background: #0a0a0a !important;
    border-color: #0a0a0a !important;
    filter: brightness(1) !important;
    font-size: 24px !important;
}

.board-cell.candle-fade-in {
    animation: candleFadeIn 0.8s ease-in forwards;
}

@keyframes candleFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
        filter: brightness(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1);
    }
}

.board-cell.candle-pulse {
    animation: candleFlicker 4s ease-in-out infinite;
}

@keyframes candleFlicker {
    0%, 100% {
        transform: scale(1);
        filter: brightness(0.9);
        opacity: 0.95;
    }
    15% {
        transform: scale(1.05);
        filter: brightness(1.3);
        opacity: 1;
    }
    18% {
        transform: scale(0.98);
        filter: brightness(0.8);
        opacity: 0.9;
    }
    25% {
        transform: scale(1.02);
        filter: brightness(1.1);
        opacity: 1;
    }
    50% {
        transform: scale(1);
        filter: brightness(0.85);
        opacity: 0.92;
        box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
    }
    65% {
        transform: scale(1.08);
        filter: brightness(1.4) saturate(1.3);
        opacity: 1;
        box-shadow: 0 0 25px rgba(255, 140, 0, 0.7);
    }
    70% {
        transform: scale(0.96);
        filter: brightness(0.75);
        opacity: 0.88;
    }
    80% {
        transform: scale(1.03);
        filter: brightness(1.15);
        opacity: 0.98;
    }
}

.board-cell.center-drop {
    animation: centerDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes centerDrop {
    0% {
        opacity: 0.5;
        transform: translateY(-300px) scale(0.5) rotate(-10deg);
        filter: brightness(2);
        background: rgba(26, 26, 46, 0.5) !important;
    }
    40% {
        opacity: 0.6;
        background: rgba(26, 26, 46, 0.6) !important;
    }
    60% {
        opacity: 1;
        transform: translateY(0) scale(1.2) rotate(5deg);
        filter: brightness(1.5);
        background: var(--theme-board-bg) !important;
    }
    75% {
        transform: translateY(-10px) scale(0.95) rotate(-2deg);
    }
    85% {
        transform: translateY(0) scale(1.05) rotate(1deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        filter: brightness(1);
    }
}

.board-cell.cell-fade-in {
    animation: dramaticCellFadeIn 0.8s ease-out forwards;
}

@keyframes dramaticCellFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.7);
        filter: brightness(0);
    }
    50% {
        filter: brightness(1.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1);
    }
}

.board-cell.cell-fade-in-delayed {
    opacity: 0;
    animation: dramaticCellFadeIn 0.6s ease-out forwards;
}

.special-pulse {
    animation: buttonPulse 1s ease-in-out;
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    }
    25%, 75% {
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(255, 221, 0, 0.8);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    }
}

/* Player Area */
.player-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 450px;
    flex-shrink: 0;
    min-height: 0;
}

/* Player Header - contains level name and menu buttons */
.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.level-name-display {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: var(--theme-secondary);
}

.header-menu-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Connection Indicator */
.connection-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    border: 2px solid #00ff88;
    font-size: 12px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 10px #00ff88;
    animation: pulse-connected 2s infinite;
}

/* Connection States */
.connection-indicator.connected {
    border-color: #00ff88;
    color: #00ff88;
}

.connection-indicator.connected .connection-dot {
    background: #00ff88;
    box-shadow: 0 0 10px #00ff88;
    animation: pulse-connected 2s infinite;
}

.connection-indicator.unstable {
    border-color: #ffaa00;
    color: #ffaa00;
}

.connection-indicator.unstable .connection-dot {
    background: #ffaa00;
    box-shadow: 0 0 10px #ffaa00;
    animation: pulse-unstable 1s infinite;
}

.connection-indicator.reconnecting {
    border-color: #4a9eff;
    color: #4a9eff;
}

.connection-indicator.reconnecting .connection-dot {
    background: #4a9eff;
    box-shadow: 0 0 10px #4a9eff;
    animation: pulse-reconnecting 0.6s infinite;
}

.connection-indicator.disconnected {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.connection-indicator.disconnected .connection-dot {
    background: #ff6b6b;
    box-shadow: 0 0 10px #ff6b6b;
    animation: none;
}

/* Pulse Animations */
@keyframes pulse-connected {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

@keyframes pulse-unstable {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

@keyframes pulse-reconnecting {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

/* Player Controls Container - unified box */
.player-controls-container {
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    padding: 15px;
    transition: background 0.5s ease, border-color 0.5s ease;
    overflow: visible;
    width: 628px;
    box-sizing: border-box;
}

/* Game action buttons (invite, menu) - hidden on desktop, shown on mobile */
.game-actions-buttons {
    display: none;
}

/* Mobile powerups and spells section - hidden on desktop, shown on mobile */
.mobile-powerups-spells {
    display: none;
}

.tiles-container {
    padding: 0;
}

.tiles-container .label {
    color: var(--theme-primary);
    font-size: 14px;
    transition: color 0.5s ease;
}

.tiles {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 2px 0;
}

/* Bonus tiles section */
.bonus-tiles-section {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 3px solid var(--theme-secondary);
}

.bonus-tile {
    background: var(--theme-filled-cell-bg);
    border: 2px solid var(--theme-secondary);
    color: var(--theme-secondary);
    font-weight: bold;
    font-size: 16px;
}

.bonus-tile .value .point-dot {
    background: var(--theme-secondary);
    opacity: 0.9;
}

.bonus-tile-appear {
    animation: bonusTileAppear 0.5s ease-out;
}

@keyframes bonusTileAppear {
    0% {
        opacity: 0;
        transform: scale(0) translateY(-20px);
    }
    50% {
        transform: scale(1.2) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tile {
    width: 36px;
    height: 36px;
    background: var(--theme-filled-cell-bg);
    border: 1px solid var(--theme-cell-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    color: var(--theme-primary);
    position: relative;
    transition: transform 0.3s ease-out, color 0.5s ease, background 0.5s ease, border-color 0.5s ease;
}

.tile .value {
    position: absolute;
    bottom: 3px;
    right: 3px;
    display: grid;
    grid-template-columns: 3px 3px;
    grid-template-rows: 3px 3px;
    gap: 2px;
    width: 8px;
    height: 8px;
}

.point-dot {
    width: 3px;
    height: 3px;
    background: var(--theme-primary);
    border-radius: 50%;
    opacity: 0.7;
}

/* Position dots for different values */
.tile .value .point-dot:only-child {
    /* 1 dot: bottom right */
    grid-column: 2;
    grid-row: 2;
}

.tile .value .point-dot:first-child:nth-last-child(2) {
    /* 2 dots: bottom left */
    grid-column: 1;
    grid-row: 2;
}

.tile .value .point-dot:first-child:nth-last-child(2) ~ .point-dot {
    /* 2 dots: bottom right */
    grid-column: 2;
    grid-row: 2;
}

.tile .value .point-dot:first-child:nth-last-child(3) {
    /* 3 dots: top right */
    grid-column: 2;
    grid-row: 1;
}

.tile .value .point-dot:first-child:nth-last-child(3) ~ .point-dot:nth-child(2) {
    /* 3 dots: bottom left */
    grid-column: 1;
    grid-row: 2;
}

.tile .value .point-dot:first-child:nth-last-child(3) ~ .point-dot:nth-child(3) {
    /* 3 dots: bottom right */
    grid-column: 2;
    grid-row: 2;
}

.tile.used {
    opacity: 0.5;
}

.tile.disabled {
    opacity: 0.4;
    filter: grayscale(80%);
    cursor: not-allowed;
    position: relative;
}

.tile.disabled::after {
    content: '🕯️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    opacity: 0.6;
    pointer-events: none;
}

.tile.highlighted {
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.6), 3px 3px 0px #00cc66;
    animation: tileHighlightPulse 1s ease-in-out infinite;
}

.tile.highlighted-valid {
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.6), 3px 3px 0px #00cc66;
    animation: tileHighlightPulse 1s ease-in-out infinite;
}

.tile.highlighted-error {
    border-color: #ff8800;
    box-shadow: 0 0 15px rgba(255, 136, 0, 0.6), 3px 3px 0px #cc6600;
    animation: tileHighlightPulse 1s ease-in-out infinite;
}

.tile.highlighted-spell {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6), 3px 3px 0px #daa520;
    animation: tileHighlightPulse 1s ease-in-out infinite;
}

.tile.selected {
    border-color: #ffaa00;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.8), 3px 3px 0px #cc8800;
    transform: scale(1.05);
    cursor: pointer;
}

.board-cell.selected {
    background-color: rgba(255, 170, 0, 0.3) !important;
    border-color: #ffaa00 !important;
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.6);
    cursor: pointer;
}

.tile.shrinking {
    animation: tileShrinkOut 0.3s ease-in forwards;
}

.tile.sliding-in {
    animation: tileSlideIn 0.4s ease-out;
}

@keyframes tileHighlightPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(0, 255, 136, 0.6), 3px 3px 0px #00cc66;
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.8), 3px 3px 0px #00cc66;
    }
}

@keyframes tileShrinkOut {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(180deg);
    }
}

@keyframes tileSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tile-slide-in-right {
    animation: tileSlideInRight 0.4s ease-out;
}

@keyframes tileSlideInRight {
    0% {
        opacity: 0;
        transform: translateX(30px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Scratch animation for stolen tiles */
.tile.scratched {
    position: relative;
    animation: tileScratched 0.8s ease-out forwards;
}

.tile.scratched::before,
.tile.scratched::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    background: #ff0000;
    opacity: 0;
    transform-origin: center;
}

.tile.scratched::before {
    animation: scratchMark1 0.4s ease-out 0.1s forwards;
    transform: translateX(-8px) rotate(-10deg);
}

.tile.scratched::after {
    animation: scratchMark2 0.4s ease-out 0.15s forwards;
    transform: translateX(8px) rotate(10deg);
}

.scratch-mark-middle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    background: #ff0000;
    transform: translateX(-50%);
    opacity: 0;
    animation: scratchMark3 0.4s ease-out 0.2s forwards;
}

@keyframes scratchMark1 {
    0% {
        opacity: 0;
        height: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        height: 100%;
    }
}

@keyframes scratchMark2 {
    0% {
        opacity: 0;
        height: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        height: 100%;
    }
}

@keyframes scratchMark3 {
    0% {
        opacity: 0;
        height: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        height: 100%;
    }
}

@keyframes tileScratched {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    40% {
        transform: scale(1.05) translateY(0);
        opacity: 1;
    }
    100% {
        transform: scale(0.8) translateY(100px);
        opacity: 0;
    }
}

/* Word Input */
.word-input-area {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 8px;
    align-items: center;
}

.word-input {
    flex: 0.65;
    min-width: 200px;
}

/* Icon-only buttons in word input area */
.pixel-button.small.icon-only {
    min-width: 40px;
    width: 40px;
    padding: 8px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide delete button on desktop (only show on mobile) */
#delete-char-btn {
    display: none;
}

/* Hide word display on desktop */
.word-display {
    display: none;
}

/* Add Letters button is hidden by default */
#add-letters-btn {
    display: none;
}

/* Leaderboard */
.leaderboard {
    position: relative;
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    padding: 15px;
    transition: background 0.5s ease, border-color 0.5s ease;
    flex-shrink: 0;
}

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

.leaderboard-header .label {
    color: var(--theme-primary);
    font-size: 14px;
    font-weight: bold;
    transition: color 0.5s ease;
    text-align: left;
    line-height: 1.4;
}

.victory-progress {
    font-size: 16px;
    color: var(--theme-primary);
    font-weight: bold;
}

.victory-total {
    font-size: 11px;
    color: var(--theme-secondary);
    opacity: 0.8;
    margin-top: 2px;
}

.header-stats {
    display: none;
}

.timer-display,
.letters-display {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--theme-primary);
    font-size: 16px;
    font-weight: bold;
    transition: color 0.5s ease;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    max-height: 400px;
}

.leaderboard-player {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--theme-hud-bg);
    border: 2px solid var(--theme-primary);
    margin-bottom: 6px;
    transition: all 0.3s ease;
}

.leaderboard-player.current-player {
    border-color: var(--theme-secondary);
}

/* Removed rank and name for more compact leaderboard */
/*.leaderboard-rank {
    font-size: 16px;
    font-weight: bold;
    color: var(--theme-primary);
    min-width: 30px;
    text-align: center;
}*/

.leaderboard-player-icon {
    font-size: 28px;
    min-width: 36px;
    text-align: center;
}

/* Disconnected player icon animation */
.disconnected-icon {
    position: relative;
    display: inline-block;
}

.disconnected-icon::before {
    content: '🛜';
    position: absolute;
    left: 0;
    top: 0;
    animation: wifiToggle 2s steps(1, end) infinite;
    opacity: 0;
}

.disconnected-icon {
    animation: iconToggle 2s steps(1, end) infinite;
}

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

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

/*.leaderboard-player-name {
    color: var(--theme-hud-text);
    font-weight: bold;
    font-size: 14px;
    flex: 1;
    min-width: 80px;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}*/

.leaderboard-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 70px;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.leaderboard-stat.highlighted {
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.leaderboard-stat .stat-value {
    color: var(--theme-hud-text);
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.combo-below-card {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.leaderboard-stat.highlighted .stat-value {
    color: #ffd700;
    font-size: 16px;
}

.leaderboard-stat .stat-label {
    color: var(--theme-primary);
    font-size: 10px;
    text-transform: uppercase;
}

.leaderboard-player .combo-flame {
    font-size: 14px;
    animation: flameFlicker 1s ease-in-out infinite;
}

.leaderboard-player .combo-flame.building {
    font-size: 10px;
    opacity: 0.5;
}

/* Card layout mode */
.leaderboard-list.cards {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
}

.leaderboard-list.cards .leaderboard-player {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 90px;
    max-width: 110px;
    min-height: 100px;
    max-height: 110px;
    padding: 8px;
    margin-bottom: 26px;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.15);
    position: relative;
}

.leaderboard-list.cards .leaderboard-player-icon {
    font-size: 42px;
    margin: 0;
}

.leaderboard-list.cards .leaderboard-stat {
    min-width: 0;
    width: 100%;
    padding: 0;
}

.leaderboard-list.cards .leaderboard-stat:not(.highlighted) {
    display: none;
}

.leaderboard-list.cards .leaderboard-stat.highlighted {
    background: none;
    border: none;
}

.leaderboard-list.cards .leaderboard-stat .stat-value {
    font-size: 18px;
    color: #fff;
}

.leaderboard-list.cards .leaderboard-stat .stat-label {
    font-size: 11px;
    color: var(--theme-hud-text);
    opacity: 0.7;
}

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

@keyframes powerupPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
    }
}

@keyframes powerupExpire {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) translateY(-10px);
        opacity: 0.7;
    }
    100% {
        transform: scale(0) translateY(-30px);
        opacity: 0;
    }
}

.powerup-item.powerup-expiring {
    animation: powerupExpire 0.5s ease-out forwards;
}

/* Status */
.status {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    padding-right: 10px;
    margin-right: 10px;
    color: var(--theme-primary);
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 175px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: color 0.5s ease, opacity 0.5s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.status.ready {
    color: var(--theme-primary);
}

.status.spell-available {
    color: gold;
    border-left-color: gold;
    opacity: 1;
    font-size: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.status.error {
    color: #ff6b6b;
}

.status.info {
    color: #ffaa00;
}

.status.special {
    color: #ffaa00;
    animation: statusPulse 1s ease-in-out infinite;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
    }
    50% {
        opacity: 0.85;
        text-shadow: 0 0 15px rgba(255, 170, 0, 0.8);
    }
}

/* Feedback */
.feedback {
    background: transparent;
    border-top: 3px solid var(--theme-primary);
    padding: 0;
    margin-top: 10px;
    height: calc(4 * 28px);
    font-size: 15px;
    font-weight: 700;
    color: var(--theme-hud-text);
    overflow-y: auto;
    transition: border-color 0.5s ease, color 0.5s ease;
}

/* Power-ups */
.powerups-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    overflow: visible;
}

.powerups-box {
    background: var(--theme-hud-bg);
    border: 3px solid var(--theme-primary);
    padding: 15px;
    margin-top: 10px;
    transition: all 0.5s ease;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    height: 360px;
}

.powerups-box.has-playable-spells {
    border-color: gold;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    animation: boxPulse 2s ease-in-out infinite;
}

@keyframes boxPulse {
    0%, 100% {
        border-color: gold;
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    }
    50% {
        border-color: #ffed4e;
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    }
}

.powerups-box .section-divider {
    border: none;
    border-top: 2px solid var(--theme-primary);
    margin: 15px 0;
    opacity: 0.3;
}

/* Inline Spells Section */
.spells-section-inline {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.spells-list-inline {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.spells-section-header {
    color: var(--theme-primary);
    font-size: 14px;
    font-weight: bold;
    padding: 10px 0 8px 0;
    margin-top: 10px;
    border-bottom: 2px solid var(--theme-primary);
    transition: color 0.5s ease;
}

.spells-section-header:first-child {
    margin-top: 0;
    padding-top: 0;
}

.spell-item-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px;
    margin-bottom: 2px;
    background: rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.spell-item-inline.playable {
    background: linear-gradient(90deg,
        rgba(255, 215, 0, 0.15) 0%,
        rgba(255, 215, 0, 0.25) 50%,
        rgba(255, 215, 0, 0.15) 100%);
    border-left: 3px solid gold;
    animation: spellGlow 2s ease-in-out infinite;
}

@keyframes spellGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
}

.spell-word-inline {
    color: var(--theme-primary);
    font-size: 13px;
    font-weight: bold;
    min-width: 40px;
    flex-shrink: 0;
    transition: color 0.5s ease;
}

.spell-item-inline.playable .spell-word-inline {
    color: gold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.spell-description-inline {
    color: var(--theme-hud-text);
    opacity: 0.9;
    font-size: 12px;
    flex: 1;
    min-width: 250px;
}

.powerups-section {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: visible;
    width: 100%;
}

.powerups-label {
    color: var(--theme-primary);
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    transition: color 0.5s ease;
}

.powerups {
    display: flex;
    gap: 8px;
    align-items: center;
    overflow: visible;
    margin-left: auto;
}

.powerup-item {
    background: var(--theme-hud-bg);
    border: 2px solid var(--theme-primary);
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    width: 36px;
    height: 36px;
    position: relative;
    color: var(--theme-primary);
}

.powerup-item:hover {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-hud-bg);
    transform: translateY(-2px);
}

.powerup-item.powerup-active {
    animation: powerupPulse 1s ease-in-out infinite;
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.powerup-item .powerup-icon {
    line-height: 1;
    transition: color 0.3s;
}

.powerup-item .powerup-count {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--theme-primary);
    color: var(--theme-hud-bg);
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid var(--theme-hud-bg);
    line-height: 1;
}

.powerup-item .powerup-name {
    display: none;
}

.powerup-item:hover::after {
    content: attr(data-name);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--theme-primary);
    color: var(--theme-hud-bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.feedback-msg {
    margin: 5px 0;
    padding: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feedback-msg .player-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.feedback-msg.success {
    color: #059669;
    font-weight: 700;
}

.feedback-msg.error {
    color: #dc2626;
    font-weight: 700;
}

.feedback-msg.info {
    color: #d97706;
    font-weight: 700;
}

/* Game Over Screen - New Design */
#gameover-screen {
    background: var(--theme-background);
    transition: background 0.5s ease;
}

#gameover-screen .content {
    background: var(--theme-hud-bg);
    border: 4px solid var(--theme-primary);
    padding: 50px 40px;
    border-radius: 12px;
    max-width: 600px;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.gameover-title {
    color: var(--theme-primary);
    transition: color 0.5s ease;
    font-size: 36px;
    margin-bottom: 30px;
    text-align: center;
    letter-spacing: 3px;
}

/* Hero Score Section */
.score-hero {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15) 0%, rgba(0, 255, 136, 0.05) 100%);
    border: 3px solid var(--theme-accent);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3), 0 0 30px rgba(0, 255, 136, 0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.5s ease;
}

.score-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%);
    transform: rotate(45deg);
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.score-hero-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--theme-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    opacity: 0.8;
    transition: color 0.5s ease;
}

.score-hero-value {
    font-size: 72px;
    font-weight: bold;
    color: var(--theme-accent);
    line-height: 1;
    margin-bottom: 10px;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 255, 136, 0.5);
    font-family: 'Press Start 2P', monospace;
    transition: color 0.5s ease;
}

.score-hero-rank {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--theme-secondary);
    text-transform: uppercase;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    display: inline-block;
    margin-top: 10px;
    transition: color 0.5s ease;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 35px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid var(--theme-primary);
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--theme-accent) 0%, var(--theme-secondary) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
    border-color: var(--theme-accent);
}

.stat-icon {
    font-size: 36px;
    margin-bottom: 12px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.stat-value {
    font-size: 42px;
    font-weight: bold;
    color: var(--theme-accent);
    margin-bottom: 8px;
    line-height: 1;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
    font-family: 'Press Start 2P', monospace;
    transition: color 0.5s ease;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--theme-primary);
    text-transform: uppercase;
    opacity: 0.8;
    transition: color 0.5s ease;
}

/* Buttons */
.gameover-buttons {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    margin-top: 0;
}

.gameover-buttons .pixel-button {
    flex: 1;
    max-width: 200px;
    font-size: 14px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--theme-hud-bg);
    border: 4px solid var(--theme-primary);
    padding: 30px;
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 30px var(--theme-primary);
    transition: background 0.5s ease, border-color 0.5s ease;
}

.modal-content h2 {
    color: var(--theme-primary);
    transition: color 0.5s ease;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: var(--theme-primary);
    cursor: pointer;
    transition: color 0.5s;
}

.modal-close:hover {
    color: var(--theme-secondary);
}

.modal-input-area {
    margin-top: 20px;
}

.modal-input-area .pixel-input {
    width: 100%;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Invite Modal */
.invite-content {
    text-align: center;
}

.invite-content p {
    color: var(--theme-hud-text);
    margin-bottom: 20px;
    font-size: 16px;
}

/* Mobile Leaderboard Modal */
#mobile-leaderboard-modal .modal-content {
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

#mobile-leaderboard-modal .leaderboard-list {
    margin: 20px 0;
    max-height: none;
}

#mobile-leaderboard-modal .leaderboard-list.cards {
    justify-content: flex-start;
    flex-wrap: wrap;
}

#mobile-leaderboard-modal .feedback {
    margin-top: 20px;
}

/* Mobile Spells Modal */
#mobile-spells-modal .modal-content {
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

#mobile-spells-modal .spells-sections,
#mobile-spells-modal #mobile-spells-sections {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#mobile-spells-modal .spells-section-header {
    color: var(--theme-primary);
    font-size: 14px;
    font-weight: bold;
    padding: 10px 0 8px 0;
    margin-top: 10px;
    border-bottom: 2px solid var(--theme-primary);
}

#mobile-spells-modal .spells-section-header:first-child {
    margin-top: 0;
}

#mobile-spells-modal .spell-item-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px;
    margin-bottom: 2px;
    background: rgba(0, 0, 0, 0.05);
}

#mobile-spells-modal .spell-item-inline.playable {
    background: linear-gradient(90deg,
        rgba(255, 215, 0, 0.15) 0%,
        rgba(255, 215, 0, 0.25) 50%,
        rgba(255, 215, 0, 0.15) 100%);
    border-left: 3px solid gold;
    animation: spellGlow 2s ease-in-out infinite;
}

#mobile-spells-modal .spell-word-inline {
    color: var(--theme-primary);
    font-size: 13px;
    font-weight: bold;
    min-width: 40px;
    flex-shrink: 0;
}

#mobile-spells-modal .spell-item-inline.playable .spell-word-inline {
    color: gold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#mobile-spells-modal .spell-description-inline {
    color: var(--theme-hud-text);
    opacity: 0.9;
    font-size: 11px;
    flex: 1;
    text-align: right;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    padding: 15px;
    background: white;
    border: 3px solid var(--theme-primary);
    box-shadow: 3px 3px 0px var(--theme-dark);
    width: fit-content;
    max-width: 200px;
}

.qr-code-container img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.invite-join-url {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--theme-primary);
    padding: 15px;
    margin: 20px 0;
    border-radius: 8px;
}

.invite-join-url span {
    color: var(--theme-secondary);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invite-join-url .pixel-button {
    flex: 0 0 auto;
    min-width: 80px;
}

.invite-room-code {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--theme-primary);
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
}

.invite-room-code span {
    color: var(--theme-primary);
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 4px;
    flex: 1;
    text-align: center;
}

.invite-room-code .pixel-button {
    flex: 0 0 auto;
    min-width: 80px;
}

.dictionary-help {
    background: rgba(0, 0, 0, 0.1);
    border: 2px solid var(--theme-primary);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.dictionary-help p {
    color: var(--theme-hud-text);
    font-size: 14px;
    margin: 8px 0;
    line-height: 1.5;
    transition: color 0.5s ease;
}

/* Talk Modal */
.talk-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.talk-option-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 2px solid var(--theme-primary);
    border-radius: 8px;
    padding: 15px 20px;
    color: var(--theme-primary);
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.talk-option-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 255, 136, 0.3);
}

.talk-option-btn:active {
    transform: translateY(0);
}

.talk-option-label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.talk-modal-description {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
}

.dictionary-help strong {
    color: var(--theme-primary);
    transition: color 0.5s ease;
}

.dictionary-help code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: var(--theme-secondary);
    font-weight: bold;
    transition: color 0.5s ease;
}

/* Combined Spells Modal */
.spells-modal-content {
    max-width: 600px;
}

.spells-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.spells-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spells-section-title {
    font-family: 'Arial', sans-serif;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    color: var(--theme-secondary);
    margin: 0 0 8px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--theme-primary);
    transition: color 0.5s ease, border-color 0.5s ease;
}

.spells-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Scrollbar styling for spells list */
.spells-list::-webkit-scrollbar {
    width: 8px;
}

.spells-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.spells-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.spells-list::-webkit-scrollbar-thumb:hover {
    background: var(--theme-primary);
    background-clip: padding-box;
}

/* Compact spell item styling matching character selection */
.special-word-item {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.4) 0%, rgba(10, 20, 30, 0.4) 100%);
    border-left: 3px solid #444;
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    text-align: left;
    border-radius: 3px;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.special-word-item:hover {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.6) 0%, rgba(10, 20, 30, 0.6) 100%);
    border-left-color: var(--theme-primary);
}

.special-word-item .word {
    color: var(--theme-secondary);
    font-weight: bold;
    font-size: 12px;
    min-width: 80px;
    transition: color 0.5s ease;
    display: flex;
    gap: 4px;
    align-items: center;
}

.special-word-item .power {
    color: var(--theme-hud-text);
    font-size: 11px;
    line-height: 1.4;
    flex: 1;
    transition: color 0.5s ease;
}

.no-spells-message {
    color: var(--theme-hud-text);
    font-family: 'Arial', sans-serif;
    font-size: 12px;
    font-style: italic;
    opacity: 0.6;
    padding: 12px;
    text-align: center;
    transition: color 0.5s ease;
}

.rules-content {
    color: var(--theme-hud-text);
    line-height: 1.6;
    transition: color 0.5s ease;
}

.rules-content h3 {
    color: var(--theme-primary);
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 18px;
    transition: color 0.5s ease;
}

.rules-content ul {
    margin-left: 20px;
    color: var(--theme-hud-text);
    transition: color 0.5s ease;
}

.rules-content li {
    margin: 8px 0;
}

.rules-content p {
    color: var(--theme-hud-text);
    margin: 10px 0;
    transition: color 0.5s ease;
}

.rules-content strong {
    color: var(--theme-primary);
    transition: color 0.5s ease;
}

/* Creatures Modal */
.creature-info {
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--theme-primary);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    transition: border-color 0.5s ease;
}

.creature-info h3 {
    margin-top: 0;
    font-size: 20px;
}

.creature-note {
    background: rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--theme-secondary);
    padding: 12px 15px;
    margin-top: 20px;
    font-style: italic;
    transition: border-color 0.5s ease;
}

/* Squirrel Hole Animation */
.squirrel-shovel {
    transform-origin: center bottom;
}

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

.squirrel-hole-container {
    /* Container with circular mask for the hole */
}

.squirrel-hole {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Dictionary Modal */
.dictionary-search-area {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.dictionary-search-area .pixel-input {
    flex: 1;
    min-width: 0;
}

.dictionary-info {
    color: var(--theme-primary);
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: bold;
    transition: color 0.5s ease;
}

.dictionary-results {
    background: rgba(0, 0, 0, 0.1);
    border: 2px solid var(--theme-primary);
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
    min-height: 200px;
    color: var(--theme-hud-text);
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

.dictionary-word {
    color: var(--theme-secondary);
    font-size: 16px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--theme-primary);
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    transition: color 0.5s ease, border-color 0.5s ease;
}

.dictionary-word:last-child {
    border-bottom: none;
}

.dictionary-word:hover {
    background: rgba(0, 255, 136, 0.1);
}

/* Removed cursor pointer and hover effects from character/player name */

/* Responsive */
@media (max-width: 1200px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .player-area {
        width: 100%;
        max-width: 600px;
    }
}

/* Tablet / Small Desktop */
@media (max-width: 900px) {
    .board {
        grid-template-columns: repeat(15, 1fr);
        grid-template-rows: repeat(15, 1fr);
        width: 100%;
        aspect-ratio: 1;
    }

    .board-cell {
        width: 100%;
        height: 100%;
        font-size: 17px;
    }

    .player-area {
        width: 100%;
        max-width: 100%;
    }

    .leaderboard-list {
        flex-wrap: wrap;
        justify-content: center;
    }

    .leaderboard-player {
        min-width: 80px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Touch-friendly optimizations */
    * {
        -webkit-tap-highlight-color: rgba(0, 255, 136, 0.2);
    }

    button, .tile, .powerup-item, .board-cell {
        touch-action: manipulation;
    }

    .board-cell, .tile, .powerup-item {
        user-select: none;
        -webkit-user-select: none;
    }

    /* QR Code mobile adjustments */
    .qr-code-container {
        max-width: 150px;
        padding: 10px;
        margin: 15px auto;
    }

    #game-screen {
        padding: 0;
        overflow-x: hidden;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .game-container {
        gap: 0;
        padding: 0;
        flex-direction: column;
        height: 100%;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: auto;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .board-area {
        flex: 0 0 auto;
        display: block;
        padding: 0;
        padding-top: 60px;
        overflow: visible;
        width: 100vw;
        max-width: 100vw;
        position: relative;
        left: 0;
        right: 0;
    }

    /* Mobile game header */
    .mobile-only {
        display: flex !important;
    }

    .board-header {
        background: rgba(0, 0, 0, 0.3);
        padding: 6px 8px;
        margin: 0;
        border-bottom: 2px solid var(--theme-primary);
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .hud-left-mobile {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .hud-right {
        display: flex;
        gap: 6px;
        align-items: center;
        flex-shrink: 0;
    }

    .hud-right .pixel-button {
        min-width: 60px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .hud-item {
        font-size: 10px;
        white-space: nowrap;
    }

    .hud-item .label {
        margin-right: 2px;
        opacity: 0.8;
    }

    #mobile-victory-condition {
        font-size: 10px;
        font-weight: bold;
        color: var(--theme-primary);
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #mobile-timer {
        font-weight: bold;
        color: var(--theme-secondary);
    }

    /* Board optimizations - full width */
    .board {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        display: grid;
        grid-template-columns: repeat(15, 1fr);
        grid-template-rows: repeat(15, 1fr);
        gap: 1px;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }

    .board-cell {
        width: 100%;
        height: 100%;
        font-size: 3.5vw;
        border-width: 1px;
    }

    .board-header {
        margin-bottom: 5px;
    }

    .level-title {
        font-size: 14px;
    }

    .menu-btn {
        font-size: 11px;
        padding: 8px 12px;
        min-height: 44px;
    }

    .menu-dropdown {
        position: fixed;
        right: 10px;
        top: 50px;
        min-width: 200px;
        z-index: 10000;
    }

    .menu-item {
        padding: 12px 15px;
        font-size: 13px;
        min-height: 44px;
    }

    /* Character dialog smaller on mobile */
    .character-dialog-container {
        min-height: 50px;
        padding: 5px 0;
        margin-top: -5px;
    }

    .character-dialog-icon {
        font-size: 28px;
    }

    .character-dialog-bubble {
        padding: 6px 10px;
        max-width: 200px;
        border-radius: 8px;
    }

    .character-dialog-text {
        font-size: 11px;
    }

    /* Player area - position off-screen but keep elements accessible for repositioning */
    .player-area {
        position: fixed;
        left: -9999px;
        pointer-events: none;
    }

    /* Show game action buttons in top right, aligned with leaderboard header */
    .game-actions-buttons {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
        position: fixed;
        top: 0;
        right: 0;
        z-index: 9999;
        padding: 6px 8px;
        pointer-events: auto;
    }

    .game-actions-buttons .pixel-button.small {
        font-size: 10px;
        padding: 6px 10px;
        min-height: 32px;
        min-width: 40px;
    }

    /* Mobile powerups and spells section */
    .mobile-powerups-spells {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 8px 10px;
        background: var(--theme-hud-bg);
        border-top: 2px solid var(--theme-primary);
    }

    .mobile-powerups-section {
        flex: 1;
        display: flex;
        align-items: center;
    }

    .mobile-powerups {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        align-items: center;
    }

    #mobile-spells-btn {
        flex: 0 0 auto;
        font-size: 11px;
        padding: 8px 12px;
        min-height: 36px;
        min-width: 70px;
    }

    #mobile-spells-btn.spell-hint-available {
        animation: spellButtonGlow 1.5s ease-in-out infinite;
        border-color: gold;
        color: gold;
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }

    @keyframes spellButtonGlow {
        0%, 100% {
            opacity: 0.9;
            transform: scale(1);
            box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
        }
        50% {
            opacity: 1;
            transform: scale(1.05);
            box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
        }
    }

    /* Reposition leaderboard header to top on mobile */
    .player-area .leaderboard-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9998;
        background: transparent;
        padding: 6px 8px;
        padding-right: 140px; /* Space for buttons */
        border-bottom: 2px solid var(--theme-primary);
        font-size: 12px;
        pointer-events: auto;
        cursor: pointer;
        height: 59px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        overflow: hidden;
    }

    /* Hide other player-area content on mobile */
    .player-area .player-header .level-name-display,
    .player-area .header-menu-buttons,
    .player-area #leaderboard-list,
    .player-area #feedback,
    .player-area #character-dialog-container,
    .player-area .powerups-box {
        display: none;
    }

    /* Player controls optimizations */
    .player-controls-container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        border: none;
        border-top: 3px solid var(--theme-primary);
        border-radius: 0;
    }

    .player-info {
        gap: 6px;
    }

    #hud-character-icon {
        font-size: 24px;
    }

    #hud-player {
        font-size: 15px;
    }

    #hud-level-name {
        font-size: 11px;
    }

    .powerups-label {
        font-size: 11px;
    }

    .powerup-item {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }

    .powerup-count {
        font-size: 10px;
    }

    /* Tiles - smaller to fit on one row */
    .tile {
        width: 32px;
        height: 32px;
        font-size: 16px;
        font-weight: normal;
    }

    .tile .value {
        font-size: 7px;
    }

    .bonus-tile {
        font-size: 13px;
    }

    /* Board emoji bonus cells */
    .board-cell.bonus-2x,
    .board-cell.bonus-6x,
    .board-cell.bonus-7x {
        font-size: 13px;
    }

    /* Board z-index higher than leaderboard header */
    .board {
        position: relative;
        z-index: 9999;
    }

    /* Tiles - compact row */
    .tiles-container {
        padding: 0 0 8px 0;
    }

    .tiles {
        display: flex;
        justify-content: center;
        gap: 3px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    /* Word input */
    .word-input-area {
        gap: 6px;
        padding-top: 8px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .status {
        width: 75px;
        max-width: 75px;
        order: -1;
        font-size: 10px;
        padding: 8px;
        margin-right: 6px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .word-input {
        display: none;
    }

    .word-display {
        display: block;
        font-size: 16px;
        padding: 12px;
        flex: 0 0 auto;
        width: 120px;
        min-width: 80px;
        max-width: 150px;
        order: 0;
        background: var(--bg-primary);
        border: 2px solid var(--theme-primary);
        box-shadow: 3px 3px 0px var(--theme-dark);
        font-family: 'Press Start 2P', monospace;
        color: var(--text-primary);
        text-transform: uppercase;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .word-display:empty::before {
        content: 'TAP TILES';
        color: rgba(255, 255, 255, 0.3);
        font-size: 10px;
    }

    .word-display.heaven-level {
        color: #1a1a1a;
    }

    .word-display.heaven-level:empty::before {
        color: rgba(0, 0, 0, 0.3);
    }

    .status.heaven-level {
        color: #1a1a1a !important;
    }

    #delete-char-btn {
        display: flex;
        flex: 0 0 auto;
        order: 1;
        min-width: 36px;
        min-height: 36px;
        padding: 8px;
        font-size: 16px;
    }

    #submit-word-btn {
        font-size: 12px;
        padding: 8px 16px;
        min-height: 36px;
        flex: 0 0 auto;
        order: 2;
    }

    #cycle-placement-btn {
        flex: 0 0 auto;
        order: 3;
        min-width: 36px;
        min-height: 36px;
        padding: 8px;
        font-size: 16px;
    }

    .player-section-divider {
        margin: 8px 0;
    }

    .pixel-button {
        min-height: 44px;
        padding: 10px 20px;
        font-size: 13px;
    }

    .pixel-button.small {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 12px;
    }

    /* Leaderboard */
    .leaderboard {
        padding: 10px;
        min-height: 200px;
    }

    .leaderboard-header .label {
        font-size: 13px;
    }

    .timer-display,
    .letters-display {
        font-size: 11px;
    }

    .leaderboard-list {
        gap: 6px;
    }

    .leaderboard-player {
        min-width: 70px;
        max-width: 80px;
        padding: 6px;
    }

    .leaderboard-player .player-icon {
        font-size: 28px;
    }

    .leaderboard-player .player-name {
        font-size: 10px;
    }

    .leaderboard-player .player-score {
        font-size: 14px;
    }

    .leaderboard-player .player-combo {
        font-size: 11px;
    }

    /* Feedback */
    .feedback {
        font-size: 12px;
        padding: 8px 0 0 0;
    }

    .feedback-msg {
        padding: 4px;
        gap: 6px;
    }

    /* Status messages */
    .status {
        font-size: 12px;
        padding: 8px;
    }

    /* Modals */
    .modal-content {
        width: 90%;
        max-width: none;
        padding: 15px;
        margin: 10px;
    }

    .modal-content h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .spells-list {
        gap: 4px;
        max-height: 180px;
    }

    .spells-section-title {
        font-size: 12px;
    }

    .special-word-item {
        padding: 6px 10px;
        font-size: 10px;
    }

    .special-word-item .word {
        font-size: 11px;
        min-width: 70px;
    }

    .special-word-item .power {
        font-size: 10px;
    }

    .special-word-name {
        font-size: 13px;
    }

    .special-word-description {
        font-size: 11px;
    }

    /* Character selection title/subtitle */
    .character-select-title {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .character-select-subtitle {
        font-size: 12px;
        margin-bottom: 20px;
        padding: 0 10px;
        white-space: normal;
    }

    /* Game Over Screen - Mobile Optimized */
    #gameover-screen {
        padding: 0;
    }

    #gameover-screen .content {
        padding: 20px 15px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        border-top: 3px solid var(--theme-primary);
        border-bottom: 3px solid var(--theme-primary);
        height: 100vh;
        display: flex;
        flex-direction: column;
        box-shadow: none;
    }

    .gameover-title {
        font-size: 24px;
        margin: 10px 0 20px 0;
        letter-spacing: 2px;
    }

    /* Hero Score - Mobile */
    .score-hero {
        padding: 25px 20px;
        margin-bottom: 20px;
        border-radius: 12px;
    }

    .score-hero-label {
        font-size: 11px;
        letter-spacing: 1.5px;
    }

    .score-hero-value {
        font-size: 48px;
    }

    .score-hero-rank {
        font-size: 13px;
        letter-spacing: 1.5px;
        padding: 6px 16px;
    }

    /* Stats Grid - Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 25px;
        flex: 1;
        overflow-y: auto;
        align-content: start;
    }

    .stat-card {
        padding: 20px;
        border-radius: 10px;
    }

    .stat-card:hover {
        transform: none;
    }

    .stat-icon {
        font-size: 32px;
        margin-bottom: 10px;
    }

    .stat-value {
        font-size: 36px;
    }

    .stat-label {
        font-size: 11px;
    }

    /* Bottom button section */
    .gameover-buttons {
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        gap: 10px;
        margin: 0;
        padding: 15px 0 0 0;
        background: transparent;
        border-top: 2px solid rgba(0, 255, 136, 0.2);
        justify-content: center;
    }

    .gameover-buttons .pixel-button {
        flex: 1;
        max-width: 200px;
        padding: 14px 20px;
        font-size: 13px;
        margin: 0;
    }
}

/* Small Mobile */
@media (max-width: 400px) {
    .board {
        grid-template-columns: repeat(15, 1fr);
        grid-template-rows: repeat(15, 1fr);
        width: 100%;
        aspect-ratio: 1;
    }

    .board-cell {
        width: 100%;
        height: 100%;
        font-size: 3.5vw;
    }

    .tile {
        width: 34px;
        height: 34px;
        font-size: 18px;
        font-weight: normal;
    }

    .tile .value {
        font-size: 7px;
    }

    .leaderboard-player {
        min-width: 65px;
        max-width: 70px;
    }
}

/* Character Selection Mobile */
@media (max-width: 768px) {
    .title {
        font-size: 48px;
    }

    .pixel-button, .pixel-input {
        min-width: 250px;
    }

    .character-inputs {
        flex-direction: column;
        gap: 15px;
    }

    .character-inputs .name-input {
        width: 100%;
        min-width: 250px;
        max-width: none;
    }

    .character-inputs #character-next-btn {
        width: 100%;
        min-width: 250px;
    }

    .character-preview-content {
        flex-direction: column;
        gap: 20px;
    }

    .character-preview-right {
        flex: 1;
        width: 100%;
        max-width: none;
    }

    .character-preview-icon {
        font-size: 90px;
    }

    .character-grid {
        grid-template-columns: repeat(4, 75px);
        grid-template-rows: repeat(4, 75px);
        gap: 8px;
        padding: 15px;
    }

    .character-icon {
        font-size: 38px;
    }

    .character-card h3 {
        font-size: 9px;
    }
}

/* Multiplayer Styles */
.lobby-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    margin-top: 30px;
}

.join-room-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Join Lobby Styles */
.join-lobby-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

.join-by-code-section {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--theme-primary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.section-label {
    color: var(--theme-secondary);
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}

.join-code-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.join-code-input-row .pixel-input {
    min-width: 200px;
    text-align: center;
    text-transform: uppercase;
}

.lobby-divider {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.lobby-divider::before,
.lobby-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 2px;
    background: var(--theme-primary);
}

.lobby-divider::before {
    left: 0;
}

.lobby-divider::after {
    right: 0;
}

.lobby-divider span {
    background: var(--bg-dark);
    padding: 0 15px;
    color: var(--theme-primary);
    font-weight: bold;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 12px;
}

.active-games-section {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--theme-primary);
    border-radius: 8px;
    padding: 20px;
}

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

.active-games-header .section-label {
    margin-bottom: 0;
}

.active-games-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loading-games {
    text-align: center;
    color: var(--theme-secondary);
    padding: 40px;
    font-style: italic;
}

.no-games {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

.game-room-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #444;
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-room-card:hover {
    border-color: var(--theme-secondary);
    background: rgba(0, 0, 0, 0.5);
    transform: translateX(5px);
}

.game-room-card.private {
    opacity: 0.6;
    border-color: #555;
    cursor: not-allowed;
}

.game-room-card.private:hover {
    border-color: #555;
    background: rgba(0, 0, 0, 0.4);
    transform: none;
}

.game-room-info {
    flex: 1;
}

.game-room-host {
    color: var(--theme-secondary);
    font-weight: bold;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.game-status-badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: bold;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}

.game-status-badge.in-lobby {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid #00ff88;
}

.game-status-badge.in-progress {
    background: rgba(255, 170, 0, 0.2);
    color: #ffaa00;
    border: 1px solid #ffaa00;
}

.game-status-badge.recap {
    background: rgba(138, 43, 226, 0.2);
    color: #ba55d3;
    border: 1px solid #ba55d3;
}

.game-status-badge.private {
    background: rgba(150, 150, 150, 0.2);
    color: #999;
    border: 1px solid #666;
}

.game-room-details {
    color: #999;
    font-size: 12px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.game-room-join-btn {
    padding: 8px 16px;
    background: #000000;
    color: var(--theme-primary);
    border: 2px solid var(--theme-primary);
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    transition: all 0.2s;
}

.game-room-join-btn:hover {
    background: var(--theme-primary);
    color: #000000;
}

.game-room-join-btn:disabled {
    background: #333;
    color: #666;
    border-color: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.game-room-join-btn:disabled:hover {
    background: #333;
    color: #666;
}

.room-status {
    margin-top: 20px;
    color: #00ff88;
    font-family: 'Courier New', monospace;
}

.room-top-section {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    align-items: flex-start;
}

.room-game-settings-wrapper {
    flex: 0 0 30%;
    margin-top: 20px;
}

.room-game-settings {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
}

#room-game-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    justify-content: space-evenly;
}

.game-info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid #555;
}

.game-info-label {
    color: #aaa;
    font-weight: bold;
}

.game-info-value {
    color: #00ff88;
    font-weight: bold;
}

.room-invite-section {
    flex: 1;
}

.invite-content-wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
}

.invite-links-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.players-list-wrapper {
    flex: 0 0 30%;
}

.players-list {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #444;
}

#room-players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid #555;
    font-family: 'Courier New', monospace;
    justify-content: flex-start;
}

.room-player .player-icon {
    font-size: 24px;
    flex: 0 0 auto;
}

.room-player .player-name {
    flex: 0 0 auto;
    color: #fff;
    text-align: left;
}

.host-badge {
    background: #ffaa00;
    color: #000;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.room-controls {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.room-controls .pixel-button {
    flex: 0 1 200px;
    min-width: 150px;
}

.room-controls .pixel-button.secondary {
    flex: 0 1 120px;
    min-width: 100px;
    font-size: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
}

.room-controls .pixel-button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.invite-label {
    color: #00ff88;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.room-join-url-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(0, 255, 136, 0.2);
}

#room-join-url-display {
    color: #ff88ff;
    font-size: 11px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    user-select: all;
    cursor: text;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    padding: 6px;
    background: rgba(255, 136, 255, 0.1);
    border-radius: 4px;
}

.room-join-url-container .pixel-button {
    width: 100%;
    padding: 8px;
    font-size: 11px;
}

.room-code-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: transparent;
    border: none;
}

#room-code-display {
    color: #00ff88;
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 4px;
    font-family: 'Courier New', monospace;
    user-select: all;
    text-align: center;
    padding: 10px;
    background: rgba(0, 255, 136, 0.1);
    border-radius: 4px;
}

.room-code-container .pixel-button {
    width: 100%;
    padding: 8px;
    font-size: 11px;
}

#room-code-display:hover {
    background: rgba(0, 255, 136, 0.2);
}

#copy-room-code-btn {
    min-width: 100px;
}

/* Victory Modal */
.victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.victory-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    animation: slideIn 0.5s ease;
}

.victory-title {
    font-size: 48px;
    margin: 0 0 30px 0;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.victory-stats {
    margin: 20px 0 30px 0;
}

.victory-stats p {
    margin: 12px 0;
    font-size: 20px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
}

.winner-name {
    font-size: 28px !important;
    color: #00ff88 !important;
    font-weight: bold;
    margin-bottom: 20px !important;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

.final-score {
    font-size: 32px !important;
    color: #ffd700 !important;
    font-weight: bold;
}

.victory-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.victory-button {
    flex: 1;
    padding: 15px 40px;
    font-size: 20px;
    transition: all 0.2s ease;
}

.victory-button.keyboard-focused {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    border-color: #ffd700;
}

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

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

/* End Game Screen */
#endgame-screen {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
    overflow-y: auto;
}

.endgame-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 15px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.endgame-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0;
    flex: 0 0 auto;
}

.endgame-title {
    font-size: 28px;
    color: var(--theme-primary, #00ff88);
    text-shadow: 0 0 15px var(--theme-primary, #00ff88);
    margin: 0;
}

.endgame-actions {
    display: flex;
    gap: 10px;
}

.endgame-actions .pixel-button {
    padding: 10px 16px;
    font-size: 13px;
}

.endgame-dialog-container {
    min-height: 60px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 0 0 auto;
}

.endgame-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Rankings Section */
.rankings-section {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0;
}

.rankings-section h2 {
    font-size: 15px;
    margin-bottom: 8px;
}

.endgame-players-section {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0;
}

.endgame-players-section h2 {
    font-size: 15px;
    margin-bottom: 8px;
}

.endgame-players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.endgame-player-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.endgame-player-item .player-icon {
    font-size: 20px;
}

.endgame-player-item .player-name {
    flex: 1;
    color: #fff;
    font-size: 14px;
}

.endgame-player-item .host-badge {
    background: var(--theme-primary, #00ff88);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.section-title {
    font-size: 16px;
    color: var(--theme-primary, #00ff88);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ranking-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 6px;
    padding: 6px 8px;
    display: grid;
    grid-template-columns: 26px 32px 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
}

.ranking-item.rank-1 {
    border-color: gold;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
}


.ranking-item.rank-2 {
    border-color: silver;
    background: rgba(192, 192, 192, 0.08);
}

.ranking-item.rank-3 {
    border-color: #cd7f32;
    background: rgba(205, 127, 50, 0.08);
}

.ranking-item.selected {
    background: rgba(0, 255, 136, 0.15);
    border-color: var(--theme-primary, #00ff88);
}

.ranking-position {
    font-size: 16px;
    font-weight: bold;
    min-width: 26px;
    color: var(--theme-primary, #00ff88);
}

.ranking-character {
    font-size: 22px;
}

.player-icon-disconnected {
    opacity: 0.3;
    filter: grayscale(1);
}

.ranking-player-info {
    flex: 1;
    text-align: left;
}

.ranking-player-name {
    font-size: 13px;
    font-weight: bold;
    color: #fff;
}

.ranking-player-stats {
    font-size: 10px;
    color: #aaa;
    grid-column: 1 / -1;
    margin-top: 0;
    padding-left: 60px;
}

.ranking-score {
    font-size: 16px;
    font-weight: bold;
    color: var(--theme-primary, #00ff88);
}

/* Player Selector */
.player-selector {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-selector label {
    color: #ccc;
    font-size: 14px;
}

.compact-select {
    flex: 1;
    max-width: 250px;
}

/* Stats Grid - Compact */
.stats-section.compact {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
}

.stats-section.compact h3 {
    font-size: 12px;
    margin-bottom: 6px;
}

.stats-list.compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.stat-label {
    color: #ccc;
    font-size: 10px;
}

.stat-value {
    color: var(--theme-primary, #00ff88);
    font-weight: bold;
    font-size: 12px;
}
}

.pixel-button.secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
    color: #fff;
}

.pixel-button.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #888;
}

/* Creature Animations (Squirrel, Bee, etc.) */
.creature {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    user-select: none;
    opacity: 1;
    visibility: visible;
}

.creature-carried-letter {
    color: var(--theme-primary, #00ff88);
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.5);
    animation: squirrel-letter-bob 0.5s ease-in-out infinite;
}

/* Keep old class for backwards compatibility */
.squirrel {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    user-select: none;
}

.squirrel-carried-letter {
    color: var(--theme-primary, #00ff88);
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.5);
    animation: squirrel-letter-bob 0.5s ease-in-out infinite;
}

@keyframes squirrel-letter-bob {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes squirrel-tile-bounce {
    0% {
        transform: scale(1) translateY(0);
    }
    25% {
        transform: scale(0.95) translateY(3px);
    }
    50% {
        transform: scale(1.02) translateY(-2px);
    }
    75% {
        transform: scale(0.98) translateY(1px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

/* ===== MOBILE RESPONSIVE STYLES ===== */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    /* Landing Page - Tablet */
    .arcade-title-screen.active {
        padding: 20px;
    }

    .arcade-logo {
        max-width: 400px;
        width: 90%;
    }

    .landing-bg-rect {
        height: 320px;
    }

    .insert-coin {
        font-size: 20px;
        margin: 15px 0;
    }

    .arcade-primary-actions {
        gap: 20px;
        margin-bottom: 30px;
    }

    .arcade-button-large {
        font-size: 24px;
        padding: 12px 40px;
        min-width: 240px;
    }

    .arcade-quick-actions {
        gap: 15px;
        margin-bottom: 25px;
    }

    .arcade-button-medium {
        font-size: 14px;
        padding: 12px 30px;
    }

    .arcade-button-small {
        font-size: 12px;
        padding: 7px 18px;
    }

    /* Level Select - Tablet */
    .level-selection-layout {
        flex-direction: column;
        max-width: 600px;
        gap: 20px;
    }

    .level-grid {
        grid-template-columns: repeat(3, 120px);
        grid-template-rows: repeat(2, 100px);
        gap: 10px;
        padding: 15px;
        height: auto;
    }

    .level-preview-panel {
        width: 100%;
        height: auto;
        max-height: 400px;
        padding: 20px;
    }

    .level-preview-icon {
        font-size: 60px;
    }

    /* Options Screen - Tablet */
    .options-layout {
        flex-direction: column;
        max-width: 600px;
        gap: 20px;
    }

    .options-form-section {
        flex: 1;
        width: 100%;
        padding: 25px;
    }

    .options-explanation-section {
        width: 100%;
        padding: 25px;
        max-height: 350px;
    }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
    /* Landing Page - Mobile */
    .arcade-title-screen.active {
        padding: 15px;
    }

    .arcade-logo {
        max-width: 280px;
        width: 85%;
    }

    .landing-bg-rect {
        height: 400px;
        top: 40px;
    }

    .insert-coin {
        font-size: 16px;
        margin: 12px 0 20px;
    }

    /* Stack primary buttons vertically on mobile */
    .arcade-primary-actions {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
        width: 100%;
        padding: 0 20px;
    }

    .arcade-button-large {
        font-size: 20px;
        padding: 14px 30px;
        min-width: 100%;
        max-width: 320px;
        width: 100%;
    }

    /* Stack quick action buttons vertically on mobile */
    .arcade-quick-actions {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
        width: 100%;
        padding: 0 20px;
    }

    .arcade-button-medium {
        font-size: 13px;
        padding: 12px 25px;
        min-width: 100%;
        max-width: 320px;
        width: 100%;
    }

    /* Smaller secondary buttons */
    .arcade-secondary-actions {
        gap: 10px;
        padding: 0 20px;
    }

    .arcade-button-small {
        font-size: 11px;
        padding: 8px 15px;
    }

    /* Character Select - Mobile - Horizontal Scroll */
    .character-select-container {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }

    .character-preview-box {
        width: 100%;
        max-width: 100%;
        margin: 0 0 20px 0;
        padding: 20px 15px;
        height: 330px;
        min-height: 330px;
        max-height: 330px;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
    }

    .character-preview-content {
        width: 100%;
        height: 100%;
        flex-direction: column;
        gap: 15px;
    }

    .character-preview-left {
        min-width: auto;
        width: 100%;
        flex-shrink: 0;
    }

    .character-preview-icon {
        font-size: 60px;
    }

    .character-preview-right {
        width: 100%;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .spell-list-title {
        font-size: 12px;
        flex-shrink: 0;
    }

    #spell-words-list {
        flex: 1;
        overflow-y: auto;
        max-height: none;
    }

    .character-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        padding: 15px;
        margin: 0 0 20px 0;
        width: 100%;
        max-width: 100%;
        grid-template-columns: none;
        grid-template-rows: none;
        /* Enable momentum scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .character-card {
        flex: 0 0 80px;
        width: 80px;
        height: 80px;
        scroll-snap-align: center;
    }

    .character-icon {
        font-size: 35px;
    }

    .character-card h3 {
        font-size: 9px;
    }

    /* Character inputs - Mobile - Horizontal layout */
    .character-inputs {
        flex-direction: row;
        gap: 10px;
        width: calc(100% - 30px);
        max-width: 340px;
        margin: 20px auto;
    }

    .character-inputs .name-input {
        flex: 1;
        min-width: 0;
        max-width: none;
        font-size: 14px;
        padding: 10px;
    }

    .character-inputs #character-next-btn {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        padding: 10px 20px;
        font-size: 13px;
        white-space: nowrap;
    }


    /* Hide back buttons on mobile */
    .back-circle-btn {
        display: none;
    }

    /* Character Intro - Mobile Optimized */
    .character-intro-content {
        flex-direction: column;
        gap: 15px;
        padding: 20px 15px;
        align-items: center;
    }

    .character-intro-left {
        gap: 20px;
        order: 1;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .character-intro-icon {
        font-size: 120px;
        order: 2;
    }

    .character-intro-name {
        gap: 6px;
        order: 1;
    }

    .character-intro-tile {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .character-intro-taunt {
        max-width: 90%;
        margin-top: 0;
        order: 3;
    }

    .speech-bubble {
        padding: 15px 20px;
    }

    /* Arrow points up to name tiles above */
    .speech-bubble::before {
        top: -20px;
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        border-top: none;
        border-bottom: 20px solid #00ff88;
        border-right: 15px solid transparent;
        border-left: 15px solid transparent;
    }

    .speech-bubble::after {
        top: -14px;
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        border-top: none;
        border-bottom: 17px solid rgba(255, 255, 255, 0.1);
        border-right: 12px solid transparent;
        border-left: 12px solid transparent;
    }

    .speech-text {
        font-size: 14px;
    }

    .skip-hint {
        font-size: 16px;
        bottom: 20px;
    }

    /* Level Select - Mobile - Horizontal Scroll (Match Character Select Style) */
    #level-select-screen .content {
        max-width: 100%;
        padding: 0;
    }

    .level-selection-layout {
        flex-direction: column-reverse;
        max-width: 100%;
        gap: 20px;
        padding: 0;
    }

    .level-grid-container {
        width: 100%;
    }

    .level-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
        padding: 15px;
        margin: 0 0 20px 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        grid-template-columns: none;
        grid-template-rows: none;
        /* Enable momentum scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .level-card {
        flex: 0 0 100px;
        width: 100px;
        height: 100px;
        padding: 8px;
        scroll-snap-align: center;
    }

    .level-icon {
        font-size: 40px;
    }

    .level-card h3 {
        font-size: 9px;
    }

    .level-preview-panel {
        width: 100%;
        max-width: 100%;
        margin: 0 0 20px 0;
        padding: 20px 15px;
        height: 330px;
        min-height: 330px;
        max-height: 330px;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
    }

    .level-preview-icon {
        font-size: 50px;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .level-preview-name {
        font-size: 16px;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .level-preview-description {
        font-size: 12px;
        margin-bottom: 15px;
        flex-shrink: 0;
    }

    .level-preview-section {
        margin-bottom: 12px;
        flex-shrink: 0;
    }

    .level-preview-section h4 {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .level-preview-section p {
        font-size: 12px;
    }

    /* Options Screen - Mobile */
    #options-screen {
        overflow-y: auto;
        align-items: flex-start;
    }

    #options-screen .content {
        max-width: 100%;
        padding: 0;
        padding-bottom: 30px;
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    #options-screen h2 {
        margin: 15px 0;
        padding: 0;
    }

    .options-layout {
        flex-direction: column;
        max-width: 100%;
        gap: 0;
        padding: 0;
        margin: 0;
        flex: 1;
    }

    .options-form-section {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 20px 15px;
        padding-bottom: 30px;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .options-bottom-buttons {
        flex-direction: row;
        gap: 10px;
        margin: 0;
        margin-top: 10px;
        padding: 15px;
        background: rgba(0, 0, 0, 0.3);
        justify-content: center;
        position: relative;
    }

    .options-bottom-buttons .pixel-button {
        flex: 0 0 auto;
        min-width: 120px;
        padding: 12px 20px;
    }

    .options-bottom-buttons .pixel-button.secondary {
        min-width: 140px;
    }

    .form-group-label {
        font-size: 13px;
    }

    .pixel-select,
    .pixel-input {
        font-size: 12px;
        padding: 8px;
    }

    .inline-label {
        font-size: 11px;
    }

    .explanation-title {
        font-size: 16px;
    }

    .explanation-item h4 {
        font-size: 12px;
    }

    .explanation-item p {
        font-size: 11px;
    }

    /* Modal - Mobile */
    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 15px;
    }

    /* Password Screen - Mobile */
    .password-logo {
        max-width: 280px;
        width: 90%;
        margin-bottom: 30px;
    }

    .password-container {
        flex-direction: row;
        gap: 8px;
        width: 100%;
        padding: 0 20px;
        max-width: 400px;
    }

    .password-container #password-input {
        flex: 1;
        font-size: 16px;
        padding: 12px;
    }

    .password-container #password-submit-btn {
        flex: 0 0 auto;
        min-width: 80px;
    }

    .password-error {
        position: static;
        margin-top: 10px;
        font-size: 13px;
    }

    /* Room Lobby - Mobile */
    #room-screen {
        overflow-y: auto;
        align-items: flex-start;
    }

    #room-screen .content {
        max-width: 100%;
        padding: 0;
        padding-bottom: 30px;
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    #room-screen h2 {
        margin: 15px 0;
        padding: 0;
    }

    .room-top-section {
        flex-direction: column;
        gap: 15px;
        margin: 0;
        padding: 15px;
        padding-bottom: 30px;
        flex: 1;
    }

    .room-game-settings-wrapper,
    .room-invite-section,
    .players-list-wrapper {
        flex: 0 0 auto;
        width: 100%;
    }

    .invite-content-wrapper {
        flex-direction: row;
        gap: 10px;
        align-items: flex-start;
    }

    .invite-links-wrapper {
        flex-direction: column;
        gap: 0;
    }

    .room-game-settings,
    .players-list {
        border: none;
        border-radius: 0;
        padding: 15px;
        background: rgba(0, 0, 0, 0.2);
    }

    .invite-label {
        font-size: 13px;
        margin-bottom: 8px;
        text-align: left;
    }

    .room-join-url-container {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        border-bottom: 1px solid rgba(0, 255, 136, 0.2);
    }

    #room-join-url-display {
        font-size: 9px;
        text-align: center;
        padding: 5px;
    }

    .room-join-url-container .pixel-button {
        font-size: 10px;
        padding: 6px;
    }

    .room-code-container {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        border: none;
        align-items: stretch;
    }

    #room-code-display {
        font-size: 20px;
        letter-spacing: 3px;
        text-align: center;
        padding: 8px;
    }

    .room-code-container .pixel-button {
        font-size: 10px;
        padding: 6px;
    }

    .room-code-container .pixel-button,
    .room-join-url-container .pixel-button {
        flex: 0 0 auto;
        min-width: 80px;
        padding: 8px 12px;
        font-size: 11px;
    }

    #room-game-info {
        font-size: 12px;
        gap: 6px;
    }

    .game-info-item {
        padding: 6px 10px;
    }

    .room-player {
        padding: 8px;
        font-size: 14px;
    }

    .room-player .player-icon {
        font-size: 20px;
    }

    .room-controls {
        flex-direction: row;
        gap: 10px;
        margin: 0;
        margin-top: 10px;
        padding: 15px;
        background: rgba(0, 0, 0, 0.3);
        justify-content: center;
        position: relative;
    }

    .room-controls .pixel-button {
        flex: 0 0 auto;
        min-width: 120px;
    }

    .room-controls .pixel-button.secondary {
        min-width: 100px;
        font-size: 11px;
        padding: 10px 15px;
    }

    /* Join Room Screen - Mobile */
    .join-lobby-content {
        max-width: 100%;
        padding: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    #join-room-screen h2 {
        margin: 15px 0;
        padding: 0;
    }

    .join-by-code-section {
        border: none;
        border-radius: 0;
        padding: 15px;
        margin: 0;
        background: rgba(0, 0, 0, 0.2);
        border-bottom: 2px solid var(--theme-primary);
    }

    .section-label {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .join-code-input-row {
        gap: 8px;
    }

    .join-code-input-row .pixel-input {
        min-width: 0;
        flex: 1;
        font-size: 14px;
        padding: 10px;
    }

    .join-code-input-row .pixel-button {
        flex: 0 0 auto;
        min-width: 70px;
        font-size: 11px;
        padding: 10px 15px;
    }

    .lobby-divider {
        margin: 15px 0;
        padding: 0 15px;
    }

    .lobby-divider span {
        font-size: 10px;
        padding: 0 10px;
    }

    .active-games-section {
        border: none;
        border-radius: 0;
        padding: 0;
        margin: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .active-games-header {
        padding: 15px;
        margin-bottom: 0;
        background: rgba(0, 0, 0, 0.2);
        border-bottom: 2px solid var(--theme-primary);
    }

    .active-games-header .section-label {
        text-align: left;
    }

    .active-games-header .pixel-button {
        font-size: 10px;
        padding: 8px 12px;
    }

    .active-games-list {
        max-height: none;
        flex: 1;
        padding: 15px;
        gap: 12px;
    }

    .loading-games,
    .no-games {
        padding: 30px 15px;
        font-size: 12px;
    }

    .game-room-card {
        border: none;
        border-radius: 0;
        padding: 12px;
        border-top: 2px solid #444;
        border-bottom: 2px solid #444;
    }

    .game-room-card:hover {
        transform: none;
        border-top-color: var(--theme-secondary);
        border-bottom-color: var(--theme-secondary);
    }

    .game-room-host {
        font-size: 13px;
        gap: 8px;
        margin-bottom: 8px;
    }

    .game-status-badge {
        font-size: 8px;
        padding: 2px 6px;
    }

    .game-room-details {
        font-size: 11px;
        gap: 10px;
        margin-bottom: 10px;
    }

    .game-room-join-btn {
        font-size: 9px;
        padding: 8px 14px;
    }

    .room-status {
        margin-top: 15px;
        padding: 0 15px;
        font-size: 12px;
    }

    /* Endgame Screen - Mobile */
    .endgame-container {
        max-width: 100%;
        padding: 10px;
        height: 100vh;
    }

    .endgame-header {
        margin-bottom: 8px;
        padding: 0;
    }

    .endgame-title {
        font-size: 18px;
    }

    .endgame-actions {
        gap: 6px;
    }

    .endgame-actions .pixel-button {
        padding: 8px 12px;
        font-size: 11px;
        min-width: 80px;
    }

    .endgame-dialog-container {
        min-height: 50px;
        margin-bottom: 8px;
    }

    .endgame-content {
        gap: 10px;
        max-width: 100%;
        padding: 0;
        padding-bottom: 10px;
    }

    .rankings-section,
    .stats-section,
    .endgame-players-section {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 12px 10px;
        margin: 0;
    }

    .rankings-section h2,
    .stats-section h3,
    .endgame-players-section h2 {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .section-title {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .rankings-list {
        gap: 8px;
    }

    .stats-list {
        gap: 6px;
    }

    .stat-item {
        font-size: 12px;
        padding: 6px 8px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-value {
        font-size: 13px;
    }

    .endgame-players-list {
        gap: 8px;
    }

    .endgame-player-item {
        padding: 8px 10px;
        font-size: 12px;
    }

    .endgame-player-item .player-icon {
        font-size: 20px;
    }
}

/* Extra small mobile (360px and below) */
@media (max-width: 360px) {
    .arcade-logo {
        max-width: 240px;
        width: 90%;
    }

    .insert-coin {
        font-size: 14px;
    }

    .arcade-button-large {
        font-size: 18px;
        padding: 12px 25px;
    }

    .arcade-button-medium {
        font-size: 12px;
        padding: 10px 20px;
    }

    .arcade-button-small {
        font-size: 10px;
        padding: 6px 12px;
    }

    .landing-bg-rect {
        height: 420px;
    }
}
