:root {
    --primary-color: #00ffcc;
    --primary-glow: rgba(0, 255, 204, 0.6);
    --secondary-color: #ff00cc;
    --secondary-glow: rgba(255, 0, 204, 0.6);
    --bg-dark: #0a0a14;
    --bg-glass: rgba(15, 15, 25, 0.7);
    --bg-glass-hover: rgba(25, 25, 40, 0.85);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* respects mobile browser chrome (address bar) */
    width: 100%;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ═══════════════════════════════════════════════
   LOGIN / ENTRY SCREEN — HTML/CSS overlay standard
   Palette & layout matched to reference_login_page.html
   ═══════════════════════════════════════════════ */
.ui-layer {
    /* Login screen design tokens (scoped — in-game overlays keep the cyan set) */
    --menu-surface: #1a063b;
    --menu-surface-container: #271448;
    --menu-surface-high: #322053;
    --menu-surface-highest: #3d2b5e;
    --menu-surface-lowest: #150136;
    --menu-bright: #412f63;
    --menu-accent: #b7f700;          /* neon green — actions, focus, selection */
    --menu-accent-deep: #506e00;     /* 3D button base / text on accent */
    --menu-accent-shadow: #374e00;
    --menu-text: #ebddff;
    --menu-text-muted: #bfb3d6;

    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    background-color: var(--menu-surface);
    background-image:
        radial-gradient(circle at 20% 30%, var(--menu-surface-highest) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, var(--menu-surface-highest) 0%, transparent 20%);
    transition: opacity 0.5s ease, visibility 0.5s;
    overflow: hidden;
}

/* Slithering track pattern over the whole screen (reference: .snake-track) */
.ui-layer::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.05;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path d="M10,50 Q30,10 50,50 T90,50" stroke="%23ecdcff" stroke-width="4" fill="none"/></svg>');
    background-repeat: repeat;
    animation: slideTrack 15s linear infinite;
}

@keyframes slideTrack {
    from { background-position: 0 0; }
    to { background-position: -100px 100px; }
}

.ui-layer.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Top Bar */
.top-bar {
    width: 100%;
    padding: 24px 32px;
    display: flex;
    justify-content: flex-end;
}

.icon-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition-bounce);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn:hover {
    background: var(--bg-glass-hover);
    transform: scale(1.1) rotate(15deg);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Main Content */
.main-menu-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* "safe" prevents the top of the content being clipped when it's taller
       than the viewport (flex centering + overflow bug) */
    justify-content: safe center;
    width: 100%;
    padding: 0 20px 10vh; /* side padding keeps card/logo off the edges */
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;   /* never allow horizontal scroll */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.main-menu-content::-webkit-scrollbar {
    display: none;
}

/* ── Logo & Branding ── */
.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    z-index: 1;
}

.float-anim {
    animation: float 4s ease-in-out infinite;
}

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

.brand-logo-ring {
    /* Fluid: scales with viewport, never larger than 176px, never overflows */
    width: clamp(96px, 38vw, 176px);
    max-width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 50%;
    overflow: hidden;
    border: 8px solid var(--menu-surface-highest);
    box-shadow: 0 10px 30px rgba(26, 15, 46, 0.6);
    margin-bottom: -34px;
    z-index: 2;
}

.brand-logo-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.brand-title {
    font-family: 'Quicksand', var(--font-heading), sans-serif;
    /* Fluid type: shrinks with viewport so the nowrap title always fits */
    font-size: clamp(1.4rem, 6.5vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--menu-accent);
    filter: drop-shadow(0 4px 0 var(--menu-accent-shadow));
    background: var(--menu-surface-high);
    border-top: 2px solid var(--menu-bright);
    border-radius: 24px;
    padding: 14px clamp(20px, 5vw, 40px);
    margin: 0;
    max-width: 100%;
    box-shadow: 0 8px 20px rgba(26, 15, 46, 0.5);
    white-space: nowrap;
    z-index: 3;
}

/* ── Login Card ── */
.login-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: 400px;
    margin-top: 34px;
    padding: 26px 24px;
    background: rgba(39, 20, 72, 0.92);   /* --menu-surface-container, hafif şeffaf */
    border-top: 1px solid var(--menu-bright);
    border-radius: 28px;
    box-shadow: 0 10px 25px rgba(26, 15, 46, 0.5);
    z-index: 1;
}

button {
    font-family: var(--font-heading);
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    transition: var(--transition-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Nickname input */
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 18px;
    color: var(--menu-text-muted);
    pointer-events: none;
}

#nickname-input {
    width: 100%;
    padding: 15px 48px;
    font-size: 1.1rem;
    font-family: 'Quicksand', var(--font-body), sans-serif;
    font-weight: 600;
    text-align: center;
    color: var(--menu-text);
    background: var(--menu-surface-lowest);
    border: none;
    border-radius: 999px;
    outline: none;
    box-shadow: inset 0 4px 6px -1px rgba(0, 0, 0, 0.5), inset 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    transition: var(--transition-fast);
}

#nickname-input::placeholder {
    color: var(--menu-text-muted);
    font-weight: 500;
}

#nickname-input:focus {
    box-shadow:
        inset 0 4px 6px -1px rgba(0, 0, 0, 0.5),
        0 0 0 4px rgba(183, 247, 0, 0.35);
}

/* ── Servers button (login card — reference: yellow secondary action) ── */
.servers-btn {
    width: 100%;
    padding: 12px 24px;
    font-family: 'Quicksand', var(--font-heading), sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #6f5c00;                 /* on-secondary-container */
    background: #fdd400;            /* secondary-container */
    border-radius: 999px;
    border-bottom: 6px solid #6f5c00;
    transition: all 0.1s;
}

