/* ============================================
   THE CITY - Game Styles
   Dark 90s Fantasy Strategy aesthetic
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&family=Press+Start+2P&display=swap');

:root {
    --bg-dark: #0a0a0f;
    --bg-medium: #121218;
    --bg-light: #1a1a24;
    --accent: #8b2020;
    --gold: #c9a84c;
    --green: #4a7a3a;
    --blood: #6b1a1a;
    --text: #c8c0a8;
    --text-dim: #6a6858;
    --wood: #5a3a20;
    --iron: #6a6a72;
    --copper: #8a5a2a;
    --cotton: #a8a898;
    --stone: #4a4a4a;
    --panel-bg: rgba(10, 10, 16, 0.95);
    --border: rgba(120, 100, 60, 0.35);
    --border-bright: rgba(180, 150, 60, 0.5);
}

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

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: 'MedievalSharp', serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ---- SCREENS ---- */
.screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}
.screen.active {
    display: flex;
}

/* ---- USERNAME SCREEN ---- */
#username-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1018 0%, #0a0808 70%, #050404 100%);
}
.username-box {
    text-align: center;
    padding: 60px;
    border: 2px solid var(--border-bright);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(20,15,10,0.98) 0%, rgba(10,8,6,0.98) 100%);
    box-shadow: 0 0 60px rgba(100, 50, 10, 0.15), inset 0 0 30px rgba(0,0,0,0.5);
}
.username-box h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: 36px;
    color: var(--gold);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 #000, 0 0 20px rgba(200,160,60,0.3);
    letter-spacing: 4px;
}
.subtitle {
    font-size: 22px;
    color: var(--text-dim);
    margin-bottom: 40px;
    font-style: italic;
}
#username-input {
    font-family: 'MedievalSharp', serif;
    font-size: 26px;
    padding: 12px 24px;
    width: 300px;
    background: #0a0808;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--gold);
    outline: none;
    text-align: center;
}
#username-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(200, 160, 60, 0.2);
}
#username-submit {
    display: block;
    margin: 24px auto 0;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 14px 48px;
    background: linear-gradient(180deg, #3a2a18 0%, #1a1208 100%);
    color: var(--gold);
    border: 1px solid var(--border-bright);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 1px 1px 0 #000;
    letter-spacing: 2px;
}
#username-submit:hover {
    background: linear-gradient(180deg, #4a3a22 0%, #2a1a10 100%);
    box-shadow: 0 0 15px rgba(200, 160, 60, 0.25);
}

/* ---- LOBBY SCREEN ---- */
#lobby-screen {
    flex-direction: column;
    background: linear-gradient(180deg, #0a0a0f 0%, #0e0c0a 100%);
}
#lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 32px;
    background: linear-gradient(180deg, #1a1510 0%, #0e0c08 100%);
    border-bottom: 1px solid var(--border);
    font-size: 20px;
}
#player-name-display {
    color: var(--gold);
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    text-shadow: 1px 1px 0 #000;
}
#runs-display {
    color: var(--accent);
    font-size: 22px;
    font-weight: bold;
}
#lobby-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 16px;
    padding: 16px;
    flex: 1;
    overflow: auto;
}

/* City Preview */
#city-preview {
    grid-column: 1;
    grid-row: 1;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
#city-preview:hover {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(200, 160, 60, 0.12);
}
#city-preview h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: var(--gold);
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 #000;
}
#city-level-badge {
    color: var(--accent);
    font-size: 9px;
}
#city-mini-canvas {
    width: 100%;
    height: 150px;
    background: #060606;
    border-radius: 2px;
    border: 1px solid rgba(60,50,30,0.3);
}
.hint {
    color: var(--text-dim);
    font-size: 16px;
    margin-top: 6px;
    font-style: italic;
}

/* Storage Panel */
#storage-panel {
    grid-column: 1;
    grid-row: 2;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 14px;
}
#world-contributions-panel {
    grid-column: 1;
    grid-row: 3;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 14px;
}
.world-hint {
    font-size: 15px;
    color: var(--text-dim);
    margin-bottom: 8px;
    font-style: italic;
}
#world-contributions .storage-item {
    font-size: 17px;
    padding: 6px 8px;
}

