/*
 * A0 Board Game - Stylesheet - Version A2.0.0 Reskin
 * Reskinned with 9-slice stone, parchment, and wood/gold assets.
 * Board and token styles are left completely untouched.
 */

/* Fonts are loaded via <link> in index.html; no @import needed here. */

:root {
    --bg-color: #080b13;
    --text-color: #f8f9fa;
    --accent-color: #ffe680; /* gold-ish accent */
    --hex-fill: rgba(255, 255, 255, 0.02);
    --hex-stroke: rgba(255, 255, 255, 0.12);
    --hex-hover-stroke: #ffe680;
    --hex-text: #ffffff;
    --header-bg: #0d1321;
    --footer-bg: #0d1321;
    --border-color: rgba(255, 255, 255, 0.08);
}

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

body {
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 50%, #161f38 0%, #07090f 100%);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    transition: background-image 0.5s ease;
}

body.perspective-p1 {
    background-image: url('../images/bg_player1.jpg');
    background-size: cover;
    background-position: center;
}

body.perspective-p2 {
    background-image: url('../images/bg_player2.jpg');
    background-size: cover;
    background-position: center;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ==========================================
   BOARD CONTAINER & WRAPPER (UNTOUCHED)
   ========================================== */
.board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    overflow: hidden;
    min-height: 0;
    gap: 10px;
    width: 100%;
}

.board-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s ease;
}

.board-wrapper.flipped {
    transform: rotate(180deg);
}

.hex-board {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.hex {
    /* Terrain art is drawn by the clipped .hex-art images underneath; the .hex
       polygon is the transparent interaction/stroke layer on top (pointer
       hit-testing + movement-highlight strokes). */
    fill: transparent;
    stroke: var(--hex-stroke);
    stroke-width: 1.5px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

/* Clipped terrain images. The pre-rotated "flipped" set is shown only when the
   board is flipped for Player 1, so terrain stays upright after the 180deg
   board rotation. Images never intercept pointer events (the .hex on top does). */
.hex-art {
    pointer-events: none;
}

.hex-art-flipped {
    display: none;
}

.board-wrapper.flipped .hex-art-normal {
    display: none;
}

.board-wrapper.flipped .hex-art-flipped {
    display: inline;
}

.hex-label {
    fill: #ffffff;
    font-size: 16px;
    pointer-events: none;
    font-weight: 800;
    text-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.8), 0 0 5px rgba(0, 0, 0, 0.9);
    transition: none;
}

.hex-group[data-hex-number="1"] .hex-label,
.hex-group[data-hex-number="37"] .hex-label {
    visibility: hidden;
}

.board-wrapper.flipped .hex-label,
.board-wrapper.flipped .base-label {
    transform-origin: center;
    transform-box: fill-box;
    transform: rotate(180deg);
}

.board-wrapper.flipped .token-art {
    transform-box: fill-box;
    transform-origin: center;
    transform: rotate(180deg);
}

.hex-group:hover .hex {
    stroke: #00ffcc;
    stroke-width: 3px;
    filter: drop-shadow(0 0 10px rgba(0, 255, 204, 0.8)) url(#tile-shadow);
}

.hex-group {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   TERRAIN STYLES (UNTOUCHED)
   ========================================== */
.hex.base-p1 {
    stroke: #ff4d4d;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 6px rgba(231, 76, 60, 0.5));
}
.legend-color.base-p1 {
    background-color: #e74c3c;
    background-image: url('../images/medieval_base_tile.jpg');
    background-size: cover;
    border: 2px solid #ff4d4d;
}

.hex.base-p2 {
    stroke: #33b5e5;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 6px rgba(52, 152, 219, 0.5));
}
.legend-color.base-p2 {
    background-color: #3498db;
    background-image: url('../images/medieval_base_tile.jpg');
    background-size: cover;
    border: 2px solid #33b5e5;
}

.hex.resource-gold {
    stroke: #ffd700;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 8px rgba(241, 196, 15, 0.6));
}
.legend-color.resource-gold {
    background-color: #f1c40f;
    background-image: url('../images/gold_mine_tile.jpg');
    background-size: cover;
    border: 2px solid #ffd700;
}

.hex-group .hex.resource-gold+.hex-label {
    fill: #ffffff;
    text-shadow: 0 0 4px #000000, 0 0 8px #000000;
}

.hex.resource-silver {
    stroke: #e0e0e0;
    stroke-width: 2px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.2));
}
.legend-color.resource-silver {
    background-color: #95a5a6;
    background-image: url('../images/silver_mine_tile.jpg');
    background-size: cover;
    border: 2px solid #e0e0e0;
}

.hex-group .hex.resource-silver+.hex-label {
    fill: #ffffff;
    text-shadow: 0 0 4px #000000, 0 0 8px #000000;
}

/* ==========================================
   SIDEBARS LAYOUT
   ========================================== */
.player-sidebar {
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 15px;
    padding: 20px 15px;
    border: 12px solid transparent;
    border-image: url('../images/stone_frame_9slice.png') 32 stretch;
    background: url('../images/ui_parchment.jpg') center/cover;
    background-clip: padding-box;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.3), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.left-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
}

