:root {
    --bg-dark: #0e1a12;
    --panel-bg: rgba(20, 28, 20, 0.72);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-light: #eef5ea;
    --text-muted: #a9bba2;
    --accent: #6fbf4f;
    --accent-dark: #4c8f34;
    --wood: #c89b5c;
    --stone: #9aa3ab;
    --coin: #e8c34a;
    --danger: #e05c5c;
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    color: var(--text-light);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    overflow: hidden;
    touch-action: none;
}

#game-root {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#scene-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

#fx-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.floating-number {
    position: absolute;
    font-weight: 700;
    font-size: 18px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    animation: float-up 900ms ease-out forwards;
    pointer-events: none;
    white-space: nowrap;
}
.floating-number.wood { color: var(--wood); }
.floating-number.stone { color: var(--stone); }

@keyframes float-up {
    0%   { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -60px); opacity: 0; }
}

.panel {
    position: absolute;
    display: flex;
    gap: 8px;
    z-index: 10;
}

#hud-top-left {
    top: 16px;
    left: 16px;
    flex-wrap: wrap;
}

.resource-pill {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    transition: transform 150ms ease;
}
.resource-pill.pulse { transform: scale(1.12); }
.resource-pill .icon { font-size: 16px; }
.resource-pill .cap { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.resource-pill.coins { color: var(--coin); }

#hud-top-right {
    top: 16px;
    right: 16px;
}

#zone-menu {
    top: 70px;
    left: 16px;
    flex-direction: column;
}

.zone-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    border-radius: 10px;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}
.zone-btn.active { border-color: var(--accent); color: var(--accent); }
.zone-btn.locked { opacity: 0.5; cursor: not-allowed; display: flex; flex-direction: column; }
.zone-btn.locked small { color: var(--text-muted); font-size: 10px; }

#sell-bar {
    bottom: 16px;
    left: 16px;
}

.btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(6px);
    transition: background 150ms ease, transform 100ms ease;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent-dark); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); }

#toast-layer {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.toast {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    animation: toast-in 200ms ease-out, toast-out 400ms ease-in 2600ms forwards;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
    background: #16231a;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    width: min(420px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    margin-bottom: 10px;
}
.shop-item-info h3 { margin: 0 0 4px; font-size: 15px; }
.shop-item-info p { margin: 0 0 4px; font-size: 12px; color: var(--text-muted); }
.shop-item-info .level { font-size: 11px; color: var(--accent); }
.shop-item-buy { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 90px; }
.shop-item-buy .cost { font-size: 12px; color: var(--coin); }

.account-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.account-form.hidden { display: none; }
.account-form input {
    background: #0e1a12;
    border: 1px solid var(--panel-border);
    color: var(--text-light);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.account-error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; }
.account-switch { font-size: 13px; color: var(--text-muted); margin: 0; }
.account-switch a { color: var(--accent); text-decoration: none; }

#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 400ms ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; }
.loading-box h1 { color: var(--accent); font-size: 32px; margin-bottom: 20px; letter-spacing: 1px; }
.spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
    #hud-top-left { top: 10px; left: 10px; }
    .resource-pill { padding: 5px 10px; font-size: 13px; }
    #hud-top-right { top: 10px; right: 10px; }
    #zone-menu { top: auto; bottom: 70px; left: 10px; flex-direction: row; flex-wrap: wrap; max-width: 60vw; }
    .zone-btn { font-size: 11px; padding: 6px 8px; }
    #sell-bar { bottom: 10px; left: 10px; }
    .btn { padding: 8px 12px; font-size: 13px; }
}
