/* AI Clash of Clans - Fullscreen Mobile Game Cockpit Stylesheet */
:root {
    --bg-dark: #07080f;
    --bg-overlay: rgba(10, 12, 22, 0.85);
    --hud-stone: linear-gradient(180deg, rgba(39, 44, 39, 0.94) 0%, rgba(15, 18, 16, 0.96) 100%);
    --hud-stone-dark: linear-gradient(180deg, rgba(25, 30, 23, 0.96) 0%, rgba(8, 10, 9, 0.98) 100%);
    --hud-rim: #34406a;
    --hud-rim-light: #5363a3;
    --hud-shadow: 0 10px 22px rgba(0,0,0,0.42), inset 0 2px 0 rgba(255,255,255,0.08), inset 0 -3px 0 rgba(0,0,0,0.35);
    --border-steel: rgba(46, 53, 92, 0.8);
    --border-gold: #c5a059;
    --border-gold-glow: #ffd54f;
    
    --color-gold: #ffb300;
    --color-elixir: #d81b60;
    --color-cyan: #00e5ff;
    --color-green: #00e676;
    --color-purple: #7b1fa2;
    --color-text: #e1e7f0;
    --color-text-dark: #7a829e;
    
    --font-heading: 'Fredoka', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Orbitron', sans-serif;
    --transition-fast: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1.15);
    --transition-fancy: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset and Global rules */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body, html {
    background-color: #000;
    color: var(--color-text);
    font-family: var(--font-body);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    margin: 0;
    padding: 0;
    overscroll-behavior: none;
}

/* Custom Scrollbars for Game list */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-cyan);
}

/* Fullscreen relative container representing the game viewport */
.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* The Canvas fits 100% of screen borderless background */
#battle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1;
    display: block;
    touch-action: none;
}

/* Enable crisp-edges / pixelated image scaling globally for all canvas and images */
canvas, img {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}



.sand-table-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* 1. FLOATING HUD TOP (Directly overlays the map) */
.hud-top {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none; /* Let clicks pass through empty spaces to the map */
}

/* Profile Badge */
.profile-cluster {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    pointer-events: auto;
    max-width: min(520px, calc(100vw - 250px));
}

/* Profile & Action Buttons Row Container */
.profile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

/* Commander Profile Pill Badge */
.player-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(10, 12, 22, 0.7);
    border: 2.5px solid #2d1e12;
    border-radius: 99px;
    padding: 4px 14px 4px 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: auto;
    transition: border-color 0.2s ease;
}

.player-profile:hover {
    border-color: var(--border-gold);
}


.avatar-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2.5px solid var(--color-cyan);
    object-fit: cover;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.3);
}

.avatar-level {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: var(--color-gold);
    color: #000;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #2d1e12;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name {
    font-family: var(--font-heading);
    font-size: 13px;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-shadow: -1px -1px 0 #2d1e12, 1px -1px 0 #2d1e12, -1px 1px 0 #2d1e12, 1px 1px 0 #2d1e12, 0 1.5px 3px rgba(0,0,0,0.5);
    margin: 0;
}

.player-league {
    font-size: 9px;
    color: #cbd5e0;
    margin-top: 0;
    text-shadow: 0 1px 1px rgba(0,0,0,0.8);
    line-height: 1;
}

.player-trophies {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--color-gold);
    line-height: 1;
    margin-top: 2px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.8);
}

/* Upgrade worker status capsule styling */
.upgrade-worker-status {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(180deg, #4c3628 0%, #2f1e14 100%);
    border: 2.5px solid #2d1e12;
    border-radius: 12px;
    padding: 6px 12px;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    box-shadow: 0 3px 0 #120e0a, 0 4px 6px rgba(0,0,0,0.4);
    text-shadow: 1px 1px 0 #000;
    pointer-events: auto;
    transition: transform 0.1s ease;
    margin-top: 2px;
}

.upgrade-worker-status::before {
    content: "👷";
    font-size: 12px;
    margin-right: 6px;
}

.upgrade-worker-status:hover {
    transform: scale(1.03);
    border-color: var(--color-gold);
}

/* Resource Tanks Capsules */
.resource-tanks {
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: auto;
    position: absolute;
    top: 0;
    right: 8px;
}

.tank {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(10, 12, 22, 0.7);
    border: 2.5px solid #2d1e12;
    border-radius: 99px;
    padding: 3px 12px 3px 24px;
    min-width: 140px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.15);
    backdrop-filter: blur(12px);
    transition: var(--transition-fast);
}

.tank:hover {
    border-color: #ffd54f;
}

.tank-icon {
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #ffd54f 0%, #ff8f00 100%);
    border: 2.5px solid #2d1e12;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.4);
    animation: none;
    z-index: 2;
}