.servers-btn:hover {
    filter: brightness(1.08);
}

.servers-btn:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

/* ── Auto-selected server readout (login card) ─────────────────────────────
   Bilgi satiri, EYLEM DEGIL: bu yuzden butonlarin 3D/pill dilinden bilincli
   olarak ayrilir ve nickname input'uyla ayni "gomulu yuzey" dilini kullanir
   (--menu-surface-lowest + inset golge). Boylece gorsel hiyerarsi korunur:
   PLAY birincil, Servers ikincil, bu satir onlarin altinda sessiz bir durum
   gostergesi olarak okunur.
   Renkler sunucu listesi kartlariyla AYNI latency tier paletinden gelir. */
.server-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 18px;
    font-family: 'Quicksand', var(--font-body), sans-serif;
    font-size: 0.9rem;
    background: var(--menu-surface-lowest);
    border-radius: 999px;
    box-shadow: inset 0 3px 5px -1px rgba(0, 0, 0, 0.45);
    /* Ping degeri degistiginde renk gecisi yumusak olsun. */
    transition: color var(--transition-fast);
}

.server-indicator-globe {
    flex-shrink: 0;
    /* Ikon, satirin tier rengini miras alir (currentColor). */
    opacity: 0.9;
}

.server-indicator-label {
    color: var(--menu-text-muted);
    font-weight: 500;
}

.server-indicator-name {
    color: var(--menu-text);
    font-weight: 700;
}

/* Ad ile ping arasindaki ayirici nokta. */
.server-indicator-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.server-indicator-ping {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Latency tier renkleri — .server-item[data-tier] ile BIREBIR ayni palet.
   Renk .server-indicator uzerinde tanimlanir; globe ikonu, ayirici nokta ve
   ping degeri currentColor uzerinden bunu miras alir. */
.server-indicator[data-tier="good"]      { color: #b7f700; }  /* primary-container */
.server-indicator[data-tier="ok"]        { color: #a0d800; }  /* primary-fixed-dim */
.server-indicator[data-tier="high"]      { color: #fdd400; }  /* secondary-container */
.server-indicator[data-tier="bad"]       { color: #ffb4ab; }  /* error */
.server-indicator[data-tier="offline"]   { color: #ffb4ab; }
.server-indicator[data-tier="measuring"] { color: var(--menu-text-muted); }

/* Olcum surerken hafif nabiz — "calisiyor" hissi, dikkat dagitmadan. */
.server-indicator[data-tier="measuring"] .server-indicator-ping {
    animation: server-indicator-pulse 1.2s ease-in-out infinite;
}

@keyframes server-indicator-pulse {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .server-indicator[data-tier="measuring"] .server-indicator-ping {
        animation: none;
    }
}

/* ═══════════════════════════════════════════════
   SERVERS MODAL (reference: server_list.html)
   ═══════════════════════════════════════════════ */
.servers-modal {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    visibility: visible;
    opacity: 1;
    transition: var(--transition-fast);
}

.servers-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.servers-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 6, 59, 0.8);   /* background/80 */
    backdrop-filter: blur(4px);
}

.servers-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: #271448;                            /* surface-container */
    border: 1px solid rgba(61, 43, 94, 0.5);        /* surface-variant/50 */
    border-radius: 28px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 32px rgba(26, 15, 46, 0.6);
    font-family: 'Quicksand', sans-serif;
}

.servers-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.servers-card-header h2 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 700;
    color: #b7f700;
    filter: drop-shadow(0 2px 0 #374e00);
}

.servers-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #322053;                /* surface-container-high */
    color: #c2b8d9;
    border-bottom: 4px solid rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, border-bottom-width 0.1s, background 0.15s, color 0.15s;
}

.servers-close-btn:hover {
    background: #412f63;
    color: #ebddff;
}

.servers-close-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* ── Server cards list ── */
.servers-cards-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(60vh, 460px);
    overflow-y: auto;
}

.servers-cards-list::-webkit-scrollbar { width: 6px; }
.servers-cards-list::-webkit-scrollbar-track { background: #150136; border-radius: 8px; }
.servers-cards-list::-webkit-scrollbar-thumb { background: #3d2b5e; border-radius: 8px; }
.servers-cards-list::-webkit-scrollbar-thumb:hover { background: #412f63; }

.server-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: #322053;                /* surface-container-high */
    border: 2px solid transparent;
    border-bottom: 4px solid rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.12s, background 0.15s, border-color 0.15s;
}

.server-item:hover {
    background: #412f63;                /* surface-bright */
    transform: scale(1.02);
    border-color: rgba(183, 247, 0, 0.3);
}

.server-item:active {
    transform: scale(0.98);
}

.server-item.selected {
    border-color: #b7f700;
    background: rgba(183, 247, 0, 0.08);
}

.server-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.server-globe {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #231043;                /* surface-container-low */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c2b8d9;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.server-item:hover .server-globe,
.server-item.selected .server-globe {
    background: rgba(183, 247, 0, 0.2);
    color: #b7f700;
}

.server-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.server-region {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ebddff;
    transition: var(--transition-fast);
}

.server-item:hover .server-region,
.server-item.selected .server-region {
    color: #b7f700;
}

.server-status {
    font-size: 0.82rem;
    font-weight: 500;
    color: #c2b8d9;
}

/* ── Ping + signal, latency-tier colored (set via data-tier in main.js) ── */
.server-ping-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c2b8d9;
    flex-shrink: 0;
}

.server-ping {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.server-item[data-tier="good"]    .server-ping-wrap { color: #b7f700; }  /* primary-container */
.server-item[data-tier="ok"]      .server-ping-wrap { color: #a0d800; }  /* primary-fixed-dim */
.server-item[data-tier="high"]    .server-ping-wrap { color: #fdd400; }  /* secondary-container */
.server-item[data-tier="bad"]     .server-ping-wrap { color: #ffb4ab; }  /* error */
.server-item[data-tier="offline"] .server-ping-wrap { color: #ffb4ab; }
.server-item[data-tier="offline"] { opacity: 0.7; }

/* ── Footer ── */
.servers-card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid rgba(61, 43, 94, 0.3);
}

.servers-confirm-btn {
    padding: 14px 32px;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #506e00;                 /* on-primary-container */
    background: #b7f700;            /* primary-container */
    border-radius: 999px;
    border-bottom: 4px solid rgba(0, 0, 0, 0.2);
    transition: transform 0.12s, filter 0.15s, border-bottom-width 0.1s;
}

.servers-confirm-btn:hover {
    filter: brightness(1.08);
    transform: scale(1.05);
}

.servers-confirm-btn:active {
    transform: scale(0.95) translateY(2px);
    border-bottom-width: 2px;
}

/* ── PLAY button (3D style from reference) ── */
.play-btn {
    width: 100%;
    padding: 16px 32px;
    font-family: 'Quicksand', var(--font-heading), sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--menu-accent-deep);
    background: var(--menu-accent);
    border-radius: 999px;
    border-bottom: 6px solid var(--menu-accent-deep);
    transition: all 0.1s;
}

.play-btn:hover {
    filter: brightness(1.1);
}

.play-btn:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

/* ── Footer ── */
.menu-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    background: var(--menu-surface-lowest);
    border-top: 4px solid var(--menu-surface-high);
    z-index: 1;
}

.menu-footer-brand {
    font-family: 'Quicksand', var(--font-heading), sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--menu-accent);
    filter: drop-shadow(0 2px 0 var(--menu-accent-shadow));
}

.menu-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.menu-footer-links a {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--menu-text-muted);
    text-decoration: none;
    transition: var(--transition-fast);
}

.menu-footer-links a:hover {
    color: var(--menu-accent);
    text-decoration: underline;
}

.menu-footer-copy {
    font-size: 0.78rem;
    color: var(--menu-text-muted);
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: visible;
    opacity: 1;
    transition: var(--transition-fast);
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: var(--bg-dark);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    overflow: hidden;
    transform: translateY(0) scale(1);
    transition: var(--transition-bounce);
}

.modal.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}

.modal-header {
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-main);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* (Eski cam-görünümlü server list stilleri kaldırıldı — sunucu seçimi artık
   server_list.html referansındaki modal kart tasarımını kullanıyor; aşağıda
   SERVERS MODAL bölümüne bakın.) */

/* ═══════════════════════════════════════════════
   MOBILE CONTROLS — Main Menu Customizer
   ═══════════════════════════════════════════════ */

.mobile-controls-section {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    backdrop-filter: blur(6px);
}

.mc-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.mc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mc-label {
    font-size: 0.92rem;
    color: var(--text-main);
    flex-shrink: 0;
}

/* Side picker */
.mc-side-picker {
    display: flex;
    gap: 8px;
}

.mc-side-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-family: var(--font-body);
    font-weight: 600;
    background: var(--bg-glass);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.mc-side-btn.active {
    background: rgba(0, 255, 204, 0.12);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.15);
}

/* Size slider */
.mc-size-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
}

#mc-scale-display {
    font-size: 0.88rem;
    font-family: monospace;
    color: var(--primary-color);
    min-width: 38px;
    text-align: right;
}

