:root {
    /* Colors */
    --bg-dark: #0a0b10;
    --bg-panel: rgba(20, 22, 30, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.05);

    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.3);
    --danger: #ef4444;
    --success: #10b981;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #4b5563;

    /* Spacing */
    --header-height: 60px;
    --nav-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Effects */
    --shadow-main: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --blur-val: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    height: 100%;
    /* Fallback */
    height: 100dvh;
    /* Mobile fix */
    overflow: hidden;
    user-select: none;
    overscroll-behavior: none;
    /* Prevent pull-to-refresh effects */
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.05em;
}

/* Layout */
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Backgrounds */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at center, #1a1c29 0%, #000000 100%);
}

.particles {
    width: 100%;
    height: 100%;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.8));
    pointer-events: none;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: var(--glass-border);
    box-shadow: var(--shadow-main);
}

/* Header */
.top-bar {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* ... skipped unchanged ... */

/* Bottom Nav */
.bottom-nav {
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: var(--glass-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    /* Remove margin for fully fixed bottom */
    padding-bottom: env(safe-area-inset-bottom);
    /* iOS Safe Area */
    z-index: 100;
    flex-shrink: 0;
    /* Prevent shrinking */
    background: rgba(20, 22, 30, 0.9);
    /* Darker background for nav */
    backdrop-filter: blur(10px);
}

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

.rank-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #333, #111);
    border: 1px solid #444;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 40px;
}

.rank-label {
    font-size: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.rank-value {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}

.player-name {
    font-weight: 600;
    font-size: 16px;
}

.resources {
    display: flex;
    gap: 20px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Cinzel', serif;
    font-size: 14px;
}

.text-gold {
    color: var(--gold);
    text-shadow: 0 0 5px var(--gold-glow);
}

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

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.hidden {
    display: none !important;
}

/* Bottom Nav */
.bottom-nav {
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: var(--glass-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
    /* iOS Safe Area */
    z-index: 100;
    flex-shrink: 0;
    background: rgba(20, 22, 30, 0.95);
    backdrop-filter: blur(10px);
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    cursor: pointer;
    width: 60px;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 20px;
    transition: all 0.2s ease;
}

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

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

.nav-item.active i {
    transform: translateY(-3px);
    text-shadow: 0 0 10px var(--primary-glow);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Loading Screen */
.loading-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loader-content {
    text-align: center;
}

.game-title {
    font-size: 3rem;
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 30px;
    letter-spacing: 0.1em;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.loading-bar-container {
    width: 250px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 0 auto 10px;
    overflow: hidden;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

/* Utility Animations */
@keyframes glow {
    0% {
        box-shadow: 0 0 5px var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 20px var(--primary-glow);
    }

    100% {
        box-shadow: 0 0 5px var(--primary-glow);
    }
}