/* ═══════════════════════════════════════════════════════════
   REIGNFALL - Medieval Kingdom Builder
   Dark pixel-art theme: Minecraft meets Travian
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────── */
:root {
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --accent: #e94560;
    --gold: #ffd700;
    --wood: #8b6914;
    --stone: #808080;
    --food: #228b22;
    --text: #e0e0e0;
    --text-dim: #888;
    --success: #4caf50;
    --danger: #f44336;
    --border: #333;
    --pixel-font: 'Press Start 2P', monospace;

    /* Building colors */
    --bld-town-hall: #8B4513;
    --bld-farm: #228B22;
    --bld-lumber-mill: #654321;
    --bld-quarry: #696969;
    --bld-gold-mine: #DAA520;
    --bld-barracks: #8B0000;
    --bld-wall: #708090;
    --bld-warehouse: #CD853F;
}

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

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, monospace;
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: var(--pixel-font);
    color: var(--gold);
    letter-spacing: 1px;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.1rem; margin-bottom: 16px; }
h3 { font-size: 0.75rem; }

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* ── Screen System ────────────────────────────────────────── */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}
.screen.active {
    display: block;
}

.screen-inner {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.hidden {
    display: none !important;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

@keyframes constructing {
    0%   { background-position: 0 0; }
    100% { background-position: 40px 40px; }
}

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

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    padding: 10px 20px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    color: var(--text);
    background: var(--bg-light);
    image-rendering: pixelated;
}
.btn:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(1px);
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-gold {
    background: var(--gold);
    color: #1a1a2e;
    font-weight: bold;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-block {
    display: block;
    width: 100%;
}
.btn-small {
    font-size: 0.5rem;
    padding: 6px 12px;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
}
.btn-icon:hover {
    color: var(--gold);
}
.btn-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}
.btn-close:hover {
    color: var(--accent);
}

/* ── Resource Bar ─────────────────────────────────────────── */
#resource-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-medium);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 16px;
    flex-wrap: wrap;
}

.resource, .resource-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--pixel-font);
    font-size: 1rem;
}

.res-icon, .resource-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 0;
    color: #fff;
}
.gold-icon  { background: var(--gold); color: #1a1a2e; }
.wood-icon  { background: var(--wood); }
.stone-icon { background: var(--stone); color: #1a1a2e; }
.food-icon  { background: var(--food); }
.gem-icon   {
    background: none;
    font-size: 1rem;
    width: auto;
    animation: pulse 2s infinite;
}

.res-amount, .resource-val {
    color: var(--text);
    min-width: 45px;
    font-size: 1rem;
}
.res-rate, .resource-rate {
    color: var(--success);
    font-size: 0.65rem;
}

.resource-gems, .resource-item.gems {
    border-left: 1px solid var(--border);
    padding-left: 12px;
    margin-left: 4px;
}

/* ── Nav Bar ──────────────────────────────────────────────── */
#nav-bar {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--bg-dark);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow-x: auto;
}

.nav-btn {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    padding: 12px 16px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    position: relative;
}
.nav-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}
.nav-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.nav-logout {
    color: var(--text-dim) !important;
    font-size: 0.55rem !important;
}
.nav-logout:hover {
    color: var(--danger) !important;
}

.msg-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 0.4rem;
    padding: 2px 5px;
    border-radius: 0;
    min-width: 14px;
    text-align: center;
}

/* ── LOGIN SCREEN ─────────────────────────────────────────── */
.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.game-title {
    text-align: center;
    margin-bottom: 40px;
}
.game-title h1 {
    font-family: var(--pixel-font);
    font-size: 3.5rem;
    color: var(--gold);
    text-shadow:
        3px 3px 0 #b8860b,
        6px 6px 0 rgba(0, 0, 0, 0.4);
    letter-spacing: 8px;
    margin-bottom: 12px;
}
.tagline {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--accent);
    letter-spacing: 4px;
}
.free-badge {
    font-family: var(--pixel-font);
    font-size: 1.1rem;
    color: #00ff00;
    margin-top: 12px;
    padding: 10px 30px;
    border: 3px solid #00ff00;
    display: inline-block;
    letter-spacing: 4px;
    animation: freeGlow 1.5s ease infinite;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}
@keyframes freeGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(0, 255, 0, 0.3); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 0, 0.6); border-color: #00ff88; color: #00ff88; }
}

.auth-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    animation: fadeIn 0.3s ease;
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 0.9rem;
}
.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-dim);
}
.auth-error {
    text-align: center;
    margin-top: 12px;
    color: var(--danger);
    font-family: var(--pixel-font);
    font-size: 0.5rem;
}

/* ── Inputs ───────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    color: var(--text);
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    padding: 10px 12px;
    width: 100%;
    outline: none;
    border-radius: 0;
    transition: border-color 0.2s;
}
input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}
input::placeholder {
    color: var(--text-dim);
}

.login-footer {
    margin-top: 40px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.75rem;
}

/* ── VILLAGE SCREEN ───────────────────────────────────────── */
#screen-village {
    padding-top: 155px;
}

.village-header {
    text-align: center;
    padding: 16px;
}
.village-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}
.village-name {
    font-size: 1rem;
    color: var(--gold);
    outline: none;
    border-bottom: 1px dashed transparent;
    padding: 2px 8px;
    cursor: text;
}
.village-name:focus {
    border-bottom-color: var(--accent);
}

/* power-badge styles are in the unified section below */

/* ── Village Grid (4x4) ──────────────────────────────────── */
.village-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-width: 700px;
    margin: 0 auto;
    padding: 10px;
    background: #1a2e10;
    border: 3px solid #2a4a1a;
}

.village-slot {
    aspect-ratio: 1 / 1;
    border: 3px solid var(--border);
    background: #2d5a1e;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: all 0.15s;
    overflow: hidden;
    min-height: 120px;
}
.village-slot:hover {
    border-color: var(--gold);
    filter: brightness(1.15);
}

.village-slot.empty {
    background: #1e3a12;
    border-style: dashed;
    border-color: #2a4a1a;
}
.village-slot.empty:hover {
    background: #2d5a1e;
    border-color: var(--success);
}

.slot-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
}

.empty-slot .slot-plus {
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.2);
    font-weight: bold;
    line-height: 1;
}
.village-slot.empty:hover .slot-plus {
    color: var(--success);
}