#mc-scale-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    cursor: pointer;
}

#mc-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-glow);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

#mc-scale-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
}

/* ═══════════════════════════════════════════════
   In-game joystick/boost controls are rendered as native Phaser GameObjects
   (this.add.circle / this.add.zone) by src/game/ui/MobileControls.js — there
   is no DOM overlay for them anymore, so no CSS is needed here.
   ═══════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════
   UNIFIED HTML/CSS GAME OVERLAYS
   (Connecting + Game Over — src/ui/overlays.js)
   ═══════════════════════════════════════════════ */

/* ── Connecting Overlay ── */
.connecting-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a063b;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s;
    overflow: hidden;
}

.connecting-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Decorative background blobs */
.connecting-overlay-blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(80px);
}

.connecting-overlay-blob-1 {
    width: 400px;
    height: 400px;
    background: #322053;
    top: -10%;
    left: -10%;
    opacity: 0.4;
}

.connecting-overlay-blob-2 {
    width: 500px;
    height: 500px;
    background: #ecdcff;
    bottom: -10%;
    right: -10%;
    opacity: 0.2;
    filter: blur(100px);
}

.connecting-card {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 420px;
    padding: 48px 32px;
    background: #271448;
    border: 1px solid #322053;
    border-radius: 28px;
    box-shadow: 0 8px 30px rgba(26, 15, 46, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* Egg Loader */
.egg-loader-container {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.egg-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(183, 247, 0, 0.2);
    filter: blur(12px);
    opacity: 0;
}

.egg-loader {
    position: relative;
    width: 64px;
    height: 64px;
    background: #a0d800;
    border-radius: 50%;
    box-shadow: 0 4px 0 #506e00, inset 0 2px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid #b7f700;
    animation: rollEgg 2s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes rollEgg {
    0% { transform: rotate(0deg) translateX(0); }
    25% { transform: rotate(90deg) translateX(10px); }
    50% { transform: rotate(180deg) translateX(0); }
    75% { transform: rotate(270deg) translateX(-10px); }
    100% { transform: rotate(360deg) translateX(0); }
}

/* Egg Eyes */
.egg-eye {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #506e00;
    border-radius: 50%;
}

.egg-eye-left {
    top: 20px;
    left: 16px;
}

.egg-eye-right {
    top: 20px;
    right: 16px;
}

/* Egg Blush */
.egg-blush {
    position: absolute;
    width: 8px;
    height: 5px;
    background: rgba(255, 107, 91, 0.5);
    border-radius: 50%;
    filter: blur(1px);
}

.egg-blush-left {
    top: 28px;
    left: 6px;
}

.egg-blush-right {
    top: 28px;
    right: 6px;
}

/* Connecting Status */
.connecting-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.connecting-title {
    font-family: 'Quicksand', var(--font-heading), sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ebddff;
    margin: 0;
    animation: pulseSoft 1.5s ease-in-out infinite;
}

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

.connecting-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'Quicksand', var(--font-body), sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #c2caad;
}

.info-label {
    color: #c2caad;
}

.info-value {
    color: #b7f700;
    font-weight: 700;
}

.info-separator {
    opacity: 0.5;
    margin: 0 4px;
}

/* Progress Bar with Snake */
.connecting-progress-bar {
    width: 100%;
    height: 16px;
    background: #150136;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.snake-animation {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 100%;
    width: 33%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    padding-right: 8px;
    animation: slither 2.5s linear infinite;
}

@keyframes slither {
    0% { transform: translateY(-50%) translateX(-100%); }
    100% { transform: translateY(-50%) translateX(300%); }
}

.snake-segment {
    border-radius: 50%;
    background: #b7f700;
    animation: wiggle 0.5s ease-in-out infinite;
    flex-shrink: 0;
}

.snake-segment-1 { width: 8px; height: 8px; opacity: 0.4; animation-delay: 0s; }
.snake-segment-2 { width: 10px; height: 10px; opacity: 0.6; animation-delay: 0.1s; }
.snake-segment-3 { width: 12px; height: 12px; opacity: 0.8; animation-delay: 0.2s; }
.snake-segment-4 { width: 14px; height: 14px; animation-delay: 0.3s; }

.snake-head {
    width: 16px;
    height: 16px;
    position: relative;
    background: #a0d800;
    border-radius: 50%;
    animation: wiggle 0.5s ease-in-out infinite, rotateHead 2s linear infinite;
    animation-delay: 0.4s, 0s;
    flex-shrink: 0;
}

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

@keyframes rotateHead {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.snake-eye {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #506e00;
    border-radius: 50%;
}

.snake-eye-1 {
    top: 3px;
    right: 4px;
}

.snake-eye-2 {
    bottom: 3px;
    right: 4px;
}

/* Cancel Button */
.connecting-cancel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: white;
    background: #ff6b5b;
    border: none;
    border-radius: 16px;
    border-bottom: 4px solid #cc3d30;
    cursor: pointer;
    transition: all 0.12s ease;
    box-shadow: 0 8px 16px rgba(255, 107, 91, 0.3);
}

.connecting-cancel-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(255, 107, 91, 0.4);
}

.connecting-cancel-btn:active {
    transform: translateY(2px) scale(0.98);
    border-bottom-width: 2px;
}

.connecting-cancel-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Game Over Overlay ── */
/* ═══════════════════════════════════════════════
   GAME OVER SCREEN (reference: game_over.html — 1:1)
   Palette: surface-container #271448, surface-container-low #231043,
   primary-container #b7f700, on-primary #253600,
   secondary-fixed #ffe170, tertiary-fixed-dim #d5baff
   ═══════════════════════════════════════════════ */

.gameover-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px; /* container-padding */
    background: #1a063b; /* background/surface-dim */
    color: #ebddff;      /* on-background */
    font-family: 'Quicksand', sans-serif;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s;
}