.elixir-tank .tank-icon {
    background: linear-gradient(135deg, #f48fb1 0%, #d81b60 100%);
}

.army-tank .tank-icon {
    background: linear-gradient(135deg, #8de0ff 0%, #1d72d8 100%);
}

.stamina-tank .tank-icon {
    background: linear-gradient(135deg, #c5e1a5 0%, #43a047 100%);
}

.tank-info {
    flex: 1;
    z-index: 1;
}

.tank-label {
    font-family: var(--font-heading);
    font-size: 7px;
    color: var(--color-text-dark);
    text-transform: uppercase;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    line-height: 1;
}

.tank-values {
    font-family: var(--font-heading);
    font-size: 10px;
    color: #fff;
    font-weight: 700;
    margin: 0;
    text-shadow: -1px -1px 0 #2d1e12, 1px -1px 0 #2d1e12, -1px 1px 0 #2d1e12, 1px 1px 0 #2d1e12, 0 1.5px 3px rgba(0,0,0,0.5);
}

.tank-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 1px;
}

.bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.gold-tank .bar-fill {
    background: linear-gradient(90deg, #ffa000 0%, var(--color-gold) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

.elixir-tank .bar-fill {
    background: linear-gradient(90deg, #c2185b 0%, var(--color-elixir) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

.army-tank .bar-fill {
    background: linear-gradient(90deg, #29b6f6 0%, var(--color-cyan) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

.stamina-tank .bar-fill {
    background: linear-gradient(90deg, #43a047 0%, var(--color-green) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Settings moved to profile badge */

/* 2. HUD FLOATING OVERLAYS (Left & Right margins) */

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

.chat-panel {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 11;
    width: min(360px, 40vw);
    max-height: 260px;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: auto;
    overflow: visible;
}

.chat-panel.collapsed {
    max-height: 38px;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    border-bottom: none;
    background: transparent;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.95), -1px -1px 2px rgba(0, 0, 0, 0.95);
}

.chat-tabs {
    display: flex;
    height: 100%;
}

.chat-tab,
.chat-toggle {
    border: 0;
    background: transparent;
    color: rgba(255,255,255,0.62);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.chat-tab {
    padding: 0 12px;
    border-right: none;
}

.chat-tab.active {
    color: #fff;
    box-shadow: none;
    text-decoration: underline;
    text-decoration-color: var(--color-gold);
    text-underline-offset: 4px;
}

.chat-toggle {
    width: 34px;
    color: var(--color-gold);
}

.chat-feed {
    height: 172px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.chat-message {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px;
    font-size: 11px;
    line-height: 1.35;
    align-self: flex-start;
    max-width: 96%;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.95), -1px -1px 2px rgba(0, 0, 0, 0.95);
    animation: slideCommentIn 0.22s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

.chat-message strong {
    color: var(--color-gold);
    font-family: var(--font-heading);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chat-league-badge {
    display: inline-flex;
    align-items: center;
    height: 15px;
    padding: 0 5px;
    border: 1px solid rgba(255, 213, 79, 0.55);
    border-radius: 4px;
    background: rgba(10, 12, 22, 0.68);
    color: #fff4c2;
    font-family: var(--font-body);
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
}

.chat-league-badge.league-iron {
    border-color: rgba(159, 168, 176, 0.62);
    background: linear-gradient(180deg, rgba(68, 78, 84, 0.72), rgba(22, 27, 29, 0.78));
    color: #dce3e6;
}

.chat-league-badge.league-silver {
    border-color: rgba(215, 226, 234, 0.78);
    background: linear-gradient(180deg, rgba(142, 158, 170, 0.7), rgba(43, 52, 60, 0.78));
    color: #f1f7fb;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
}

.chat-league-badge.league-gold {
    border-color: rgba(255, 213, 79, 0.86);
    background: linear-gradient(180deg, rgba(255, 179, 0, 0.76), rgba(92, 55, 0, 0.82));
    color: #fff8d6;
    box-shadow: 0 0 6px rgba(255, 179, 0, 0.22), inset 0 1px 0 rgba(255,255,255,0.2);
}

.chat-league-badge.league-master {
    border-color: rgba(128, 222, 234, 0.88);
    background: linear-gradient(180deg, rgba(0, 188, 212, 0.58), rgba(17, 43, 78, 0.82));
    color: #dbfbff;
    box-shadow: 0 0 7px rgba(0, 229, 255, 0.22);
}

.chat-league-badge.league-legend {
    border-color: rgba(255, 128, 171, 0.9);
    background: linear-gradient(180deg, rgba(171, 71, 188, 0.72), rgba(74, 20, 140, 0.88));
    color: #ffe6f1;
    box-shadow: 0 0 8px rgba(255, 64, 129, 0.28), inset 0 1px 0 rgba(255,255,255,0.18);
}

.chat-message span {
    color: #fff;
    word-break: break-word;
}

.chat-message.system strong {
    color: var(--color-cyan);
}

.chat-message.system.unread span {
    color: #fff4c2;
}

.chat-message.raid-blocked {
    border-left: 3px solid var(--color-cyan);
    background: rgba(0, 200, 200, 0.06);
}

.notif-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin: 2px 4px 2px 0;
    font-weight: 700;
    vertical-align: middle;
}

.badge-ward {
    background: rgba(0, 180, 200, 0.25);
    color: #4ae0f0;
    border: 1px solid rgba(0, 180, 200, 0.5);
}

.badge-shield {
    background: rgba(100, 200, 100, 0.2);
    color: #7de87d;
    border: 1px solid rgba(100, 200, 100, 0.4);
}

.chat-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 6px;
    padding: 4px;
    border-top: none;
    background: transparent;
}

.chat-input-row input {
    min-width: 0;
    height: 30px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 6px;
    background: rgba(0,0,0,0.35);
    color: #fff;
    padding: 0 8px;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.95);
}

.chat-input-row .game-btn {
    padding: 6px 8px;
    font-size: 10px;
}

/* Rival Info Card overlay (floating on the right) */
.rival-card-overlay {
    position: absolute;
    top: 86px;
    right: 8px;
    width: 230px;
    background: rgba(10, 12, 22, 0.65);
    border: 2.5px solid #2d1e12;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
    pointer-events: auto;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.15),
                height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.15),
                max-height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.15),
                padding 0.3s ease,
                right 0.3s ease,
                border-radius 0.3s ease,
                background-color 0.3s ease,
                opacity 0.3s ease,
                transform 0.2s ease;
}

.rival-card-header {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 900;
    color: var(--color-elixir);
    letter-spacing: 0;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(83, 99, 163, 0.45);
    padding-bottom: 3px;
    transition: filter 0.2s ease;
}
.rival-card-header:hover {
    filter: brightness(1.3);
}

.rival-card-body {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.rival-img-container {
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    background: #090a12;
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.rival-img-status {
    font-size: 8px;
    color: var(--color-text-dark);
    padding: 2px;
    text-align: center;
    line-height: 1.1;
}

.rival-meta {
    flex: 1;
    min-width: 0;
}

.rival-meta h4 {
    font-family: var(--font-heading);
    font-size: 11px;
    color: var(--color-elixir);
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rival-doctrine {
    font-size: 8px;
    color: var(--color-text-dark);
    line-height: 1.2;
    max-height: 24px;
    overflow-y: auto;
    margin-bottom: 4px;
}

.rival-specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    border-top: 1px dashed rgba(255,255,255,0.08);
    padding-top: 4px;
}

.rival-specs-grid span {
    font-size: 8px;
    color: var(--color-text-dark);
}

.rival-specs-grid strong {
    color: #fff;
    margin-left: 1px;
}

/* Radar scanning overlay */
.match-radar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(7, 8, 15, 0.95);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-sweep {
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    border: 1px solid rgba(0, 229, 255, 0.2);
    background: conic-gradient(from 0deg, rgba(0, 229, 255, 0.15) 0deg, transparent 180deg);
    animation: rotateSweep 2s linear infinite;
}

.radar-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.radar-ping {
    width: 18px;
    height: 18px;
    background: var(--color-cyan);
    border-radius: 50%;
    margin: 0 auto 16px;
    position: relative;
}

.radar-ping::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    border: 2px solid var(--color-cyan);
    animation: pingRipple 1s ease-out infinite;
}

.radar-content h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: #fff;
    margin-bottom: 4px;
}

.radar-status {
    font-size: 11px;
    color: var(--color-cyan);
    font-family: var(--font-mono);
}

/* Battle Stats HUD Layer (floating top center below resources) */
.battle-progress-overlay {
    position: absolute;
    top: 82px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0;
    z-index: 10;
    pointer-events: none;
    overflow: hidden;
    background: var(--hud-stone-dark);
    border: 3px solid var(--hud-rim);
    border-radius: 14px;
    box-shadow: var(--hud-shadow), 0 0 0 1px rgba(197,160,89,0.12);
}

.battle-stat-badge {
    background: transparent;
    border: none;
    border-right: 2px solid rgba(83, 99, 163, 0.55);
    border-radius: 0;
    padding: 6px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: none;
    backdrop-filter: blur(10px);
    min-width: 80px;
}

.battle-stat-badge.duration {
    border-right: none;
    background: rgba(0, 229, 255, 0.07);
}

.battle-stat-badge .lbl {
    font-size: 8px;
    color: var(--color-text-dark);
    text-transform: uppercase;
}

.battle-stat-badge .val {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
}

body.battle-mode .player-profile,
body.battle-mode .tank,
body.battle-mode .hud-btn {
    border-color: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 0 rgba(0,0,0,0.45), 0 8px 18px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.18);
}

body.battle-mode .battle-progress-overlay {
    top: 16px;
    min-width: 310px;
    border-color: rgba(255, 255, 255, 0.78);
    background: linear-gradient(180deg, rgba(38, 42, 35, 0.94), rgba(11, 12, 10, 0.96));
}

body.battle-mode .battle-stat-badge {
    min-width: 96px;
    padding: 5px 18px;
}

body.battle-mode .battle-stat-badge .lbl {
    font-size: 8px;
    color: rgba(229, 236, 219, 0.62);
}

body.battle-mode .battle-stat-badge .val {
    font-size: 15px;
}


body.battle-mode .rival-card-overlay {
    top: 132px;
    right: 8px;
    width: 240px;
    border-color: rgba(255, 255, 255, 0.7);
    background: linear-gradient(180deg, rgba(30, 22, 25, 0.92), rgba(8, 7, 7, 0.94));
}

body.battle-mode .rival-img-container {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
}

body.battle-mode .rival-doctrine {
    max-height: 28px;
}


body.battle-mode .rival-card-overlay.collapsed {
    width: 38px !important;
    height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    right: 0 !important;
    border-radius: 10px 0 0 10px !important;
    border-right: none !important;
    cursor: pointer;
    overflow: hidden;
}

body.battle-mode .rival-card-overlay.collapsed .rival-card-header {
    border-bottom: none !important;
    padding: 0 !important;
    font-size: 16px !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.battle-mode .rival-card-overlay.collapsed .rival-card-header .header-text,
body.battle-mode .rival-card-overlay.collapsed .rival-card-header .collapse-icon {
    display: none !important;
}

body.battle-mode .rival-card-overlay.collapsed .rival-card-body {
    display: none !important;
}

/* Hover glows for collapsed tabs */

body.battle-mode .rival-card-overlay.collapsed:hover {
    background: rgba(216, 27, 96, 0.2) !important;
    border-color: var(--color-elixir) !important;
    box-shadow: 0 0 12px rgba(216, 27, 96, 0.5) !important;
    transform: scale(1.05);
}

/* Victory / Defeat Splash Overlay */
.splash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(7, 8, 15, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.splash-card {
    background: linear-gradient(135deg, rgba(23, 26, 43, 0.98) 0%, rgba(12, 14, 24, 0.98) 100%);
    border: 2.5px solid var(--border-gold);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(197, 160, 89, 0.4);
    border-radius: 24px;
    padding: 36px;
    width: 340px;
    text-align: center;
    animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.victory-ribbon {
    background: linear-gradient(180deg, var(--color-gold-glow) 0%, #ff8f00 100%);
    color: #000;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 20px;
    padding: 8px 24px;
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(255, 179, 0, 0.4);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.splash-card .stars {
    font-size: 26px;
    letter-spacing: 4px;
    margin: 14px 0;
    animation: pulseGlow 1.5s infinite alternate ease-in-out;
}

.result-desc {
    font-size: 12.5px;
    color: var(--color-text-dark);
    line-height: 1.5;
    margin-bottom: 24px;
}

/* 3. FLOATING HUD BOTTOM (Drawer deck layout) */
.hud-bottom {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 760px);
    z-index: 10;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    transition: transform 0.28s ease, bottom 0.28s ease;
}

.drawer-toggle {
    position: relative;
    z-index: 2;
    width: 48px;
    height: 18px;
    margin-bottom: -3px;
    border: 2.5px solid #2d1e12;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: rgba(10, 12, 22, 0.85);
    color: var(--color-gold);
    box-shadow: 0 -3px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 11px;
    line-height: 1;
    transition: var(--transition-fast);
}

.drawer-toggle:hover {
    border-color: var(--border-gold);
    color: #fff;
}

.toggle-rune {
    transform: translateY(-1px);
}

.deck-drawer {
    width: 100%;
    background: rgba(10, 12, 22, 0.65);
    border: 3.5px solid #2d1e12;
    border-radius: 18px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.65), inset 0 2px 4px rgba(255,255,255,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
    pointer-events: auto;
    transition: opacity 0.22s ease, transform 0.28s ease, max-height 0.28s ease;
}

.drawer-tabs {
    display: flex;
    border-bottom: 2px solid #2d1e12;
    background: linear-gradient(180deg, rgba(20, 24, 40, 0.9), rgba(10, 12, 22, 0.95));
}

.tab-btn {
    min-height: 30px;
    padding: 4px 14px;
    background: transparent;
    border: none;
    border-right: 2px solid #2d1e12;
    color: var(--color-text-dark);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(180deg, rgba(108, 140, 255, 0.3), rgba(58, 80, 188, 0.45));
    box-shadow: inset 0 -3px 0 var(--color-gold);
}

.tab-btn:hover {
    color: #fff;
}

.drawer-content {
    padding: 8px 10px 10px;
    display: none;
    max-height: 108px;
    overflow-y: auto;
}

.drawer-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out forwards;
}

.hud-bottom.collapsed {
    bottom: 8px;
}

.hud-bottom.collapsed .deck-drawer {
    max-height: 0;
    opacity: 0;
    transform: translateY(20px) scaleY(0.9);
    pointer-events: none;
    border-width: 0;
}

.hud-bottom.collapsed .drawer-toggle {
    width: 56px;
    height: 22px;
    margin-bottom: 0;
    border: 2.5px solid #2d1e12;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

/* Upgrades Building list */
.cards-grid {
    display: flex;
    gap: 8px;
    padding-bottom: 4px;
}

.scroll-x {
    overflow-x: auto;
    flex-wrap: nowrap;
}

.building-card {
    flex: 0 0 140px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid #2d1e12;
    border-radius: 10px;
    padding: 5px;
    display: flex;
    gap: 6px;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.building-card:hover {
    border-color: var(--color-gold);
    background: rgba(255, 213, 79, 0.1);
}

.building-card.locked,
.troop-card.locked,
.shop-item-card.locked {
    opacity: 0.58;
    filter: grayscale(0.7);
}

.building-card.locked:hover,
.troop-card.locked:hover,
.shop-item-card.locked:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.45);
    transform: none;
}

.unlock-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 20px;
    border: 1px solid rgba(255, 213, 79, 0.28);
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(0, 0, 0, 0.48);
    color: #ffd54f;
    font-family: var(--font-heading);
    font-size: 9px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.card-thumb-wrap {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
}

.building-card .card-thumb-wrap {
    position: relative;
}

.building-card .card-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 400%;
    height: 400%;
    object-fit: contain;
}

.card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-details {
    flex: 1;
    overflow: hidden;
}

.card-details h4 {
    font-family: var(--font-heading);
    font-size: 10px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-details p {
    font-size: 8px;
    color: var(--color-text-dark);
    margin: 1px 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Deploy Prep View */
.deploy-view {
    display: flex;
    gap: 12px;
    align-items: center;
    height: 100%;
}

.train-view {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    height: 100%;
    align-items: stretch;
}


.troop-deploy-deck {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.troop-card {
    flex: 0 0 85px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid #2d1e12;
    border-radius: 10px;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.troop-card .card-thumb-wrap {
    width: 28px;
    height: 28px;
}

.troop-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    font-weight: 700;
}

.troop-card input[type="range"] {
    width: 100%;
    height: 3px;
    accent-color: var(--color-cyan);
    cursor: pointer;
}

.train-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
}

.train-actions .btn-train {
    grid-column: span 3;
    min-height: 26px;
}

.train-quick-btn {
    min-height: 22px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 6px;
    background: rgba(255, 179, 0, 0.13);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 9px;
    cursor: pointer;
}

.train-quick-btn:hover:not(:disabled) {
    border-color: var(--color-gold);
    background: rgba(255, 179, 0, 0.24);
}

.train-quick-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

.deploy-actions {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.deploy-all-btn {
    height: 28px;
    font-size: 10px !important;
}

.start-battle-btn {
    height: 38px;
    font-size: 11px !important;
}

/* Doctrine Editor View */
.doctrine-view {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
}

.doctrine-header h4 {
    font-family: var(--font-heading);
    font-size: 11px;
    color: var(--color-gold);
}

.doctrine-header p {
    font-size: 8px;
    color: var(--color-text-dark);
}

.doctrine-view textarea {
    flex: 1;
    background: rgba(0,0,0,0.35);
    border: 1.5px solid var(--border-steel);
    border-radius: 10px;
    padding: 8px 12px;
    color: #fff;
    font-size: 11px;
    font-family: var(--font-body);
    resize: none;
    outline: none;
    min-height: 60px;
    transition: var(--transition-fast);
}

.doctrine-view textarea:focus {
    border-color: var(--color-gold);
}

.doctrine-view .layout-intent-input {
    flex: 0 0 62px;
    min-height: 58px;
    font-size: 12px;
    border-color: rgba(128, 222, 234, 0.45);
    background: rgba(4, 14, 18, 0.58);
}

/* 4. ACTIVE COMBAT DRAWER */
.battle-console-layout {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 14px;
    height: 100%;
    padding: 2px 6px 0;
    align-items: center;
}

.spells-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spells-section h5, .command-terminal-section h5 {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gold);
    text-transform: uppercase;
    white-space: nowrap;
}

.spells-grid {
    display: flex;
    gap: 7px;
    flex: 1;
}

.spell-btn-card {
    flex: 1;
    min-width: 0;
    background: linear-gradient(180deg, rgba(34, 22, 38, 0.85), rgba(7, 8, 10, 0.9));
    border: 2px solid rgba(83, 99, 163, 0.72);
    border-radius: 10px;
    padding: 5px 6px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.spell-btn-card:hover {
    border-color: var(--color-elixir);
    box-shadow: 0 0 10px rgba(216, 27, 96, 0.3), inset 0 0 0 1px rgba(255,255,255,0.08);
    transform: translateY(-1px);
}

.spell-btn-card img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
}

.spell-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.spell-meta .name {
    font-size: 9px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52px;
}

.spell-meta .cost {
    font-size: 8px;
    font-family: var(--font-mono);
    color: var(--color-elixir);
    font-weight: 700;
}

.command-terminal-section {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.terminal-input-wrap {
    display: flex;
    gap: 8px;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.terminal-input-wrap input {
    flex: 1;
    height: 36px;
    background: rgba(0,0,0,0.52);
    border: 2px solid rgba(83, 99, 163, 0.72);
    border-radius: 10px;
    padding: 0 14px;
    color: #fff;
    font-size: 11px;
    outline: none;
    transition: var(--transition-fast);
}

.terminal-input-wrap input:focus {
    border-color: var(--color-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.terminal-input-wrap button {
    height: 36px;
    padding: 0 16px;
    font-size: 11px !important;
    white-space: nowrap;
}

body.battle-mode .hud-bottom {
    width: min(92vw, 760px);
    bottom: 8px;
}

body.battle-mode #battle-drawer {
    max-height: 80px;
    border-color: #2d1e12;
    background: rgba(10, 12, 22, 0.85);
}

body.battle-mode .battle-console-layout {
    min-height: 56px;
    padding: 4px 8px 8px;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 8px;
}

body.battle-mode .spells-section,
body.battle-mode .command-terminal-section {
    background: rgba(0,0,0,0.22);
    border: 2px solid #2d1e12;
    border-radius: 8px;
    padding: 4px 6px;
    height: 100%;
}

body.battle-mode .spells-grid {
    gap: 4px;
}

body.battle-mode .spell-btn-card {
    min-height: 38px;
    border-color: #2d1e12;
    background: rgba(20, 10, 25, 0.7);
    padding: 3px 4px;
}

body.battle-mode .spell-btn-card img {
    width: 22px;
    height: 22px;
}

body.battle-mode .spell-meta .name {
    font-size: 8px;
    max-width: 44px;
}

body.battle-mode .spell-meta .cost {
    font-size: 7px;
}

body.battle-mode .terminal-input-wrap input {
    height: 28px;
    border-color: #2d1e12;
    padding: 0 8px;
    font-size: 10px;
}

body.battle-mode .terminal-input-wrap button {
    height: 28px;
    font-size: 10px !important;
}

body.battle-mode .hud-bottom.collapsed {
    bottom: 8px;
}

body.battle-mode .hud-bottom.collapsed #battle-drawer {
    max-height: 0;
    height: 0;
    opacity: 0;
    transform: translateY(20px) scaleY(0.9);
    pointer-events: none;
    border-width: 0;
}

/* 5. GAME BUTTONS (Premium Gamified UI look) */
/* 5. GAME BUTTONS (Premium Gamified UI look) */
.game-btn {
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 12px;
    padding: 8px 16px;
    cursor: pointer;
    outline: none;
    border: 3.5px solid #2d1e12;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(180deg, #6c8cff 0%, #3a50bc 100%);
    color: #fff;
    box-shadow: 0 5px 0 #1b2660, 0 6px 10px rgba(0,0,0,0.4);
    position: relative;
    top: 0;
}

.game-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 0 #1b2660, 0 8px 12px rgba(0,0,0,0.45);
}

.game-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #1b2660, 0 3px 6px rgba(0,0,0,0.3);
}

.btn-gold {
    background: linear-gradient(180deg, #ffca28 0%, #ff8f00 100%);
    color: #fff;
    box-shadow: 0 5px 0 #854a00, 0 6px 10px rgba(0,0,0,0.4);
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.5);
}

.btn-gold:hover {
    box-shadow: 0 6px 0 #854a00, 0 8px 12px rgba(0,0,0,0.45), 0 0 10px rgba(255, 179, 0, 0.4);
}

.btn-gold:active {
    box-shadow: 0 2px 0 #854a00, 0 3px 6px rgba(0,0,0,0.3);
}

.btn-cyan {
    background: linear-gradient(180deg, #00e5ff 0%, #00b0ff 100%);
    color: #fff;
    box-shadow: 0 5px 0 #006064, 0 6px 10px rgba(0,0,0,0.4);
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.5);
}

.btn-cyan:hover {
    box-shadow: 0 6px 0 #006064, 0 8px 12px rgba(0,0,0,0.45), 0 0 10px rgba(0, 229, 255, 0.4);
}

.btn-cyan:active {
    box-shadow: 0 2px 0 #006064, 0 3px 6px rgba(0,0,0,0.3);
}

.btn-red {
    background: linear-gradient(180deg, #ff5f57 0%, #c62828 100%);
    color: #fff;
    box-shadow: 0 5px 0 #651515, 0 6px 10px rgba(0,0,0,0.4);
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.5);
}

.btn-red:hover {
    box-shadow: 0 6px 0 #651515, 0 8px 12px rgba(0,0,0,0.45), 0 0 10px rgba(255, 95, 87, 0.35);
}

.settings-version-check-btn,
.account-switch-btn {
    width: 100%;
    margin-top: 10px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 6px;
}

/* Floating canvas bubble above upgrade node */
.floating-upgrade-bubble {
    position: absolute;
    background: rgba(14, 17, 30, 0.95);
    border: 1.5px solid var(--border-gold);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6), 0 0 12px rgba(197, 160, 89, 0.2);
    backdrop-filter: blur(8px);
    z-index: 50;
    min-width: 150px;
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.floating-upgrade-bubble h5 {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-gold);
    margin-bottom: 2px;
}

.floating-upgrade-bubble p {
    font-size: 10px;
    color: var(--color-text-dark);
    margin-bottom: 8px;
}

.upgrade-worker-status {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    margin-left: 0;
    padding: 4px 12px;
    border: 2px solid #2d1e12;
    border-radius: 99px;
    background: linear-gradient(180deg, rgba(22, 25, 22, 0.86), rgba(9, 11, 10, 0.82));
    color: #ffe082;
    pointer-events: auto;
    font-weight: 800;
    font-size: 11px;
    line-height: 1.15;
    text-shadow: -1px -1px 0 #2d1e12, 1px -1px 0 #2d1e12, -1px 1px 0 #2d1e12, 1px 1px 0 #2d1e12;
    box-shadow: 0 4px 10px rgba(0,0,0,0.45), inset 0 1px 2px rgba(255,255,255,0.12);
    backdrop-filter: blur(12px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.upgrade-worker-status::before {
    content: "🔨";
    width: 22px;
    height: 22px;
    margin-right: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid #2d1e12;
    background: linear-gradient(135deg, #ffd54f 0%, #ff8f00 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.36);
}

/* 6. MODALS (CSS Native Dialog) */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(7, 9, 13, 0.72), rgba(5, 6, 9, 0.9)),
        url("assets/ui/map_bg.png") center / cover no-repeat;
}

.auth-card {
    width: min(440px, calc(100vw - 32px));
    border: 3px solid #26335f;
    border-bottom-color: #11182f;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(24, 28, 42, 0.98), rgba(9, 11, 17, 0.98));
    box-shadow: 0 18px 50px rgba(0,0,0,0.58), inset 0 1px 0 rgba(255,255,255,0.08);
    padding: 18px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.auth-brand img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    border: 3px solid var(--color-cyan);
    object-fit: cover;
}

.auth-brand h1 {
    margin: 0;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 22px;
}

.auth-brand p {
    margin-top: 4px;
    color: var(--color-text-dark);
    font-size: 12px;
}

.auth-provider-btn {
    width: 100%;
    min-height: 44px;
    margin-top: 6px;
}

.auth-message {
    min-height: 18px;
    margin-top: 12px;
    color: var(--color-text-dark);
    font-size: 11px;
    line-height: 1.4;
}

.auth-message.error {
    color: #ff8a80;
}

body.auth-locked .game-container {
    pointer-events: none;
    filter: blur(2px) saturate(0.75);
}

.game-modal {
    margin: auto;
    background: transparent;
    border: none;
    outline: none;
}

.game-modal::backdrop {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-card {
    background: rgba(14, 16, 28, 0.98);
    border: 2px solid var(--border-steel);
    border-radius: 20px;
    width: 420px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.leaderboard-modal-card {
    width: min(760px, calc(100vw - 32px));
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1.5px solid var(--border-steel);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--color-gold);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-dark);
    font-size: 20px;
    cursor: pointer;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.celebration-modal-card {
    width: min(560px, calc(100vw - 28px));
}

.celebration-body {
    gap: 14px;
}

.celebration-hero {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.celebration-hero img {
    width: 74px;
    height: 74px;
    object-fit: contain;
    border: 2px solid rgba(255, 213, 79, 0.3);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.32);
}

.celebration-kicker {
    margin: 0 0 6px;
    color: var(--color-gold);
    font-family: var(--font-heading);
    font-size: 12px;
    text-transform: uppercase;
}

#celebration-subtitle {
    margin: 0;
    color: var(--color-text);
    font-size: 13px;
    line-height: 1.45;
}

.celebration-sections,
.celebration-section {
    display: grid;
    gap: 10px;
}

.celebration-section h4 {
    margin: 0;
    color: var(--color-cyan);
    font-family: var(--font-heading);
    font-size: 12px;
}

.celebration-unlock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 8px;
}

.celebration-unlock-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.28);
}

.celebration-unlock-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: rgba(255, 213, 79, 0.11);
    font-size: 18px;
}

.celebration-unlock-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.celebration-unlock-item strong {
    min-width: 0;
    color: #fff;
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.celebration-growth-list {
    display: grid;
    gap: 6px;
}

.celebration-growth-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--color-text);
    font-size: 12px;
}

.celebration-growth-row strong {
    color: var(--color-gold);
    text-align: right;
}

.setting-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-field label {
    font-size: 11px;
    color: var(--color-text-dark);
    font-weight: 600;
}

.setting-field input {
    height: 36px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-steel);
    border-radius: 8px;
    color: #fff;
    padding: 0 12px;
    font-size: 11px;
    outline: none;
}

.setting-field input:focus {
    border-color: var(--color-cyan);
}

.rename-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.rename-control .game-btn {
    min-width: 118px;
    padding: 8px 10px;
    font-size: 10px;
}

.hint-text {
    font-size: 10px;
    color: var(--color-text-dark);
    line-height: 1.4;
}

/* My Profile Dialog */
.my-profile-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0 16px;
    border-bottom: 1px solid var(--border-steel);
    margin-bottom: 4px;
}
.my-profile-avatar {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    position: relative;
}
#player-avatar-container {
    cursor: pointer;
}
.my-profile-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.my-profile-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-gold);
    letter-spacing: 0.5px;
}
.my-profile-meta {
    font-size: 12px;
    color: var(--color-text-dark);
}