.empty-slot .slot-label {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ── Building Blocks (inside grid slots) ──────────────────── */
.building-slot {
    image-rendering: pixelated;
    box-shadow:
        inset -4px -4px 0 rgba(0, 0, 0, 0.3),
        inset 4px 4px 0 rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(0, 0, 0, 0.3);
}

.building-emoji {
    font-size: 2.2rem;
    line-height: 1;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
}

.building-name {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
    text-align: center;
    line-height: 1.3;
    padding: 2px 4px;
    margin-top: 4px;
}

.building-level {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
    margin-top: 2px;
}

/* Construction overlay */
.construction-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2;
}
.construction-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 215, 0, 0.12) 10px,
        rgba(255, 215, 0, 0.12) 20px
    );
    background-size: 50px 50px;
    animation: constructing 1s linear infinite;
    pointer-events: none;
}

.construction-icon {
    font-size: 1.8rem;
    z-index: 3;
}

.construction-timer {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--gold);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
    z-index: 3;
    margin-top: 4px;
}

/* Rush button on constructing slot */
.rush-btn-small {
    z-index: 3;
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    padding: 4px 8px;
    background: var(--gold);
    color: #1a1a2e;
    border: 2px solid #b8860b;
    cursor: pointer;
    line-height: 1;
    margin-top: 6px;
}
.rush-btn-small:hover {
    filter: brightness(1.2);
}

/* ── Building Detail Panel ────────────────────────────────── */
.building-detail-panel {
    max-width: 500px;
    margin: 16px auto 0;
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.detail-block {
    width: 48px;
    height: 48px;
    box-shadow:
        inset -3px -3px 0 rgba(0, 0, 0, 0.3),
        inset 3px 3px 0 rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.detail-level {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.detail-body {
    margin-top: 8px;
}
.detail-production {
    font-size: 0.85rem;
    color: var(--success);
    margin-bottom: 12px;
}
.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.detail-cost {
    display: block;
    font-size: 0.45rem;
    opacity: 0.85;
    margin-top: 2px;
}
.detail-time {
    display: block;
    font-size: 0.45rem;
    color: var(--gold);
}

/* ── Detail Modal (full screen) ───────────────────────────── */
#screen-building-detail {
    padding-top: 155px;
}
.detail-modal {
    max-width: 450px;
    margin: 0 auto;
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 24px;
}
.detail-stats {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.8;
}

/* ── BUILD MENU SCREEN ────────────────────────────────────── */
#screen-build-menu {
    padding-top: 155px;
}

.build-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.build-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.build-card:hover {
    border-color: var(--gold);
    transform: scale(1.03);
}
.build-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.build-preview {
    width: 60px;
    height: 60px;
    margin: 0 auto 10px;
    box-shadow:
        inset -3px -3px 0 rgba(0, 0, 0, 0.3),
        inset 3px 3px 0 rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(0, 0, 0, 0.3);
}
.build-preview.town_hall   { background: var(--bld-town-hall); }
.build-preview.farm        { background: var(--bld-farm); }
.build-preview.lumber_mill { background: var(--bld-lumber-mill); }
.build-preview.quarry      { background: var(--bld-quarry); }
.build-preview.gold_mine   { background: var(--bld-gold-mine); }
.build-preview.barracks    { background: var(--bld-barracks); }
.build-preview.wall        { background: var(--bld-wall); }
.build-preview.warehouse   { background: var(--bld-warehouse); }

.build-card h3 {
    text-align: center;
    margin-bottom: 6px;
    color: var(--text);
}
.build-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.4;
}

.build-costs {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.cost {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    padding: 3px 8px;
    border-radius: 0;
}
.gold-cost  { background: rgba(255, 215, 0, 0.15); color: var(--gold); }
.wood-cost  { background: rgba(139, 105, 20, 0.2); color: #c9a83c; }
.stone-cost { background: rgba(128, 128, 128, 0.2); color: #b0b0b0; }
.food-cost  { background: rgba(34, 139, 34, 0.2); color: #5ddf5d; }

.build-time {
    text-align: center;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--gold);
    margin-top: 4px;
}

.build-req {
    text-align: center;
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--danger);
    margin-top: 6px;
    padding: 4px;
    background: rgba(244, 67, 54, 0.1);
}

/* ── MAP SCREEN ───────────────────────────────────────────── */
#screen-map {
    padding-top: 155px;
}

.map-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 16px 0;
}
.map-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.map-arrow {
    font-size: 1rem;
    padding: 6px 10px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    color: var(--text-dim);
    min-width: 36px;
}
.map-arrow:hover {
    color: var(--text);
    border-color: var(--gold);
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 1px;
    background: var(--border);
    border: 2px solid var(--border);
    width: fit-content;
}

.map-cell {
    width: 42px;
    height: 42px;
    background: #0d0d1a;
    border: 1px solid #1a1a2e;
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden;
}
.map-cell:hover {
    filter: brightness(1.4);
    z-index: 2;
}
.map-cell.map-own {
    background: #1a3a6e;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.6);
    animation: pulse 2s infinite;
}
.map-cell.map-enemy {
    background: #4a1a1a;
    box-shadow: 0 0 6px rgba(244, 67, 54, 0.4);
}
.map-cell.map-empty {
    background: #0a0a14;
}
.map-cell.map-void {
    background: #050508;
    cursor: default;
}
.map-village-icon {
    font-size: 1.1rem;
    line-height: 1;
}
.map-village-name {
    font-family: var(--pixel-font);
    font-size: 0.25rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    overflow: hidden;
    white-space: nowrap;
}
.map-terrain {
    font-size: 0.7rem;
    opacity: 0.4;
}

.map-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
}
.map-coords {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--text-dim);
}

/* Map popup */
.map-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-medium);
    border: 2px solid var(--gold);
    padding: 20px;
    z-index: 1100;
    text-align: center;
    min-width: 200px;
    animation: fadeIn 0.2s ease;
}
.map-popup h3 {
    color: var(--gold);
    margin-bottom: 8px;
}
.map-popup p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.map-popup .btn {
    margin-top: 12px;
}

/* ── NPC Camp Tiles ──────────────────────────────────────── */
.map-cell.map-camp {
    cursor: pointer;
}
.map-camp-bandit { background: #3a2a10 !important; }
.map-camp-lumber { background: #1a3a1a !important; }
.map-camp-quarry { background: #2a2a2a !important; }
.map-camp-farm   { background: #3a3a10 !important; }
.map-camp-shrine { background: #2a1a3a !important; }

.map-camp-icon {
    font-size: 1rem;
    line-height: 1;
    filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.5));
}

/* ── Camp Raid Popup ─────────────────────────────────────── */
.camp-popup {
    min-width: 260px;
    max-width: 320px;
}
.camp-popup .popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.camp-popup .popup-header strong {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--gold);
}
.camp-popup .popup-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.camp-popup .popup-close:hover {
    color: var(--accent);
}
.camp-popup .popup-body {
    margin-bottom: 10px;
}
.camp-popup .popup-body p {
    margin-bottom: 4px;
    font-size: 0.75rem;
}
.camp-popup .popup-label {
    color: var(--text-dim);
    margin-right: 4px;
}
.camp-troop-selector {
    margin: 10px 0;
}
.camp-troop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 8px;
}
.camp-troop-row label {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text);
    white-space: nowrap;
}
.camp-troop-row input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    font-size: 0.55rem;
    text-align: center;
}
.camp-power-display {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    text-align: center;
    padding: 6px;
    margin-top: 6px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    color: var(--text-dim);
    transition: color 0.2s;
}
.camp-warning {
    font-size: 0.65rem;
    color: var(--accent);
    text-align: center;
    margin-top: 8px;
    padding: 6px;
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.3);
}
.camp-popup .popup-actions {
    text-align: center;
    margin-top: 10px;
}