.gameover-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Animated background decor (blurred blobs) */
.gameover-decor {
    position: absolute;
    border-radius: 9999px;
    opacity: 0.05;
    pointer-events: none;
}

.gameover-decor-1 {
    top: 80px;
    left: 40px;
    width: 256px;  /* w-64 */
    height: 256px;
    background: #b7f700; /* primary-container */
    filter: blur(120px);
}

.gameover-decor-2 {
    bottom: 80px;
    right: 40px;
    width: 384px;  /* w-96 */
    height: 384px;
    background: #ecdcff; /* tertiary-container */
    filter: blur(150px);
}

/* Modal cluster: mascot + panel */
.gameover-cluster {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 512px; /* max-w-lg */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Mascot */
.gameover-mascot-wrap {
    position: relative;
    margin-bottom: -64px; /* -mb-16 */
    z-index: 20;
}

.gameover-float {
    animation: gameoverFloat 3s ease-in-out infinite;
}

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

.gameover-mascot-ring {
    width: 160px;   /* w-40 */
    height: 160px;
    border-radius: 9999px;
    padding: 8px;   /* p-2 */
    background: #b7f700; /* primary-container */
    box-shadow: 0 8px 0 0 #374e00;
}

@media (min-width: 768px) {
    .gameover-mascot-ring {
        width: 224px;  /* md:w-56 */
        height: 224px;
    }
}

.gameover-mascot-ring img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 9999px;
    background: #150136; /* surface-container-lowest */
    display: block;
}

/* Dizzy stars */
.gameover-star {
    position: absolute;
}

.gameover-star .material-symbols-outlined {
    color: #ffe170; /* secondary-fixed */
    font-variation-settings: 'FILL' 1;
}

.gameover-star-spin {
    top: -16px;   /* -top-4 */
    right: -16px; /* -right-4 */
    animation: gameoverSpin 1s linear infinite;
}

.gameover-star-spin .material-symbols-outlined {
    font-size: 36px; /* text-4xl */
}