/* Settings info table */
.settings-info-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-steel);
    border-radius: 6px;
    padding: 10px 14px;
}
.settings-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-dark);
}
.settings-info-row span:last-child {
    color: var(--color-text);
    text-align: right;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1.5px solid var(--border-steel);
    display: flex;
    justify-content: flex-end;
}

.leaderboard-body {
    gap: 10px;
    max-height: min(68vh, 620px);
}

.leaderboard-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 213, 79, 0.35);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(47, 37, 12, 0.82), rgba(16, 14, 10, 0.92));
    color: #fff4c2;
    font-family: var(--font-heading);
    font-size: 12px;
}

.leaderboard-summary:empty {
    display: none !important;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    padding-right: 4px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 36px 34px 1fr 76px 54px 68px;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 6px 12px;
    border: 2px solid #2d1e12;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(25, 29, 44, 0.8) 0%, rgba(13, 15, 25, 0.9) 100%);
    box-shadow: 0 4px 0 #120e0a, inset 0 1px 2px rgba(255, 255, 255, 0.08);
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.leaderboard-row.is-human:not(.is-player) {
    cursor: pointer;
}

.leaderboard-row.is-human:not(.is-player):hover {
    border-color: var(--color-cyan);
    background: linear-gradient(180deg, rgba(34, 40, 60, 0.85) 0%, rgba(18, 21, 33, 0.95) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #120e0a, 0 6px 12px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.1);
}

.leaderboard-row.is-player {
    border-color: var(--border-gold);
    background: linear-gradient(180deg, rgba(57, 42, 10, 0.95) 0%, rgba(18, 15, 10, 0.98) 100%);
    box-shadow: 0 4px 0 #120e0a, 0 0 10px rgba(255, 179, 0, 0.25), inset 0 1px 2px rgba(255,255,255,0.1);
}

.online-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 10px;
    font-family: var(--font-heading);
    color: var(--color-text-muted);
    background: rgba(4, 8, 18, 0.65);
    white-space: nowrap;
}

.online-status i,
.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    background: #111827;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
}

