/* ===========================
   Fonts (Local)
   =========================== */
@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter-Variable.woff2') format('woff2 supports variations'),
         url('fonts/Inter-Variable.woff2') format('woff2-variations');
    font-weight: 100 900;
    font-display: swap;
    font-style: oblique 0deg 10deg;
}

/* ===========================
   Minimal Design - CSS
   =========================== */
:root {
    --bg-color: #f5f0e8;
    --text-color: #333;
    --text-muted: #666;
    --accent-color: #22c55e;
    --accent-dark: #16a34a;
    --danger-color: #ef4444;
    --white: #fff;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: var(--font-family);
    background: var(--bg-color);
    color: var(--text-color);
}

/* ===========================
   Game Container
   =========================== */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ===========================
   Score Display
   =========================== */
#score-display {
    position: absolute;
    top: calc(var(--safe-top) + 16px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 32px;
    z-index: 10;
}

.score-item {
    text-align: center;
}

.score-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.score-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
}

.score-value.best {
    color: var(--danger-color);
}

/* ===========================
   Balance Bar
   =========================== */
#balance-bar {
    position: absolute;
    bottom: calc(var(--safe-bottom) + 40px);
    left: 50%;
    transform: translateX(-50%);
    width: min(300px, 70%);
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
    z-index: 10;
}

#balance-fill {
    height: 100%;
    width: 100%;
    background: var(--accent-color);
    border-radius: 4px;
    transform-origin: center;
    transition: transform 0.1s ease-out, background-color 0.2s;
}

#balance-fill.warning {
    background: #f59e0b;
}

#balance-fill.danger {
    background: var(--danger-color);
}

.balance-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

/* ===========================
   Overlays
   =========================== */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-color);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    max-width: 300px;
}

/* ===========================
   Start Screen
   =========================== */
.egg-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-color);
}

h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-color);
}

.subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
}

/* Desktop Warning */
.desktop-warning {
    margin: 16px 0;
    padding: 12px 16px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.desktop-warning span {
    font-size: 32px;
    flex-shrink: 0;
}

/* ===========================
   Buttons
   =========================== */
.btn-primary {
    display: inline-block;
    padding: 14px 48px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    background: var(--accent-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:active {
    transform: scale(0.97);
    background: var(--accent-dark);
}

/* ===========================
   Calibration Screen
   =========================== */
.countdown-display {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

#countdown {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-color);
}

.calibration-text {
    font-size: 16px;
    color: var(--text-muted);
}

/* ===========================
   Game Over Screen
   =========================== */
.broken-egg {
    font-size: 64px;
    margin-bottom: 8px;
}

.final-score {
    margin-bottom: 8px;
}

.result-label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-color);
}

.best-score {
    margin-bottom: 24px;
    padding: 8px 16px;
    background: #fef3c7;
    border-radius: 8px;
    display: inline-block;
}

.best-score.hidden {
    display: none;
}

/* ===========================
   Permission Screen
   =========================== */
.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ===========================
   Utility
   =========================== */
.hidden {
    display: none !important;
}