@keyframes gameoverSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.gameover-star-pulse {
    top: 0;
    left: -24px; /* -left-6 */
    animation: gameoverPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.gameover-star-pulse .material-symbols-outlined {
    font-size: 30px; /* text-3xl */
}

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

/* Modal Panel */
.gameover-panel {
    width: 100%;
    background: #271448; /* surface-container */
    border: 6px solid #b7f700; /* border-primary-container */
    border-radius: 2rem; /* rounded-lg */
    padding: 80px 32px 40px; /* pt-20 px-8 pb-10 */
    text-align: center;
    /* .bubbly-container */
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), 0 10px 25px rgba(26, 15, 46, 0.5);
}

.gameover-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 48px;         /* text-display */
    line-height: 56px;
    letter-spacing: -0.02em;
    font-weight: 700;
    margin: 0 0 32px;        /* mb-8 */
    /* .snake-gradient */
    background: linear-gradient(180deg, #ff5f6d 0%, #ffc371 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.35)); /* drop-shadow-lg */
}

/* Stats Bento Grid */
.gameover-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;          /* gap-4 */
    margin-bottom: 40px; /* mb-10 */
}

.gameover-stat {
    background: #231043; /* surface-container-low */
    padding: 16px;       /* p-4 */
    border-radius: 2rem; /* rounded-lg */
    border-bottom: 4px solid #322053; /* border-b-4 surface-container-high */
}

.gameover-stat-score {
    grid-column: span 2 / span 2; /* col-span-2 */
    padding: 24px; /* p-6 */
}

.gameover-stat-label {
    font-size: 12px;     /* text-label-bold */
    line-height: 16px;
    font-weight: 700;
    color: #c2caad;      /* on-surface-variant */
    margin: 0 0 4px;     /* mb-1 */
    text-transform: uppercase;
    letter-spacing: 0.1em; /* tracking-widest */
}

.gameover-score-value {
    font-family: 'Quicksand', sans-serif;
    font-size: 64px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;      /* leading-none */
    color: #b7f700;      /* primary-container */
    filter: drop-shadow(0 0 15px rgba(183, 247, 0, 0.4));
    margin: 0;
}

.gameover-rank-value {
    font-size: 32px;     /* text-headline-lg */
    line-height: 40px;
    font-weight: 700;
    color: #ffe170;      /* secondary-fixed */
    margin: 0;
}

.gameover-food-value {
    font-size: 32px;     /* text-headline-lg */
    line-height: 40px;
    font-weight: 700;
    color: #d5baff;      /* tertiary-fixed-dim */
    margin: 0;
}

/* Action Buttons */
.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 16px; /* gap-4 */
}

.gameover-btn-primary {
    width: 100%;
    background: #b7f700;  /* primary-container */
    color: #253600;       /* on-primary */
    padding: 16px 32px;   /* py-button-padding-y px-button-padding-x */
    border-radius: 2rem;  /* rounded-lg */
    font-family: 'Quicksand', sans-serif;
    font-size: 32px;      /* text-headline-lg */
    line-height: 40px;
    font-weight: 700;
    box-shadow: 0 4px 0 0 #374e00;
    border: none;
    transition: all 0.1s ease; /* .pressable-button */
}

.gameover-btn-primary:hover {
    transform: scale(1.02);
}

.gameover-btn-primary:active {
    box-shadow: none;
    transform: translateY(4px);
}

.gameover-btn-secondary {
    width: 100%;
    background: #322053;  /* surface-container-high */
    color: #ebddff;       /* on-surface */
    padding: 16px 32px;
    border-radius: 2rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 20px;      /* text-title-md */
    line-height: 28px;
    font-weight: 600;
    border: none;
    border-bottom: 4px solid #3d2b5e; /* surface-container-highest */
    transition: background-color 0.15s ease, color 0.15s ease;
}

.gameover-btn-secondary:hover {
    background: #412f63; /* surface-bright */
}

.gameover-btn-secondary:active {
    transform: translateY(2px);
}

/* Bottom links */
.gameover-links {
    margin-top: 32px; /* mt-8 */
    display: flex;
    justify-content: center;
    gap: 24px; /* gap-6 */
}

.gameover-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    color: #c2caad; /* on-surface-variant */
    transition: color 0.15s ease;
}

.gameover-link .material-symbols-outlined {
    font-size: 24px;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.gameover-link-label {
    font-size: 12px;   /* text-label-bold */
    line-height: 16px;
    font-weight: 700;
}

.gameover-link-share:hover {
    color: #b7f700; /* primary-container */
}

.gameover-link-board:hover {
    color: #ffe170; /* secondary-fixed */
}

/* ═══════════════════════════════════════════════
   SETTINGS MODAL (reference: settings.html)
   ═══════════════════════════════════════════════ */

.settings-modal {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    visibility: visible;
    opacity: 1;
    transition: var(--transition-fast);
}

.settings-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.settings-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 6, 59, 0.8);
    backdrop-filter: blur(4px);
}

.settings-card {
    position: relative;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    background: #271448;
    border: 1px solid rgba(61, 43, 94, 0.5);
    border-radius: 28px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 32px rgba(26, 15, 46, 0.6);
    overflow: hidden;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px;
    background: rgba(50, 32, 83, 0.5);
    border-bottom: 1px solid rgba(61, 43, 94, 0.3);
}

.settings-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-header-title .material-symbols-outlined {
    color: #b7f700;
    font-size: 24px;
}

.settings-header-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ebddff;
    letter-spacing: 1px;
}

.settings-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: #c2b8d9;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close-btn:hover {
    background: #322053;
    color: #ebddff;
}

.settings-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-body::-webkit-scrollbar {
    width: 6px;
}

.settings-body::-webkit-scrollbar-track {
    background: #150136;
    border-radius: 8px;
}

