/* ============================================
   RESPONSIVE DESIGN SYSTEM - CSS Variables
   ============================================ */

:root {
    color-scheme: dark;

    /* Canonical Warriors palette: docs/COLOR_PALETTE.md */
    --warriors-ink: #251b17;
    --warriors-espresso: #3e2c24;
    --warriors-cocoa: #3f2c20;
    --warriors-deep-brown: #493324;
    --warriors-walnut: #5e412d;
    --warriors-cream: #ead8c0;
    --warriors-sandstone: #d1bb9e;
    --warriors-taupe: #a79277;
    --warriors-copper: #c48145;
    --warriors-rust: #b87333;
    --warriors-roasted-copper: #8c5526;
    --warriors-chestnut: #7a4519;
    --warriors-deep-umber: #59300f;
    --warriors-burnt-umber: #3f210b;
    --warriors-blue-highlight: #378eae;
    --warriors-blue: #2a7b9b;
    --warriors-blue-deep: #18566f;
    --warriors-green-highlight: #9db880;
    --warriors-green: #5d7448;
    --warriors-green-deep: #465a35;
    --warriors-red-highlight: #a34b3f;
    --warriors-red: #7b2d26;
    --warriors-red-deep: #521d19;
    --map-army-route-width: 3px;

    /* Shared surface hierarchy */
    --surface-canvas: var(--warriors-ink);
    --surface-base: var(--warriors-cocoa);
    --surface-panel: var(--warriors-deep-brown);
    --surface-raised: var(--warriors-walnut);
    --surface-hover: #6b4931;
    --surface-selected: var(--warriors-chestnut);
    --border-subtle: var(--warriors-deep-umber);
    --border-default: var(--warriors-chestnut);
    --border-strong: var(--warriors-copper);
    --accent-gold: var(--warriors-copper);
    --accent-gold-bright: var(--warriors-rust);

    /* Typography - Improved fluid sizing for modern phones (320px-932px) */
    --font-size-base: clamp(0.9rem, 2.2vw, 1.05rem);
    --font-size-sm: clamp(0.8rem, 1.8vw, 0.95rem);
    --font-size-lg: clamp(1.15rem, 2.8vw, 1.35rem);
    --font-size-xl: clamp(1.3rem, 3.2vw, 1.6rem);
    --font-size-2xl: clamp(1.6rem, 3.8vw, 2.1rem);

    /* Spacing - Better scaling for landscape mode */
    --spacing-xs: clamp(0.3rem, 1.2vw, 0.6rem);
    --spacing-sm: clamp(0.55rem, 1.8vw, 0.85rem);
    --spacing-md: clamp(0.8rem, 2.2vw, 1.1rem);
    --spacing-lg: clamp(1.1rem, 2.8vw, 1.6rem);
    --spacing-xl: clamp(1.6rem, 3.2vw, 2.2rem);

    /* Layout dimensions - Optimized for modern phones */
    --sidebar-width: clamp(70px, 8vw, 110px);
    --header-height: clamp(50px, 7vh, 70px);
    --top-bar-height: clamp(50px, 7vh, 70px);
    --total-header-space: calc(var(--header-height) + var(--top-bar-height));

    /* IMPORTANT: --container-height is GENERIC for all game tabs
       All tabs have StatusBar in MainLayout (line 37 of MainLayout.razor: <StatusBarComponent />)

       --container-height = 100dvh - header-height - top-bar-height

       This accounts for:
       1. Main navigation header (sidebar + top area)
       2. StatusBar component (resources/troops display)

       Use var(--container-height) for ALL page containers to ensure consistent height calculation
    */
    --container-height: calc(100dvh - var(--total-header-space));
    --border-radius: clamp(3px, 0.6vw, 10px);

    /* Mobile landscape optimizations - Better for modern wide phones */
    --sidebar-width-landscape: clamp(70px, 10vw, 80px);
    --nav-link-height-landscape: 40px;
    --sidebar-clock-height-landscape: clamp(40px, 5.5vh, 52px);
    --sidebar-meta-height-landscape: 26px;

    /* Border widths */
    --border-thin: 1px;
    --border-medium: 2px;
    --border-color: var(--border-default);
    --border-radius-sm: 4px;

    /* Theme aliases used by shared components */
    --primary-color: var(--warriors-rust);
    --success-color: var(--warriors-green);
    --info-color: var(--warriors-blue);
    --danger-color: var(--warriors-red);
    --text-primary: var(--warriors-cream);
    --text-secondary: var(--warriors-sandstone);
    --bg-primary: var(--surface-base);
    --bg-secondary: var(--surface-panel);

    /* Shared modal system, derived from the City Intel panel */
    --modal-surface: var(--warriors-sandstone);
    --modal-surface-raised: #bea789;
    --modal-surface-inset: var(--warriors-taupe);
    --modal-border: var(--warriors-chestnut);
    --modal-border-muted: rgba(122, 69, 25, 0.48);
    --modal-accent: var(--warriors-rust);
    --modal-accent-bright: var(--warriors-copper);
    --modal-text: var(--warriors-deep-brown);
    --modal-text-muted: var(--warriors-walnut);
    --modal-padding-x: clamp(1rem, 2vw, 1.35rem);
    --modal-padding-y: clamp(0.8rem, 1.5vw, 1rem);

    /* Blazor sets these while loading; defaults keep CSS inspections quiet. */
    --blazor-load-percentage: 0%;
    --blazor-load-percentage-text: "Loading";

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4);

    /* ============================================
       COMPONENT SIZING - Optimized for modern devices
       ============================================ */

    /* Button Heights - Better touch targets (min 44px recommended) */
    --button-height-sm: clamp(36px, 4vh, 42px);
    --button-height-md: clamp(42px, 5vh, 50px);
    --button-height-lg: clamp(50px, 6vh, 62px);
    --touch-target-landscape: 38px;

    /* Input Widths - Better for modern wide screens */
    --input-width-sm: clamp(60px, 7vw, 90px);
    --input-width-md: clamp(110px, 14vw, 170px);
    --input-width-lg: clamp(170px, 20vw, 280px);

    /* Icon Sizes - More visible on modern displays */
    --icon-size-xs: clamp(18px, 2.4vw, 28px);
    --icon-size-sm: clamp(28px, 3.5vw, 36px);
    --icon-size-md: clamp(36px, 4.5vw, 50px);
    --icon-size-lg: clamp(50px, 5.5vw, 70px);

    /* Modal/Card Widths - Better for landscape orientation */
    --modal-width-sm: clamp(min(90vw, 400px), 45vw, 550px);
    --modal-width-md: clamp(min(90vw, 550px), 55vw, 750px);
    --modal-width-lg: clamp(min(90vw, 750px), 65vw, 950px);

    /* Container Heights - Better vertical space usage */
    --container-height-sm: clamp(110px, 12vh, 170px);
    --container-height-md: clamp(170px, 22vh, 330px);
    --container-height-lg: clamp(220px, 32vh, 440px);

    /* Grid Column Widths - More usable cell sizes */
    --grid-cell-width-xs: clamp(45px, 5.5vw, 68px);
    --grid-cell-width-sm: clamp(55px, 9vw, 88px);
    --grid-cell-width-md: clamp(68px, 11vw, 110px);

    /* Card Heights - Better proportions */
    --card-height-sm: clamp(55px, 7vh, 78px);
    --card-height-md: clamp(78px, 9vh, 110px);
    --card-height-lg: clamp(110px, 14vh, 165px);

    /* Progress Bar & Indicator Heights - More visible */
    --progress-bar-height: clamp(4px, 0.6vh, 8px);
    --indicator-size: clamp(5px, 0.8vh, 10px);
}

html, body {
    color-scheme: dark;
    font-family: Inter, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--surface-canvas);
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent all scrolling */
    width: 100%;
    max-width: 100dvw;
    height: 100dvh;
    max-height: 100dvh;
    position: fixed; /* Fix body position */
}

* {
    box-sizing: border-box;
}

::selection {
    color: var(--warriors-ink);
    background: var(--warriors-copper);
}

:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

#app {
    width: 100%;
    max-width: 100dvw;
    overflow-x: hidden;
}

.page {
    width: 100%;
    max-width: 100dvw;
    height: 100dvh;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Page Container - Fills remaining flex space */
.page-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    background: #251b17;
}

/* ============================================
   REUSABLE TAB LAYOUT SYSTEM
   Based on Market's successful responsive pattern
   ============================================ */

/* Tab Container - wraps entire tab content */
.tab-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    height: 100%;
    background: #251b17;
}