.online-status.online i,
.online-dot.online {
    background: #1ee36d;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 0 8px rgba(30,227,109,0.65);
}

.online-status.online {
    color: #fff;
}

.online-status.offline i,
.online-dot.offline {
    background: #0b1020;
}

.online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    border: 1px solid #111827;
}

.leaderboard-rank {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text-dark);
    text-align: center;
}

.leaderboard-row:nth-child(1) .leaderboard-rank {
    color: #ffd54f;
    font-size: 18px;
    font-weight: 900;
    text-shadow: 0 0 8px rgba(255, 213, 79, 0.6);
}

.leaderboard-row:nth-child(2) .leaderboard-rank {
    color: #e2e8f0;
    font-size: 16px;
    font-weight: 900;
}

.leaderboard-row:nth-child(3) .leaderboard-rank {
    color: #b97a57;
    font-size: 15px;
    font-weight: 900;
}

.leaderboard-avatar-wrapper {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaderboard-agent {
    min-width: 0;
}

.leaderboard-agent-header {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
}

.leaderboard-agent-header strong {
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.leaderboard-agent > span {
    display: block;
    color: var(--color-text-dark);
    font-size: 10px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-trophies,
.leaderboard-level,
.leaderboard-form {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text);
    text-align: right;
}

.leaderboard-trophies {
    font-weight: 700;
    color: var(--color-gold);
}

.leaderboard-level {
    color: var(--color-cyan);
    font-weight: 600;
}

.leaderboard-form {
    font-weight: 700;
}

.leaderboard-form.positive {
    color: var(--color-green);
}

.leaderboard-form.negative {
    color: var(--color-elixir);
}

.friends-modal-card {
    max-width: min(620px, 92vw);
}

.friends-body {
    gap: 10px;
    max-height: min(68vh, 620px);
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

/* Friend search */
.friend-search-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 16px 8px;
    border-bottom: 1px solid var(--border-steel);
}
.friend-search-bar input {
    background: rgba(0,0,0,0.3);
    border: 1.5px solid var(--border-steel);
    border-radius: 6px;
    color: var(--color-text);
    font-family: var(--font-heading);
    font-size: 11px;
    padding: 6px 10px;
    outline: none;
}
.friend-search-bar input:focus {
    border-color: var(--color-cyan);
}
.friend-search-results {
    border-bottom: 1px solid var(--border-steel);
    background: rgba(0, 220, 255, 0.04);
    max-height: 180px;
    overflow-y: auto;
}
.search-hint {
    padding: 10px 16px;
    font-size: 11px;
    color: var(--color-text-dark);
}

.friend-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 8px 10px;
    border: 1px solid rgba(46, 53, 92, 0.9);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(24, 28, 42, 0.96), rgba(10, 12, 18, 0.98));
}

.friend-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-cyan);
    background: rgba(0, 229, 255, 0.12);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 700;
}

.friend-main {
    min-width: 0;
}

.friend-main strong,
.friend-main span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-main strong {
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
}

.friend-main span,
.empty-friends {
    color: var(--color-text-dark);
    font-size: 10px;
}

.friend-actions {
    display: flex;
    gap: 6px;
}

.mini-action {
    min-width: 44px;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 6px;
    background: rgba(0, 229, 255, 0.12);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 10px;
    cursor: pointer;
}

.mini-action.accept {
    background: rgba(0, 230, 118, 0.18);
}

.mini-action.reject {
    background: rgba(216, 27, 96, 0.18);
}

.mini-action:disabled {
    cursor: default;
    opacity: 0.58;
}

.announcements-modal-card {
    width: min(820px, calc(100vw - 32px));
}

.announcements-body {
    gap: 10px;
    max-height: min(72vh, 660px);
}

.announcement-sections {
    display: grid;
    grid-template-columns: 1fr 1.05fr;
    gap: 12px;
    min-height: 0;
}

.announcement-section {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-title {
    color: var(--color-gold);
    font-family: var(--font-heading);
    font-size: 12px;
}

.announcement-list,
.event-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 3px;
}

.announcement-card,
.event-card {
    padding: 10px 11px;
    border: 1px solid rgba(46, 53, 92, 0.9);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(24, 28, 42, 0.96), rgba(10, 12, 18, 0.98));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.event-card.claimed {
    opacity: 0.72;
}

.announcement-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.announcement-card-head strong {
    min-width: 0;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.announcement-card-head span {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 213, 79, 0.35);
    color: #fff4c2;
    font-size: 9px;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.announcement-card p,
.event-card p {
    margin: 0;
    color: var(--color-text);
    font-size: 11px;
    line-height: 1.55;
}

.announcement-card small {
    display: block;
    margin-top: 8px;
    color: var(--color-text-dark);
    font-size: 9px;
}

.event-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 8px 0;
    color: var(--color-text-dark);
    font-size: 10px;
}

.event-card .mini-action {
    width: 100%;
}