/* ── TROOPS SCREEN ────────────────────────────────────────── */
#screen-troops {
    padding-top: 155px;
}

/* Defense Box */
.troop-defense-box {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}
.troop-defense-title {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 12px;
}
.troop-defense-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.troop-defense-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}
.troop-defense-label {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
}
.troop-defense-value {
    font-family: var(--pixel-font);
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1.2;
}
.troop-defense-sub {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.troop-defense-vs {
    font-family: var(--pixel-font);
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: bold;
}

/* Section Titles */
.troop-section-title {
    font-size: 0.7rem;
    color: var(--text);
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Army Roster Grid */
.troop-roster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.troop-roster-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
}
.troop-roster-card:hover {
    border-color: var(--gold);
}
.troop-roster-emoji {
    font-size: 1.8rem;
    flex-shrink: 0;
}
.troop-roster-info {
    flex: 1;
    min-width: 0;
}
.troop-roster-name {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text);
}
.troop-roster-count {
    font-family: var(--pixel-font);
    font-size: 1.1rem;
    color: var(--gold);
    margin-top: 2px;
}
.troop-roster-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.troop-stat {
    font-size: 0.65rem;
    color: var(--text-dim);
    white-space: nowrap;
}
.troop-stat.atk { color: var(--accent); }
.troop-stat.def { color: var(--success); }

/* Training Queue */
.troop-queue {
    background: linear-gradient(135deg, #2a1a00 0%, var(--bg-medium) 100%);
    border: 2px solid var(--gold);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}
.troop-queue-header {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text);
    margin-bottom: 8px;
}
.troop-queue-emoji {
    font-size: 1.5rem;
    margin-right: 8px;
}
.troop-queue-timer {
    font-family: monospace;
    font-size: 1.3rem;
    color: var(--gold);
    margin-bottom: 8px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}
.troop-queue-bar {
    width: 100%;
    height: 6px;
    background: #333;
    overflow: hidden;
}
.troop-queue-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold), var(--accent));
    transition: width 1s linear;
}

/* Train Cards Grid */
.troop-train-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.troop-train-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 16px;
    transition: all 0.15s;
}
.troop-train-card:hover:not(.disabled) {
    border-color: var(--gold);
    transform: scale(1.02);
}
.troop-train-card.disabled {
    opacity: 0.45;
}
.troop-train-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.troop-train-emoji {
    font-size: 1.6rem;
}
.troop-train-name {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--gold);
}
.troop-train-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.troop-train-cost {
    display: flex;
    gap: 10px;
    font-size: 0.75rem;
    margin-bottom: 6px;
}
.troop-train-cost span {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
}
.troop-train-time {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 10px;
}
.troop-train-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}
.troop-count-input {
    width: 60px;
    text-align: center;
    padding: 6px 4px !important;
    font-size: 0.6rem !important;
}
.troop-train-btn {
    flex: 1;
    padding: 8px 12px !important;
    font-size: 0.5rem !important;
}
.troop-req {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--danger);
    margin-top: 8px;
    padding: 6px;
    background: rgba(244, 67, 54, 0.1);
    text-align: center;
}
.troop-no-barracks {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 16px;
    font-style: italic;
}

/* ── MARKET SCREEN ────────────────────────────────────────── */
#screen-market {
    padding-top: 155px;
}
.market-subtitle {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-bottom: 16px;
}
.market-balance {
    display: flex;
    gap: 20px;
    justify-content: center;
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--text);
    background: var(--bg-medium);
    padding: 12px;
    border: 2px solid var(--border);
    margin-bottom: 20px;
}
.market-section {
    margin-bottom: 24px;
}
.market-section h3 {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 12px;
}
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.market-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 16px;
    text-align: center;
}
.market-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}
.market-emoji {
    font-size: 1.5rem;
}
.market-res-name {
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    color: var(--text);
}
.market-rate {
    font-size: 0.75rem;
    color: var(--gold);
    margin-bottom: 6px;
}
.market-available {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.market-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}
.market-input {
    width: 80px;
    padding: 6px 8px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    color: var(--text);
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    text-align: center;
}
.market-btn {
    font-size: 0.55rem !important;
    padding: 6px 12px !important;
}
.market-preview {
    margin-top: 8px;
    font-size: 0.65rem;
    color: var(--success);
    font-family: monospace;
}

/* ── SHOP SCREEN ──────────────────────────────────────────── */
#screen-shop {
    padding-top: 155px;
}

/* Starter Pack */
.starter-pack {
    background: linear-gradient(135deg, #2a1a00 0%, #1a1a2e 50%, #2a1a00 100%);
    border: 3px solid var(--gold);
    padding: 20px;
    margin-bottom: 24px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: center;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    animation: starterGlow 2s ease infinite;
}
@keyframes starterGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); }
}
.starter-pack:hover {
    filter: brightness(1.1);
}
.starter-badge {
    background: var(--accent);
    color: #fff;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    padding: 6px 16px;
    margin-bottom: 10px;
    display: inline-block;
    letter-spacing: 1px;
}
.starter-content h3 {
    font-family: var(--pixel-font);
    font-size: 0.9rem;
    color: var(--gold);
    margin-bottom: 12px;
}
.starter-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.starter-price {
    font-family: var(--pixel-font);
    font-size: 1.2rem;
    color: var(--success);
    margin-bottom: 12px;
}

.shop-balance {
    text-align: center;
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    color: var(--text);
    margin-bottom: 24px;
}

.gem-packs {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.gem-pack {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 24px 20px;
    text-align: center;
    flex: 1;
    min-width: 160px;
    max-width: 220px;
    transition: all 0.15s;
    position: relative;
}
.gem-pack:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}

.gem-pack.popular {
    border-color: var(--accent);
    transform: scale(1.05);
}
.gem-pack.popular:hover {
    transform: scale(1.08) translateY(-2px);
}

.gem-pack.best-value {
    border-color: var(--gold);
}