.settings-body::-webkit-scrollbar-thumb {
    background: #3d2b5e;
    border-radius: 8px;
}

.settings-body::-webkit-scrollbar-thumb:hover {
    background: #412f63;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #b7f700;
    margin: 0 0 16px 0;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-option-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ebddff;
}

/* Toggle Switch */
.settings-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.settings-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.settings-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #322053;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.settings-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .settings-slider {
    background-color: #b7f700;
}

input:checked + .settings-slider:before {
    transform: translateX(24px);
    background-color: #506e00;
}

/* Range Slider */
.settings-slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.settings-slider-header span:first-child {
    color: #ebddff;
    font-weight: 600;
}

.settings-value {
    color: #b7f700;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.settings-range {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #150136;
    outline: none;
    accent-color: #b7f700;
    cursor: pointer;
}

.settings-range::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #b7f700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(183, 247, 0, 0.3);
}

.settings-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #b7f700;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(183, 247, 0, 0.3);
}

/* Button Group */
.settings-joystick {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-button-group {
    display: flex;
    gap: 8px;
    background: #150136;
    border-radius: 999px;
    padding: 4px;
}

.settings-group-btn {
    flex: 1;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #c2b8d9;
    background: transparent;
}

.settings-group-btn.active {
    background: #b7f700;
    color: #506e00;
    box-shadow: 0 2px 8px rgba(183, 247, 0, 0.2);
}

.settings-group-btn:hover:not(.active) {
    color: #ebddff;
}

/* Footer */
.settings-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid rgba(61, 43, 94, 0.3);
    background: #150136;
}

.settings-save-btn {
    flex: 1;
    padding: 12px 24px;
    background: #b7f700;
    color: #506e00;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.12s ease;
    box-shadow: 0 4px 12px rgba(183, 247, 0, 0.2);
}

.settings-save-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(183, 247, 0, 0.3);
}

.settings-save-btn:active {
    transform: translateY(1px) scale(0.98);
}

.settings-reset-btn {
    padding: 12px 24px;
    background: transparent;
    color: #c2b8d9;
    border: 1px solid #3d2b5e;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.settings-reset-btn:hover {
    background: #322053;
    color: #ebddff;
    border-color: #412f63;
}

/* ─── Responsive: keep panel on-screen on narrow viewports ─── */
@media (max-width: 380px) {
    .settings-panel {
        width: calc(100vw - 48px);
        right: -8px;
    }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Mobile portrait / narrow viewports
   (tablets & phones held vertically, ≤768px wide)
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .top-bar {
        padding: 16px 20px;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .main-menu-content {
        padding: 0 16px 6vh;
    }

    .login-card {
        max-width: min(400px, 100%);
        gap: 14px;
        padding: 20px 18px;
    }

    #nickname-input {
        padding: 13px 44px;
        font-size: 1rem;
    }

    .play-btn {
        padding: 14px 24px;
        font-size: 1.4rem;
    }

    /* Footer: stack vertically and center on narrow screens */
    .menu-footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 8px;
        padding: 12px 16px;
    }

    .menu-footer-brand {
        font-size: 1.1rem;
    }
}

/* Very small phones (≤400px wide) */
@media (max-width: 400px) {
    .brand-logo-ring {
        border-width: 5px;
        margin-bottom: -24px;
    }

    .login-card {
        margin-top: 26px;
        padding: 18px 14px;
        border-radius: 22px;
    }

    .play-btn {
        font-size: 1.25rem;
    }

    .servers-btn {
        font-size: 0.95rem;
    }

    /* Dar ekranda "Connected to" etiketi satiri kirar; sadece bolge + ping
       kalsin — bilgi yogunlugu korunur, satir tek satirda kalir. */
    .server-indicator {
        font-size: 0.82rem;
        padding: 9px 14px;
        gap: 6px;
    }

    .server-indicator-label {
        display: none;
    }

    .menu-footer-links {
        gap: 10px 14px;
    }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Mobile landscape / short viewports
   (covers phones in landscape, e.g. ~360–430px tall)
   ═══════════════════════════════════════════════ */
@media (max-height: 500px) {
    .top-bar {
        padding: 10px 20px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    /* Landscape: put logo and login card SIDE BY SIDE — the vertical stack
       was taller than the short viewport and flex-centering clipped the logo.
       A row layout uses the abundant width instead, so nothing gets cut. */
    .main-menu-content {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        justify-content: safe center;
        gap: 28px;
        padding: 0 16px;
    }

    .brand {
        width: auto;
        flex-shrink: 0;
    }

    /* Disable the ±10px float so the logo can't bob out of a tight viewport */
    .float-anim {
        animation: none;
    }

    .brand-logo-ring {
        width: 96px;
        border-width: 4px;
        margin-bottom: -18px;
    }

    .brand-title {
        font-size: clamp(1.1rem, 3.2vw, 1.5rem);
        padding: 8px 20px;
        border-radius: 14px;
    }

    .login-card {
        gap: 10px;
        max-width: min(340px, 48vw);
        margin-top: 0;
        padding: 16px;
        border-radius: 20px;
    }

    #nickname-input {
        padding: 9px 40px;
        font-size: 0.95rem;
    }

    .servers-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
        border-bottom-width: 4px;
    }

    /* Landscape mobilde dikey alan kritik — satiri sikistir ve etiketi gizle. */
    .server-indicator {
        padding: 7px 14px;
        font-size: 0.8rem;
        gap: 6px;
    }

    .server-indicator-label {
        display: none;
    }

    .play-btn {
        padding: 9px 24px;
        font-size: 1.15rem;
        border-bottom-width: 4px;
    }

    .menu-footer {
        display: none; /* kısa (landscape mobil) ekranlarda yer aç */
    }
}