.base-preview-banner {
    position: absolute;
    left: 50%;
    top: 70px;
    transform: translateX(-50%);
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 14px;
    border: 2px solid var(--border-gold);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(47, 37, 12, 0.94), rgba(16, 14, 10, 0.96));
    box-shadow: var(--hud-shadow);
    color: #fff4c2;
    font-family: var(--font-heading);
    pointer-events: auto;
}

.base-preview-banner .game-btn {
    padding: 7px 10px;
    font-size: 10px;
}

.player-profile-modal-card {
    max-width: min(560px, 92vw);
}

.player-profile-body {
    gap: 12px;
}

.player-profile-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.player-profile-stat,
.player-base-cell {
    border: 1px solid rgba(46, 53, 92, 0.9);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(24, 28, 42, 0.96), rgba(10, 12, 18, 0.98));
    padding: 9px 10px;
}

.player-profile-stat span,
.player-base-cell span {
    display: block;
    color: var(--color-text-dark);
    font-size: 10px;
}

.player-profile-stat strong,
.player-base-cell strong {
    display: block;
    margin-top: 3px;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
}

.player-base-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

/* Helpers & Colors */
.text-cyan { color: var(--color-cyan) !important; }
.text-elixir { color: var(--color-elixir) !important; }
.text-gold { color: var(--color-gold) !important; }
.hidden { display: none !important; }

/* 7. ANIMATIONS KEYFRAMES */
@keyframes rotateSweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pingRipple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(3.5); opacity: 0; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes bounceSlow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes pulseGlow {
    from { transform: scale(1); filter: drop-shadow(0 0 2px rgba(255, 179, 0, 0.4)); }
    to { transform: scale(1.05); filter: drop-shadow(0 0 8px rgba(255, 179, 0, 0.8)); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 0.9; transform: scale(1.1); }
    70% { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Shake screen effect */
.screen-shake {
    animation: shakeEffect 0.3s linear;
}

@keyframes shakeEffect {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -3px); }
    20%, 40%, 60%, 80% { transform: translate(4px, 3px); }
}

/* ==========================================================================
   8. HUD DOCK & DIALOG MODAL LAYOUTS FOR ACTION BUTTONS
   ========================================================================== */

/* Floating Action Bar (HUD Dock Tray - Horizontal wrapper at the bottom right) */
.hud-dock {
    position: absolute;
    right: 10px;
    bottom: 14px;
    left: auto;
    transform: none;
    z-index: 10;
    display: flex;
    flex-direction: row;
    align-items: center; /* Vertically align button centers */
    gap: 6px;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.dock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #2d1e12;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    background: rgba(10, 12, 22, 0.75);
    box-shadow: 0 4px 0 #120e0a, 0 4px 6px rgba(0,0,0,0.4);
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    top: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    padding: 0;
    text-decoration: none;
}

.dock-download-btn {
    border-color: #23465c;
}

.dock-download-btn .icon,
.dock-download-btn .lbl {
    color: #8de0ff;
}

.dock-download-btn:hover {
    border-color: var(--color-gold);
}

.dock-btn .icon {
    font-size: 18px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    transition: transform 0.2s ease;
}

.dock-btn .lbl {
    display: none; /* Hide labels for small circular dock buttons */
}

/* 3D button press animation and colors */
.dock-btn:hover {
    transform: translateY(-3px);
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--color-cyan);
    box-shadow: 0 7px 0 #120e0a, 0 8px 12px rgba(0,0,0,0.5);
}

.dock-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #120e0a;
}

.dock-btn:hover .icon {
    transform: scale(1.15) rotate(5deg);
}

/* Highlight Deploy button in gold as the main game action (pill layout) */
#btn-open-deploy {
    width: 96px;
    height: 44px;
    border-radius: 22px; /* Pill shape */
    background: linear-gradient(180deg, #ffca28 0%, #ff8f00 100%);
    border: 2.5px solid #2d1e12;
    box-shadow: 0 4px 0 #854a00, 0 5px 9px rgba(0,0,0,0.4);
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: row;
    gap: 5px;
    padding: 0 10px;
}

#btn-open-deploy .icon {
    font-size: 20px;
}

#btn-open-deploy .lbl {
    display: block; /* Show text for main Attack action */
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.5px;
    color: #fff;
}

body.battle-mode #home-hud-dock .dock-btn:not(#btn-open-battlelog):not(#btn-open-shop) {
    display: none;
}

body.battle-mode #home-hud-dock {
    right: 10px;
    bottom: 12px;
    gap: 6px;
}

body.battle-mode #home-hud-dock .dock-btn {
    width: 38px;
    height: 38px;
}

#btn-open-deploy:hover {
    transform: translateY(-3px) scale(1.05);
    border-color: #ffd54f;
    background: linear-gradient(180deg, #ffd54f 0%, #ff8f00 100%);
    box-shadow: 0 7px 0 #854a00, 0 8px 12px rgba(255, 179, 0, 0.25);
}

#btn-open-deploy:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #854a00;
}

/* Gamified Dialog Modal Tablet */
.game-modal .modal-card {
    background: linear-gradient(180deg, #282c3c 0%, #151821 100%);
    border: 4.5px solid #2d1e12;
    border-radius: 24px;
    box-shadow: 0 12px 0 #120e0a, 0 20px 35px rgba(0,0,0,0.65), inset 0 3px 0 rgba(255, 255, 255, 0.08);
}

/* Gamified Wooden Modal Header */
.game-modal .modal-header {
    background: linear-gradient(180deg, #4c3628 0%, #2f1e14 100%);
    border-bottom: 4px solid #2d1e12;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-modal .modal-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: #fff;
    text-shadow: -1.5px -1.5px 0 #2d1e12, 1.5px -1.5px 0 #2d1e12, -1.5px 1.5px 0 #2d1e12, 1.5px 1.5px 0 #2d1e12, 0 2px 4px rgba(0,0,0,0.5);
}

/* Red 3D Game Close Button */
.game-modal .modal-close {
    background: linear-gradient(180deg, #ff5252 0%, #d32f2f 100%);
    border: 2.5px solid #2d1e12;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 0 #7b1c1c, 0 4px 6px rgba(0,0,0,0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.game-modal .modal-close:hover {
    transform: scale(1.1);
    color: #fff;
}

.game-modal .modal-close:active {
    transform: scale(0.9) translateY(2px);
    box-shadow: 0 1px 0 #7b1c1c, 0 2px 3px rgba(0,0,0,0.3);
}

.game-modal .modal-footer {
    background: rgba(0, 0, 0, 0.25);
    border-top: 4px solid #2d1e12;
    padding: 12px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Modal Content Layouts */
.wide-modal-card {
    width: min(840px, calc(100vw - 32px)) !important;
}

.game-modal {
    position: fixed;
    inset: 0;
    margin: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    padding: 12px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
}

.game-modal[open] {
    display: flex;
}

.game-modal .modal-card {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.game-modal .modal-header,
.game-modal .modal-footer {
    flex: 0 0 auto;
}

.game-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#train-dialog .modal-body,
#deploy-dialog .modal-body,
#shop-dialog .modal-body,
#inventory-dialog .modal-body,
#leaderboard-dialog .modal-body,
#friends-dialog .modal-body,
#announcements-dialog .modal-body,
#player-profile-dialog .modal-body,
#battlelog-dialog .modal-body,
#upgrades-dialog .modal-body {
    overflow: hidden;
}

#train-dialog .modal-troops-grid,
#deploy-dialog .modal-troops-grid,
#shop-dialog .shop-items-grid,
#inventory-dialog .inventory-items-grid,
#battlelog-dialog .battlelog-panel,
#upgrades-dialog .modal-cards-grid,
#leaderboard-dialog .leaderboard-list,
#friends-dialog .friends-list,
#player-profile-dialog .player-base-grid,
.announcement-list,
.event-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#train-dialog .modal-troops-grid,
#deploy-dialog .modal-troops-grid,
#shop-dialog .shop-items-grid,
#inventory-dialog .inventory-items-grid,
#battlelog-dialog .battlelog-panel,
#upgrades-dialog .modal-cards-grid,
#leaderboard-dialog .leaderboard-list,
#friends-dialog .friends-list,
#player-profile-dialog .player-base-grid {
    overflow-y: auto;
}

#leaderboard-dialog .leaderboard-body,
#friends-dialog .friends-body,
#announcements-dialog .announcements-body,
#player-profile-dialog .player-profile-body,
#battlelog-dialog .battlelog-dialog-body {
    max-height: none;
}

#upgrades-dialog .modal-body {
    flex: 0 0 auto;
}

#announcements-dialog .announcement-sections {
    flex: 1 1 auto;
    min-height: 0;
}

#announcements-dialog .announcement-section {
    min-height: 0;
}

#train-dialog .modal-troops-grid,
#deploy-dialog .modal-troops-grid {
    padding-bottom: 16px;
}

.modal-cards-grid {
    max-height: min(480px, 60vh);
    overflow-y: auto;
    padding: 16px;
}

#upgrades-dialog .modal-cards-grid {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto;
}

.vertical-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    padding: 2px;
}

/* Stone Beveled Item Cards */
.vertical-cards-grid .building-card {
    flex: unset !important;
    width: auto !important;
    height: 80px;
    background: linear-gradient(180deg, #373b4d 0%, #20222e 100%);
    border: 3px solid #2d1e12;
    border-radius: 14px;
    box-shadow: 0 4px 0 #121319, inset 0 1px 2px rgba(255,255,255,0.12);
    padding: 8px;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.vertical-cards-grid .building-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-gold);
    background: linear-gradient(180deg, #44495e 0%, #292b3a 100%);
}

.vertical-cards-grid .building-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #121319;
}

.vertical-cards-grid .building-card .card-thumb-wrap {
    width: 48px;
    height: 48px;
    border: 2px solid #2d1e12;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border-radius: 8px;
}

.vertical-cards-grid .card-details h4 {
    font-size: 11px;
    color: var(--color-gold);
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 2px;
}

/* ── Active Buff Bar ──────────────────────────────────────── */
.active-buffs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 0;
    min-height: 0;
    pointer-events: auto;
}

.buff-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: rgba(0,0,0,0.55);
    border: 1.5px solid rgba(255,213,79,0.4);
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 11px;
    font-family: var(--font-heading);
    color: #e8d97a;
    cursor: pointer;
    white-space: nowrap;
    appearance: none;
    user-select: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 0 rgba(45, 30, 18, 0.65);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.buff-badge:hover,