#storage-panel h3,
#instances-panel h3,
#world-contributions-panel h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--gold);
    margin-bottom: 14px;
    text-shadow: 1px 1px 0 #000;
}
.storage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: rgba(20, 18, 12, 0.6);
    border-radius: 2px;
    border-left: 2px solid var(--border);
    font-size: 20px;
}
.storage-item .res-icon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}
.res-wood { background: var(--wood); }
.res-iron { background: var(--iron); }
.res-copper { background: var(--copper); }
.res-cotton { background: var(--cotton); }
.res-stone { background: var(--stone); }

/* Instances Panel */
#instances-panel {
    grid-column: 2;
    grid-row: 1 / 4;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 20px;
}
#instance-cards {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.instance-card {
    width: 260px;
    padding: 22px;
    background: linear-gradient(180deg, rgba(25,20,14,0.9) 0%, rgba(12,10,6,0.9) 100%);
    border: 1px solid var(--border);
    border-radius: 2px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
}
.instance-card:hover {
    border-color: var(--gold);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(100, 50, 10, 0.2);
}
.instance-card .res-preview {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border: 1px solid var(--border);
}
.instance-card h4 {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--gold);
    margin-bottom: 6px;
    text-shadow: 1px 1px 0 #000;
}
.instance-card p {
    color: var(--text-dim);
    font-size: 18px;
}
#reroll-btn {
    display: block;
    margin: 0 auto;
    font-family: 'MedievalSharp', serif;
    font-size: 20px;
    padding: 10px 28px;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
#reroll-btn:hover {
    background: var(--accent);
    color: var(--text);
}

/* ---- RUNNER SCREEN ---- */
#runner-screen {
    flex-direction: column;
    background: #000;
}
#runner-hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    padding: 14px 28px;
    z-index: 10;
    pointer-events: none;
}
#timer-display {
    font-family: 'Press Start 2P', cursive;
    font-size: 24px;
    color: var(--accent);
    text-shadow: 2px 2px 0 #000;
}
#resource-count {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: var(--gold);
    text-shadow: 2px 2px 0 #000;
}
#game-canvas {
    width: 100%;
    height: 100%;
}