.gem-ribbon {
    position: absolute;
    top: -1px;
    right: -1px;
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    padding: 4px 10px;
    background: var(--accent);
    color: #fff;
    letter-spacing: 1px;
}
.ribbon-best {
    background: var(--gold);
    color: #1a1a2e;
}

.gem-pack-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    animation: pulse 3s infinite;
}

.gem-pack h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.gem-price {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 14px;
}

.gem-pack .btn {
    width: 100%;
}

.gem-info {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
    padding: 20px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
}
.gem-info h3 {
    color: var(--text);
    margin-bottom: 12px;
}
.gem-info ul {
    list-style: none;
    padding: 0;
}
.gem-info li {
    font-size: 0.8rem;
    color: var(--text-dim);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.gem-info li:last-child {
    border-bottom: none;
}

/* ── LEADERBOARD SCREEN ───────────────────────────────────── */
#screen-leaderboard {
    padding-top: 155px;
}
#screen-leaderboard .screen-inner {
    max-width: 800px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 0.8rem;
}
.leaderboard-table th {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--gold);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    background: var(--bg-medium);
}
.leaderboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
.leaderboard-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

/* Top 3 highlights */
.leaderboard-table tbody tr.rank-1 td:first-child {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}
.leaderboard-table tbody tr.rank-1 {
    background: rgba(255, 215, 0, 0.06) !important;
}
.leaderboard-table tbody tr.rank-2 td:first-child {
    color: #c0c0c0;
    font-weight: bold;
}
.leaderboard-table tbody tr.rank-2 {
    background: rgba(192, 192, 192, 0.04) !important;
}
.leaderboard-table tbody tr.rank-3 td:first-child {
    color: #cd7f32;
    font-weight: bold;
}
.leaderboard-table tbody tr.rank-3 {
    background: rgba(205, 127, 50, 0.04) !important;
}

.empty-row {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
}

/* ── MESSAGES SCREEN ──────────────────────────────────────── */
#screen-messages {
    padding-top: 155px;
}

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

.message-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-card {
    display: flex;
    gap: 12px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    padding: 14px;
    transition: all 0.15s;
}
.message-card:hover {
    background: rgba(22, 33, 62, 0.8);
}
.message-card.unread {
    border-left-color: var(--accent);
}

.msg-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}
.msg-body {
    flex: 1;
}
.msg-text {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 4px;
}
.msg-time {
    font-size: 0.7rem;
    color: var(--text-dim);
}

/* ── Timer utility class ──────────────────────────────────── */
.timer {
    font-family: monospace;
    color: var(--gold);
}

/* ── Season Banner ───────────────────────────────────────── */
.season-banner {
    position: fixed;
    top: 100px; /* below resource bar + nav bar */
    left: 0;
    right: 0;
    z-index: 90;
    background: linear-gradient(135deg, #2a0a0a 0%, #1a1a2e 50%, #2a0a0a 100%);
    border-bottom: 2px solid #8B0000;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.season-label {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.season-timer {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text);
    margin-left: 12px;
}

.wave-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--accent);
}

.wave-timer {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.wave-progress {
    width: 100%;
    height: 4px;
    background: #333;
    margin-top: 4px;
}

.wave-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--gold), var(--accent));
    transition: width 0.5s ease;
}

/* Wave attack alert animation */
.season-banner.wave-imminent {
    animation: waveAlert 1s ease infinite;
}

/* ── Wave Attack Overlay ──────────────────────────────────── */
.wave-attack-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(139, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background 0.3s ease;
}
.wave-attack-overlay.active {
    background: rgba(139, 0, 0, 0.7);
    pointer-events: all;
}
.wave-attack-overlay.fading {
    background: rgba(139, 0, 0, 0);
}
.wave-attack-content {
    text-align: center;
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.4s ease;
}
.wave-attack-overlay.active .wave-attack-content {
    transform: scale(1);
    opacity: 1;
}
.wave-attack-overlay.fading .wave-attack-content {
    transform: scale(1.5);
    opacity: 0;
}
.wave-attack-icon {
    font-size: 5rem;
    animation: waveShake 0.3s ease infinite;
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 0.8));
}
.wave-attack-title {
    font-family: var(--pixel-font);
    font-size: 1.5rem;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 2px 2px 0 #000;
    margin-top: 16px;
    letter-spacing: 2px;
}
.wave-attack-sub {
    font-family: var(--pixel-font);
    font-size: 0.8rem;
    color: var(--text);
    margin-top: 8px;
}

/* Wave result screens */
.wave-result-survived {
    background: rgba(0, 80, 0, 0.85) !important;
}
.wave-result-failed {
    background: rgba(100, 0, 0, 0.85) !important;
}
.wave-result-icon {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 12px;
}
.wave-result-title {
    font-family: var(--pixel-font);
    font-size: 1.5rem;
    text-shadow: 0 0 20px currentColor, 2px 2px 0 #000;
    margin-bottom: 16px;
}
.wave-result-msg {
    font-size: 1rem;
    color: var(--text);
    max-width: 500px;
    line-height: 1.6;
    margin-bottom: 12px;
}
.wave-result-detail {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    margin-bottom: 24px;
}
.wave-dismiss-btn {
    font-family: var(--pixel-font);
    font-size: 0.8rem;
    padding: 12px 40px;
    cursor: pointer;
}

/* ── Report Bug Popup ─────────────────────────────────────── */
.report-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}
.report-overlay.active { background: rgba(0, 0, 0, 0.8); }
.report-popup {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 24px;
    max-width: 450px;
    width: 90%;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
}
.report-overlay.active .report-popup { transform: scale(1); opacity: 1; }
.report-title {
    font-family: var(--pixel-font);
    font-size: 0.9rem;
    color: var(--gold);
    margin-bottom: 8px;
}
.report-desc { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 12px; }
.report-input {
    width: 100%;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    padding: 10px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.report-input:focus { border-color: var(--gold); outline: none; }
.report-chars { font-size: 0.65rem; color: var(--text-dim); text-align: right; margin: 4px 0 12px; }
.report-buttons { display: flex; gap: 10px; justify-content: center; }

/* ── Daily Reward Popup ──────────────────────────────────── */
.daily-reward-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}
.daily-reward-overlay.active {
    background: rgba(0, 0, 0, 0.8);
}
.daily-reward-overlay.fading {
    background: rgba(0, 0, 0, 0);
}
.daily-reward-popup {
    background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
    border: 3px solid var(--gold);
    padding: 24px 32px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}