.buff-badge:focus-visible {
    border-color: rgba(255,213,79,0.85);
    background: rgba(0,0,0,0.72);
    outline: none;
    transform: translateY(-1px);
}

.buff-badge-row {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.buff-badge .buff-uses {
    color: #aaa;
    font-size: 10px;
}

.buff-desc {
    display: none;
    font-size: 10px;
    color: #ccc;
    line-height: 1.3;
    margin-top: 2px;
    white-space: normal;
    max-width: 160px;
}

.buff-badge.buff-expanded {
    border-color: rgba(255,213,79,0.75);
    background: rgba(0,0,0,0.75);
}

.buff-badge.buff-expanded .buff-desc {
    display: block;
}

.buff-detail-modal-card {
    width: min(460px, calc(100vw - 32px)) !important;
}

.buff-detail-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px 20px;
}

.buff-detail-hero {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    background: rgba(0,0,0,0.26);
    border: 2px solid rgba(255,213,79,0.24);
    border-radius: 14px;
    padding: 12px;
}

.buff-detail-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 205, 72, 0.95), rgba(184, 104, 10, 0.95));
    border: 3px solid #2d1e12;
    box-shadow: 0 4px 0 #6d3f06, inset 0 2px 0 rgba(255,255,255,0.25);
    font-size: 27px;
}

.buff-detail-summary {
    color: #fff7c4;
    font-family: var(--font-heading);
    font-size: 15px;
    line-height: 1.35;
    text-shadow: 1px 1px 0 #000;
}

.buff-detail-status {
    margin-top: 4px;
    color: #7ff4ff;
    font-size: 12px;
    line-height: 1.35;
}

.buff-detail-desc {
    color: #d6d9e8;
    font-size: 13px;
    line-height: 1.55;
}

.buff-effect-list {
    display: grid;
    gap: 8px;
}

.buff-effect-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    background: rgba(0,0,0,0.22);
    border: 1.5px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 9px 10px;
}

.buff-effect-row span {
    color: #9aa5c5;
    font-size: 12px;
}

.buff-effect-row strong {
    color: #fff;
    font-size: 12px;
    line-height: 1.45;
}

/* Modal Tab Navigation (Shop & Battle Log Tabs) */
.shop-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #2d1e12;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.shop-tab {
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid #2d1e12;
    border-radius: 99px; /* Rounded pill tabs */
    color: var(--color-text-dark);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.shop-tab:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.shop-tab.active {
    color: #fff;
    background: linear-gradient(180deg, #4c3628 0%, #2f1e14 100%); /* Wooden active button */
    border-color: var(--border-gold);
    box-shadow: 0 2px 4px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.1);
}

/* ── Battle Log ───────────────────────────────────────────── */
.battlelog-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
    min-height: 340px;
}

.battlelog-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 420px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 2.5px solid #2d1e12;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.8);
}

.battlelog-card {
    background: linear-gradient(180deg, rgba(25, 29, 44, 0.8) 0%, rgba(13, 15, 25, 0.9) 100%);
    border: 2.5px solid #2d1e12;
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    box-shadow: 0 4px 0 #120e0a, inset 0 1px 2px rgba(255, 255, 255, 0.08);
    transition: transform 0.15s cubic-bezier(0.25, 0.8, 0.25, 1.15), border-color 0.15s ease, background 0.15s ease;
    position: relative;
    top: 0;
}

.battlelog-card:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(34, 40, 60, 0.85) 0%, rgba(18, 21, 33, 0.95) 100%);
    border-color: var(--border-gold);
    box-shadow: 0 6px 0 #120e0a, 0 6px 12px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.battlelog-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #120e0a;
}

.battlelog-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1.5px dashed rgba(45, 30, 18, 0.4);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.battlelog-rival {
    font-family: var(--font-heading);
    font-weight: 700;
    color: #fff;
    font-size: 13px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: -1px -1px 0 #2d1e12, 1px -1px 0 #2d1e12, -1px 1px 0 #2d1e12, 1px 1px 0 #2d1e12;
}

.battlelog-outcome {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.outcome-win {
    background: linear-gradient(180deg, #00c853 0%, #009624 100%);
    color: #fff;
    border: 1.5px solid #1b5e20;
    box-shadow: 0 2px 4px rgba(0, 200, 83, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.outcome-lose {
    background: linear-gradient(180deg, #d50000 0%, #b71c1c 100%);
    color: #fff;
    border: 1.5px solid #7f0000;
    box-shadow: 0 2px 4px rgba(213, 0, 0, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.outcome-draw {
    background: linear-gradient(180deg, #ffd600 0%, #ffab00 100%);
    color: #000;
    border: 1.5px solid #ff6f00;
    box-shadow: 0 2px 4px rgba(255, 214, 0, 0.3);
    text-shadow: 0 1px 1px rgba(255,255,255,0.3);
}

.outcome-raid {
    background: linear-gradient(180deg, #ff6d00 0%, #e65100 100%);
    color: #fff;
    border: 1.5px solid #bf360c;
    box-shadow: 0 2px 4px rgba(255, 109, 0, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.outcome-blocked {
    background: linear-gradient(180deg, #00b8d4 0%, #006064 100%);
    color: #fff;
    border: 1.5px solid #004d40;
    box-shadow: 0 2px 4px rgba(0, 184, 212, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.battlelog-stars {
    color: #ffd54f;
    font-size: 13px;
    letter-spacing: 1px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.battlelog-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: 10px;
}

.battlelog-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.38);
    border: 1.5px solid #2d1e12;
    border-radius: 8px;
    padding: 3px 8px;
    color: #a0aec0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.battlelog-stat .val {
    color: #fff;
    font-weight: 700;
}

/* Value colors for specific stats based on display sequence */
.battlelog-stat:nth-child(1) .val { color: #00e5ff; } /* percent (cyan) */
.battlelog-stat:nth-child(2) .val { color: #ffca28; } /* trophy (gold) */
.battlelog-stat:nth-child(3) .val { color: #ffd54f; } /* gold reward (gold) */
.battlelog-stat:nth-child(4) .val { color: #ff80ab; } /* elixir reward (pink) */

.battlelog-time {
    font-size: 10px;
    color: var(--color-text-dark);
    margin-left: auto;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.battlelog-narrative {
    display: none;
    margin-top: 10px;
    font-size: 11px;
    color: #ebdcb9; /* Warm parchment text */
    line-height: 1.55;
    background: rgba(18, 14, 10, 0.85); /* Antique scroll style background */
    border-left: 3px solid var(--color-gold);
    border-radius: 6px;
    padding: 10px 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.3);
    font-family: var(--font-body);
    text-shadow: 0 1px 1px rgba(0,0,0,0.9);
}

.battlelog-card.expanded .battlelog-narrative {
    display: block;
}

.battlelog-card.is-new {
    border-color: var(--color-cyan);
    box-shadow: 0 4px 0 #120e0a, 0 0 10px rgba(0, 220, 255, 0.15);
}
.battlelog-card.is-new::before {
    content: "NEW";
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--color-cyan);
    background: rgba(0, 220, 255, 0.12);
    border: 1px solid rgba(0, 220, 255, 0.35);
    border-radius: 4px;
    padding: 1px 5px;
}

/* Dock button unread dot */
#btn-open-battlelog {
    position: relative;
}
#btn-open-battlelog.has-badge::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff3b3b;
    border: 1.5px solid #1a0c0c;
    animation: pulse-badge 1.5s ease-in-out infinite;
}
@keyframes pulse-badge {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.8; }
}

.battlelog-empty {
    text-align: center;
    color: var(--color-text-dark);
    padding: 50px 0;
    font-size: 13px;
    font-family: var(--font-heading);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ── Shop & Inventory ─────────────────────────────────────── */
.shop-dialog-body,
.inventory-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
}

/* Split Shop & Inventory Grid */
.shop-items-grid,
.inventory-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
    gap: 16px;
    overflow-y: auto;
    max-height: 58vh;
    padding: 10px 4px;
}

/* Base card styling */
.shop-item-card {
    position: relative;
    background: linear-gradient(135deg, rgba(20, 24, 38, 0.95), rgba(10, 12, 18, 0.98));
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5px;
    transition: transform 0.22s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.22s, border-color 0.22s;
    cursor: default;
    overflow: hidden;
}

.shop-item-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
}

/* Card inner styling */
.item-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: rgba(14, 17, 27, 0.96);
    border-radius: 10px;
    padding: 14px 10px;
    height: 100%;
    min-height: 204px;
    justify-content: space-between;
    box-sizing: border-box;
}

/* Card Icon/Emoji Wrapper */
.item-card-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    margin-bottom: 6px;
    transition: transform 0.3s ease;
}

.shop-item-card:hover .item-card-icon-wrapper {
    transform: scale(1.12);
}

.item-card-emoji {
    font-size: 32px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* Card Details */
.item-card-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    margin-bottom: 10px;
}

.item-card-name {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.item-card-desc {
    font-size: 10px;
    color: #8892b0;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 28px;
}

/* Card Quantity Badge (for Inventory) */
.item-card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, var(--color-cyan, #00e5ff), #00b0ff);
    color: #000;
    font-size: 9px;
    font-weight: 800;
    font-family: var(--font-mono);
    padding: 2px 6px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 2;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Card Action Button */
.item-card-action {
    width: 100%;
}

.item-card-action .game-btn {
    width: 100%;
    font-size: 9.5px;
    padding: 6px 4px;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0;
}

/* Rarity-specific styles and glows */
.shop-item-card.rarity-common {
    border-color: rgba(255, 255, 255, 0.08);
}
.shop-item-card.rarity-common .item-card-name {
    color: #e2e8f0;
}

.shop-item-card.rarity-rare {
    border-color: rgba(33, 150, 243, 0.35);
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.15), rgba(10, 12, 18, 0.98));
}
.shop-item-card.rarity-rare .item-card-name {
    color: #90caf9;
    text-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
}
.shop-item-card.rarity-rare .item-card-icon-wrapper {
    background: radial-gradient(circle, rgba(33, 150, 243, 0.15) 0%, rgba(33, 150, 243, 0) 70%);
}

.shop-item-card.rarity-epic {
    border-color: rgba(156, 39, 176, 0.45);
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.18), rgba(10, 12, 18, 0.98));
}
.shop-item-card.rarity-epic .item-card-name {
    color: #e040fb;
    text-shadow: 0 0 10px rgba(224, 64, 251, 0.6);
}
.shop-item-card.rarity-epic .item-card-icon-wrapper {
    background: radial-gradient(circle, rgba(156, 39, 176, 0.2) 0%, rgba(156, 39, 176, 0) 70%);
}

.shop-item-card.rarity-legendary {
    border-color: rgba(255, 179, 0, 0.55);
    background: linear-gradient(135deg, rgba(255, 179, 0, 0.22), rgba(10, 12, 18, 0.98));
    animation: legendary-glow 3s infinite alternate;
}
.shop-item-card.rarity-legendary .item-card-name {
    color: #ffd54f;
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.7);
}
.shop-item-card.rarity-legendary .item-card-icon-wrapper {
    background: radial-gradient(circle, rgba(255, 179, 0, 0.25) 0%, rgba(255, 179, 0, 0) 70%);
}

@keyframes legendary-glow {
    0% {
        box-shadow: 0 0 4px rgba(255, 179, 0, 0.1);
    }
    100% {
        box-shadow: 0 0 12px rgba(255, 179, 0, 0.35);
        border-color: rgba(255, 179, 0, 0.75);
    }
}

.shop-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #8892b0;
    font-size: 12px;
    padding: 60px 0;
    font-family: var(--font-body);
}

.vertical-cards-grid .card-details p {
    font-size: 9px;
    color: #ffffff; /* Brighter high contrast color */
    margin-bottom: 4px;
    text-shadow: 1px 1px 1px #000;
}

.vertical-cards-grid .card-details .game-btn {
    padding: 3px 8px;
    font-size: 9px;
    min-height: 22px;
    border: 2px solid #2d1e12;
    border-radius: 8px;
    box-shadow: 0 2.5px 0 #854a00, 0 3px 5px rgba(0,0,0,0.3);
    text-shadow: 1px 1px 1px rgba(0,0,0,0.85); /* Clean text shadow for small text */
}

.vertical-cards-grid .card-details .game-btn:active {
    transform: translateY(1.5px);
    box-shadow: 0 1px 0 #854a00;
}

.wall-card-buttons {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

/* Troops Grid (Train & Deploy) */
.modal-troops-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 12px;
    max-height: min(480px, 60vh);
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 20px;
}

.modal-troops-grid .troop-card {
    flex: unset !important;
    width: auto !important;
    background: linear-gradient(180deg, #2c313d 0%, #171a21 100%);
    border: 3px solid #2d1e12;
    border-radius: 14px;
    box-shadow: 0 4px 0 #0d0f13, inset 0 1px 2px rgba(255,255,255,0.1);
    padding: 8px;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.modal-troops-grid .troop-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-cyan);
}

.modal-troops-grid .troop-card .card-thumb-wrap {
    width: 44px;
    height: 44px;
    border: 2px solid #2d1e12;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border-radius: 8px;
}

.train-modal-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #202432 0%, #151822 100%);
    border: 3.5px solid #2d1e12;
    border-radius: 14px;
    padding: 8px 14px;
    margin: 16px 16px 0;
    box-shadow: 0 4px 0 #0c0e14;
}

.train-modal-status span {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-shadow: 1px 1px 0 #000;
}

/* Custom Gamified Progress Range Sliders */
.troop-card input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: #0f1118;
    border: 2.5px solid #2d1e12;
    border-radius: 6px;
    outline: none;
    margin: 8px 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.7);
}

.troop-card input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(180deg, #00e5ff 0%, #00b0ff 100%);
    border: 2.5px solid #2d1e12;
    cursor: pointer;
    box-shadow: 0 3px 0 #005f73, 0 2px 4px rgba(0,0,0,0.4);
    transition: transform 0.1s ease;
}

.troop-card input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.troop-card input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(0.95);
    background: #00b0ff;
}