/* ---- RESULTS SCREEN ---- */
#results-screen {
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.9);
}
.results-box {
    text-align: center;
    padding: 50px 70px;
    background: linear-gradient(180deg, rgba(20,16,10,0.98) 0%, rgba(8,6,4,0.98) 100%);
    border: 1px solid var(--border-bright);
    border-radius: 2px;
    box-shadow: 0 0 40px rgba(100, 50, 10, 0.15);
}
.results-box h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 18px;
    color: var(--gold);
    margin-bottom: 22px;
    text-shadow: 2px 2px 0 #000;
}
#results-resource {
    font-size: 28px;
    margin-bottom: 6px;
    color: var(--text);
}
#results-amount {
    font-family: 'Press Start 2P', cursive;
    font-size: 32px;
    color: var(--gold);
    margin-bottom: 28px;
    text-shadow: 1px 1px 0 #000;
}
.results-box button {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 14px 32px;
    background: linear-gradient(180deg, #3a2a18 0%, #1a1208 100%);
    color: var(--gold);
    border: 1px solid var(--border-bright);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
.results-box button:hover {
    background: linear-gradient(180deg, #4a3a22 0%, #2a1a10 100%);
    box-shadow: 0 0 12px rgba(200, 160, 60, 0.2);
}

/* ---- CITY SCREEN ---- */
#city-screen {
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
}
#city-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px;
    background: linear-gradient(180deg, #1a1510 0%, #0e0c08 100%);
    border-bottom: 1px solid var(--border);
}
.back-btn {
    font-family: 'MedievalSharp', serif;
    font-size: 22px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
.back-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}
#city-header h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    color: var(--gold);
    text-shadow: 1px 1px 0 #000;
}
#city-level-display {
    color: var(--accent);
}
#city-canvas {
    flex: 1;
    width: 100%;
    background: #060606;
    cursor: grab;
    touch-action: none;
}
#city-canvas:active {
    cursor: grabbing;
}
#city-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    border-top: 1px solid var(--border);
    transition: height 0.3s ease;
    z-index: 20;
}
#city-ui.expanded {
    height: 60vh;
}
#city-ui-toggle {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 24px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: var(--gold);
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    line-height: 20px;
}
#city-ui-toggle:hover {
    border-color: var(--gold);
    color: #fff;
}
#city-ui.expanded #city-ui-toggle {
    transform: translateX(-50%) rotate(180deg);
}
#city-ui-content {
    display: flex;
    gap: 0;
    height: 100%;
}
#buildings-panel, #city-storage-panel {
    flex: 1;
    padding: 14px;
    background: var(--panel-bg);
    overflow-y: auto;
}
#buildings-panel {
    border-right: 1px solid rgba(60,50,30,0.2);
}
#buildings-panel h3, #city-storage-panel h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    color: var(--gold);
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 #000;
}
.building-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: rgba(20, 18, 12, 0.6);
    border-radius: 2px;
    border-left: 2px solid var(--border);
    font-size: 18px;
    flex-direction: column;
    align-items: stretch;
}
.building-info {
    width: 100%;
}
.building-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    color: var(--gold);
    margin-bottom: 8px;
    text-shadow: 1px 1px 0 #000;
}
.building-item .build-btn {
    font-family: 'MedievalSharp', serif;
    font-size: 16px;
    padding: 4px 14px;
    background: linear-gradient(180deg, #3a2a18, #1a1208);
    color: var(--gold);
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
.building-item .build-btn:hover {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(200,160,60,0.15);
}
.building-item .build-btn:disabled {
    background: #111;
    color: #444;
    border-color: #222;
    cursor: not-allowed;
}
.building-item .cost-list {
    font-size: 15px;
    color: var(--text-dim);
}
.building-item.built {
    opacity: 0.5;
    border-left-color: var(--green);
}

/* Mission / Communal Progress Styles */
.mission-res {
    margin-top: 8px;
    background: rgba(0,0,0,0.2);
    padding: 6px;
    border-radius: 2px;
}
.mission-res-header {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text);
}
.progress-bar {
    width: 100%;
    height: 6px;
    background: #000;
    border: 1px solid rgba(120, 100, 60, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-fill {
    height: 100%;
    transition: width 0.3s ease-out;
}
.contrib-btns {
    display: flex;
    gap: 4px;
}
.contrib-btn {
    flex: 1;
    font-family: 'MedievalSharp', serif;
    font-size: 13px;
    padding: 2px 0;
    background: rgba(60, 50, 40, 0.4);
    border: 1px solid rgba(120, 100, 60, 0.3);
    color: var(--gold);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
.contrib-btn:hover:not(:disabled) {
    background: rgba(100, 80, 60, 0.6);
    border-color: var(--gold);
}
.contrib-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Activity Feed */
#world-activity-panel {
    margin-top: 16px;
}
#world-activity-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}
.activity-item {
    font-family: 'MedievalSharp', serif;
    font-size: 15px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: rgba(10, 8, 6, 0.4);
    border-radius: 2px;
    border-left: 2px solid var(--accent);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
}
.activity-user {
    color: var(--gold);
    font-weight: bold;
    font-size: 14px;
}
.activity-text {
    color: var(--text-dim);
    margin: 2px 0;
}
.activity-time {
    font-size: 12px;
    color: rgba(200, 192, 168, 0.4);
    text-align: right;
    font-style: italic;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(201, 168, 76, 0); }
    100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0); }
}
.new-contribution {
    animation: pulse 1s ease-out;
}

/* Leaderboard */
#world-leaderboard-panel {
    margin-top: 16px;
}
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'MedievalSharp', serif;
}
.leaderboard-table tr {
    border-bottom: 1px solid rgba(120, 100, 60, 0.1);
}
.leaderboard-table td {
    padding: 8px 4px;
    font-size: 16px;
}
.rank-col {
    color: var(--text-dim);
    width: 40px;
    font-weight: bold;
}
.name-col {
    color: var(--text);
}
.score-col {
    text-align: right;
    color: var(--gold);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
}

/* Rank Highlights */
.rank-1 .rank-col { color: #ffd700; text-shadow: 0 0 5px rgba(255, 215, 0, 0.4); }
.rank-1 .name-col { color: #ffd700; font-weight: bold; }
.rank-2 .rank-col { color: #c0c0c0; }
.rank-2 .name-col { color: #c0c0c0; }
.rank-3 .rank-col { color: #cd7f32; }
.rank-3 .name-col { color: #cd7f32; }

/* ---- ANIMATIONS ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.screen.active {
    animation: fadeIn 0.4s ease-out;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: rgba(100,80,40,0.3); border-radius: 2px; }