.daily-reward-overlay.active .daily-reward-popup {
    transform: scale(1);
    opacity: 1;
}
.daily-reward-overlay.fading .daily-reward-popup {
    transform: scale(0.8);
    opacity: 0;
}
.dr-title {
    font-family: var(--pixel-font);
    font-size: 1.2rem;
    color: var(--gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    margin-bottom: 4px;
}
.dr-subtitle {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-bottom: 16px;
}
.dr-streak {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.dr-day {
    width: 48px;
    padding: 6px 4px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    text-align: center;
    position: relative;
}
.dr-day-num {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-dim);
}
.dr-day-gems {
    font-size: 0.65rem;
    color: var(--text);
    margin-top: 2px;
}
.dr-day.dr-today {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}
.dr-day.dr-today .dr-day-num {
    color: var(--gold);
}
.dr-day.dr-claimed {
    opacity: 0.5;
}
.dr-check {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.7rem;
}
.dr-reward-box {
    background: var(--bg-dark);
    border: 2px solid var(--gold);
    padding: 12px;
    margin-bottom: 16px;
}
.dr-reward-label {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
    margin-bottom: 8px;
}
.dr-rewards {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.dr-item {
    font-size: 1rem;
}
.dr-claim-btn {
    font-family: var(--pixel-font);
    font-size: 0.75rem;
    padding: 12px 32px;
    margin-bottom: 12px;
    animation: pulse 1.5s ease infinite;
}
.dr-note {
    font-size: 0.65rem;
    color: var(--text-dim);
}

@keyframes waveShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-5px) rotate(-5deg); }
    75% { transform: translateX(5px) rotate(5deg); }
}

@keyframes waveAlert {
    0%, 100% { border-bottom-color: #8B0000; }
    50% { border-bottom-color: var(--accent); box-shadow: 0 2px 20px rgba(233, 69, 96, 0.3); }
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast {
    position: fixed;
    top: 160px; /* below resource bar + nav + season banner */
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    border: 2px solid var(--border);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
    line-height: 1.6;
    white-space: pre-line;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.error {
    background: #3a0a0a;
    border-color: var(--danger);
    color: #ff6b6b;
}
.toast.success {
    background: #0a2a0a;
    border-color: var(--success);
    color: #7dff7d;
}
.toast.celebration {
    background: linear-gradient(135deg, #1a2a00 0%, #0a2a0a 100%);
    border-color: var(--gold);
    color: var(--gold);
    font-size: 0.65rem;
    padding: 16px 28px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}
.toast.celebration .toast-emoji {
    font-size: 1.8rem;
    display: block;
    margin-bottom: 6px;
}
.toast.celebration .toast-detail {
    font-size: 0.5rem;
    color: var(--success);
    margin-top: 4px;
}

/* ── Loading Spinner ─────────────────────────────────────── */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
}
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    animation: spin 0.8s linear infinite;
    /* pixel-art feel: square spinner */
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text-dim);
    animation: shimmer 1.5s ease infinite;
}

/* ── New Player Hint (pulsing build guide) ───────────────── */
@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50%      { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
}
.village-slot.hint-slot {
    animation: hintPulse 2s ease infinite;
    border-color: var(--success) !important;
    position: relative;
}
.hint-text {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--pixel-font);
    font-size: 0.35rem;
    color: var(--success);
    white-space: nowrap;
    text-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
    animation: shimmer 2s ease infinite;
    pointer-events: none;
}

/* ── Power Badge (enhanced) ──────────────────────────────── */
.power-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--pixel-font);
    font-size: 0.75rem;
    background: linear-gradient(135deg, #4a1a00 0%, #8B0000 50%, #4a1a00 100%);
    color: var(--gold);
    padding: 8px 20px;
    border-radius: 0;
    border: 2px solid var(--gold);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
}
.power-badge .power-icon {
    font-size: 1rem;
}
.power-badge .power-value {
    font-size: 1rem;
    font-weight: bold;
}

/* ── Wave Urgency States ─────────────────────────────────── */
.season-banner.wave-warning {
    border-bottom-color: var(--accent);
    background: linear-gradient(135deg, #3a0a0a 0%, #1a1a2e 50%, #3a0a0a 100%);
}
.season-banner.wave-warning .wave-timer {
    color: var(--accent) !important;
    font-weight: bold;
}
.season-banner.wave-critical {
    border-bottom-color: #ff0000;
    background: linear-gradient(135deg, #4a0000 0%, #2a0000 50%, #4a0000 100%);
    animation: waveCritical 0.5s ease infinite;
}
.season-banner.wave-critical .wave-timer {
    color: #ff4444 !important;
    font-weight: bold;
    font-size: 0.85rem;
}
.season-banner.wave-critical .wave-icon {
    animation: pulse 0.5s ease infinite;
}
@keyframes waveCritical {
    0%, 100% { border-bottom-color: #ff0000; box-shadow: 0 2px 20px rgba(255, 0, 0, 0.3); }
    50% { border-bottom-color: #ff4444; box-shadow: 0 2px 30px rgba(255, 0, 0, 0.5); }
}
.wave-urgent-text {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: #ff4444;
    margin-left: 8px;
    animation: shimmer 0.8s ease infinite;
}

/* ── Leaderboard Highlights ──────────────────────────────── */
.leaderboard-me td {
    background: rgba(233, 69, 96, 0.12) !important;
    color: #fff !important;
    font-weight: bold;
}
.leaderboard-my-rank {
    text-align: center;
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--accent);
    padding: 10px 16px;
    margin-bottom: 12px;
    background: rgba(233, 69, 96, 0.08);
    border: 1px solid rgba(233, 69, 96, 0.2);
}

/* ── Resource Bar Color Badges ───────────────────────────── */
.resource-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 0;
}
.resource-item.gold {
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
}
.resource-item.wood {
    background: rgba(139, 105, 20, 0.1);
    border: 1px solid rgba(139, 105, 20, 0.25);
}
.resource-item.stone {
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.2);
}
.resource-item.food {
    background: rgba(34, 139, 34, 0.08);
    border: 1px solid rgba(34, 139, 34, 0.2);
}
.resource-item.gems {
    border-left: 1px solid var(--border);
    padding-left: 12px;
    margin-left: 4px;
}
.resource-item.power {
    border-left: 1px solid var(--border);
    padding-left: 12px;
    margin-left: 4px;
}
.resource-icon {
    font-size: 1rem;
}
.resource-val {
    color: var(--text);
    min-width: 35px;
    font-size: 0.65rem;
}
.resource-rate {
    color: var(--success);
    font-size: 0.5rem;
}

/* ── Build Card Production Rate ──────────────────────────── */
.build-production-rate {
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--success);
    text-align: center;
    margin-top: 4px;
    padding: 3px 6px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

/* ── Build Card Header ───────────────────────────────────── */
.build-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    margin: -16px -16px 12px -16px;
}
.build-emoji {
    font-size: 1.6rem;
}
.build-name {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}
.build-card-body {
    padding: 0;
}
.build-cost {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 6px;
}
.build-cost span {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
}
.build-card.unaffordable {
    opacity: 0.65;
}
.req-text {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--danger);
    text-align: center;
    margin-top: 6px;
    padding: 4px;
    background: rgba(244, 67, 54, 0.1);
}