/* Tab Header - fixed at top, never shrinks */
.tab-header {
    padding: 0.3rem;
    background: linear-gradient(135deg, #493324 0%, #5e412d 100%);
    border-bottom: 2px solid #7a4519;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 2.5rem;
}

.tab-header h3 {
    font-size: 1.6rem;
    margin: 0;
    color: #ead8c0;
}

/* Vertically center phosphor icons in page headers with text */
.tab-header h2 i,
.tab-header h3 i,
.tab-header h4 i {
    vertical-align: middle;
    display: inline-block;
    line-height: 1;
}

/* Tab Main Layout - THE KEY: flex: 1 1 auto + min-height: 0 allows shrinking */
.tab-main-layout {
    display: flex;
    flex: 1 1 auto;
    gap: 0.5rem;
    padding: 0.5rem;
    overflow: hidden;
    min-height: 0;
    background: #251b17;
}

/* Tab Content Window - for single-column layouts */
.tab-content-window {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

/* Tab Content Wrapper - scrollable content area */
.tab-content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

/* Tab Scrollable - for content that needs vertical scroll */
.tab-scrollable {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Tab Panel - for split layouts (left/right panels) */
.tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.tab-panel-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Tab Sidebar - fixed-width side panel */
.tab-sidebar {
    flex: 0 0 15%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

/* Apply market layout pattern to ALL page containers */
.armies-container,
.ranking-container,
.nexus-container,
.emails-container,
.village-container,
.barracks-container,
.tech-container,
.news-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

/* Apply flex: 1 1 auto + min-height: 0 to main content areas */
.armies-list,
.rankings-container,
.emails-split-container,
.main-content-split,
.game-board,
.tech-scrollable,
.samurai-game-layout {
    display: flex;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
}

/* Make scroll containers work properly */
.armies-section,
.ranking-table,
.emails-column {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Responsive adjustments for tab layouts - medium height screens (e.g., 1200x800) */
@media only screen and (max-height: 850px) and (min-height: 501px) {
    .tab-header h3 {
        font-size: 1.2rem;
    }

    .tab-main-layout {
        gap: 0.3rem;
        padding: 0.3rem;
    }

    /* Nexus tab - reduce card and button sizes */
    .nexus-header {
        padding: 0.3rem !important;
    }

    .nexus-header h3 {
        font-size: 1rem !important;
    }

    .tab-navigation {
        padding: 0.2rem !important;
        gap: 0.3rem !important;
    }

    .tab-button {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .game-setup {
        padding: 0.5rem !important;
    }

    .game-setup h3 {
        font-size: 1rem !important;
    }

    .game-board {
        padding: 0.3rem !important;
        gap: 0.3rem !important;
    }

    .game-status {
        padding: 0.3rem !important;
        gap: 0.3rem !important;
    }

    .type-card {
        padding: 0.3rem !important;
        font-size: 0.75rem !important;
    }

    .btn-start-game {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
    }

    /* Tech tab - reduce node sizes */
    .tech-header {
        padding: 0.3rem !important;
    }

    .tech-header h3 {
        font-size: 1rem !important;
    }

    .tech-tree-container {
        gap: 0 !important;
    }

    .tree-circle {
        width: 40px !important;
        height: 40px !important;
        font-size: 0.9rem !important;
    }

    .tree-node-wrapper {
        padding: 0 0.2rem !important;
    }
}

@media only screen and (max-height: 500px) and (orientation: landscape) {
    .tab-header {
        padding: 0.2rem 0.3rem;
    }

    .tab-header h3 {
        font-size: 0.7rem;
        margin: 0;
    }

    .tab-main-layout {
        flex: 1 1 auto;
        gap: 0.2rem;
        padding: 0.2rem;
        overflow: hidden;
    }
}

/* Fix ONLY the barely readable dark grey text elements */
/* Target specific problematic text that uses var(--bs-body-color) or similar */
.text-body,
[style*="color: var(--bs-body-color)"],
.card-text,
.list-group-item-text {
    color: #ead8c0 !important;
}

/* Fix specific text elements that are barely readable - but NOT in navigation or headers */
.content h3:not([class*="nav"]):not([class*="btn"]):not([class*="header"]),
.content h4:not([class*="nav"]):not([class*="btn"]):not([class*="header"]),
.content h5:not([class*="nav"]):not([class*="btn"]):not([class*="header"]) {
    color: #ead8c0 !important;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #d1bb9e;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding: 0 !important; /* Remove all padding */
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: #d1bb9e;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/* ============================================
   GLOBAL SCROLLBAR STYLING - APPLIES EVERYWHERE
   ============================================ */
::-webkit-scrollbar {
    width: 8px !important;
    height: 8px !important;
}

::-webkit-scrollbar-track {
    background: rgba(48, 48, 54, 0.3) !important;
    border-radius: 4px !important;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c48145 0%, #b8860b 100%) !important;
    border-radius: 4px !important;
    border: 2px solid rgba(48, 48, 54, 0.5) !important;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ffd700 0%, #c48145 100%) !important;
}

/* Override ANY element-specific scrollbar styles */
.players-list::-webkit-scrollbar,
.messages-list::-webkit-scrollbar,
.messages-display::-webkit-scrollbar,
.armies-list::-webkit-scrollbar,
.emails-list::-webkit-scrollbar,
.rankings-container::-webkit-scrollbar,
.chat-panel-scroll::-webkit-scrollbar,
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.owner-info-popup::-webkit-scrollbar,
.cities-box::-webkit-scrollbar {
    width: 8px !important;
    height: 8px !important;
}

.players-list::-webkit-scrollbar-track,
.messages-list::-webkit-scrollbar-track,
.messages-display::-webkit-scrollbar-track,
.armies-list::-webkit-scrollbar-track,
.emails-list::-webkit-scrollbar-track,
.rankings-container::-webkit-scrollbar-track,
.chat-panel-scroll::-webkit-scrollbar-track,
.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track,
.owner-info-popup::-webkit-scrollbar-track,
.cities-box::-webkit-scrollbar-track {
    background: rgba(48, 48, 54, 0.3) !important;
    border-radius: 4px !important;
}

.players-list::-webkit-scrollbar-thumb,
.messages-list::-webkit-scrollbar-thumb,
.messages-display::-webkit-scrollbar-thumb,
.armies-list::-webkit-scrollbar-thumb,
.emails-list::-webkit-scrollbar-thumb,
.rankings-container::-webkit-scrollbar-thumb,
.chat-panel-scroll::-webkit-scrollbar-thumb,
.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
.owner-info-popup::-webkit-scrollbar-thumb,
.cities-box::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c48145 0%, #b8860b 100%) !important;
    border-radius: 4px !important;
    border: 2px solid rgba(48, 48, 54, 0.5) !important;
}

.players-list::-webkit-scrollbar-thumb:hover,
.messages-list::-webkit-scrollbar-thumb:hover,
.messages-display::-webkit-scrollbar-thumb:hover,
.armies-list::-webkit-scrollbar-thumb:hover,
.emails-list::-webkit-scrollbar-thumb:hover,
.rankings-container::-webkit-scrollbar-thumb:hover,
.chat-panel-scroll::-webkit-scrollbar-thumb:hover,
.left-panel::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover,
.owner-info-popup::-webkit-scrollbar-thumb:hover,
.cities-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #ffd700 0%, #c48145 100%) !important;
}

/* Firefox scrollbar styling */
* {
    scrollbar-color: #c48145 rgba(48, 48, 54, 0.3) !important;
    scrollbar-width: thin !important;
}

/* GLOBAL SIDEBAR NAVIGATION STYLES */
.sidebar-nav {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #3e2c24 0%, #251b17 100%);
    border-right: 1px solid #7a4519;
    box-shadow: none; /* Remove shadow */
    overflow-y: auto;
    position: relative;
    z-index: 100;
}

.nav-items-vertical {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-sm);
}

.nav-items-vertical .nav-item {
    width: 100%;
}

/* GLOBAL SIDEBAR NAVIGATION LINKS - RESPONSIVE SIZING */
.sidebar-nav a,
.sidebar-nav .nav-link,
.nav-items-vertical a,
.nav-items-vertical .nav-link,
nav.sidebar-nav a,
nav.sidebar-nav .nav-link {
    all: unset !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: clamp(0.15rem, 0.5vw, 0.25rem) !important;
    padding: var(--spacing-sm) var(--spacing-xs) !important;
    background: linear-gradient(180deg, #493324 0%, #30231c 100%) !important;
    border: var(--border-thin) solid #5e412d !important;
    border-radius: var(--border-radius) !important;
    color: #c48145 !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(90, 90, 100, 0.2) !important;
    cursor: pointer !important;
    width: 100% !important;
    min-height: clamp(52px, 8vh, 60px) !important;
    max-height: clamp(52px, 8vh, 60px) !important;
    height: clamp(52px, 8vh, 60px) !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    text-align: center !important;
    box-sizing: border-box !important;
    position: relative !important;
    overflow: hidden !important;
}

/* HOVER STATES */
.sidebar-nav a:hover,
.sidebar-nav .nav-link:hover,
.nav-items-vertical a:hover,
.nav-items-vertical .nav-link:hover,
nav.sidebar-nav a:hover,
nav.sidebar-nav .nav-link:hover {
    transform: translateY(-1px) !important;
    border-color: #7a4519 !important;
    color: #d1bb9e !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(196, 129, 69, 0.16) !important;
    background: linear-gradient(180deg, #5e412d 0%, #493324 100%) !important;
}

/* ACTIVE STATES */
.sidebar-nav a.active,
.sidebar-nav .nav-link.active,
.nav-items-vertical a.active,
.nav-items-vertical .nav-link.active,
nav.sidebar-nav a.active,
nav.sidebar-nav .nav-link.active {
    background: linear-gradient(180deg, #6b3f22 0%, #493324 100%) !important;
    border-color: #c48145 !important;
    color: #d1bb9e !important;
    box-shadow: inset 3px 0 0 #c48145, 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(196, 129, 69, 0.2) !important;
}

/* ICONS AND TEXT */
.sidebar-nav .nav-icon,
.nav-items-vertical .nav-icon {
    display: inline-block !important;
    font-size: clamp(1.1rem, 2.8vw, 1.5rem) !important;
    font-weight: bold !important;
    text-shadow: 0 0 4px rgba(196, 129, 69, 0.38) !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar-nav .nav-text,
.nav-items-vertical .nav-text {
    display: block !important;
    font-size: clamp(0.65rem, 1.4vw, 0.85rem) !important;
    text-transform: uppercase !important;
    letter-spacing: 0 !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
}

/* LAYOUT STYLES */
.main-layout {
    display: flex;
    flex: 1;
    height: var(--container-height);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.main-content > .content {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #251b17;
}

/* STANDARD PAGE CONTAINER - Use this for ALL tabs to ensure consistency */
.page-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

/* STANDARD CONTENT CONTAINER - All tab-specific containers should use these rules */
.village-container,
.nexus-container,
.market-container,
.armies-container,
.emails-container,
.barracks-container,
.tech-container,
.news-container,
.news-content,
.ranking-container,
.rankings-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: #3f2c20 !important;
}

/* Landscape-only responsive design for modern phones and tablets */
@media only screen and (max-height: 500px) and (orientation: landscape) {
    .sidebar-nav {
        width: var(--sidebar-width-landscape) !important;
        min-width: var(--sidebar-width-landscape) !important;
    }

    .sidebar-nav a,
    .sidebar-nav .nav-link,
    .nav-items-vertical a,
    .nav-items-vertical .nav-link,
    nav.sidebar-nav a,
    nav.sidebar-nav .nav-link {
        min-height: var(--nav-link-height-landscape) !important;
        max-height: var(--nav-link-height-landscape) !important;
        height: var(--nav-link-height-landscape) !important;
        padding: var(--spacing-xs) clamp(0.2rem, 0.8vw, 0.4rem) !important;
    }

    .sidebar-nav .nav-icon,
    .nav-items-vertical .nav-icon {
        font-size: clamp(1rem, 2.5vw, 1.3rem) !important;
    }

    .sidebar-nav .nav-text,
    .nav-items-vertical .nav-text {
        font-size: clamp(0.5rem, 1vw, 0.65rem) !important;
    }

    .main-layout {
        height: var(--container-height);
    }

    .container,
    .container-fluid,
    .container-lg,
    .container-md,
    .container-sm,
    .container-xl,
    .container-xxl {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}
/* Fine-tuned landscape breakpoints for different device widths */
@media only screen and (max-height: 500px) and (orientation: landscape) {
    /* Tablet landscape (800px-1200px) */
    @media only screen and (min-width: 801px) and (max-width: 1200px) {
        .sidebar-nav {
            width: clamp(75px, 8vw, 100px) !important;
            min-width: clamp(75px, 8vw, 100px) !important;
        }

        .sidebar-nav a,
        .sidebar-nav .nav-link,
        .nav-items-vertical a,
        .nav-items-vertical .nav-link,
        nav.sidebar-nav a,
        nav.sidebar-nav .nav-link {
            min-height: clamp(38px, 4.5vh, 48px) !important;
            max-height: clamp(38px, 4.5vh, 48px) !important;
            height: clamp(38px, 4.5vh, 48px) !important;
        }

        .sidebar-nav .nav-text,
        .nav-items-vertical .nav-text {
            font-size: clamp(0.55rem, 1.1vw, 0.7rem) !important;
        }
    }

    /* Medium Desktop - 150% Windows scaling (1200-1400px) */
    @media only screen and (min-width: 1200px) and (max-width: 1400px) {
        .sidebar-nav {
            width: 80px !important;
            min-width: 80px !important;
        }

        /* Reduce vertical gaps between nav items */
        .nav-items-vertical {
            gap: 0.2rem !important;
            padding: 0.1rem !important;
        }

        .sidebar-nav a,
        .sidebar-nav .nav-link,
        .nav-items-vertical a,
        .nav-items-vertical .nav-link,
        nav.sidebar-nav a,
        nav.sidebar-nav .nav-link {
            min-height: 36px !important;
            max-height: 36px !important;
            height: 36px !important;
            padding: 3px 2px !important;
            gap: 0.1rem !important;
        }

        .sidebar-nav .nav-icon,
        .nav-items-vertical .nav-icon {
            font-size: 1rem !important;
        }

        .sidebar-nav .nav-text,
        .nav-items-vertical .nav-text {
            font-size: 0.55rem !important;
        }

        .sidebar-clock {
            min-height: 38px !important;
            max-height: 38px !important;
            height: 38px !important;
            padding: 3px !important;
            gap: 1px !important;
        }

        .clock-time {
            font-size: 0.55rem !important;
        }

        .clock-label {
            font-size: 0.48rem !important;
        }
    }

    /* Desktop and larger (1400px+) */
    @media only screen and (min-width: 1401px) {
        .sidebar-nav {
            width: var(--sidebar-width) !important;
            min-width: var(--sidebar-width) !important;
        }

        .sidebar-nav a,
        .sidebar-nav .nav-link,
        .nav-items-vertical a,
        .nav-items-vertical .nav-link,
        nav.sidebar-nav a,
        nav.sidebar-nav .nav-link {
            min-height: clamp(45px, 5vh, 55px) !important;
            max-height: clamp(45px, 5vh, 55px) !important;
            height: clamp(45px, 5vh, 55px) !important;
        }

        .sidebar-nav .nav-text,
        .nav-items-vertical .nav-text {
            font-size: clamp(0.65rem, 1.4vw, 0.85rem) !important;
        }
    }
}

/* ============================================
   LOGIN COMPONENT STYLES
   ============================================ */

.login-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    background: linear-gradient(135deg, #3f2c20 0%, #493324 50%, #251b17 100%);
    padding: 2rem;
}

/* Hide sidebar and top bar when login is visible */
.login-container ~ *:not(.beta-privacy-overlay) {
    display: none !important;
}

body:has(.login-container) .sidebar-nav,
body:has(.login-container) .top-row {
    display: none !important;
}

.login-wrapper {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    align-items: center;
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-right {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.install-button-bar {
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 450px;
    padding: 1rem;
    background: linear-gradient(135deg, #493324 0%, #3f2c20 100%);
    border: 2px solid #c48145;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(196, 129, 69, 0.3);
}

.install-btn {
    width: 100%;
    background: linear-gradient(135deg, #c48145 0%, #8c5526 100%);
    color: #3f2c20;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(196, 129, 69, 0.4);
}

.install-btn:hover {
    background: linear-gradient(135deg, #ffd700 0%, #c48145 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(196, 129, 69, 0.6);
}

.install-icon {
    font-size: 1.2rem;
}

/* Hide install button when app is running as installed PWA */
@media (display-mode: standalone) {
    .install-button-bar {
        display: none !important;
    }
}

.samurai-login-card {
    background: linear-gradient(135deg, #493324 0%, #3f2c20 100%);
    border: 3px solid #7a4519;
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.8),
        inset 0 2px 0 rgba(90, 90, 100, 0.3),
        0 0 30px rgba(196, 129, 69, 0.2);
    overflow: hidden;
    position: relative;
    animation: slideInDown 0.6s ease-out;
}

.samurai-login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #c48145 0%, #ffd700 50%, #c48145 100%);
}

.login-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
    background: linear-gradient(135deg, #5e412d 0%, #493324 100%);
    border-bottom: 2px solid #7a4519;
    position: relative;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 10px rgba(196, 129, 69, 0.6));
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-image {
    height: 150px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(196, 129, 69, 0.6));
}

.login-title {
    color: #c48145;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

.login-subtitle {
    color: #d1bb9e;
    font-size: 0.9rem;
    margin: 0;
    font-style: italic;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.login-body {
    padding: 0;
    background: linear-gradient(135deg, #493324 0%, #3f2c20 100%);
}

/* Tab Button Row (inside pages that have sub-tabs like Market) */
.tab-button-row {
    display: flex;
    background: linear-gradient(135deg, #3f2c20 0%, #251b17 100%);
    border-bottom: 2px solid #7a4519;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    color: #a79277;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(196, 129, 69, 0.1);
    color: #c48145;
}

.tab-btn.active {
    color: #c48145;
    background: linear-gradient(135deg, #493324 0%, #3f2c20 100%);
    border-bottom-color: #c48145;
}

.tab-icon {
    font-size: 1.2rem;
}

.login-form {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.samurai-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    border: 2px solid;
}

.alert-success {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.2) 0%, rgba(25, 135, 84, 0.1) 100%);
    border-color: #5d7448;
    color: #d1e7dd;
}

.alert-error {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.2) 0%, rgba(184, 34, 55, 0.1) 100%);
    border-color: #7b2d26;
    color: #f8d7da;
}

.alert-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.8));
}

.alert-text {
    flex: 1;
    font-weight: 500;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.samurai-label {
    color: #c48145;
    font-weight: 600;
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.samurai-input {
    background: linear-gradient(135deg, #5e412d 0%, #493324 100%);
    border: 2px solid #7a4519;
    border-radius: 6px;
    color: #d1bb9e;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.samurai-input:focus {
    outline: none;
    border-color: #c48145;
    box-shadow:
        0 0 0 3px rgba(196, 129, 69, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #59300f 0%, #5e412d 100%);
}

.samurai-input::placeholder {
    color: #a79277;
    font-style: italic;
}

.char-limit-info {
    display: block;
    color: #d1bb9e;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-style: italic;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.full-width {
    width: 100%;
    margin-top: 0.5rem;
}

.samurai-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.samurai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.login-btn {
    background: linear-gradient(135deg, #c48145 0%, #8c5526 100%);
    border-color: #c48145;
    color: #493324;
}

.login-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffd700 0%, #c48145 100%);
    border-color: #ffd700;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(196, 129, 69, 0.4);
}

.register-btn {
    background: linear-gradient(135deg, #5e412d 0%, #493324 100%);
    border-color: #7a4519;
    color: #c48145;
}

.register-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #59300f 0%, #5e412d 100%);
    border-color: #5e412d;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(72, 72, 80, 0.4);
}

.secondary-btn {
    background: linear-gradient(135deg, #2d3e50 0%, #1a2332 100%);
    border-color: #4a7ba7;
    color: #87ceeb;
    margin-top: 0.5rem;
}

.secondary-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #3d4e60 0%, #2a3342 100%);
    border-color: #5a8bb7;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 123, 167, 0.4);
}

.btn-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.8));
}

.btn-text {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0;
    font-weight: 700;
}

.login-footer {
    padding: 1rem;
    text-align: center;
    background: linear-gradient(135deg, #3f2c20 0%, #251b17 100%);
    border-top: 1px solid #7a4519;
}

.footer-decoration {
    color: #a79277;
    font-size: 1.2rem;
    opacity: 0.7;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.8));
}

/* Follow Us Section */
.follow-us-card {
    background: linear-gradient(135deg, #493324 0%, #3f2c20 100%);
    border: 3px solid #7a4519;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.8),
        inset 0 2px 0 rgba(90, 90, 100, 0.3),
        0 0 30px rgba(196, 129, 69, 0.2);
    overflow: hidden;
    position: relative;
}

.follow-us-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #c48145 0%, #ffd700 50%, #c48145 100%);
}

.follow-us-header {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #5e412d 0%, #493324 100%);
    border-bottom: 2px solid #7a4519;
}

.follow-us-title {
    color: #c48145;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

.follow-us-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #5e412d 0%, #493324 100%);
    border: 2px solid #7a4519;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.social-link:hover {
    transform: translateY(-2px);
    border-color: #c48145;
    box-shadow: 0 6px 16px rgba(196, 129, 69, 0.4);
}

.instagram-link:hover {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border-color: #fd1d1d;
}

.discord-link:hover {
    background: linear-gradient(135deg, #5865f2 0%, #404eed 100%);
    border-color: #5865f2;
}

.social-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(196, 129, 69, 0.6));
}

.social-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.social-platform {
    color: #c48145;
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.social-handle {
    color: #d1bb9e;
    font-size: 0.9rem;
    font-style: italic;
}

/* Tablet and smaller - Stack vertically */
@media (max-width: 1024px) {
    .login-wrapper {
        flex-direction: column;
        gap: 2rem;
    }

    .login-left,
    .login-right {
        width: 100%;
        max-width: 450px;
    }

    .follow-us-card {
        max-width: 450px;
    }
}

/* Mobile Landscape - Compact login */
@media only screen and (max-height: 500px) and (orientation: landscape) {
    .login-container {
        padding: 0.5rem;
        align-items: flex-start;
        overflow-y: auto;
    }

    .login-wrapper {
        flex-direction: row;
        gap: 1rem;
        align-items: flex-start;
    }

    .login-left,
    .login-right {
        max-width: 50%;
    }

    .samurai-login-card,
    .follow-us-card {
        max-width: 100%;
        max-height: 90dvh;
        overflow-y: auto;
    }

    .login-header {
        padding: 0.5rem;
    }

    .login-icon {
        display: none;
    }

    .tab-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .tab-icon {
        font-size: 0.9rem;
    }

    .login-form {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .logo-image {
        height: 40px;
    }

    .login-title {
        font-size: 0.9rem;
        margin: 0;
    }

    .login-body {
        padding: 0.5rem;
    }

    .form-group {
        gap: 0.2rem;
    }

    .samurai-label {
        font-size: 0.7rem;
    }

    .samurai-input {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    .char-limit-info {
        font-size: 0.6rem;
        margin-top: 0.1rem;
    }

    .samurai-alert {
        padding: 0.4rem;
        gap: 0.3rem;
        margin-bottom: 0.5rem;
        font-size: 0.7rem;
    }

    .alert-icon {
        font-size: 0.9rem;
    }

    .button-group {
        flex-direction: row;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .samurai-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }

    .btn-icon {
        font-size: 0.9rem;
    }

    .btn-text {
        font-size: 0.7rem;
    }

    .login-form {
        gap: 0.5rem;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
        min-height: 100dvh;
    }

    .login-wrapper {
        flex-direction: column;
    }

    .samurai-login-card,
    .follow-us-card {
        max-width: 100%;
    }

    .login-header {
        padding: 1.5rem;
    }

    .login-form {
        padding: 1.5rem;
    }

    .login-title {
        font-size: 1.3rem;
    }

    .button-group {
        gap: 0.75rem;
    }

    .follow-us-header {
        padding: 1.5rem;
    }

    .follow-us-body {
        padding: 1.5rem;
    }

    .social-link {
        padding: 1rem;
    }
}

/* Animation */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* GEMS TAB STYLING */
.gems-tab {
    padding: var(--spacing-md);
    overflow-y: auto;
    max-height: calc(100dvh - 180px);
}

.gems-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.gems-header h3 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.gems-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.gems-collection {
    display: flex;
    flex-direction: column;
}

.gem-type-row {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.gem-type-header {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1bb9e;
    font-weight: bold;
    min-height: 40px;
}

.gem-stat {
    font-size: 1.1rem;
    font-weight: bold;
}

.gem-flags-container {
    display: flex;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
    justify-content: center;
}

.gem-flag-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.gem-flag {
    width: 60px;
    height: 60px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
    cursor: default;
    background: var(--bg-primary);
}

.gem-flag:hover {
    transform: translateY(-2px);
}

.gem-flag-greyed {
    opacity: 0.2;
    filter: grayscale(95%);
}

.gem-flag-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.gem-flag-count {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--success-color);
}

.btn-upgrade-flag {
    width: 32px;
    height: 24px;
    border: 2px solid;
    border-radius: var(--border-radius-sm);
    color: #d1bb9e;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-upgrade-flag:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-upgrade-flag:active {
    transform: scale(0.95);
}

.gem-assignments {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.gem-assignments-header {
    font-weight: bold;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.gem-assignment-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    padding: var(--spacing-xs);
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
}

.gem-assignment-level {
    font-weight: bold;
    color: var(--primary-color);
    min-width: 40px;
}

.gem-city-select {
    flex: 1;
    padding: 0.4rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.gem-city-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.gem-assignment-city {
    font-size: 0.8rem;
    color: var(--info-color);
    font-weight: 500;
}

/* Mobile landscape optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .gems-tab {
        padding: var(--spacing-sm);
        max-height: calc(100dvh - 120px);
    }

    .gem-type-header {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-height: 35px;
    }

    .gem-flags-container {
        padding: var(--spacing-sm);
        gap: 12px;
    }

    .gem-flag {
        width: 50px;
        height: 50px;
    }

    .gem-flag-icon {
        font-size: 1.4rem;
    }

    .gem-assignments {
        padding: var(--spacing-sm);
    }
}

/* Tablet and smaller */
@media (max-width: 768px) {
    .gem-flag {
        width: 58px;
        height: 58px;
    }

    .gem-flag-icon {
        font-size: 1.6rem;
    }

    .gem-flags-container {
        gap: 16px;
    }
}

/* Icon Color Classes - for resource/troop type coloring */
/* Duotone icons: :before = inner (lighter), :after = outline (darker base color) */
/* Boosted contrast: brighter outlines for dark backgrounds, fully opaque duotone fill */
.icon-wood {
    color: #7fcf7f !important;
    text-shadow: 0 0 6px rgba(127, 207, 127, 0.55) !important;
}
.icon-wood:before {
    color: #c8f0c8 !important;
    opacity: 1 !important;
}

.icon-clay {
    color: #d97a3a !important;
    text-shadow: 0 0 6px rgba(217, 122, 58, 0.55) !important;
}
.icon-clay:before {
    color: #e89866 !important;
    opacity: 1 !important;
}

.icon-brick-wall {
    color: #c08555 !important;
    text-shadow: 0 0 6px rgba(192, 133, 85, 0.55) !important;
}
.icon-brick-wall:before {
    color: #e6b890 !important;
    opacity: 1 !important;
}

.icon-wheat {
    color: #d4a52b !important;
    text-shadow: 0 0 6px rgba(212, 165, 43, 0.55) !important;
}
.icon-wheat:before {
    color: #f0d878 !important;
    opacity: 1 !important;
}

.icon-iron {
    color: #a8a8b0 !important;
    text-shadow: 0 0 6px rgba(168, 168, 176, 0.55) !important;
}
.icon-iron:before {
    color: #d8d8e0 !important;
    opacity: 1 !important;
}

.icon-crop {
    color: #8bc34a !important;
    text-shadow: 0 0 6px rgba(139, 195, 74, 0.55) !important;
}
.icon-crop:before {
    color: #c5e878 !important;
    opacity: 1 !important;
}

.icon-gold {
    color: #b87333 !important;
    text-shadow: 0 0 6px rgba(255, 193, 7, 0.65) !important;
}
.icon-gold:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

.icon-star {
    color: #b87333 !important;
    text-shadow: 0 0 6px rgba(255, 193, 7, 0.65) !important;
}
.icon-star:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

/* Building icon colors - boosted for dark backgrounds, full duotone */
.icon-castle {
    color: #d4a52b !important;
    text-shadow: 0 0 6px rgba(196, 129, 69, 0.55) !important;
}
.icon-castle:before {
    color: #ffd966 !important;
    opacity: 1 !important;
}

.icon-dojo {
    color: #f04757 !important;
    text-shadow: 0 0 6px rgba(220, 53, 69, 0.55) !important;
}
.icon-dojo:before {
    color: #ff8a95 !important;
    opacity: 1 !important;
}

.icon-email-white {
    color: #f5f5f5 !important;
    text-shadow: 0 0 6px rgba(245, 245, 245, 0.25) !important;
}
.icon-email-white:before {
    color: #888888 !important;
    opacity: 1 !important;
}

.icon-wall {
    color: #d97745 !important;
    text-shadow: 0 0 6px rgba(121, 85, 72, 0.55) !important;
}
.icon-wall:before {
    color: #f0a679 !important;
    opacity: 1 !important;
}

.icon-market {
    color: #b87333 !important;
    text-shadow: 0 0 6px rgba(255, 193, 7, 0.55) !important;
}
.icon-market:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

.icon-granary {
    color: #c5e64a !important;
    text-shadow: 0 0 6px rgba(205, 220, 57, 0.55) !important;
}
.icon-granary:before {
    color: #e0f48a !important;
    opacity: 1 !important;
}

.icon-storage {
    color: #78909c !important;
    text-shadow: 0 0 6px rgba(96, 125, 139, 0.55) !important;
}
.icon-storage:before {
    color: #a4b8c4 !important;
    opacity: 1 !important;
}

.icon-houses {
    color: #ec407a !important;
    text-shadow: 0 0 6px rgba(233, 30, 99, 0.55) !important;
}
.icon-houses:before {
    color: #f88cb3 !important;
    opacity: 1 !important;
}

.icon-barracks {
    color: #ab47bc !important;
    text-shadow: 0 0 6px rgba(156, 39, 176, 0.55) !important;
}
.icon-barracks:before {
    color: #d281e0 !important;
    opacity: 1 !important;
}

.icon-ninja-den {
    color: #78909c !important;
    text-shadow: 0 0 6px rgba(96, 125, 139, 0.55) !important;
}
.icon-ninja-den:before {
    color: #a4b8c4 !important;
    opacity: 1 !important;
}

.icon-archery-range {
    color: #26c6da !important;
    text-shadow: 0 0 6px rgba(0, 188, 212, 0.55) !important;
}
.icon-archery-range:before {
    color: #80deea !important;
    opacity: 1 !important;
}

.icon-stables {
    color: #ff7043 !important;
    text-shadow: 0 0 6px rgba(255, 87, 34, 0.55) !important;
}
.icon-stables:before {
    color: #ffa590 !important;
    opacity: 1 !important;
}

.icon-academy {
    color: #7e57c2 !important;
    text-shadow: 0 0 6px rgba(103, 58, 183, 0.55) !important;
}
.icon-academy:before {
    color: #b39dde !important;
    opacity: 1 !important;
}

.icon-workshop {
    color: #d97745 !important;
    text-shadow: 0 0 6px rgba(121, 85, 72, 0.55) !important;
}
.icon-workshop:before {
    color: #f0a679 !important;
    opacity: 1 !important;
}

.icon-warehouse {
    color: #c5e64a !important;
    text-shadow: 0 0 6px rgba(205, 220, 57, 0.55) !important;
}
.icon-warehouse:before {
    color: #e0f48a !important;
    opacity: 1 !important;
}

.icon-package {
    color: #78909c !important;
    text-shadow: 0 0 6px rgba(96, 125, 139, 0.55) !important;
}
.icon-package:before {
    color: #a4b8c4 !important;
    opacity: 1 !important;
}

.icon-house {
    color: #ec407a !important;
    text-shadow: 0 0 6px rgba(233, 30, 99, 0.55) !important;
}
.icon-house:before {
    color: #f88cb3 !important;
    opacity: 1 !important;
}

.icon-village {
    color: #d4a574 !important;
    text-shadow: 0 0 6px rgba(212, 165, 116, 0.55) !important;
}
.icon-village:before {
    color: #9ca3af !important;
    opacity: 1 !important;
}

.icon-buildings {
    color: #f04757 !important;
    text-shadow: 0 0 6px rgba(220, 53, 69, 0.55) !important;
}
.icon-buildings:before {
    color: #ff8a95 !important;
    opacity: 1 !important;
}

.icon-sword {
    color: #ab47bc !important;
    text-shadow: 0 0 6px rgba(156, 39, 176, 0.55) !important;
}
.icon-sword:before {
    color: #d281e0 !important;
    opacity: 1 !important;
}

.icon-star-fill {
    color: #b87333 !important;
    text-shadow: 0 0 6px rgba(255, 193, 7, 0.65) !important;
}
.icon-star-fill:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

.icon-target {
    color: #26c6da !important;
    text-shadow: 0 0 6px rgba(0, 188, 212, 0.55) !important;
}
.icon-target:before {
    color: #80deea !important;
    opacity: 1 !important;
}

.icon-horse {
    color: #ff7043 !important;
    text-shadow: 0 0 6px rgba(255, 87, 34, 0.55) !important;
}
.icon-horse:before {
    color: #ffa590 !important;
    opacity: 1 !important;
}

.icon-storefront {
    color: #b87333 !important;
    text-shadow: 0 0 6px rgba(255, 193, 7, 0.55) !important;
}
.icon-storefront:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

.icon-book-open {
    color: #7e57c2 !important;
    text-shadow: 0 0 6px rgba(103, 58, 183, 0.55) !important;
}
.icon-book-open:before {
    color: #b39dde !important;
    opacity: 1 !important;
}

.icon-hammer {
    color: #d97745 !important;
    text-shadow: 0 0 6px rgba(121, 85, 72, 0.55) !important;
}
.icon-hammer:before {
    color: #f0a679 !important;
    opacity: 1 !important;
}

.icon-shield {
    color: #d97745 !important;
    text-shadow: 0 0 6px rgba(121, 85, 72, 0.55) !important;
}
.icon-shield:before {
    color: #f0a679 !important;
    opacity: 1 !important;
}

/* Troop icon colors - boosted for dark backgrounds, full duotone */
.icon-recruit {
    color: #fbbf24 !important;
    text-shadow: 0 0 6px rgba(251, 191, 36, 0.55) !important;
}
.icon-recruit:before {
    color: #c48145 !important;
    opacity: 1 !important;
}

.icon-archer {
    color: #5dd55d !important;
    text-shadow: 0 0 6px rgba(50, 205, 50, 0.55) !important;
}
.icon-archer:before {
    color: #98e898 !important;
    opacity: 1 !important;
}

.icon-samurai {
    color: #6189f0 !important;
    text-shadow: 0 0 6px rgba(65, 105, 225, 0.55) !important;
}
.icon-samurai:before {
    color: #9eb4f4 !important;
    opacity: 1 !important;
}

.icon-cavalry {
    color: #ef4d6b !important;
    text-shadow: 0 0 6px rgba(220, 20, 60, 0.55) !important;
}
.icon-cavalry:before {
    color: #f48a9c !important;
    opacity: 1 !important;
}

.icon-ninja {
    color: #78909c !important;
    text-shadow: 0 0 6px rgba(96, 125, 139, 0.55) !important;
}
.icon-ninja:before {
    color: #a4b8c4 !important;
    opacity: 1 !important;
}

.icon-ram {
    color: #d97745 !important;
    text-shadow: 0 0 6px rgba(121, 85, 72, 0.55) !important;
}
.icon-ram:before {
    color: #f0a679 !important;
    opacity: 1 !important;
}

.icon-merchant {
    color: #ff8a3a !important;
    text-shadow: 0 0 6px rgba(253, 126, 20, 0.55) !important;
}
.icon-merchant:before {
    color: #ffb380 !important;
    opacity: 1 !important;
}

/* Tech / science / knowledge blue duotone */
.icon-tech {
    color: #1e88e5 !important;
    text-shadow: 0 0 6px rgba(30, 136, 229, 0.55) !important;
}
.icon-tech:before {
    color: #90caf9 !important;
    opacity: 1 !important;
}

/* Lock icon - neutral grey for "locked" state indicators */
.icon-lock {
    color: #c0c0c0 !important;
    text-shadow: 0 0 6px rgba(192, 192, 192, 0.55) !important;
}
.icon-lock:before {
    color: #e0e0e0 !important;
    opacity: 1 !important;
}

.icon-alert-success {
    color: #3ec55e !important;
    text-shadow: 0 0 6px rgba(40, 167, 69, 0.65) !important;
}
.icon-alert-success:before {
    color: #7ee093 !important;
    opacity: 1 !important;
}

.icon-alert-error {
    color: #f04757 !important;
    text-shadow: 0 0 6px rgba(220, 53, 69, 0.65) !important;
}
.icon-alert-error:before {
    color: #ff8a95 !important;
    opacity: 1 !important;
}

/* village-type-badge: filled 100% duotone - strong outline + lighter inner, 100% opacity */
.village-type-badge .ph-duotone {
    /* Strong outline color is set by icon-* class; ensure visibility against badge bg */
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.6) !important;
}
.village-type-badge .ph-duotone:before {
    opacity: 1 !important;
    text-shadow: none !important;
}

/* Shared popup close control: one bold Phosphor X, without circular chrome. */
button.popup-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    appearance: none;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    color: #d1bb9e;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.18s ease, transform 0.18s ease;
}

button.popup-close-button:hover,
button.popup-close-button:active,
button.popup-close-button:focus {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
}

button.popup-close-button:hover {
    color: var(--warriors-roasted-copper);
    transform: scale(1.08);
}

button.popup-close-button:focus-visible {
    outline: 2px solid #c48145;
    outline-offset: 2px;
}

button.popup-close-button .ph-bold {
    display: block;
}

/* Application-wide modal composition. Page-specific classes control content,
   while these classes keep every popup visually consistent. */
div.app-modal-overlay.app-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    overflow: auto;
    background: rgba(37, 27, 23, 0.82);
    backdrop-filter: blur(3px);
    z-index: 10000;
}

div.app-modal-surface.app-modal-surface {
    --app-modal-width: 560px;
    position: relative;
    width: min(92vw, var(--app-modal-width));
    min-width: 0;
    max-width: var(--app-modal-width);
    max-height: 84dvh;
    padding: 0;
    overflow-y: auto;
    isolation: isolate;
    color: var(--modal-text);
    background:
        repeating-linear-gradient(0deg, rgba(89, 48, 15, 0.025) 0 1px, transparent 1px 4px),
        radial-gradient(ellipse at top left, rgba(89, 48, 15, 0.24), transparent 22%),
        radial-gradient(ellipse at top right, rgba(89, 48, 15, 0.2), transparent 22%),
        radial-gradient(ellipse at bottom left, rgba(89, 48, 15, 0.22), transparent 24%),
        radial-gradient(ellipse at bottom right, rgba(89, 48, 15, 0.24), transparent 24%),
        linear-gradient(90deg, #92775b 0%, #ad9374 5%, #bea789 50%, #ad9374 95%, #92775b 100%);
    border: 1px solid var(--modal-border);
    border-radius: 0;
    clip-path: polygon(
        1.1% 0.9%, 18% 0.25%, 32% 0.8%, 49% 0.3%, 67% 0.85%, 83% 0.2%, 98.9% 0.95%,
        99.4% 20%, 98.9% 35%, 99.55% 50%, 98.9% 66%, 99.45% 82%, 98.8% 99%,
        82% 99.55%, 66% 98.95%, 50% 99.6%, 34% 98.95%, 18% 99.5%, 1.15% 98.95%,
        0.55% 82%, 1.15% 66%, 0.45% 50%, 1.1% 35%, 0.55% 19%
    );
    box-shadow:
        0 18px 55px rgba(37, 27, 23, 0.72),
        inset 0 0 22px rgba(89, 48, 15, 0.28);
}

div.app-modal-surface.app-modal-surface:not(.city-scroll-prototype):not(.help-scroll-surface)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(89, 48, 15, 0.38), transparent 5%, transparent 94%, rgba(89, 48, 15, 0.4)),
        linear-gradient(90deg, rgba(89, 48, 15, 0.3), transparent 5%, transparent 95%, rgba(89, 48, 15, 0.34));
}

div.app-modal-surface.app-modal-surface:not(.city-scroll-prototype):not(.help-scroll-surface)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    box-shadow:
        inset 0 0 7px rgba(74, 35, 12, 0.46),
        inset 0 0 24px rgba(122, 69, 25, 0.22);
}

div.app-modal-surface.app-modal-surface > .app-modal-header,
div.app-modal-surface.app-modal-surface > .app-modal-body,
div.app-modal-surface.app-modal-surface > .app-modal-footer {
    position: relative;
    z-index: 1;
}

div.app-modal-surface.app-modal-wide {
    --app-modal-width: 820px;
}

div.app-modal-surface.app-modal-compact {
    --app-modal-width: 460px;
}

:is(div, header).app-modal-header.app-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    padding: calc(var(--modal-padding-y) + 0.18rem) calc(var(--modal-padding-x) + 0.25rem) 0.78rem;
    color: var(--modal-text);
    background:
        radial-gradient(ellipse at top left, rgba(89, 48, 15, 0.2), transparent 35%),
        radial-gradient(ellipse at top right, rgba(89, 48, 15, 0.18), transparent 35%),
        linear-gradient(180deg, rgba(209, 187, 158, 0.72), rgba(167, 146, 119, 0.48));
    border: 0;
    border-bottom: 1px solid rgba(122, 69, 25, 0.52);
}

:is(h2, h3, h4, h5, h6).app-modal-title.app-modal-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    color: var(--warriors-deep-brown) !important;
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    border: 0;
}

.app-modal-surface .app-modal-header :is(h2, h3, h4, h5, h6) {
    color: var(--warriors-deep-brown) !important;
    -webkit-text-fill-color: var(--warriors-deep-brown);
}

.app-modal-surface .app-modal-header :is(h2, h3, h4, h5, h6) > i {
    color: var(--warriors-roasted-copper) !important;
    -webkit-text-fill-color: var(--warriors-roasted-copper);
}

.app-modal-title > i,
.app-modal-title .modal-icon {
    color: var(--warriors-roasted-copper);
    font-size: 1.2rem;
}

.app-modal-title .modal-subtitle {
    color: var(--warriors-walnut);
    font-size: inherit;
    font-weight: inherit;
    text-transform: none;
    letter-spacing: 0;
}

div.app-modal-body.app-modal-body {
    margin: 0;
    padding: var(--modal-padding-y) calc(var(--modal-padding-x) + 0.25rem) 0.95rem;
    color: var(--modal-text);
    background: linear-gradient(135deg, rgba(190, 167, 137, 0.72), rgba(167, 146, 119, 0.74));
}

div.app-modal-footer.app-modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin: 0;
    padding: 0.78rem calc(var(--modal-padding-x) + 0.25rem) calc(var(--modal-padding-y) + 0.2rem);
    background:
        radial-gradient(ellipse at bottom left, rgba(89, 48, 15, 0.2), transparent 35%),
        radial-gradient(ellipse at bottom right, rgba(89, 48, 15, 0.18), transparent 35%),
        rgba(209, 187, 158, 0.45);
    border-top: 1px solid var(--modal-border-muted);
}

.app-modal-surface :is(input, textarea, select) {
    color: var(--modal-text) !important;
    background-color: rgba(234, 216, 192, 0.45) !important;
    border-color: var(--warriors-chestnut) !important;
    color-scheme: light;
}

.app-modal-surface :is(input, textarea, select):focus {
    color: var(--modal-text) !important;
    background-color: rgba(234, 216, 192, 0.58) !important;
    border-color: var(--modal-accent) !important;
    box-shadow: 0 0 0 2px rgba(196, 129, 69, 0.18) !important;
}

.app-modal-surface :is(p, li, label, span, strong, small) {
    color: inherit;
}

.app-modal-surface :is(h4, h5, h6),
.app-modal-surface .section-title {
    color: var(--warriors-deep-brown) !important;
}

.app-modal-body :where(p, li, label, small, span, strong, dt, dd) {
    color: var(--warriors-deep-brown) !important;
}

.app-modal-surface button :where(span, strong) {
    color: var(--warriors-cream) !important;
}

.app-modal-surface :is(.text-danger, .error-message, .danger-text, .status-danger) {
    color: var(--warriors-red-deep) !important;
}

.app-modal-surface :is(.text-success, .success-message, .status-success) {
    color: var(--warriors-green-deep) !important;
}

.app-modal-surface :is(.text-info, .status-info, .defense-text) {
    color: var(--warriors-blue-deep) !important;
}

.app-modal-surface :is(
    .section,
    .info-section,
    .message-box,
    .achievements-box,
    .cities-box,
    .winner-card,
    .achievement-item,
    .stat-row,
    .city-intel-section,
    .city-intel-fact,
    .city-intel-report-row,
    .city-intel-conquest,
    .protection-warning-content
) {
    color: var(--warriors-deep-brown) !important;
    background: rgba(234, 216, 192, 0.22) !important;
    border-color: rgba(122, 69, 25, 0.48) !important;
    box-shadow: inset 0 1px 0 rgba(234, 216, 192, 0.18);
}

.app-modal-surface :is(.btn, button:not(.popup-close-button)) {
    color: var(--warriors-cream);
    background: linear-gradient(180deg, var(--warriors-roasted-copper), var(--warriors-chestnut));
    border-color: var(--warriors-deep-umber);
    box-shadow: inset 0 1px 0 rgba(234, 216, 192, 0.18);
}

.app-modal-surface :is(.btn, button:not(.popup-close-button)):hover:not(:disabled) {
    color: var(--warriors-cream);
    background: linear-gradient(180deg, var(--warriors-copper), var(--warriors-rust));
    border-color: var(--warriors-burnt-umber);
}

.app-modal-surface :is(.btn, button:not(.popup-close-button)):disabled {
    color: rgba(73, 51, 36, 0.58);
    background: var(--warriors-taupe);
    border-color: rgba(89, 48, 15, 0.35);
    box-shadow: none;
}

.app-modal-surface :is(.btn-danger, .delete-button, .danger-button) {
    background: linear-gradient(180deg, var(--warriors-red-highlight), var(--warriors-red));
    border-color: var(--warriors-red-deep);
}

.app-modal-surface :is(.btn-success, .select-button, .confirm-button) {
    background: linear-gradient(180deg, #708858, var(--warriors-green));
    border-color: var(--warriors-green-deep);
}

.app-modal-surface :is(.btn-info, .defend-button, .defense-button) {
    background: linear-gradient(180deg, var(--warriors-blue-highlight), var(--warriors-blue));
    border-color: var(--warriors-blue-deep);
}

@media (max-width: 520px) {
    div.app-modal-overlay.app-modal-overlay {
        padding: 0.45rem;
    }

    div.app-modal-surface.app-modal-surface {
        width: 94vw;
        max-height: 90dvh;
        clip-path: polygon(
            1.5% 0.8%, 22% 0.2%, 50% 0.8%, 78% 0.2%, 98.5% 0.8%,
            99.4% 28%, 98.6% 50%, 99.4% 72%, 98.5% 99.2%,
            76% 99.7%, 50% 99.15%, 24% 99.7%, 1.5% 99.15%,
            0.6% 72%, 1.4% 50%, 0.6% 28%
        );
    }
}

@media (prefers-reduced-motion: reduce) {
    div.app-modal-surface.app-modal-surface,
    div.app-modal-overlay.app-modal-overlay {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================
   WARRIORS APPLICATION THEME CONTRACT
   Shared chrome for every authenticated tab.
   ============================================ */

:is(
    .page-container,
    .tab-container,
    .tab-main-layout,
    .market-page-container,
    .market-container,
    .market-main-layout,
    .news-page,
    .news-content,
    .nexus-container,
    .armies-container,
    .emails-container,
    .village-container,
    .barracks-container,
    .tech-container,
    .ranking-container
) {
    color: var(--warriors-cream);
    background-color: var(--warriors-ink) !important;
}

:is(
    .tab-main-layout,
    .page-container > .tab-container,
    .page-container > .armies-container,
    .page-container > .news-content
) {
    background: var(--warriors-cocoa) !important;
}

.page-container.village-page {
    background: var(--warriors-cocoa) !important;
}

:is(
    .tab-header,
    .market-header,
    .news-header,
    .nexus-header,
    .armies-header,
    .emails-header,
    .village-header,
    .barracks-header,
    .tech-header,
    .compact-header
) {
    color: var(--warriors-cream) !important;
    background: linear-gradient(180deg, var(--warriors-espresso), var(--warriors-ink)) !important;
    border-color: var(--warriors-chestnut) !important;
    box-shadow:
        0 2px 8px rgba(37, 27, 23, 0.58),
        inset 0 1px 0 rgba(234, 216, 192, 0.06) !important;
}

:is(
    .tab-header,
    .market-header,
    .news-header,
    .nexus-header,
    .armies-header,
    .emails-header,
    .village-header,
    .barracks-header,
    .tech-header
) :is(h2, h3, h4, h5, h6) {
    color: var(--warriors-cream) !important;
}

:is(
    .tab-header,
    .market-header,
    .news-header,
    .nexus-header,
    .armies-header,
    .emails-header,
    .village-header,
    .barracks-header,
    .tech-header
) > :is(i, h2 i, h3 i, h4 i) {
    color: var(--warriors-copper) !important;
}

:is(
    .section-header,
    .ranking-section-title,
    .history-header,
    .reader-header,
    .cards-header,
    .gems-header,
    .boosters-header,
    .evolution-header,
    .building-header,
    .training-header,
    .order-header
) {
    color: var(--warriors-sandstone) !important;
    background: linear-gradient(180deg, var(--warriors-espresso), var(--warriors-ink)) !important;
    border-color: var(--warriors-chestnut) !important;
}

:is(
    .left-panel,
    .right-panel,
    .inbox-panel,
    .reader-panel,
    .ranking-table,
    .market-window,
    .market-orders-section,
    .price-history-compact,
    .market-queue-section,
    .exchange-card,
    .order-section,
    .tech-tree-container,
    .training-section,
    .training-queue-section,
    .buildings-section,
    .building-queue-section,
    .armies-section,
    .news-article,
    .admin-commands-section,
    .game-setup,
    .setup-content,
    .cards-view-wrapper,
    .evolution-panel,
    .player-hand-section
) {
    color: var(--warriors-cream);
    background-color: var(--warriors-cocoa) !important;
    border-color: var(--warriors-chestnut) !important;
}

:is(
    .army-card,
    .winner-card,
    .status-card,
    .type-card,
    .trade-queue-item,
    .building-row,
    .troop-row,
    .ranking-row,
    .email-list-item,
    .order-item,
    .resource-row
) {
    color: var(--warriors-cream);
    border-color: var(--warriors-deep-umber);
}

:is(
    .market-type-tab,
    .resource-tab,
    .sub-tab,
    .period-btn-compact,
    .army-filter-tab,
    .message-filter-tab,
    .tab-button
) {
    color: var(--warriors-sandstone) !important;
    background: linear-gradient(180deg, var(--warriors-deep-brown), var(--warriors-cocoa)) !important;
    border-color: var(--warriors-walnut) !important;
}

:is(
    .market-type-tab,
    .resource-tab,
    .sub-tab,
    .period-btn-compact,
    .army-filter-tab,
    .message-filter-tab,
    .tab-button
):hover:not(:disabled) {
    color: var(--warriors-cream) !important;
    background: linear-gradient(180deg, var(--warriors-walnut), var(--warriors-deep-brown)) !important;
    border-color: var(--warriors-copper) !important;
}

:is(
    .market-type-tab,
    .resource-tab,
    .sub-tab,
    .period-btn-compact,
    .army-filter-tab,
    .message-filter-tab,
    .tab-button
).active {
    color: var(--warriors-cream) !important;
    background: linear-gradient(180deg, var(--warriors-roasted-copper), var(--warriors-chestnut)) !important;
    border-color: var(--warriors-copper) !important;
    box-shadow: inset 0 -2px 0 var(--warriors-copper) !important;
}

:is(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select,
    .form-control,
    .form-select,
    .compact-input,
    .exchange-input,
    .exchange-select
) {
    color: var(--warriors-cream);
    background-color: var(--warriors-walnut);
    border-color: var(--warriors-chestnut);
}

:is(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select,
    .form-control,
    .form-select,
    .compact-input,
    .exchange-input,
    .exchange-select
)::placeholder {
    color: var(--warriors-taupe);
}

:is(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select,
    .form-control,
    .form-select,
    .compact-input,
    .exchange-input,
    .exchange-select
):focus {
    color: var(--warriors-cream);
    background-color: var(--warriors-walnut);
    border-color: var(--warriors-copper);
    box-shadow: 0 0 0 2px rgba(196, 129, 69, 0.18);
}

:is(.btn-primary, .samurai-btn, .send-btn, .btn-exchange, .btn-start-game, .btn-rematch, .btn-save-deck) {
    color: var(--warriors-cream);
    background: linear-gradient(180deg, var(--warriors-roasted-copper), var(--warriors-chestnut));
    border-color: var(--warriors-deep-umber);
}

:is(.btn-primary, .samurai-btn, .send-btn, .btn-exchange, .btn-start-game, .btn-rematch, .btn-save-deck):hover:not(:disabled) {
    color: var(--warriors-cream);
    background: linear-gradient(180deg, var(--warriors-copper), var(--warriors-rust));
    border-color: var(--warriors-burnt-umber);
}

:is(.btn-danger, .delete-btn, .reader-delete-btn, .end-season-btn, .btn-cancel-attack-inline) {
    color: var(--warriors-cream);
    background-color: var(--warriors-red);
    border-color: var(--warriors-red-deep);
}

:is(.btn-success, .confirm-btn) {
    color: var(--warriors-cream);
    background-color: var(--warriors-green);
    border-color: var(--warriors-green-deep);
}

:is(.btn-info, .defense-button) {
    color: var(--warriors-cream);
    background-color: var(--warriors-blue);
    border-color: var(--warriors-blue-deep);
}

.help-button {
    color: var(--warriors-copper) !important;
    background: transparent !important;
    border-color: var(--warriors-copper) !important;
    box-shadow: none !important;
}

.help-button:hover {
    color: var(--warriors-cream) !important;
    background: rgba(196, 129, 69, 0.14) !important;
}

:is(table, .ranking-header-row, .order-header) {
    border-color: var(--warriors-chestnut);
}

:is(th, .ranking-header-row, .order-header) {
    color: var(--warriors-cream);
    background-color: var(--warriors-deep-brown);
}

:is(td, .ranking-row, .order-item) {
    border-color: var(--warriors-deep-umber);
}

a:not(.nav-link) {
    color: var(--warriors-copper);
}

a:not(.nav-link):hover {
    color: var(--warriors-rust);
}

/* ============================================
   VISUAL REFINEMENT
   Keep the established chrome while giving content a clearer depth hierarchy.
   ============================================ */

:root {
    --surface-card: #4a3428;
    --surface-card-hover: #543a2b;
    --border-hairline: rgba(196, 129, 69, 0.34);
    --text-muted: #b9a68f;
    --focus-ring: rgba(196, 129, 69, 0.32);
}

:is(
    .left-panel,
    .right-panel,
    .inbox-panel,
    .ranking-table,
    .market-window,
    .market-orders-section,
    .price-history-compact,
    .market-queue-section,
    .exchange-card,
    .order-section,
    .training-section,
    .training-queue-section,
    .buildings-section,
    .building-queue-section,
    .armies-section,
    .news-article,
    .admin-commands-section
) {
    background: linear-gradient(145deg, var(--surface-card) 0%, var(--warriors-espresso) 100%) !important;
    border-color: var(--border-hairline) !important;
    box-shadow:
        0 5px 14px rgba(37, 27, 23, 0.24),
        inset 0 1px 0 rgba(234, 216, 192, 0.045) !important;
}

.building-queue-section > .section-header,
.training-queue-section > .section-header {
    padding-block-end: 2px;
}

:is(
    .building-row,
    .troop-row,
    .ranking-row,
    .email-item,
    .order-item,
    .trade-queue-item,
    .army-card,
    .status-card,
    .type-card
) {
    background-color: rgba(94, 65, 45, 0.34);
    border-color: rgba(167, 146, 119, 0.44) !important;
    box-shadow: inset 0 1px 0 rgba(234, 216, 192, 0.035);
}

:is(
    .building-row,
    .troop-row,
    .ranking-row,
    .email-item,
    .order-item,
    .trade-queue-item,
    .army-card
):hover {
    background-color: rgba(94, 65, 45, 0.58);
    border-color: rgba(196, 129, 69, 0.58) !important;
}

:is(
    .section-header,
    .ranking-section-title,
    .history-header,
    .reader-header,
    .building-header,
    .training-header,
    .order-header
) {
    box-shadow:
        inset 3px 0 0 var(--warriors-roasted-copper),
        inset 0 -1px 0 rgba(196, 129, 69, 0.22) !important;
}

:is(
    .empty-queue-message,
    .empty-emails-section,
    .reader-empty-state,
    .empty-message,
    .no-armies-message
) {
    color: var(--text-muted) !important;
}

:is(.article-date, .email-date, .email-preview, .message-time, .queue-empty, .empty-state p) {
    color: var(--text-muted) !important;
}

.message-sender {
    color: var(--warriors-blue-highlight) !important;
}

:is(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--warriors-copper) !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--focus-ring) !important;
}

:is(button, .btn, .samurai-btn):disabled {
    filter: saturate(0.45);
    opacity: 0.52;
}

.help-button {
    line-height: 1;
}

* {
    scrollbar-color: var(--warriors-roasted-copper) var(--warriors-ink);
    scrollbar-width: thin;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid var(--warriors-ink);
    border-radius: 999px;
    background: var(--warriors-roasted-copper);
}

*::-webkit-scrollbar-track {
    background: var(--warriors-ink);
}

@media (prefers-reduced-motion: reduce) {
    :is(button, a, .building-row, .troop-row, .ranking-row, .email-item, .order-item) {
        transition: none !important;
    }
}
/* Analytics dashboard styles are isolated in Pages/Analytics.razor.css. This
   marker participates in the global CSS cache hash when that admin surface ships. */
