/* ============================================
   Grow Games - Complete Dark Theme Stylesheet
   Mobile-first, native app feel
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --primary-lighter: #1f2b47;
    --primary-surface: #243052;
    --accent: #e94560;
    --accent-hover: #d63851;
    --accent-glow: rgba(233, 69, 96, 0.3);
    --text-primary: #f0f0f5;
    --text-secondary: #8892a8;
    --text-muted: #5a6378;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-active: rgba(255, 255, 255, 0.12);
    --card-bg: #16213e;
    --card-hover: #1a2744;
    --input-bg: #0f1729;
    --input-border: rgba(255, 255, 255, 0.08);
    --input-focus: rgba(233, 69, 96, 0.5);
    --overlay: rgba(10, 10, 20, 0.7);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --font-stack: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-stack);
    background-color: var(--primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hide scrollbars but allow scrolling */
/* Temporarily disabled for scroll debugging */

a {
    text-decoration: none;
    color: inherit;
}

input, button {
    font-family: inherit;
    font-size: inherit;
    border: none;
    outline: none;
    background: none;
}

button {
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}


/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding-top: calc(20px + var(--safe-top));
    padding-bottom: calc(20px + var(--safe-bottom));
    background: var(--primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(233, 69, 96, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(22, 33, 62, 0.5) 0%, transparent 50%);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.login-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 40px 28px 36px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.app-logo {
    display: inline-flex;
    margin-bottom: 16px;
}

.app-logo svg {
    filter: drop-shadow(0 4px 12px rgba(233, 69, 96, 0.3));
}

.app-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.app-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-left: 4px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.input-wrapper input {
    width: 100%;
    height: 52px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-md);
    padding: 0 16px 0 46px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--input-focus);
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper input:focus + .input-icon {
    color: var(--accent);
}

/* Fix: icon color on focus - icon is before input */
.input-wrapper:focus-within .input-icon {
    color: var(--accent);
}

/* Login Button */
.btn-login {
    width: 100%;
    height: 52px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-login:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-login:active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

.btn-login.loading {
    pointer-events: none;
    opacity: 0.85;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: rgba(233, 69, 96, 0.12);
    border: 1px solid rgba(233, 69, 96, 0.25);
    border-radius: var(--radius-sm);
    color: #ff6b81;
    font-size: 13px;
    font-weight: 500;
    animation: shakeIn 0.4s ease;
}

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

/* Login Footer */
.login-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}


/* ============================================
   LOBBY PAGE
   ============================================ */

.lobby-page {
    padding-top: calc(var(--header-height) + var(--safe-top));
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
}

/* App Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--header-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: calc(16px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-greeting {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.header-logout:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent);
}

.header-logout:active {
    transform: scale(0.92);
}

/* Lobby Content */
.lobby-content {
    padding: 20px;
    padding-left: calc(16px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
    max-width: 800px;
    margin: 0 auto;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-count {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Category Filters */
.category-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding: 0 16px;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
    height: 40px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--primary-lighter);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    white-space: nowrap;
    scroll-snap-align: start;
}

.filter-chip:hover {
    background: var(--primary-surface);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.filter-chip:active {
    transform: scale(0.95);
}

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    text-align: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    min-height: 48px;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.game-card:hover {
    background: var(--card-hover);
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.game-card:hover::before {
    opacity: 0.5;
}

.game-card:active {
    transform: translateY(0) scale(0.97);
    box-shadow: none;
}

.game-card.hidden {
    display: none;
}

.game-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid;
    flex-shrink: 0;
}

.game-emoji {
    font-size: 28px;
    line-height: 1;
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.game-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.game-category {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--primary-light);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 64px;
}

.nav-item:hover {
    color: var(--text-secondary);
}

.nav-item.active {
    color: var(--accent);
}

.nav-item:active {
    transform: scale(0.9);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}


/* ============================================
   GAME PAGE
   ============================================ */

.game-page {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: none;
    touch-action: none;
}

.game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--header-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: calc(8px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
    z-index: 100;
}

.game-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.game-back:hover {
    background: rgba(255, 255, 255, 0.06);
}

.game-back:active {
    transform: scale(0.9);
}

.game-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.game-header-icon {
    font-size: 22px;
    line-height: 1;
}

.game-header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-header-spacer {
    width: 48px;
    flex-shrink: 0;
}

/* Game Header Actions (fullscreen button) */
.game-header-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.game-fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.game-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.game-fullscreen-btn:active {
    transform: scale(0.9);
}

.game-container {
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    touch-action: manipulation;
    overflow: hidden;
    transition: top 0.3s ease;
}

.game-container iframe {
    border: none;
    display: block;
    touch-action: manipulation;
    opacity: 0;
    transition: opacity 0.4s ease;
    /* Default: fill container (desktop) */
    width: 100%;
    height: 100%;
}

.game-container iframe.loaded {
    opacity: 1;
}


/* Game Loading */
.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--primary);
    color: var(--text-secondary);
    font-size: 14px;
    z-index: 5;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Game Loading fade-out */
.game-loading.fade-out {
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

/* Game Error State */
.game-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--primary);
    color: var(--text-secondary);
    font-size: 14px;
    z-index: 6;
    padding: 24px;
    text-align: center;
}