.troop-card input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(180deg, #00e5ff 0%, #00b0ff 100%);
    border: 2.5px solid #2d1e12;
    cursor: pointer;
    box-shadow: 0 3px 0 #005f73;
}

.doctrine-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.doctrine-modal-body textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 3px solid #2d1e12;
    border-radius: 12px;
    padding: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.5;
    resize: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.doctrine-modal-body textarea:focus {
    border-color: var(--color-gold);
    outline: none;
}

/* Modal High-Contrast Text Color Adjustments */
.game-modal .text-elixir {
    color: #ff529c !important; /* Vivid bright pink for high contrast on dark stone panels */
    font-weight: 700;
    text-shadow: 
      -1.5px -1.5px 0 #000, 
       1.5px -1.5px 0 #000, 
      -1.5px  1.5px 0 #000, 
       1.5px  1.5px 0 #000, 
       0 2px 4px rgba(0,0,0,0.8) !important;
}

.game-modal .text-cyan {
    color: #00e5ff !important; /* Glowing bright cyan */
    font-weight: 700;
    text-shadow: 
      -1.5px -1.5px 0 #000, 
       1.5px -1.5px 0 #000, 
      -1.5px  1.5px 0 #000, 
       1.5px  1.5px 0 #000, 
       0 2px 4px rgba(0,0,0,0.8) !important;
}

.game-modal .setting-field label {
    color: var(--color-gold) !important; /* Clear golden labels instead of dark steel grey */
    font-size: 11px;
    font-weight: 700;
    text-shadow: 
      -1px -1px 0 #000, 
       1px -1px 0 #000, 
      -1px  1px 0 #000, 
       1px  1px 0 #000;
    margin-bottom: 4px;
}

.game-modal .hint-text {
    color: #cbd5e0 !important; /* Brighter grey hint text for readability */
    font-size: 10px;
    line-height: 1.4;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.train-modal-status {
    color: #e2e8f0 !important;
}

/* Modal Troop Metadata contrast boost */
.game-modal .troop-meta {
    font-size: 11px !important;
    font-weight: 700;
    margin-top: 4px;
    margin-bottom: 6px;
    width: 100%;
}

.game-modal .troop-card .troop-name {
    color: #ffffff !important;
    font-weight: 700;
    text-shadow: 
      -1.5px -1.5px 0 #000, 
       1.5px -1.5px 0 #000, 
      -1.5px  1.5px 0 #000, 
       1.5px  1.5px 0 #000, 
       0 2px 4px rgba(0,0,0,0.8) !important;
}

.game-modal .troop-card .game-btn {
    font-size: 11px !important;
    text-shadow: 1px 1px 1px #000 !important;
    box-shadow: 0 2.5px 0 #854a00, 0 3px 5px rgba(0,0,0,0.3) !important;
    padding: 3px 6px !important;
}

.game-modal .troop-card .game-btn:active {
    transform: translateY(1.5px) !important;
    box-shadow: 0 1px 0 #854a00, 0 1.5px 3px rgba(0,0,0,0.2) !important;
}

.game-modal .troop-meta span {
    text-shadow: 
      -1px -1px 0 #000, 
       1px -1px 0 #000, 
      -1px  1px 0 #000, 
       1px  1px 0 #000;
}

/* Beveled 3D Train Sub-buttons */
.game-modal .train-quick-btn {
    min-height: 24px;
    border: 2px solid #2d1e12;
    border-radius: 8px;
    background: linear-gradient(180deg, #4b5a80 0%, #2e3b59 100%);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2.5px 0 #151c2d, 0 3px 5px rgba(0,0,0,0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    text-shadow: 1px 1px 0 #000;
}

.game-modal .train-quick-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #586994 0%, #374669 100%);
    border-color: var(--color-gold);
}

.game-modal .train-quick-btn:active:not(:disabled) {
    transform: translateY(1.5px);
    box-shadow: 0 1px 0 #151c2d;
}

.game-modal .train-quick-btn:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: default;
}

/* Align modal status horizontally with troop card grids */
.game-modal .train-modal-status {
    margin: 0 0 14px 0 !important;
    width: 100% !important;
}

/* Standardize footer buttons layout inside all modals */
.game-modal .modal-footer .game-btn {
    height: 38px !important;
    font-size: 11px !important;
    padding: 6px 16px !important;
    top: 0 !important;
    box-shadow: 0 4px 0 #1b2660, 0 5px 8px rgba(0,0,0,0.3) !important;
}

.game-modal .modal-footer .btn-gold {
    box-shadow: 0 4px 0 #854a00, 0 5px 8px rgba(0,0,0,0.3) !important;
}

.game-modal .modal-footer .game-btn:active {
    transform: translateY(3px) !important;
    box-shadow: 0 1px 0 #1b2660, 0 2px 4px rgba(0,0,0,0.2) !important;
}

.game-modal .modal-footer .btn-gold:active {
    box-shadow: 0 1px 0 #854a00, 0 2px 4px rgba(0,0,0,0.2) !important;
}

@media (max-width: 700px), (max-height: 560px) {
    .game-modal {
        align-items: stretch;
        justify-content: center;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-right: max(6px, env(safe-area-inset-right));
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        padding-left: max(6px, env(safe-area-inset-left));
    }

    .game-modal .modal-card,
    .wide-modal-card,
    .leaderboard-modal-card,
    .friends-modal-card,
    .announcements-modal-card,
    .player-profile-modal-card,
    .buff-detail-modal-card,
    .onboard-modal-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 12px);
        max-height: calc(100dvh - 12px);
        min-height: 0;
        border-radius: 16px;
    }

    .game-modal .modal-header {
        padding: 10px 14px;
    }

    .game-modal .modal-header h3 {
        min-width: 0;
        font-size: 13px;
        line-height: 1.25;
    }

    .game-modal .modal-body,
    #train-dialog .modal-body,
    #deploy-dialog .modal-body,
    #shop-dialog .modal-body,
    #inventory-dialog .modal-body,
    #leaderboard-dialog .modal-body,
    #friends-dialog .modal-body,
    #announcements-dialog .modal-body,
    #player-profile-dialog .modal-body,
    #battlelog-dialog .modal-body,
    #upgrades-dialog .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 12px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    #train-dialog .modal-troops-grid,
    #deploy-dialog .modal-troops-grid,
    #shop-dialog .shop-items-grid,
    #inventory-dialog .inventory-items-grid,
    #battlelog-dialog .battlelog-panel,
    #leaderboard-dialog .leaderboard-list,
    #friends-dialog .friends-list,
    #player-profile-dialog .player-base-grid,
    .announcement-list,
    .event-list {
        flex: 0 0 auto;
        max-height: none !important;
        overflow: visible;
    }

    #upgrades-dialog .modal-body {
        flex: 0 0 auto;
        padding-bottom: 8px;
    }

    #upgrades-dialog .modal-cards-grid {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
        padding: 12px;
    }

    .game-modal .modal-footer {
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .game-modal .modal-footer .game-btn {
        flex: 1 1 140px;
        min-width: 0;
    }

    .shop-tabs,
    .friend-search-bar,
    .upgrades-filter-bar,
    .train-modal-status {
        flex-wrap: wrap;
    }

    .friend-search-bar {
        grid-template-columns: 1fr;
        padding: 8px 0;
    }

    .announcement-sections {
        grid-template-columns: 1fr;
    }

    .player-profile-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .modal-troops-grid,
    .shop-items-grid,
    .inventory-items-grid,
    .modal-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
        gap: 10px;
        padding: 8px 2px 12px;
    }

    .onboard-input-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .onboard-roll-btn {
        width: 100%;
    }

    .onboard-avatar-tray {
        grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
        max-height: none;
        overflow: visible;
    }
}