/* ── Upgrade/Detail Styles ───────────────────────────────── */
.detail-emoji {
    font-size: 2.5rem;
    filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.5));
}
.detail-desc {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-bottom: 12px;
}
.detail-production h3 {
    font-size: 0.6rem;
    color: var(--text);
    margin-bottom: 4px;
}
.detail-production p {
    color: var(--success);
    font-family: var(--pixel-font);
    font-size: 0.55rem;
}
.detail-upgrading,
.detail-upgrade,
.detail-maxlevel {
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}
.detail-upgrading h3,
.detail-upgrade h3,
.detail-maxlevel h3 {
    margin-bottom: 10px;
}
.detail-timer {
    font-family: monospace;
    font-size: 1.5rem;
    color: var(--gold);
    text-align: center;
    margin: 8px 0;
}
.upgrade-cost {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.upgrade-cost span {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
}
.upgrade-time {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--gold);
    margin-bottom: 10px;
}
.btn-upgrade {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    color: #fff;
    background: var(--accent);
    transition: all 0.15s;
}
.btn-upgrade:hover:not(:disabled) {
    filter: brightness(1.2);
    transform: translateY(-1px);
}
.btn-upgrade:disabled,
.btn-upgrade.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-gems {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    background: var(--gold);
    color: #1a1a2e;
    font-weight: bold;
    margin-top: 8px;
    transition: all 0.15s;
}
.btn-gems:hover {
    filter: brightness(1.2);
}
.btn-back {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    padding: 10px 20px;
    border: 2px solid var(--border);
    cursor: pointer;
    background: var(--bg-dark);
    color: var(--text);
    margin-top: 16px;
    transition: all 0.15s;
    display: inline-block;
}
.btn-back:hover {
    border-color: var(--text-dim);
}

/* ── How to Play Section ─────────────────────────────────── */
.how-to-play {
    max-width: 400px;
    width: 100%;
    margin-top: 32px;
    padding: 20px 24px;
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid var(--border);
    text-align: left;
}
.how-to-play h3 {
    text-align: center;
    color: var(--text);
    margin-bottom: 14px;
    font-size: 0.6rem;
}
.how-to-play-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.how-to-play-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.how-to-play-list li:last-child {
    border-bottom: none;
}
.how-to-play-list .htp-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

/* ── Shop Card Styles ────────────────────────────────────── */
.shop-header {
    text-align: center;
    margin-bottom: 24px;
}
.shop-packs {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 32px;
}
.shop-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 24px 20px;
    text-align: center;
    min-width: 160px;
    max-width: 220px;
    flex: 1;
    cursor: pointer;
    transition: all 0.15s;
}
.shop-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
}
.shop-card-gems {
    font-size: 2rem;
    margin-bottom: 8px;
}
.shop-card-label {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text);
    margin-bottom: 8px;
}
.shop-card-price {
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    color: var(--gold);
    margin-bottom: 12px;
}
.btn-buy {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    padding: 8px 16px;
    border: none;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    transition: all 0.15s;
}
.btn-buy:hover {
    filter: brightness(1.2);
}

/* ── Login Footer Update ─────────────────────────────────── */
.login-footer p {
    color: var(--text-dim);
    font-size: 0.65rem;
    font-family: var(--pixel-font);
    letter-spacing: 1px;
}

/* ── Message Item Styles ─────────────────────────────────── */
.message-item {
    padding: 14px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.message-item:hover {
    background: rgba(22, 33, 62, 0.8);
}
.message-item.unread {
    border-left-color: var(--accent);
}
.message-item.read {
    opacity: 0.6;
}
.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}
.message-from {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--gold);
}
.message-time {
    font-size: 0.65rem;
    color: var(--text-dim);
}
.message-subject {
    font-size: 0.8rem;
    color: var(--text);
    margin-bottom: 4px;
}
.message-body {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ── Error/Empty Text ────────────────────────────────────── */
.error-text {
    color: var(--danger);
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
}
.empty-text {
    color: var(--text-dim);
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
    font-style: italic;
}

/* ── Rename Input ────────────────────────────────────────── */
.rename-input {
    background: var(--bg-dark);
    border: 2px solid var(--accent);
    color: var(--gold);
    font-family: var(--pixel-font);
    font-size: 1rem;
    padding: 4px 8px;
    text-align: center;
    outline: none;
    width: 200px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .game-title h1 {
        font-size: 2.2rem;
        letter-spacing: 4px;
    }
    .tagline {
        font-size: 0.55rem;
        letter-spacing: 2px;
    }

    #resource-bar {
        gap: 4px;
        padding: 6px 8px;
    }
    .resource-item {
        font-size: 0.5rem;
        padding: 1px 4px;
        gap: 3px;
    }
    .resource-icon {
        font-size: 0.8rem;
    }
    .resource-val {
        font-size: 0.5rem;
        min-width: 28px;
    }
    .resource-rate {
        display: none;
    }
    .resource, .res-icon {
        font-size: 0.45rem;
    }
    .res-icon {
        width: 18px;
        height: 18px;
    }

    #nav-bar {
        top: 36px;
    }
    .nav-btn {
        font-size: 0.4rem;
        padding: 8px 8px;
    }

    #screen-village,
    #screen-build-menu,
    #screen-building-detail,
    #screen-map,
    #screen-troops,
    #screen-shop,
    #screen-leaderboard,
    #screen-messages,
    #screen-market {
        padding-top: 110px;
    }

    .season-banner {
        top: 72px;
        padding: 6px 10px;
    }

    .toast {
        top: 115px;
        font-size: 0.5rem;
        padding: 8px 16px;
    }

    .village-grid {
        gap: 4px;
        max-width: 100%;
    }
    .village-slot {
        min-height: 80px;
    }
    .building-emoji {
        font-size: 1.5rem;
    }
    .building-name {
        font-size: 0.4rem;
    }
    .building-level {
        font-size: 0.4rem;
    }

    .power-badge {
        font-size: 0.55rem;
        padding: 6px 12px;
    }
    .power-badge .power-value {
        font-size: 0.75rem;
    }

    .build-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .map-cell {
        width: 28px;
        height: 28px;
    }

    .gem-packs, .shop-packs {
        flex-direction: column;
        align-items: center;
    }
    .gem-pack, .shop-card {
        max-width: 280px;
    }
    .gem-pack.popular {
        transform: none;
    }

    .leaderboard-table {
        font-size: 0.7rem;
    }
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 6px;
    }

    .how-to-play {
        padding: 16px;
    }
    .how-to-play-list li {
        font-size: 0.65rem;
    }

    .hint-text {
        font-size: 0.3rem;
    }
}