.game-error-text {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.5;
}

.game-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    min-width: 160px;
    padding: 0 24px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    touch-action: manipulation;
    margin-top: 8px;
}

.game-retry-btn:hover {
    background: var(--accent-hover);
}

.game-retry-btn:active {
    transform: scale(0.96);
}

/* Rotate Device Overlay */
.rotate-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 20, 0.92);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.rotate-overlay.visible {
    display: flex;
}

.rotate-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.rotate-overlay-content p {
    font-size: 16px;
    max-width: 260px;
    line-height: 1.5;
}

.rotate-icon {
    animation: rotateHint 2s ease-in-out infinite;
}

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

/* Fullscreen mode styles */
.game-page.fullscreen .game-header {
    display: none !important;
}

.game-page.fullscreen .game-container {
    top: 0 !important;
}

/* Header hidden in landscape */
.game-page.header-hidden .game-header {
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.game-page .game-header {
    transition: transform 0.3s ease;
}

.game-page.header-hidden .game-container {
    top: 0;
}


/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--primary-surface);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Very small phones - single column */
@media (max-width: 319px) {
    .game-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .game-card {
        flex-direction: row;
        padding: 14px;
        gap: 14px;
        text-align: left;
    }

    .game-info {
        align-items: flex-start;
    }

    .header-greeting {
        display: none;
    }
}

/* Small phones */
@media (max-width: 359px) {
    .login-card {
        padding: 32px 20px 28px;
    }

    .app-title {
        font-size: 22px;
    }

    .game-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .game-card {
        flex-direction: row;
        padding: 14px;
        gap: 14px;
        text-align: left;
        min-height: 72px;
    }

    .game-card .game-info {
        align-items: flex-start;
    }

    .game-emoji {
        font-size: 24px;
    }

    .game-icon {
        width: 48px;
        height: 48px;
    }

    .filter-chip {
        height: 40px;
        padding: 0 14px;
        font-size: 12px;
    }

    .section-title {
        font-size: 20px;
    }

    .header-greeting {
        display: none;
    }

    .game-header-title {
        font-size: 15px;
    }

    .game-header-icon {
        font-size: 18px;
    }
}

/* Tablets and larger screens */
@media (min-width: 600px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .game-card {
        padding: 24px 16px 20px;
    }

    .game-icon {
        width: 64px;
        height: 64px;
    }

    .game-emoji {
        font-size: 32px;
    }

    .game-name {
        font-size: 15px;
    }

    .lobby-content {
        padding: 24px 32px;
    }
}

/* Desktop (wider) */
@media (min-width: 900px) {
    .game-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .lobby-content {
        max-width: 960px;
    }
}


/* ============================================
   ANIMATIONS & UTILITIES
   ============================================ */

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