/* ==========================================
   PARCHMENT PANELS (Right Sidebar Player Panels)
   ========================================== */
.player-panel {
    width: 100%;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    color: #2e1c0c;
    padding: 5px 0;
    border: none;
    background: none;
    box-shadow: none;
    position: relative;
}

/* Player title banners: generated carved-wood banner art with the name
   as real centered text on the fabric band. */
.player-panel .player-info h2 {
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.p1-panel .player-info h2 {
    background: url('../images/gen/banner_red.png') no-repeat center/100% 100%;
}

.p2-panel .player-info h2 {
    background: url('../images/gen/banner_blue.png') no-repeat center/100% 100%;
}

.player-info {
    text-align: center;
    width: 100%;
}

/* Gold display: generated forged-iron pill + painted coin-stack icon.
   border-radius clips the pill art's square corners. */
.gold-display {
    width: 180px;
    height: 46px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 5px auto;
    padding: 0 20px;
    background: url('../images/gen/gold_pill.png') no-repeat center/100% 100%;
    background-color: #17100a;
    border-radius: 999px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.gold-display::before {
    content: '';
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #17100a url('../images/gen/icon_coins.png') no-repeat center/cover;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.gold-amount {
    font-size: 1.25rem;
    font-weight: 900;
    font-family: 'Cinzel', 'Georgia', serif;
    color: #ffe680;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
    line-height: 1;
    -webkit-text-fill-color: initial;
    background: none;
}

.gold-unit {
    font-size: 0.55rem;
    font-weight: bold;
    color: #5c4033;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 1.5px;
    line-height: 1;
    margin-top: 1px;
}

.income-display {
    margin-top: 4px;
    font-size: 0.8rem;
    color: #5c4033;
    font-weight: bold;
    font-family: 'Outfit', sans-serif;
}

.income-amount {
    color: #27ae60;
}

/* ==========================================
   PURCHASE BUTTONS (WOOD TABLET THEME)
   ========================================== */
.purchase-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    width: 100%;
    margin-top: 5px;
}

.purchase-btn {
    width: 110px;
    height: 125px;
    cursor: pointer;
    position: relative;
    border: none;
    background: url('../images/gen/buy_card.png') no-repeat center/100% 100%;
    color: #2e1c0c;
    text-shadow: none;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px 6px;
    font-weight: 900;
    font-size: 0.7rem;
    font-family: 'Outfit', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    flex: none;
}

.purchase-btn:hover {
    filter: brightness(1.08);
}

.purchase-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.purchase-btn .btn-label {
    font-family: 'Cinzel', serif;
    font-size: 0.55rem;
    color: #2e1c0c;
    font-weight: 900;
    text-align: center;
    margin-top: 6px;
    letter-spacing: 0.5px;
}

.purchase-btn .btn-icon {
    display: block;
    width: 80px;
    height: 48px;
    margin: auto;
}

.worker-btn .btn-icon {
    background: url('../images/icon_worker.png') no-repeat center/contain;
}

.warrior-btn .btn-icon {
    background: url('../images/icon_warrior.png') no-repeat center/contain;
}

.btn-price-tag {
    background: #1c140d;
    border: 1px solid #d4af37;
    border-radius: 3px;
    padding: 2px 6px;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 4px;
}

.btn-price-tag::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #ffd700;
    border-radius: 50%;
    border: 1px solid #b8860b;
}