/* ═══════════════════════════════════════════════
   FULLSCREEN TOGGLE — universal, all screens
   ═══════════════════════════════════════════════ */

.fullscreen-btn {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 55;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(39, 20, 72, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(235, 221, 255, 0.1);
    border-radius: 10px;
    color: rgba(235, 221, 255, 0.6);
    cursor: pointer;
    padding: 0;
    pointer-events: auto;
    transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    overflow: visible;
}

.fullscreen-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    overflow: visible;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.fullscreen-btn:hover {
    background: rgba(50, 32, 83, 0.75);
    color: #ebddff;
    -webkit-transform: translateZ(0) scale(1.08);
    transform: translateZ(0) scale(1.08);
}

.fullscreen-btn:active {
    -webkit-transform: translateZ(0) scale(0.94);
    transform: translateZ(0) scale(0.94);
}

@media (max-width: 768px), (max-height: 500px) {
    .fullscreen-btn {
        bottom: 10px;
        left: 10px;
        width: 32px;
        height: 32px;
    }

    .fullscreen-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* ── iOS Safari pseudo-fullscreen fallback ── */
html.pseudo-fullscreen,
html.pseudo-fullscreen body {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    z-index: 0;
}

html.pseudo-fullscreen #app {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1;
}

/* ═══════════════════════════════════════════════
   GAME HUD — In-game Overlay (Match reference design exactly)
   ═══════════════════════════════════════════════ */

.game-hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'Quicksand', sans-serif;
}

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

/* Color system matching reference */
:root {
    --hud-surface: #1a063b;
    --hud-surface-container-high: #322053;
    --hud-surface-container-highest: #3d2b5e;
    --hud-surface-container-lowest: #150136;
    --hud-primary: #ffffff;
    --hud-primary-container: #b7f700;
    --hud-secondary-container: #fdd400;
    --hud-on-surface: #ebddff;
    --hud-on-surface-variant: #c2caad;
}

/* Bubbly panel base */
.hud-bubbly-panel {
    background-color: rgba(50, 32, 83, 0.85);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(235, 221, 255, 0.1);
    box-shadow: 0 4px 20px rgba(26, 15, 46, 0.4);
    pointer-events: auto;
}

/* Top HUD Row */
.hud-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 24px;
}

/* Stats Panel - Rounded pill shape */
.hud-stats-panel {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 8px 16px;
    border-radius: 999px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
}

.hud-stats-panel.hud-bubbly-panel {
    background-color: rgba(50, 32, 83, 0.85);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-label {
    color: var(--hud-on-surface-variant);
    font-weight: 700;
}

.stat-value {
    color: var(--hud-primary-container);
    font-family: 'JetBrains Mono', monospace;
}

/* Score Pod */
.hud-score-pod {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px;
    border-radius: 16px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
}

.hud-score-pod.hud-bubbly-panel {
    background-color: rgba(50, 32, 83, 0.85);
}

.score-icon-wrapper {
    background-color: var(--hud-surface-container-lowest);
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.score-icon {
    color: var(--hud-primary-container);
    font-size: 24px;
    font-variation-settings: 'FILL' 1;
}

.score-value {
    font-size: 32px;
    line-height: 40px;
    color: var(--hud-primary);
    font-family: 'Quicksand', sans-serif;
}

/* Leaderboard Pod */
.hud-leaderboard-pod {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px;
    border-radius: 14px;
    width: 220px;
    font-family: 'Quicksand', sans-serif;
}

.hud-leaderboard-pod.hud-bubbly-panel {
    background-color: rgba(39, 20, 72, 0.55);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(235, 221, 255, 0.08);
    box-shadow: 0 2px 12px rgba(26, 15, 46, 0.3);
}

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

.leaderboard-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 700;
    line-height: 18px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--hud-primary);
}

.leaderboard-icon {
    color: var(--hud-secondary-container);
    font-size: 16px;
    font-variation-settings: 'FILL' 1;
}

.leaderboard-info {
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    color: var(--hud-on-surface-variant);
    margin-bottom: 4px;
}

#hud-players {
    color: var(--hud-primary-container);
}

/* Leaderboard entries */
.leaderboard-entries {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 15px;
}

.leaderboard-entry.rank-1 {
    background-color: rgba(21, 1, 54, 0.5);
}

.leaderboard-entry.rank-you {
    border-top: 1px solid var(--hud-surface-container-highest);
    padding-top: 8px;
    margin-top: 4px;
}

.rank-number, .rank-crown {
    min-width: 14px;
    text-align: center;
    color: var(--hud-on-surface-variant);
    font-weight: 700;
    line-height: 15px;
}

.rank-crown {
    font-size: 13px;
}