.game-card {
    animation: fadeIn 0.3s ease forwards;
}

.game-card:nth-child(1) { animation-delay: 0.02s; }
.game-card:nth-child(2) { animation-delay: 0.04s; }
.game-card:nth-child(3) { animation-delay: 0.06s; }
.game-card:nth-child(4) { animation-delay: 0.08s; }
.game-card:nth-child(5) { animation-delay: 0.10s; }
.game-card:nth-child(6) { animation-delay: 0.12s; }
.game-card:nth-child(7) { animation-delay: 0.14s; }
.game-card:nth-child(8) { animation-delay: 0.16s; }
.game-card:nth-child(9) { animation-delay: 0.18s; }
.game-card:nth-child(10) { animation-delay: 0.20s; }
.game-card:nth-child(11) { animation-delay: 0.22s; }
.game-card:nth-child(12) { animation-delay: 0.24s; }

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Selection color */
::selection {
    background: var(--accent);
    color: #fff;
}

/* Prevent text selection on UI elements */
.bottom-nav,
.app-header,
.game-header,
.filter-chip,
.nav-item {
    -webkit-user-select: none;
    user-select: none;
}

/* ============================================
   AUTH SWITCH (Login <-> Register link)
   ============================================ */

.auth-switch {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--accent);
    font-weight: 600;
    transition: color 0.2s ease;
}

.auth-switch a:hover {
    color: var(--accent-hover);
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */

.lang-switcher {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.lang-option {
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--primary-lighter);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    text-decoration: none;
}

.lang-option:hover {
    color: var(--text-primary);
    background: var(--primary-surface);
}

.lang-option.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}


/* ============================================
   GAME PAGE - LANDSCAPE ORIENTATION
   ============================================ */

/* Landscape: auto-hide game header for maximum game area */
@media (orientation: landscape) and (max-height: 500px) {
    .game-page .game-header {
        transform: translateY(-100%);
        transition: transform 0.3s ease;
    }

    .game-page .game-container {
        top: 0;
    }

    /* Show header briefly on tap at top area - controlled by JS */
    .game-page.show-header .game-header {
        transform: translateY(0);
    }

    .game-page.show-header .game-container {
        top: calc(var(--header-height) + var(--safe-top));
    }

    /* Hide rotate overlay in landscape */
    .rotate-overlay {
        display: none !important;
    }
}

/* Portrait: allow rotate overlay to show */
@media (orientation: portrait) and (max-width: 600px) {
    .rotate-overlay.visible {
        display: flex;
    }
}

/* Landscape: hide rotate overlay */
@media (orientation: landscape) {
    .rotate-overlay {
        display: none !important;
    }
}

/* Compact game header on small screens */
@media (max-width: 400px) {
    .game-header {
        padding-left: calc(4px + var(--safe-left));
        padding-right: calc(8px + var(--safe-right));
    }

    .game-header-info {
        gap: 6px;
    }

    .game-header-icon {
        font-size: 18px;
    }

    .game-header-title {
        font-size: 15px;
    }

    .game-back {
        width: 44px;
        height: 44px;
    }

    .game-fullscreen-btn {
        width: 44px;
        height: 44px;
    }
}

/* Fullscreen API styles (when browser fullscreen is active) */
.game-page:-webkit-full-screen .game-header {
    display: none;
}

.game-page:-webkit-full-screen .game-container {
    top: 0;
}

.game-page:-moz-full-screen .game-header {
    display: none;
}

.game-page:-moz-full-screen .game-container {
    top: 0;
}

.game-page:fullscreen .game-header {
    display: none;
}

.game-page:fullscreen .game-container {
    top: 0;
}

/* Ensure nav items meet touch target minimum */
.nav-item {
    min-height: 48px;
    min-width: 48px;
}

/* Lobby page compact header on very small screens */
@media (max-width: 380px) {
    .header-title {
        font-size: 17px;
    }

    .header-greeting {
        font-size: 12px;
    }

    .lobby-content {
        padding: 16px 12px;
    }
}