@media (max-width: 400px) {
    .game-title h1 {
        font-size: 1.8rem;
    }
    .village-grid {
        gap: 2px;
    }
    .village-slot {
        min-height: 65px;
    }
    .building-emoji {
        font-size: 1.2rem;
    }
    .map-cell {
        width: 24px;
        height: 24px;
    }
}

/* ── Scroll Safety ───────────────────────────────────────── */
.screen {
    padding-bottom: 40px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ══════════════════════════════════════════════════════════
   HOW TO PLAY SCREEN
   ══════════════════════════════════════════════════════════ */

/* How to Play button on login screen */
.btn-howtoplay {
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    padding: 14px 32px;
    border: 2px solid var(--gold);
    background: linear-gradient(135deg, #2a1a00 0%, var(--bg-medium) 50%, #2a1a00 100%);
    color: var(--gold);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 24px;
    letter-spacing: 1px;
    display: block;
    width: fit-content;
    text-align: center;
}
.btn-howtoplay:hover {
    filter: brightness(1.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

/* Help "?" button in nav bar */
.nav-help-btn {
    font-size: 0.9rem !important;
    font-weight: bold;
    padding: 10px 14px !important;
    color: var(--gold) !important;
    border-bottom: 3px solid transparent;
    min-width: 40px;
    text-align: center;
}
.nav-help-btn:hover {
    color: #fff !important;
    background: rgba(255, 215, 0, 0.1);
}
.nav-help-btn.active {
    color: var(--gold) !important;
    border-bottom-color: var(--gold);
}

/* Screen container */
#screen-howtoplay {
    padding-top: 0;
    background: var(--bg-dark);
}

.htp-screen-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* Hero / Title */
.htp-hero {
    text-align: center;
    padding: 48px 20px 32px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}
.htp-title {
    font-family: var(--pixel-font);
    font-size: 1.6rem;
    color: var(--gold);
    text-shadow: 3px 3px 0 #b8860b, 5px 5px 0 rgba(0, 0, 0, 0.4);
    letter-spacing: 3px;
    margin-bottom: 12px;
}
.htp-subtitle {
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* Table of Contents */
.htp-toc {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 20px;
    margin-bottom: 32px;
}
.htp-toc h3 {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text);
    margin-bottom: 16px;
}
.htp-toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.htp-toc-link {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--text-dim);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.15s;
    text-align: center;
}
.htp-toc-link:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.05);
    text-decoration: none;
    transform: translateY(-1px);
}

/* Section */
.htp-section {
    margin-bottom: 36px;
    scroll-margin-top: 170px;
}
.htp-section-title {
    font-family: var(--pixel-font);
    font-size: 0.85rem;
    color: var(--gold);
    padding: 14px 20px;
    background: linear-gradient(135deg, #2a1a00 0%, var(--bg-medium) 50%, #2a1a00 100%);
    border: 2px solid #5a3a00;
    border-left: 5px solid var(--gold);
    margin-bottom: 16px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    letter-spacing: 1px;
}
.htp-section-body {
    padding: 0 4px;
    line-height: 1.7;
    font-size: 0.85rem;
    color: var(--text);
}
.htp-section-body p {
    margin-bottom: 12px;
}
.htp-section-body ul {
    padding-left: 20px;
    margin-bottom: 12px;
}
.htp-section-body ul li {
    margin-bottom: 6px;
    line-height: 1.6;
}

/* Steps (numbered list) */
.htp-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}
.htp-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    padding: 14px 16px;
    transition: border-color 0.15s;
}
.htp-step:hover {
    border-color: rgba(255, 215, 0, 0.3);
}
.htp-step-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-family: var(--pixel-font);
    font-size: 0.7rem;
    font-weight: bold;
    border: 2px solid rgba(0, 0, 0, 0.3);
}
.htp-step strong {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
    margin-bottom: 4px;
}
.htp-step p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}

/* Note box */
.htp-note {
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-left: 3px solid var(--gold);
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--text);
    margin: 12px 0;
}

/* Building Cards */
.htp-building-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.htp-building-card:hover {
    border-color: rgba(255, 215, 0, 0.3);
}
.htp-building-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}
.htp-building-emoji {
    font-size: 2rem;
    filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.5));
    flex-shrink: 0;
}
.htp-building-header h3 {
    font-family: var(--pixel-font);
    font-size: 0.65rem;
    color: #fff;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 2px;
}
.htp-building-tag {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
}
.htp-building-body {
    padding: 14px 16px;
}
.htp-building-body p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    line-height: 1.5;
}
.htp-building-body ul {
    padding-left: 16px;
    margin-bottom: 10px;
}
.htp-building-body ul li {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 4px;
    line-height: 1.5;
}
.htp-building-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}
.htp-building-stats span {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--text-dim);
    line-height: 1.6;
}

/* Resource cards */
.htp-resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.htp-resource-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    padding: 14px;
}
.htp-res-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel-font);
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff;
}
.htp-resource-card strong {
    display: block;
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
    margin-bottom: 4px;
}
.htp-resource-card p {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.4;
}

/* Info Box */
.htp-info-box {
    background: rgba(15, 52, 96, 0.4);
    border: 1px solid rgba(15, 52, 96, 0.6);
    border-left: 3px solid var(--bg-light);
    padding: 14px 16px;
    margin: 16px 0;
}
.htp-info-box h4 {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text);
    margin-bottom: 8px;
}
.htp-info-box p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.htp-info-box ul {
    padding-left: 16px;
}
.htp-info-box ul li {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 4px;
    line-height: 1.5;
}

/* Troop Grid */
.htp-troop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}
.htp-troop-card {
    background: var(--bg-medium);
    border: 2px solid var(--border);
    overflow: hidden;
    transition: border-color 0.15s;
}
.htp-troop-card:hover {
    border-color: rgba(255, 215, 0, 0.3);
}
.htp-troop-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(139, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
}
.htp-troop-emoji {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.htp-troop-header h3 {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--gold);
}
.htp-troop-body {
    padding: 12px 14px;
}
.htp-troop-req {
    font-family: var(--pixel-font);
    font-size: 0.4rem;
    color: var(--accent);
    margin-bottom: 8px;
    padding: 3px 8px;
    background: rgba(233, 69, 96, 0.1);
    display: inline-block;
}
.htp-troop-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.htp-stat-atk {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--accent);
}
.htp-stat-def {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    color: var(--success);
}
.htp-troop-cost {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}
.htp-troop-cost span {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--text-dim);
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
}
.htp-troop-time {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--gold);
    display: block;
    margin-bottom: 8px;
}
.htp-troop-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.4;
    margin: 0;
    font-style: italic;
}