/* ==========================================
   SMALL LEGEND BOX (STONE STYLED)
   ========================================== */
.small-legend {
    width: 100%;
    flex: 0 0 auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: url('../images/gen/legend_scroll.png') no-repeat center/100% 100%;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.small-legend h4 {
    font-size: 0.95rem;
    font-family: 'Cinzel', 'Georgia', serif;
    text-transform: uppercase;
    color: #2e1c0c;
    margin-bottom: 5px;
    font-weight: bold;
    text-shadow: none;
    text-align: center;
}

.legend-items-small {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.legend-items-small .legend-item {
    font-size: 0.75rem;
    font-family: 'Outfit', sans-serif;
    color: #3d2616;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
}

.legend-items-small .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* ==========================================
   TOKENS (UNTOUCHED)
   ========================================== */
.token-group {
    cursor: grab;
    transition: opacity 0.2s ease;
}

.token-group:active {
    cursor: grabbing;
}

.token-group.dragging {
    opacity: 0.7;
    cursor: grabbing;
}

.token {
    stroke-width: 2px;
    transition: all 0.2s ease;
}

.token-group.dragging .token {
    transition: none;
}

.player1-token .token {
    fill: rgba(231, 76, 60, 0.85);
    stroke: #ff4d4d;
    stroke-width: 2px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.player1-token:hover .token {
    fill: rgba(255, 107, 90, 0.95);
    stroke: #ffffff;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 12px rgba(231, 76, 60, 0.9));
}

.player2-token .token {
    fill: rgba(52, 152, 219, 0.85);
    stroke: #33b5e5;
    stroke-width: 2px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.player2-token:hover .token {
    fill: rgba(93, 173, 226, 0.95);
    stroke: #ffffff;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 12px rgba(52, 152, 219, 0.9));
}

.token-label {
    fill: white;
    font-size: 10px;
    font-weight: 800;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.hex.valid-destination {
    stroke: #2ecc71;
    stroke-width: 4px;
    filter: drop-shadow(0 0 8px rgba(46, 204, 113, 0.8)) brightness(1.3);
}

.hex.highlight-reachable-p1 {
    stroke: #ff4d4d;
    stroke-width: 4px;
    filter: drop-shadow(0 0 8px rgba(231, 76, 60, 0.8)) brightness(1.3);
}

.hex.highlight-reachable-p2 {
    stroke: #33b5e5;
    stroke-width: 4px;
    filter: drop-shadow(0 0 8px rgba(52, 152, 219, 0.8)) brightness(1.3);
}

.hex.highlight-limit {
    stroke-width: 4px;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
}

/* ==========================================
   FEEDBACK MESSAGES & ERRORS (UNTOUCHED)
   ========================================== */
.purchase-error {
    color: white;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 5px;
    border-radius: 4px;
    margin-bottom: 5px;
    text-align: center;
    width: 100%;
    animation: fadeIn 0.3s ease;
    transition: opacity 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error text boxes in player sidebar panels */
.error-box {
    color: #c0392b;
    font-size: 0.8rem;
    font-weight: bold;
    margin-top: 5px;
    text-align: center;
    transition: opacity 0.3s ease;
}

/* ==========================================
   GAME TIMER PANEL (STONE STYLED)
   ========================================== */
.left-sidebar .game-timer-panel {
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 10px;
    border: 14px solid transparent;
    border-image: url('../images/gen/panel_stone.png') 90 fill stretch;
    background: #17130f url('../images/ui_stone.jpg') center/cover; /* fallback */
    background-clip: padding-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.tick-config {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
    background: rgba(16, 12, 8, 0.85);
    border: 1px solid #d4af37;
    border-radius: 4px;
    padding: 3px;
}

.tick-config label {
    font-size: 0.75rem;
    color: #f4e8d1;
    font-weight: bold;
}

.config-row {
    display: flex;
    gap: 5px;
}

.config-select {
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #5a4a35;
    background: #2b1d0c;
    color: #ffe680;
    font-weight: bold;
    font-size: 0.75rem;
}

.config-btn {
    padding: 4px 8px;
    background-color: #d4af37;
    color: #2b1d0c;
    border: 1px solid #ffe680;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    transition: all 0.2s;
}

.config-btn:hover {
    background-color: #ffe680;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

.game-timer-panel h3, .panel-divider {
    display: none !important;
}

.timer-display {
    text-align: center;
    margin: 0;
}

.timer-seconds {
    font-size: 2.4rem;
    font-weight: 700;
    color: #ff9900;
    font-family: 'Share Tech Mono', monospace;
    text-shadow: 0 0 10px rgba(255, 153, 0, 0.6);
}

.tick-counter {
    text-align: center;
    font-size: 0.85rem;
    color: #bdc3c7;
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-weight: bold;
}

.ticker-controls {
    display: flex;
    gap: 6px;
    margin: 2px 0 0;
}

/* Enamel-and-gold control buttons: generated 9-slice frames with real
   text labels (gradients kept as fallback under the border-image fill). */
.game-timer-panel .control-btn {
    flex: 1 1 0;
    padding: 8px 0;
    border: 8px solid transparent;
    cursor: pointer;
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fdf3d0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, filter 0.2s;
}

.game-timer-panel .btn-start {
    background: linear-gradient(180deg, #3f9d4a 0%, #1f6b2c 60%, #164f20 100%);
    border-image: url('../images/gen/btn_green.png') 150 fill stretch;
}

.game-timer-panel .btn-pause {
    background: linear-gradient(180deg, #c98f2e 0%, #96631c 60%, #6f4813 100%);
    border-image: url('../images/gen/btn_amber.png') 150 fill stretch;
}

.game-timer-panel .btn-reset {
    background: linear-gradient(180deg, #b8443a 0%, #8c2d26 60%, #691f1a 100%);
    border-image: url('../images/gen/btn_red.png') 150 fill stretch;
}

.game-timer-panel .control-btn:hover {
    filter: brightness(1.15) drop-shadow(0 0 5px rgba(255,230,128,0.5));
}

.game-timer-panel .control-btn:active {
    transform: translateY(1px);
}

.game-timer-panel .control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================
   LED & HP VISUALS (UNTOUCHED / BASE MODIFIED)
   ========================================== */
.token-led {
    stroke: #333;
    stroke-width: 0.5px;
}

.led-red { fill: #e74c3c; }
.led-yellow { fill: #f1c40f; }
.led-green { fill: #2ecc71; }

.hp-bar-bg {
    fill: #e74c3c;
    opacity: 0.6;
}

.hp-bar-fg {
    fill: #2ecc71;
}

.player1-base .base {
    fill: rgba(231, 76, 60, 0.45);
    stroke: #ff4d4d;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 8px rgba(231, 76, 60, 0.7));
}

.player2-base .base {
    fill: rgba(52, 152, 219, 0.45);
    stroke: #33b5e5;
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 8px rgba(52, 152, 219, 0.7));
}

.base-label {
    fill: white;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    letter-spacing: 1px;
}

/* ==========================================
   BASE HP PANEL (WOOD & GOLD THEMED)
   Rebuilt: normal flex flow (title / HP readout / vial), no absolute
   magic-percentage overlays, nothing baked into the background art.
   Interim frame = stone 9-slice + wood texture until the generated
   panel_wood_red/blue 9-slice assets land.
   ========================================== */
.base-hp-panel {
    width: 100%;
    flex: 1 1 40%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 12px 14px;
    border: 16px solid transparent;
    background: #241812 url('../images/ui_wood.jpg') center/cover; /* fallback */
    background-clip: padding-box;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.p1-base-hp {
    border-image: url('../images/gen/panel_wood_red.png') 190 fill stretch;
}

.p2-base-hp {
    border-image: url('../images/gen/panel_wood_blue.png') 230 fill stretch;
}

.base-hp-panel h3 {
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: 1.05rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.p1-base-hp h3 {
    color: #ff4d4d;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

.p2-base-hp h3 {
    color: #33b5e5;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

.base-hp-text {
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
    margin-top: 2px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #f4e8d1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    font-family: 'Share Tech Mono', monospace;
}

/* The vial: a real HTML element the liquid can never escape from. */
.base-hp-bar-container {
    flex: 1 1 auto;
    min-height: 40px;
    width: 34px;
    margin-top: 8px;
    border: 3px solid #b8923a;
    border-radius: 10px;
    background: linear-gradient(180deg, #0b0805 0%, #17100a 100%);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9), 0 1px 3px rgba(255, 230, 160, 0.25);
    overflow: hidden;
}

.p1-base-hp .base-hp-bar-container { border-color: #a8462f; }
.p2-base-hp .base-hp-bar-container { border-color: #2f6ea8; }

.base-hp-bar-bg {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
    border: none;
}

.base-hp-bar-fg {
    width: 100%;
    position: absolute;
    bottom: 0;
    transition: height 0.3s ease;
    border-radius: 0;
    box-shadow: none;
}

.p1-base-hp .base-hp-bar-fg {
    background: url('../images/vial_liquid_red.png') repeat-y bottom center;
    background-size: 100% auto;
}

.p2-base-hp .base-hp-bar-fg {
    background: url('../images/vial_liquid_blue.png') repeat-y bottom center;
    background-size: 100% auto;
}

/* ==========================================
   RESPONSIVE DESIGN ADJS
   ========================================== */
@media (max-height: 900px) {
    .base-hp-panel {
        padding: 8px 8px 10px;
    }
    .base-hp-panel h3 {
        font-size: 0.95rem;
    }
    .base-hp-text {
        font-size: 0.8rem;
    }
}

@media (max-height: 750px) {
    .base-hp-panel {
        padding: 6px 6px 8px;
        border-width: 10px;
    }
    .base-hp-panel h3 {
        font-size: 0.85rem;
    }
    .left-sidebar .game-timer-panel {
        padding: 8px;
        border-width: 10px;
    }
}

/* ==========================================
   LOBBY SCREEN (PARCHMENT & STONE THEMED)
   Phase 1 reskin: matches mockup_lobby_accurate.jpg
   Layout strategy: the carved-stone-framed parchment card is the
   gen/lobby_menu_card.png background; all content lives inside the parchment
   inset via .lobby-card-content percentage padding so it never spills
   onto the stone frame.
   ========================================== */
.lobby-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
    /* Tavern/stone ambiance: dark vignette over a wood-grain tile */
    background:
        radial-gradient(ellipse at center, rgba(40, 26, 12, 0.25) 0%, rgba(12, 7, 3, 0.78) 100%),
        url('../images/ui_wood.jpg') repeat;
    background-size: auto, 640px;
}

/* The framed parchment card. 896:1200 keeps the stone frame undistorted. */
.lobby-view {
    position: relative;
    box-sizing: border-box;
    width: min(560px, 92vw);
    aspect-ratio: 896 / 1200;
    background: url('../images/gen/lobby_menu_card.png') no-repeat center center;
    background-size: 100% 100%;
    border: none;
    filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.85));
    display: flex;
    align-items: stretch;
    justify-content: center;
}

/* Content sits inside the parchment writing area. The stone frame of
   gen/lobby_menu_card.png is ~12% of the card height on top/bottom and
   ~13% of its width on the sides; CSS %-padding resolves against WIDTH,
   so the top/bottom values are scaled accordingly (card is 3:4). */
.lobby-card-content {
    box-sizing: border-box;
    width: 100%;
    padding: 18% 14% 17% 14%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4%;
}

/* Main lobby view: anchor the banner at top, let the input + plaque
   buttons occupy the body of the parchment so it reads like the mockup. */
#lobby-main-view .lobby-menu {
    flex: 1 1 auto;
    justify-content: center;
    gap: 22px;
}

/* Gold ornate banner heading */
.lobby-banner {
    margin: 0 0 2%;
    text-align: center;
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(1.3rem, 4.2vw, 2.1rem);
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #f6d271;
    background: linear-gradient(180deg, #fff0c0 0%, #f2c64f 45%, #b9802a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 2px rgba(60, 30, 0, 0.35);
    filter: drop-shadow(0 1px 0 #5a3410) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(120, 84, 40, 0.55);
    width: 100%;
}

.lobby-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: 100%;
}

.lobby-field-label {
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(0.85rem, 2.6vw, 1.05rem);
    letter-spacing: 1px;
    color: #3a2713;
    text-shadow: 0 1px 0 rgba(255, 247, 220, 0.5);
    margin-bottom: -4px;
    align-self: center;
}

.game-name-input {
    box-sizing: border-box;
    padding: 8px 26px;
    border: none;
    background: url('../images/gen/input_frame.png') no-repeat center/100% 100%;
    color: #f3e2a8;
    font-size: clamp(0.9rem, 2.8vw, 1.1rem);
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    box-shadow: none;
    width: 100%;
    aspect-ratio: 632 / 150;
    text-align: center;
}

.game-name-input::placeholder {
    color: #b8a36a;
    opacity: 0.85;
}

.game-name-input:focus {
    outline: none;
    filter: brightness(1.12) drop-shadow(0 0 6px rgba(255, 210, 110, 0.35));
}

/* Two large carved-wood plaque buttons (icon baked into the art) */
.lobby-buttons-row {
    display: flex;
    gap: 5%;
    justify-content: center;
    width: 100%;
    margin-top: 6px;
}

.btn-create, .btn-join-main {
    border: none;
    padding: 0;
    flex: 1 1 0;
    max-width: 47%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
    /* Icon + label live in the PNG art; hide the accessible text label */
    text-indent: -9999px;
    overflow: hidden;
    white-space: nowrap;
    transition: transform 0.15s ease, filter 0.15s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.btn-create {
    background-image: url('../images/gen/btn_create.png');
}

.btn-join-main {
    background-image: url('../images/gen/btn_join.png');
}

.btn-create:hover, .btn-join-main:hover {
    filter: brightness(1.12) contrast(1.04) drop-shadow(0 6px 12px rgba(255, 220, 130, 0.35));
}

.btn-create:active, .btn-join-main:active {
    filter: brightness(0.94) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

/* ---- Secondary / waiting-room buttons (wood plaque strips) ---- */
.lobby-actions-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    width: 100%;
    margin-top: auto;
    padding-top: 10px;
}

.lobby-actions-row .btn-back-lobby,
.lobby-actions-row .btn-refresh-lobby {
    flex: 1 1 0;
    max-width: 180px;
    margin: 0;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waiting-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 280px;
    margin: auto auto 0;
}

.waiting-actions .btn-cancel-lobby,
.waiting-actions .btn-back-lobby {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waiting-actions .btn-start-game-lobby,
.waiting-actions .btn-ready-lobby {
    width: 100%;
    max-width: 240px;
}

/* Wood plaque buttons: generated btn_wood_strip 9-slice with real text
   labels (gradient kept as fallback under the border-image fill). */
.btn-refresh-lobby, .btn-back-lobby, .btn-start-game-lobby, .btn-ready-lobby, .btn-cancel-lobby {
    box-sizing: border-box;
    padding: 12px 16px;
    font-size: clamp(0.85rem, 2.4vw, 1rem);
    font-weight: 700;
    font-family: 'Cinzel', 'Georgia', serif;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #f7e9c8;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.9);
    background: linear-gradient(180deg, #6b4a2a 0%, #4a3018 60%, #3a2512 100%);
    border: 6px solid transparent;
    border-image: url('../images/gen/btn_wood_strip.png') 40 fill stretch;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s ease, filter 0.15s ease;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    display: block;
    text-align: center;
}

/* Hero buttons: green enamel plaques */
.btn-start-game-lobby,
.btn-ready-lobby {
    background: linear-gradient(180deg, #3f9d4a 0%, #1f6b2c 60%, #164f20 100%);
    border-width: 8px;
    border-image: url('../images/gen/btn_green.png') 150 fill stretch;
    color: #fdf3d0;
}

.btn-refresh-lobby:hover, .btn-back-lobby:hover, .btn-start-game-lobby:hover, .btn-ready-lobby:hover, .btn-cancel-lobby:hover {
    filter: brightness(1.13) drop-shadow(0 0 6px rgba(255, 220, 130, 0.35));
}

.btn-refresh-lobby:active, .btn-back-lobby:active, .btn-start-game-lobby:active, .btn-ready-lobby:active, .btn-cancel-lobby:active {
    transform: translateY(1px);
    filter: brightness(0.92) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Disabled state (host's Start before guest is ready) */
.btn-start-game-lobby.btn-disabled,
.btn-start-game-lobby:disabled {
    filter: grayscale(0.6) brightness(0.8);
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Guest "Ready!" confirmed state */
.btn-ready-lobby.btn-success {
    filter: brightness(1.2) drop-shadow(0 0 8px rgba(120, 230, 120, 0.5));
}

/* ---- Available games list (parchment rows) ---- */
.games-list {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 6px 0 4px;
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Custom Scrollbar for parchment lists */
.games-list::-webkit-scrollbar {
    width: 8px;
}
.games-list::-webkit-scrollbar-track {
    background: rgba(90, 74, 53, 0.12);
    border-radius: 4px;
}
.games-list::-webkit-scrollbar-thumb {
    background: #7a5428;
    border-radius: 4px;
    border: 1px solid #5a4a35;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background:
        linear-gradient(180deg, rgba(255, 250, 235, 0.35), rgba(120, 90, 50, 0.12)),
        url('../images/ui_parchment.jpg') center/cover;
    border: 2px solid #7a5428;
    border-radius: 5px;
    box-shadow: inset 0 0 12px rgba(70, 45, 15, 0.18), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    min-width: 0;
}

.game-info h3 {
    margin: 0;
    color: #2c1e0c;
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: clamp(0.9rem, 2.6vw, 1.05rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-id {
    color: #6a5230;
    font-size: 0.78rem;
    font-family: 'Outfit', sans-serif;
}

/* Per-row Join button (rendered by lobby_ui.js as .btn-join) */
.btn-join {
    flex: 0 0 auto;
    padding: 8px 16px;
    cursor: pointer;
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #f7e9c8;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.85);
    background: linear-gradient(180deg, #6b4a2a 0%, #4a3018 60%, #3a2512 100%);
    border: 5px solid transparent;
    border-image: url('../images/gen/btn_wood_strip.png') 40 fill stretch;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-join:hover {
    filter: brightness(1.13) drop-shadow(0 0 5px rgba(255, 220, 130, 0.35));
}

.btn-join:active {
    transform: translateY(1px);
    filter: brightness(0.92);
}

.no-games {
    text-align: center;
    color: #5a4a35;
    padding: 24px 12px;
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-style: italic;
}

/* ---- Waiting room ---- */
.waiting-info {
    width: 100%;
    text-align: center;
    margin-top: 8px;
}

#waiting-room p {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(0.95rem, 2.8vw, 1.1rem);
    font-weight: 600;
    color: #5a4a35;
    text-align: center;
    margin: 0 0 14px;
}

#waiting-role {
    font-size: clamp(1.05rem, 3.2vw, 1.25rem);
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 700;
    color: #2c1e0c !important;
}

#waiting-status {
    color: #6a5230;
    font-style: italic;
}

/* ==========================================
   DISCONNECT OVERLAY & COUNTDOWN
   ========================================== */
.disconnect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.disconnect-overlay.hidden {
    display: none;
}

.disconnect-content {
    border: 24px solid transparent;
    border-image: url('../images/stone_frame_9slice.png') 32 stretch;
    background: url('../images/ui_parchment.jpg') center/cover;
    background-clip: padding-box;
    padding: 25px;
    text-align: center;
    max-width: 420px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.8);
    color: #2c1e0c;
}

.disconnect-content h2 {
    font-family: 'Cinzel', 'Georgia', serif;
    color: #c0392b;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.disconnect-content p {
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
}

.countdown-display {
    margin: 20px 0;
}

.countdown-timer {
    font-size: 3rem;
    font-weight: bold;
    color: #c0392b;
    font-family: 'Share Tech Mono', monospace;
}

.countdown-unit {
    font-size: 1.5rem;
    color: #5a4a35;
}

.disconnect-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

/* Connection Error Banner (A1-004) */
.error-banner {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background-color: #c0392b;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    font-family: 'Outfit', sans-serif;
}

/* SWR-FE-PER-11: Utility class to completely hide elements from layout flow */
.hidden {
    display: none !important;
}