.player-name {
    flex: 1;
    margin-left: 6px;
    color: var(--hud-on-surface);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-entry.rank-1 .player-name {
    color: var(--hud-primary);
    font-weight: 700;
}

.leaderboard-entry.rank-you .player-name {
    color: var(--hud-primary);
    font-weight: 700;
}

.player-score {
    color: var(--hud-on-surface-variant);
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.leaderboard-entry.rank-1 .player-score,
.leaderboard-entry.rank-you .player-score {
    color: var(--hud-primary-container);
}

/* Boş durum: sıralama paketi henüz gelmedi ya da haritada sıralanacak oyuncu
   yok. Sahte oyuncu satırlarının yerini alan tek, nötr mesaj satırı. */
.leaderboard-empty {
    padding: 4px;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    color: var(--hud-on-surface-variant);
    opacity: 0.7;
}

/* Leaderboard expand/collapse toggle */
.leaderboard-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 20px;
    margin-top: 2px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0 0 8px 8px;
    color: var(--hud-on-surface-variant);
    cursor: pointer;
    pointer-events: auto;
    transition: color 0.15s ease, background 0.15s ease;
}

.leaderboard-toggle:hover {
    color: var(--hud-primary-container);
    background: rgba(21, 1, 54, 0.4);
}

.leaderboard-toggle-icon {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s ease;
}

/* Minimap: Phaser tarafında çizilir (Game.js drawMinimap) — DOM elemanı yok. */

/* ═══════════════════════════════════════════════
   RESPONSIVE — In-game HUD on mobile
   (portrait phones OR short landscape viewports)
   ═══════════════════════════════════════════════ */
@media (max-width: 768px), (max-height: 500px) {
    .game-hud {
        padding: 10px 12px;
    }

    .hud-top-row {
        gap: 10px;
    }

    /* Stats pill: smaller type, tighter spacing */
    .hud-stats-panel {
        gap: 12px;
        padding: 5px 12px;
        font-size: 10px;
        line-height: 14px;
    }

    /* Score pod: was blocking the view — roughly half size */
    .hud-score-pod {
        gap: 8px;
        padding: 5px 10px 5px 5px;
        border-radius: 12px;
    }

    .score-icon-wrapper {
        width: 24px;
        height: 24px;
    }

    .score-icon {
        font-size: 16px;
    }

    .score-value {
        font-size: 20px;
        line-height: 24px;
    }

    /* Leaderboard: compact for mobile field-of-view */
    .hud-leaderboard-pod {
        width: 148px;
        padding: 7px 8px;
        gap: 3px;
        border-radius: 10px;
    }

    .leaderboard-header {
        margin-bottom: 1px;
    }

    .leaderboard-title {
        font-size: 10px;
        line-height: 14px;
        letter-spacing: 1px;
    }

    .leaderboard-icon {
        font-size: 12px;
    }

    .leaderboard-info {
        font-size: 9px;
        line-height: 12px;
        margin-bottom: 1px;
    }

    .leaderboard-entries {
        gap: 2px;
    }

    .leaderboard-entry {
        padding: 2px 4px;
        font-size: 9px;
        line-height: 13px;
    }

    .leaderboard-entry.rank-you {
        padding-top: 5px;
        margin-top: 2px;
    }

    .leaderboard-toggle {
        height: 16px;
        margin-top: 1px;
    }

    .leaderboard-toggle-icon {
        font-size: 14px;
    }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Game Over & Connecting overlays
   Overlays must NEVER clip: switch from rigid centering to
   scrollable + margin:auto (keeps centered when it fits,
   scrolls when it doesn't), and scale inner elements down.
   ═══════════════════════════════════════════════ */
@media (max-width: 768px), (max-height: 640px) {
    /* ── Game Over ── */
    .gameover-overlay {
        padding: 16px;
        align-items: flex-start;   /* centering handled by margin:auto below */
        overflow-y: auto;
    }

    .gameover-cluster {
        margin: auto;              /* centers when short, scrolls when tall */
        max-width: 420px;
    }

    .gameover-mascot-wrap {
        margin-bottom: -40px;
    }

    .gameover-mascot-ring {
        width: 96px;
        height: 96px;
        padding: 5px;
        box-shadow: 0 5px 0 0 #374e00;
    }

    .gameover-star-spin .material-symbols-outlined { font-size: 24px; }
    .gameover-star-pulse .material-symbols-outlined { font-size: 20px; }

    .gameover-panel {
        padding: 52px 20px 24px;
        border-width: 4px;
        border-radius: 1.5rem;
    }

    .gameover-title {
        font-size: 30px;
        line-height: 36px;
        margin-bottom: 16px;
    }

    .gameover-stats-grid {
        gap: 10px;
        margin-bottom: 20px;
    }

    .gameover-stat {
        padding: 10px;
        border-radius: 1.25rem;
    }

    .gameover-stat-score {
        padding: 14px;
    }

    .gameover-score-value {
        font-size: 40px;
    }

    .gameover-rank-value,
    .gameover-food-value {
        font-size: 20px;
        line-height: 26px;
    }

    .gameover-actions {
        gap: 10px;
    }

    .gameover-btn-primary {
        font-size: 20px;
        line-height: 26px;
        padding: 12px 20px;
        border-radius: 1.25rem;
    }

    .gameover-btn-secondary {
        font-size: 15px;
        line-height: 20px;
        padding: 10px 20px;
        border-radius: 1.25rem;
    }

    .gameover-links {
        margin-top: 16px;
        gap: 16px;
    }

    /* ── Connecting / "Waiting for Server..." ── */
    .connecting-overlay {
        padding: 16px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .connecting-card {
        margin: auto;
        max-width: 360px;
        gap: 18px;
        padding: 24px 20px;
    }

    .egg-loader-container {
        width: 64px;
        height: 64px;
    }

    .egg-loader {
        width: 48px;
        height: 48px;
    }

    /* Re-align face features to the smaller 48px egg */
    .egg-eye { width: 6px; height: 6px; }
    .egg-eye-left  { top: 15px; left: 12px; }
    .egg-eye-right { top: 15px; right: 12px; }
    .egg-blush-left  { top: 21px; left: 4px; }
    .egg-blush-right { top: 21px; right: 4px; }

    .connecting-status {
        gap: 8px;
    }

    .connecting-title {
        font-size: 1.15rem;
    }

    .connecting-info {
        font-size: 0.65rem;
        letter-spacing: 1px;
    }

    .connecting-progress-bar {
        height: 12px;
    }

    .connecting-cancel-btn {
        padding: 10px 20px;
        font-size: 0.8rem;
    }
}

/* Landscape phones with taller-than-768px width still hit the height limit
   via (max-height: 640px) above — no separate landscape block needed. */