/* Warning Box (Barbarian Waves) */
.htp-warning-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(139, 0, 0, 0.15);
    border: 2px solid rgba(139, 0, 0, 0.4);
    border-left: 5px solid var(--accent);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.htp-warning-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.htp-warning-box p {
    font-size: 0.85rem;
    color: var(--text);
    margin: 0;
    line-height: 1.5;
}

/* Detail List */
.htp-detail-list {
    padding-left: 20px;
    margin: 8px 0 16px;
}
.htp-detail-list li {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 6px;
    line-height: 1.5;
}

/* Formula Box */
.htp-formula-box {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--border);
    padding: 14px 16px;
    margin: 12px 0;
}
.htp-formula-box p {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
    margin-bottom: 8px;
}
.htp-formula-box ul {
    padding-left: 16px;
    margin-bottom: 0;
}
.htp-formula-box ul li {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.htp-formula-box em {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Outcome Grid (Win/Lose) */
.htp-outcome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.htp-outcome-card {
    padding: 14px 16px;
    border: 2px solid var(--border);
}
.htp-outcome-card h4 {
    font-family: var(--pixel-font);
    font-size: 0.5rem;
    margin-bottom: 10px;
}
.htp-outcome-card ul {
    padding-left: 16px;
    margin: 0;
}
.htp-outcome-card ul li {
    font-size: 0.8rem;
    margin-bottom: 4px;
    line-height: 1.5;
}
.htp-outcome-win {
    background: rgba(76, 175, 80, 0.08);
    border-color: rgba(76, 175, 80, 0.3);
}
.htp-outcome-win h4 {
    color: var(--success);
}
.htp-outcome-win ul li {
    color: var(--text-dim);
}
.htp-outcome-lose {
    background: rgba(244, 67, 54, 0.08);
    border-color: rgba(244, 67, 54, 0.3);
}
.htp-outcome-lose h4 {
    color: var(--danger);
}
.htp-outcome-lose ul li {
    color: var(--text-dim);
}

/* Tip text */
.htp-tip {
    font-size: 0.8rem;
    color: var(--text);
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.15);
    padding: 10px 14px;
    margin: 12px 0;
    line-height: 1.5;
}

/* Prize Table */
.htp-prize-table {
    margin: 16px 0;
    border: 2px solid var(--border);
    overflow: hidden;
}
.htp-prize-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.htp-prize-row:last-child {
    border-bottom: none;
}
.htp-prize-rank {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--text);
}
.htp-prize-reward {
    font-family: var(--pixel-font);
    font-size: 0.55rem;
    color: var(--gold);
}
.htp-prize-gold {
    background: rgba(255, 215, 0, 0.08);
}
.htp-prize-gold .htp-prize-rank {
    color: #ffd700;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}
.htp-prize-silver {
    background: rgba(192, 192, 192, 0.05);
}
.htp-prize-silver .htp-prize-rank {
    color: #c0c0c0;
}
.htp-prize-bronze {
    background: rgba(205, 127, 50, 0.05);
}
.htp-prize-bronze .htp-prize-rank {
    color: #cd7f32;
}

/* Market Rates Table */
.htp-market-rates {
    margin: 16px 0;
}
.htp-market-rates h4 {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--gold);
    margin-bottom: 10px;
}
.htp-rate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    border: 2px solid var(--border);
}
.htp-rate-table th {
    font-family: var(--pixel-font);
    font-size: 0.45rem;
    color: var(--gold);
    padding: 10px 12px;
    text-align: left;
    background: var(--bg-medium);
    border-bottom: 2px solid var(--border);
}
.htp-rate-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.htp-rate-sell {
    color: var(--success) !important;
}
.htp-rate-buy {
    color: var(--accent) !important;
}

/* Gem Pack Grid */
.htp-gem-pack-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
}
.htp-gem-pack {
    flex: 1;
    min-width: 140px;
    background: var(--bg-medium);
    border: 2px solid var(--border);
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}
.htp-gem-pack span {
    font-size: 0.85rem;
    color: var(--text);
}
.htp-gem-pack strong {
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    color: var(--gold);
}
.htp-gem-pack em {
    font-size: 0.7rem;
    color: var(--success);
}
.htp-gem-best {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.06);
}

/* Strategy Tips Grid */
.htp-tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.htp-tip-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-medium);
    border: 1px solid var(--border);
    padding: 14px;
    transition: border-color 0.15s;
}
.htp-tip-card:hover {
    border-color: rgba(255, 215, 0, 0.25);
}
.htp-tip-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.htp-tip-card p {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 0;
    line-height: 1.5;
}
.htp-tip-card strong {
    color: var(--text);
}

/* Fixed Back Button */
.htp-fixed-back {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 1100;
    font-family: var(--pixel-font);
    font-size: 0.6rem;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: 2px solid #c0392b;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.htp-fixed-back:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

/* Back Button Section */
.htp-back-section {
    text-align: center;
    padding: 32px 0 16px;
    border-top: 2px solid var(--border);
    margin-top: 16px;
}
.htp-back-btn {
    max-width: 300px;
    margin: 0 auto;
    font-size: 0.65rem !important;
    padding: 14px 32px !important;
}

/* ── How to Play Mobile Responsive ───────────────────────── */
@media (max-width: 600px) {
    .htp-hero {
        padding: 32px 12px 20px;
    }
    .htp-title {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }
    .htp-subtitle {
        font-size: 0.75rem;
    }
    .htp-section-title {
        font-size: 0.65rem;
        padding: 10px 14px;
    }
    .htp-toc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .htp-toc-link {
        font-size: 0.4rem;
        padding: 6px 8px;
    }
    .htp-building-header {
        padding: 10px 12px;
    }
    .htp-building-emoji {
        font-size: 1.5rem;
    }
    .htp-building-header h3 {
        font-size: 0.55rem;
    }
    .htp-troop-grid {
        grid-template-columns: 1fr;
    }
    .htp-outcome-grid {
        grid-template-columns: 1fr;
    }
    .htp-tips-grid {
        grid-template-columns: 1fr;
    }
    .htp-resource-grid {
        grid-template-columns: 1fr;
    }
    .htp-gem-pack-grid {
        flex-direction: column;
    }
    #screen-howtoplay {
        padding-top: 0;
    }
    .htp-screen-inner {
        padding: 0 10px 40px;
    }
    .btn-howtoplay {
        font-size: 0.55rem;
        padding: 10px 20px;
    }
}