/* Premium Game Cockpit Select Dropdowns */
.game-select {
    background: linear-gradient(180deg, #373b4d 0%, #20222e 100%);
    border: 2.5px solid #2d1e12;
    border-radius: 10px;
    color: #fff;
    padding: 5px 24px 5px 12px;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    box-shadow: 0 3px 0 #121319, inset 0 1px 2px rgba(255,255,255,0.12);
    text-shadow: 1px 1px 0 #000;
    transition: transform 0.1s ease, border-color 0.1s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 18px;
}

.game-select:hover {
    border-color: var(--color-gold);
    transform: scale(1.02);
}

.game-select option {
    background-color: #1a1d29;
    color: #fff;
    font-family: var(--font-heading);
}

.upgrades-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background: linear-gradient(180deg, #202432 0%, #151822 100%);
    border: 3px solid #2d1e12;
    border-radius: 14px;
    padding: 8px 12px;
    box-shadow: 0 4px 0 #0c0e14;
    width: 100%;
}

.upgrades-filter-bar span {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gold);
    text-shadow: 1px 1px 0 #000;
    font-weight: 700;
}

/* Friend Status Badges for Leaderboard */
.friend-badge {
    font-size: 8px;
    font-weight: 800;
    padding: 1.5px 5px;
    border-radius: 4px;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    text-shadow: none !important;
    font-family: var(--font-body);
    flex-shrink: 0;
}

.friend-badge.accepted {
    background-color: rgba(0, 230, 118, 0.2);
    border: 1px solid rgba(0, 230, 118, 0.6);
    color: #b9f6ca;
}

.friend-badge.pending {
    background-color: rgba(255, 179, 0, 0.2);
    border: 1px solid rgba(255, 179, 0, 0.6);
    color: #ffe082;
}

/* Onboarding Dialog Styles */
.onboard-modal-card {
    width: min(540px, calc(100vw - 32px)) !important;
}

.onboard-section {
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid #2d1e12;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.6);
}

.onboard-section-title {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--color-gold);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.onboard-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.onboard-name-input {
    flex-grow: 1;
    height: 40px;
    background: #120e0a !important;
    border: 3px solid #2d1e12 !important;
    border-radius: 10px !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-align: center;
    padding: 0 12px !important;
    outline: none;
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.7) !important;
    transition: border-color 0.2s ease;
}

.onboard-name-input:focus {
    border-color: var(--color-cyan) !important;
}

.onboard-roll-btn {
    height: 40px !important;
    min-width: 120px;
    font-size: 11px !important;
    font-weight: 700;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 0 4px 0 #854a00, 0 5px 8px rgba(0,0,0,0.4) !important;
    margin: 0 !important;
    top: 0 !important;
}

.onboard-roll-btn:active {
    transform: translateY(3px) !important;
    box-shadow: 0 1px 0 #854a00, 0 2px 4px rgba(0,0,0,0.3) !important;
}

.onboard-avatar-tray {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin: 4px 0 0 0;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.8);
    border: 2.5px solid #2d1e12;
}

.onboard-avatar-slot {
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2px;
    background-clip: padding-box;
    background: #120e0a;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.8);
}

.onboard-avatar-slot:hover {
    transform: scale(1.1);
    border-color: rgba(0, 229, 255, 0.5);
}

.onboard-avatar-slot.selected {
    transform: scale(1.08);
    border-color: var(--color-gold);
    box-shadow: 0 0 10px var(--color-gold), inset 0 0 0 1px var(--color-gold);
}

.onboard-avatar-slot .avatar-render-troop,
.onboard-avatar-slot .avatar-render-emoji {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.onboard-avatar-slot .avatar-render-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.onboard-avatar-tray::-webkit-scrollbar {
    width: 6px;
}
.onboard-avatar-tray::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}
.onboard-avatar-tray::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.onboard-avatar-tray::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Independent Profile HUD Actions Bar */
.profile-actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    pointer-events: auto;
}

.profile-actions-bar .profile-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(10, 12, 22, 0.75);
    border: 2px solid #2d1e12;
    box-shadow: 0 3px 0 #120e0a, 0 4px 6px rgba(0,0,0,0.45);
    color: var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
    padding: 0;
    text-decoration: none;
}

.profile-actions-bar .profile-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-cyan);
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #120e0a, 0 6px 10px rgba(0,0,0,0.55);
}

.profile-actions-bar .profile-action-btn:active {
    transform: translateY(1.5px);
    box-shadow: 0 1px 0 #120e0a, 0 2px 3px rgba(0,0,0,0.3);
}

.profile-actions-bar .profile-settings-btn:hover {
    transform: rotate(45deg) translateY(-2px);
}

.profile-actions-bar .profile-download-btn {
    color: #8de0ff;
    border-color: #23364d;
}

.profile-actions-bar .profile-download-btn:hover {
    border-color: var(--color-gold);
    color: #fff2a8;
}

.btn-green {
    background: linear-gradient(180deg, #66bb6a 0%, #2e7d32 100%);
    box-shadow: 0 4px 0 #17441b, 0 5px 8px rgba(0,0,0,0.35);
}

.btn-steel {
    background: linear-gradient(180deg, #78909c 0%, #37474f 100%);
    box-shadow: 0 4px 0 #1c252a, 0 5px 8px rgba(0,0,0,0.35);
}

.worldmap-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    color: #fff;
}

.worldmap-topbar {
    height: 54px;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    padding: 0 14px;
    background: linear-gradient(180deg, rgba(10,8,20,0.95) 0%, rgba(20,16,40,0.92) 100%);
    border-bottom: 2px solid rgba(255,200,80,0.25);
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.wm-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: #f5c842;
    text-shadow: 0 0 8px rgba(245,200,66,0.5);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.wm-stats {
    display: flex;
    gap: 8px;
    margin-left: 4px;
    flex: 1;
}

.wm-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 20px;
    font-family: var(--font-heading);
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
}

.wm-stat-badge.wm-income {
    color: #ffd54f;
}

.wm-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.worldmap-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.worldmap-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
}

.worldmap-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#worldmap-cities {
    position: absolute;
    inset: 0;
}

.city-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 0;
    background: transparent;
    padding: 0;
}

.city-marker .city-icon {
    font-size: 20px;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.8));
}

.city-marker .city-label {
    font-size: 10px;
    background: rgba(0,0,0,0.72);
    color: white;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.city-marker .city-owner {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.7);
}

.city-marker.is-mine .city-owner {
    color: #69f0ae;
    background: rgba(0,150,60,0.35);
}

.city-marker.is-enemy .city-owner {
    color: #ff8a80;
    background: rgba(180,0,0,0.35);
}

.city-marker .city-attacker {
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(255, 80, 0, 0.55);
    border: 1px solid rgba(255,140,0,0.7);
    color: #ffe082;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.city-marker .city-level {
    font-size: 9px;
    color: #ffd700;
    background: rgba(0,0,0,0.55);
    border-radius: 3px;
    padding: 0 3px;
}

.city-marker.is-mine .city-icon {
    filter: drop-shadow(0 0 4px #00C853);
}

.city-marker.is-enemy .city-icon {
    filter: drop-shadow(0 0 4px #D50000);
}

.city-marker.is-neutral .city-icon {
    filter: drop-shadow(0 0 4px #8B7355);
}

.city-marker.state-besieged .city-icon {
    animation: city-blink-orange 0.8s ease-in-out infinite;
}

.city-marker.state-falling .city-icon {
    animation: city-blink-red 0.4s ease-in-out infinite;
}

@keyframes city-blink-orange {
    0%, 100% { filter: drop-shadow(0 0 4px #ff8f00); transform: scale(1); }
    50% { filter: drop-shadow(0 0 9px #ffcc80); transform: scale(1.12); }
}

@keyframes city-blink-red {
    0%, 100% { filter: drop-shadow(0 0 4px #d50000); }
    50% { filter: drop-shadow(0 0 10px #ff5252); }
}

.city-detail-panel {
    position: absolute;
    right: 0;
    top: 58px;
    bottom: 0;
    width: min(320px, 92vw);
    background: rgba(20,20,40,0.95);
    border-left: 1px solid rgba(255,255,255,0.16);
    overflow-y: auto;
    padding: 16px;
    z-index: 2;
    box-shadow: -10px 0 28px rgba(0,0,0,0.35);
}

.city-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.city-detail-header h3 {
    margin: 0;
    font-size: 18px;
}

#btn-city-detail-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.35);
    color: #fff;
    cursor: pointer;
}

.city-region-badge,
.badge-mine {
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    color: #b2ebf2;
    font-size: 11px;
}

.badge-mine {
    color: #a5d6a7;
}

.city-owner-row,
.city-level-row {
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255,255,255,0.84);
}

.city-fort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 12px;
}

.fort-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.fort-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.city-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.city-status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    margin: 4px 0;
}

.city-status-badge.besieged {
    background: rgba(255,100,0,0.2);
    border: 1px solid #ff6400;
    color: #ff9040;
}

.city-status-badge.weakened {
    background: rgba(255,200,0,0.2);
    border: 1px solid #ffc800;
    color: #ffd040;
}

.city-status-badge.falling {
    background: rgba(255,50,50,0.2);
    border: 1px solid #ff3232;
    color: #ff6060;
}

@media (max-width: 700px) {
    .worldmap-topbar {
        flex-wrap: wrap;
        min-height: 82px;
        align-content: center;
    }

    .city-detail-panel {
        top: auto;
        left: 0;
        width: auto;
        max-height: 45vh;
        border-left: 0;
        border-top: 1px solid rgba(255,255,255,0.16);
    }
}
