/* style.css - Medieval Parchment Theme for 1497 AD */

/* ===== Foundations ===== */

:root {
    --parchment: #f5e6c8;
    --parchment-dark: #e8d5a3;
    --parchment-deep: #d4bc82;
    --ink: #2c1810;
    --ink-light: #5c3a2a;
    --gold: #c9a227;
    --gold-bright: #e6b800;
    --gold-dim: #8b6914;
    --wood: #3e2723;
    --wood-light: #5d4037;
    --leather: #6d4c2f;
    --leather-light: #8d6e4a;
    --danger: #a33;
    --success: #4a7c3f;
    --warning: #b8860b;
    --panel-bg: linear-gradient(160deg, #f5e6c8 0%, #e8d5a3 50%, #dcc68e 100%);
    --panel-border: 2px solid var(--gold-dim);
    --panel-shadow: 0 3px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
    --font-heading: 'Cinzel', 'Georgia', serif;
    --font-body: 'Crimson Text', 'Georgia', serif;

    /* Reusable shadows */
    --shadow-portrait: 0 4px 16px rgba(0,0,0,0.5), 0 0 12px rgba(201,162,39,0.3);

    /* Z-index scale — use these instead of raw numbers */
    --z-base: 1;
    --z-sticky: 2;
    --z-float: 50;
    --z-tooltip: 9999;
    --z-topbar: 10001;
    /* Modals must sit above the topbar — otherwise on tall/high-DPI
       viewports the topbar (z 10001) clips the modal's top edge where
       `align-items: safe center` places it. */
    --z-modal: 10100;
    --z-modal-event: 10110;
    --z-modal-detail: 10120;
    --z-modal-system: 10200;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: clamp(14px, 0.9vw + 0.45vh, 24px); /* Fluid body text: scales with both width and height */
    color: var(--ink);
    background-color: #1a1208;
    height: 100%;
}

h3, h4 {
    font-family: var(--font-heading);
    color: var(--wood);
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

/* ===== Game Container ===== */

#game-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    overflow: hidden;
}

/* Dim overlay so panels are readable over city backgrounds */
#game-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(20, 12, 5, 0.35);
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#game-container.city-fade::before {
    opacity: 1;
}

#game-container > * {
    position: relative;
    z-index: var(--z-base);
}

#player-stats {
    z-index: var(--z-topbar);
    overflow: visible;
}

/* ===== Panels (parchment cards) ===== */

.panel {
    background: var(--panel-bg);
    border: var(--panel-border);
    border-radius: 6px;
    box-shadow: var(--panel-shadow);
    padding: 12px 16px;
    transition: box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ===== Stats Bar ===== */

#player-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 10px 12px 0;
    padding: 6px 16px;
    background: linear-gradient(180deg, var(--wood) 0%, #2a1a10 100%);
    border: 2px solid var(--gold-dim);
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
    min-height: 52px;
}

.stats-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stats-center {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    flex: 1;
}

.stats-right {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex-shrink: 0;
}

.stats-right .stat {
    display: inline-flex;
    align-items: center;
}

/* Merchant portrait in header */
.stats-portrait img {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 3px solid var(--gold);
    object-fit: cover;
    object-position: center 15%;
    background: var(--parchment);
    box-shadow: var(--shadow-portrait);
    margin: -10px 0 -22px;
    transform: scale(1.15);
    transform-origin: center center;
}

.stats-portrait {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
    z-index: var(--z-topbar);
    transition: transform 0.15s ease;
}

.stats-portrait:hover img {
    border-color: #fff2b8;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.6), var(--shadow-portrait);
}

.stats-portrait:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 4px;
    border-radius: 4px;
}

.stats-portrait img.silhouette {
    opacity: 0.5;
}

.stats-portrait-name {
    font-family: var(--font-heading);
    font-size: 0.78em;
    color: var(--parchment);
    font-style: italic;
    white-space: nowrap;
}

/* Season icon in header */
.stats-season {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: var(--z-topbar);
}

.stats-season img {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 3px solid var(--gold);
    object-fit: cover;
    background: var(--parchment);
    box-shadow: var(--shadow-portrait);
    margin: -10px 0 -22px;
    transform: scale(1.15);
    transform-origin: center center;
}

.stats-season-name {
    font-family: var(--font-heading);
    font-size: 0.78em;
    color: var(--parchment);
    font-style: italic;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sound-toggle-float {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: var(--z-float);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--wood) 0%, #2a1a10 100%);
    border: 1.5px solid var(--gold-dim);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 6px rgba(201,162,39,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.sound-toggle-float:hover, .feedback-toggle-float:hover {
    border-color: var(--gold);
    box-shadow: 0 5px 16px rgba(0,0,0,0.6), 0 0 10px rgba(201,162,39,0.3);
    transform: translateY(-1px);
}

.kofi-toggle-float {
    position: fixed;
    bottom: 194px;
    right: 18px;
    z-index: var(--z-float);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f0e8;
    border: 1.5px solid var(--gold-dim);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 6px rgba(201,162,39,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-decoration: none;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.kofi-toggle-float:hover {
    border-color: var(--gold);
    box-shadow: 0 5px 16px rgba(0,0,0,0.6), 0 0 10px rgba(201,162,39,0.3);
    transform: translateY(-1px);
}

.feedback-toggle-float {
    position: fixed;
    bottom: 62px;
    right: 18px;
    z-index: var(--z-float);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--wood) 0%, #2a1a10 100%);
    border: 1.5px solid var(--gold-dim);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 6px rgba(201,162,39,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--gold-dim);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.leaderboard-toggle-float {
    position: fixed;
    bottom: 106px;
    right: 18px;
    z-index: var(--z-float);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--wood) 0%, #2a1a10 100%);
    border: 1.5px solid var(--gold-dim);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 6px rgba(201,162,39,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--gold-dim);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.leaderboard-toggle-float:hover {
    border-color: var(--gold);
    box-shadow: 0 5px 16px rgba(0,0,0,0.6), 0 0 10px rgba(201,162,39,0.3);
    transform: translateY(-1px);
}

.share-toggle-float {
    position: fixed;
    bottom: 150px;
    right: 18px;
    z-index: var(--z-float);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--wood) 0%, #2a1a10 100%);
    border: 1.5px solid var(--gold-dim);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 6px rgba(201,162,39,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--gold-dim);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.share-toggle-float:hover {
    border-color: var(--gold);
    box-shadow: 0 5px 16px rgba(0,0,0,0.6), 0 0 10px rgba(201,162,39,0.3);
    transform: translateY(-1px);
}

.share-modal-box {
    width: min(94vw, 420px);
    max-width: 420px;
}
.share-native-btn {
    width: 100%;
    margin: 0 0 10px;
}

/* Shared h3 heading inside small utility modals (leaderboard, share,
 * feedback). Kept terse so the parchment frame does the heavy lifting. */
.modal-heading {
    font-family: var(--font-heading);
    margin: 0 0 12px;
    color: var(--wood);
}

/* ===== Feedback modal ===== */
.feedback-modal-box {
    width: min(94vw, 420px);
    max-width: 420px;
}
.feedback-field {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: var(--parchment);
    font-family: var(--font-body);
    box-sizing: border-box;
}
.feedback-field + .feedback-field { margin-top: 8px; }
textarea.feedback-field { resize: vertical; }
.feedback-footer {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-end;
}
.feedback-status {
    margin: 8px 0 0;
    font-size: 0.85em;
    color: var(--ink-light);
    display: none;
}
.share-pitch {
    margin: 0 0 10px;
    font-family: var(--font-body);
    font-size: 0.95em;
    color: var(--ink);
    line-height: 1.45;
}
.share-rewards {
    margin: 0 0 12px;
    font-family: var(--font-body);
    font-size: 0.88em;
    color: var(--ink-light);
    line-height: 1.4;
    min-height: 1.1em;
}
.share-rewards:empty { display: none; }
.share-pending-pill {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 4px;
    background: var(--gold);
    color: #2a1a10;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9em;
}
.share-link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.share-link-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: var(--parchment);
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink);
    min-width: 0;
}
.share-link-row .action-btn {
    flex-shrink: 0;
}
.share-channels {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 14px;
}
.share-channel {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1.5px solid var(--gold-dim);
    background: var(--parchment);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.share-channel:hover {
    border-color: var(--gold);
    background: #f7efd8;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3), 0 0 8px rgba(201,162,39,0.25);
    transform: translateY(-1px);
}
.share-channel-whatsapp { color: #25D366; }
.share-channel-twitter { color: #111; }
.share-channel-facebook { color: #1877F2; }
.share-footnote {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.8em;
    color: var(--ink-light);
    font-style: italic;
    line-height: 1.4;
}
.share-status {
    margin: 8px 0 0;
    font-size: 0.85em;
    font-family: var(--font-body);
    display: none;
}

.parchment-modal.leaderboard-modal-box {
    width: min(90vw, 1080px);
    max-width: 1080px;
    max-height: 82vh;
    padding: 24px 32px 28px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.leaderboard-modal-box .leaderboard-table {
    width: 100%;
    table-layout: auto;
}
.leaderboard-modal-box .leaderboard-table th,
.leaderboard-modal-box .leaderboard-table td {
    white-space: nowrap;
}
.leaderboard-modal-box .leaderboard-col-rank { width: 44px; }
.leaderboard-modal-box .leaderboard-col-name { min-width: 180px; }
.leaderboard-modal-box .leaderboard-col-score { min-width: 120px; }
.leaderboard-modal-box .leaderboard-col-tier { min-width: 130px; }
.leaderboard-modal-box .leaderboard-col-city { min-width: 150px; }
.leaderboard-modal-box .leaderboard-col-mods {
    min-width: 220px;
    white-space: normal;
}
.leaderboard-table-stable {
    width: 100%;
    table-layout: fixed;
}
.leaderboard-table-stable .leaderboard-col-rank { width: 52px; }
.leaderboard-table-stable .leaderboard-col-score { width: 140px; }
.leaderboard-table-stable .leaderboard-col-tier { width: 150px; }
.leaderboard-table-stable .leaderboard-col-city { width: 170px; }
.leaderboard-table-stable .leaderboard-col-mods { width: 260px; }
.leaderboard-table-stable .leaderboard-col-name,
.leaderboard-table-stable .leaderboard-col-score,
.leaderboard-table-stable .leaderboard-col-tier,
.leaderboard-table-stable .leaderboard-col-city {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.leaderboard-table-stable .leaderboard-col-mods {
    overflow-wrap: anywhere;
    white-space: normal;
}

/* Reserve vertical space inside the leaderboard modal so an empty or
 * loading list doesn't make the parchment look truncated. ~10 row
 * heights keeps the frame feeling like a leaderboard even on first
 * open of an unseeded tier. Flex centering puts the empty/loading
 * message in the visual middle instead of stranded at the top. */
#lb-modal-list {
    min-height: 280px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable both-edges;
}
#lb-modal-list > .ss-empty {
    margin: auto;
    font-size: 1em;
    color: var(--ink-light);
    text-align: center;
}
#lb-modal-list > table { align-self: stretch; }

/* Leaderboard modal filter controls */
.lb-filters {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.lb-filters select {
    font-family: var(--font-body);
    font-size: 0.82em;
    padding: 5px 10px;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: var(--parchment);
    color: var(--wood);
    cursor: pointer;
    transition: border-color 0.15s;
}
.lb-filters select:hover,
.lb-filters select:focus { border-color: var(--gold); outline: none; }
.lb-mod-toggle {
    display: inline-flex;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    overflow: hidden;
}
.lb-mod-opt {
    font-family: var(--font-body);
    font-size: 0.82em;
    padding: 5px 12px;
    background: transparent;
    color: var(--wood);
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.lb-mod-opt:hover { background: rgba(201,162,39,0.08); }
.lb-mod-opt.active { background: var(--wood); color: var(--parchment); font-weight: 600; }
.lb-mod-opt + .lb-mod-opt { border-left: 1px solid var(--gold-dim); }
.lb-mod-vanilla { color: var(--parchment-dark); opacity: 0.5; }
.lb-mod-badge {
    display: inline-block;
    font-size: 0.72em;
    padding: 1px 6px;
    margin: 1px 2px 1px 0;
    background: rgba(201,162,39,0.12);
    border: 1px solid var(--gold-dim);
    border-radius: 3px;
    color: var(--wood);
    white-space: nowrap;
}

/* Sound settings modal */
.sound-slider-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}
.sound-slider-row {
    display: flex;
    align-items: center;
    gap: 18px;
}
.sound-slider-row label {
    font-family: var(--font-heading);
    font-size: 0.92em;
    color: var(--ink);
    width: 58px;
    text-align: right;
    flex-shrink: 0;
}
.sound-vol-label {
    font-family: var(--font-body);
    font-size: 0.88em;
    color: var(--ink);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.sound-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--parchment-deep);
    outline: none;
    cursor: pointer;
}
.sound-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    border: 1.5px solid var(--gold-bright);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s;
}
.sound-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}
.sound-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    border: 1.5px solid var(--gold-bright);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
}
.sound-mute-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--gold-dim);
}
.sound-mute-row label {
    font-family: var(--font-heading);
    font-size: 0.92em;
    color: var(--ink);
    cursor: pointer;
}
.sound-mute-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
    cursor: pointer;
}

/* ===== Settings Modal ===== */
.settings-modal-content {
    max-width: 460px;
    width: min(94vw, 460px);
    padding: 28px 34px 24px;
}

/* Reusable × close button for parchment modals */
.modal-close-x {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4em;
    color: var(--ink-light);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.55;
    transition: opacity 0.15s, color 0.15s;
}
.modal-close-x:hover {
    opacity: 1;
    color: var(--wood);
}

.settings-heading {
    font-family: var(--font-heading);
    font-size: 1.3em;
    color: var(--wood);
    margin: 0 0 4px;
    text-align: center;
    letter-spacing: 0.5px;
}

.settings-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(139, 105, 20, 0.3);
}

.settings-section-label {
    font-family: var(--font-heading);
    font-size: 0.85em;
    color: var(--gold-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
}

.settings-section .sound-slider-group {
    margin-bottom: 14px;
}

.settings-section .sound-mute-row {
    border-top: none;
    padding-top: 6px;
    padding-bottom: 6px;
}

.settings-quit-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 0.92em;
    opacity: 0.85;
    margin-top: 4px;
}
.settings-quit-btn:hover {
    opacity: 1;
}

.settings-about {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid rgba(139, 105, 20, 0.3);
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.84em;
    color: var(--ink-light);
    opacity: 0.75;
    line-height: 1.6;
}
.settings-about p { margin: 0; }
.settings-about a,
.settings-about a:visited {
    color: var(--gold-dim);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, color 0.2s;
}
.settings-about a:hover {
    border-bottom-color: var(--gold);
    color: var(--gold);
}

/* Legacy alias — kept for backward compat with existing selectors */
.sound-prefs-section {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--gold-dim);
}
.sound-prefs-label {
    font-family: var(--font-heading);
    font-size: 0.78em;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 8px;
}
.sound-prefs-section .sound-mute-row {
    border-top: none;
    padding-top: 2px;
    padding-bottom: 2px;
}

#player-stats .stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-heading);
    font-size: 0.82em;
    font-weight: 600;
    color: var(--parchment);
    padding: 3px 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(201,162,39,0.25);
    border-radius: 4px;
    white-space: nowrap;
}

#player-stats .stat-label {
    color: var(--gold);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#player-stats .stat-value {
    color: #fff;
    transition: color 0.3s ease;
}

@keyframes flash-trade {
    0% { color: #fff; }
    30% { color: var(--gold-bright); text-shadow: 0 0 8px rgba(230,184,0,0.8); transform: scale(1.15); }
    100% { color: #fff; text-shadow: none; transform: scale(1); }
}
#player-stats .stat-value.flash-gold { animation: flash-trade 0.6s ease; }

#player-stats .stat-value.condition-good { color: #8bc34a; }
#player-stats .stat-value.condition-mid { color: #ffc107; }
#player-stats .stat-value.condition-low { color: #f44336; }

#player-stats .crew-badge {
    font-size: 0.75em;
    padding: 2px 7px;
    background: rgba(201,162,39,0.2);
    border: 1px solid var(--gold);
    border-radius: 3px;
    color: var(--gold-bright);
    cursor: help;
}

/* ===== Two-Column Layout ===== */

#main-content {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    flex: 1;
    min-height: 0; /* Allow flex children to shrink */
    overflow: hidden;
}

#left-column {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
}

#right-column {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
}

/* ===== City Info ===== */

#city-info {
    flex-shrink: 0;
    padding: 0;
    overflow: hidden;
}

.city-banner {
    position: relative;
    width: 100%;
    height: clamp(120px, 12vw, 220px); /* Scales with viewport width for consistent aspect ratio */
    overflow: hidden;
    cursor: pointer;
}

.city-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.city-banner-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: linear-gradient(transparent, rgba(20, 12, 5, 0.8));
}

.city-banner-overlay h3 {
    font-size: 1.4em;
    color: var(--parchment);
    margin: 0;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
    border: none;
    padding: 0;
}

.city-details {
    padding: 8px 16px 10px;
}

.city-details p {
    margin: 3px 0;
    font-size: 0.92em;
    color: var(--ink-light);
}

/* Feature 2: one-sentence seasonal arrival flavor rendered below the
   static city description. Italic and dimmed to sit apart from the
   population/status/tax row and to signal it is atmospheric, not
   mechanical, information. */
.city-details .seasonal-flavor {
    margin-top: 6px;
    font-style: italic;
    color: var(--ink-light);
    opacity: 0.82;
}

/* ===== Market Table ===== */

#market-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#market-container h4 {
    flex-shrink: 0;
    font-size: 1.05em;
    border-bottom: 1px solid var(--parchment-deep);
    padding-bottom: 5px;
    margin-bottom: 0;
}

#market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

#market-table thead {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

#market-table th {
    background: linear-gradient(180deg, var(--wood-light), var(--wood));
    color: var(--parchment);
    font-family: var(--font-heading);
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 7px 8px;
    text-align: left;
    border-bottom: 2px solid var(--gold-dim);
}

#market-table th:nth-child(2),
#market-table th:nth-child(4) {
    text-align: right;
}

#market-table th:nth-child(3),
#market-table th:nth-child(5),
#market-table th:nth-child(6),
#market-table th:nth-child(7) {
    text-align: center;
}

/* Sort arrows */
#market-table th.sortable {
    cursor: pointer;
    user-select: none;
}

#market-table th.sortable:hover {
    background: linear-gradient(180deg, var(--wood), var(--wood-dark, #5a3a1a));
}

.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    margin-left: 2px;
    line-height: 1;
    gap: 0px;
}

.sort-arrows .arrow-up,
.sort-arrows .arrow-down {
    font-size: 0.5em;
    opacity: 0.35;
    line-height: 1;
    transition: opacity 0.15s;
}

.sort-arrows .arrow-up:hover,
.sort-arrows .arrow-down:hover {
    opacity: 0.8;
}

#market-table th.sort-asc .arrow-up {
    opacity: 1;
    color: var(--gold, #d4a843);
}

#market-table th.sort-desc .arrow-down {
    opacity: 1;
    color: var(--gold, #d4a843);
}

#market-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(139,105,20,0.2);
    vertical-align: middle;
}

#market-table tbody tr:nth-child(even) {
    background: rgba(139,105,20,0.06);
}

#market-table tbody tr:hover {
    background: rgba(139,105,20,0.14);
}

#market-table tbody tr.row-profit {
    background: rgba(34,120,34,0.09);
}

#market-table tbody tr.row-loss {
    background: rgba(160,40,40,0.09);
}

#market-table tbody tr.row-profit:hover {
    background: rgba(34,120,34,0.17);
}

#market-table tbody tr.row-loss:hover {
    background: rgba(160,40,40,0.17);
}

#market-table td:nth-child(1) {
    font-weight: 600;
    white-space: nowrap;
    cursor: help;
}

#market-table td:nth-child(2) {
    text-align: right;
    color: var(--ink-light);
}

#market-table td:nth-child(3),
#market-table td:nth-child(5),
#market-table td:nth-child(6),
#market-table td:nth-child(7) {
    text-align: center;
    white-space: nowrap;
}

#market-table td:nth-child(4) {
    text-align: right;
    font-weight: 600;
    font-family: var(--font-heading);
    font-size: 0.95em;
    color: var(--wood);
}

.good-icon {
    width: clamp(20px, 1.8vw, 36px); /* Commodity icons scale with viewport */
    height: clamp(20px, 1.8vw, 36px);
    vertical-align: middle;
    margin-right: 8px;
    border-radius: 3px;
    border: 1px solid rgba(139,105,20,0.3);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.good-icon:hover {
    border-color: var(--gold);
    box-shadow: 0 0 4px rgba(201, 162, 39, 0.4);
}

.good-name {
    cursor: pointer;
}

.good-name:hover {
    color: var(--gold);
}

.trade-row {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Market inputs and buttons */

#market-table input[type="number"] {
    width: 56px;
    padding: 3px 6px;
    font-size: 0.9em;
    font-family: var(--font-body);
    border: 1px solid var(--parchment-deep);
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    text-align: center;
}

.bm-sell-btn {
    background: linear-gradient(180deg, #4a3520, #2c1810) !important;
    color: var(--gold-bright) !important;
    border-color: var(--gold-dim) !important;
    font-weight: 700;
    font-size: 0.78em !important;
}
.bm-sell-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5a4530, #3c2820) !important;
    border-color: var(--gold) !important;
}

#market-table input[type="number"]:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201,162,39,0.25);
}

#market-table button {
    padding: 3px 10px;
    font-size: 0.82em;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s ease;
}

#market-table button.buy-btn {
    background: linear-gradient(180deg, var(--success), #3a6632);
    color: #fff;
    border: 1px solid #2e5228;
}

#market-table button.buy-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5a9c4f, var(--success));
}

#market-table button.sell-btn {
    background: linear-gradient(180deg, var(--leather), #5a3a20);
    color: var(--parchment);
    border: 1px solid #4a2a15;
}

#market-table button.sell-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
}

#market-table button:disabled {
    /* Explicit disabled palette instead of opacity:0.35, which dropped the
     * label contrast below 2:1. Keeps the visual "unavailable" cue without
     * making the text unreadable for low-vision users. */
    background: #c9b98d;
    color: #5e4a1f;
    border-color: #8a6a2b;
    cursor: not-allowed;
    text-shadow: none;
    box-shadow: none;
}

.qty-shortcut {
    padding: 2px 5px;
    font-size: 0.7em;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    border-radius: 2px;
    background: var(--parchment-deep);
    color: var(--ink);
    border: 1px solid var(--gold-dim);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.15s ease;
}

.qty-shortcut:hover:not(:disabled) {
    background: var(--gold);
    color: var(--wood);
}

.qty-shortcut:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ===== Actions Panel ===== */

#actions-container {
    flex-shrink: 0;
    padding: 10px 14px;
    position: relative;
}

/* Thin progress bar while an API action is in flight */
#actions-container.action-busy::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 3px;
    width: 40%;
    background: var(--gold);
    opacity: 0.7;
    animation: busy-slide 1s ease-in-out infinite alternate;
    z-index: 1;
}

/* Brief pulse when a click is blocked by an in-flight action */
#actions-container.action-busy-pulse::before {
    opacity: 1;
    background: var(--gold-bright, var(--gold));
    animation: busy-flash 0.3s ease-out;
}

@keyframes busy-slide {
    from { left: 0; }
    to   { left: 60%; }
}

@keyframes busy-flash {
    0%   { opacity: 1; width: 100%; }
    100% { opacity: 0.7; width: 40%; }
}

.action-section-label {
    font-family: var(--font-heading);
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold-dim);
    margin-bottom: 4px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: flex-start;
    margin-bottom: 8px;
}

#travel-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

/* Shared button style for actions */
.action-btn {
    padding: 6px 12px;
    font-size: 0.85em;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border: 1px solid var(--gold-dim);
}

.action-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #a07850, var(--leather-light));
    border-color: var(--gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Press feedback — tactile "push" on click */
.action-btn:active:not(:disabled),
.ss-btn:active:not(:disabled),
.ss-sail-btn:active,
.ss-daily-btn:active,
#market-table button:active:not(:disabled),
.qty-shortcut:active:not(:disabled) {
    transform: scale(0.97);
}

.action-btn:disabled {
    cursor: not-allowed;
}

.action-btn:disabled .btn-label,
.action-btn:disabled .btn-cost {
    opacity: 0.4;
    filter: grayscale(0.4);
}

/* Secondary / cancel variant — muted background so the primary CTA
 * next to it reads as the affirmative action. Keeps the leather/gold
 * family but drops the gradient fill and softens the text. */
.action-btn.secondary-btn {
    background: transparent;
    color: var(--wood);
    border-color: var(--gold-dim);
}
.action-btn.secondary-btn:hover:not(:disabled) {
    background: rgba(201,162,39,0.08);
    border-color: var(--gold);
    box-shadow: none;
}

.action-btn.travel-btn {
    background: linear-gradient(180deg, var(--wood-light), var(--wood));
    font-size: 0.8em;
    padding: 5px 10px;
}

.action-btn.travel-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #7d5e47, var(--wood-light));
}

.action-btn.travel-btn.travel-medium {
    border-left: 3px solid var(--warning);
}
.action-btn.travel-btn.travel-long {
    border-left: 3px solid var(--danger);
    background: linear-gradient(180deg, #5d3a2a, #4a2a1a);
}
.action-btn.travel-btn.travel-long:hover:not(:disabled) {
    background: linear-gradient(180deg, #7d4a3a, #5d3a2a);
}
.action-btn.travel-btn.last-trip {
    border-color: var(--warning);
    box-shadow: 0 0 4px rgba(184,134,11,0.4);
}

#other-actions,
#crew-actions,
#shipyard-actions {
    display: block;
}

.action-btn.hired {
    background: linear-gradient(180deg, #5a7c4f, #3a5c32);
    border-color: var(--success);
    cursor: default;
}

/* ===== Tooltips ===== */

.has-tooltip {
    position: relative;
}

#global-tooltip {
    display: none;
    position: fixed;
    z-index: var(--z-tooltip);
    background: var(--wood);
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 0.85em;
    font-weight: 400;
    padding: 8px 14px;
    border-radius: 6px;
    white-space: normal;
    width: max-content;
    max-width: min(360px, 50vw);
    text-align: left;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,0.5);
    border: 1px solid var(--gold-dim);
}

/* Hide the inline tooltip spans — they're just data carriers */
.has-tooltip .tooltip {
    display: none !important;
}

/* ===== Message Log ===== */

#message-log {
    flex: 1;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, #3e2723 0%, #2a1a10 100%);
    border: 2px solid var(--gold-dim);
    overflow: hidden;
}

#message-log h4 {
    flex-shrink: 0;
    color: var(--gold);
    font-size: 0.9em;
    margin: 0 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(201,162,39,0.3);
}

#message-log-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 0.88em;
    line-height: 1.4;
}

#message-log-content p {
    margin: 0;
    padding: 3px 4px;
    color: var(--parchment);
    word-wrap: break-word;
}

@keyframes log-entry-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Turn-grouped log: every addMessage call lands inside a
   .log-turn-group keyed to the current turn. New turns prepend new
   groups (newest on top); messages within a turn append chronologically
   inside their group. The fade-in is on the group itself — individual
   paragraphs inside the same turn appear without animation. */
.log-turn-group {
    margin: 0 0 10px 0;
    border-left: 2px solid rgba(201,162,39,0.25);
    padding-left: 6px;
    animation: log-entry-in 0.25s ease;
}

.log-turn-group:first-child {
    /* Brighten the "current turn" group so the newest events are
       visually distinct from past history. */
    border-left-color: rgba(201,162,39,0.6);
}

.log-turn-header {
    font-family: var(--font-heading);
    font-size: 0.78em;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 0 3px 0;
    border-bottom: 1px solid rgba(201,162,39,0.3);
    margin-bottom: 3px;
}

/* In-port group header: week number is bright gold, city name is
   slightly softer. The default .log-turn-header color applies to all
   spans unless overridden. */
.log-turn-header .log-turn-week {
    color: var(--gold);
}

.log-turn-header .log-turn-sep {
    color: rgba(201,162,39,0.4);
    margin: 0 3px;
}

.log-turn-header .log-turn-city {
    color: var(--gold);
}

/* At-sea group header: distinct visual treatment (deep navy tint,
   italic leg label, wave-tinted border) so players can scan the log
   at a glance and distinguish weeks spent sailing from weeks spent
   in port. Tuned for a true "ocean depth" feel — darker than the
   first two drafts which read as washed-out against the parchment
   panel background. The base color is roughly #27547d / navy-blue,
   with the week number slightly brighter for emphasis. */
.log-turn-group.log-turn-sea {
    border-left-color: rgba(40, 80, 120, 0.85);
    background: linear-gradient(
        to right,
        rgba(25, 55, 90, 0.22),
        transparent 70%
    );
}

.log-turn-group.log-turn-sea:first-child {
    border-left-color: rgba(55, 105, 155, 1);
}

.log-turn-group.log-turn-sea .log-turn-header {
    color: rgba(60, 100, 145, 1);
    border-bottom-color: rgba(40, 80, 120, 0.65);
    font-weight: 600;
}

.log-turn-group.log-turn-sea .log-turn-header .log-turn-week {
    color: rgba(75, 120, 170, 1);
}

.log-turn-group.log-turn-sea .log-turn-header .log-turn-leg {
    font-style: italic;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.3px;
    color: rgba(55, 95, 140, 1);
}

/* Legacy .turn-tag rule — harmless since addMessage no longer emits
   this span, but kept here in case an older cached page somehow
   renders one. Would be removed in a future cleanup pass. */
#message-log-content p .turn-tag {
    color: var(--gold-dim);
    font-size: 0.85em;
    margin-right: 4px;
}

/* Scrollbar styling for log */
#message-log-content::-webkit-scrollbar {
    width: 6px;
}
#message-log-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
#message-log-content::-webkit-scrollbar-thumb {
    background: var(--gold-dim);
    border-radius: 3px;
}

/* Left column scrollbar */
#left-column::-webkit-scrollbar {
    width: 6px;
}
#left-column::-webkit-scrollbar-track {
    background: transparent;
}
#left-column::-webkit-scrollbar-thumb {
    background: rgba(139,105,20,0.4);
    border-radius: 3px;
}

/* ===== Tavern Panel (anchored to market) ===== */

.tavern-anchored-panel {
    position: fixed;
    z-index: var(--z-float);
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 6px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4), 0 0 15px rgba(201,162,39,0.15);
    overflow-y: auto;
    animation: tavern-slide-in 0.25s ease;
}

@keyframes tavern-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.tavern-dimmed {
    position: relative;
    pointer-events: none;
    transition: filter 0.25s ease;
    filter: brightness(0.3);
}

#tavern-panel-content { padding: 10px 14px 14px; }

.tavern-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 8px;
    border-bottom: 2px solid var(--gold-dim);
    background: linear-gradient(180deg, var(--parchment), var(--parchment-dark));
    position: sticky;
    top: 0;
    z-index: var(--z-base);
}

.tavern-panel-header h3 {
    margin: 0;
    font-family: var(--font-heading);
    color: var(--wood);
    font-size: 1.1em;
}

.tavern-close {
    background: none;
    border: none;
    font-size: 1.4em;
    color: var(--ink-light);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.tavern-close:hover { color: var(--danger); }

.tavern-city {
    padding: 10px 16px 6px;
    border-bottom: 1px solid var(--parchment-deep);
}

.tavern-city-name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95em;
    color: var(--wood);
    margin-bottom: 4px;
}

.tavern-price-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 0.88em;
    color: var(--ink);
}

.tavern-price-row .tavern-good { color: var(--ink); }
.tavern-price-row .tavern-price { font-weight: 600; color: var(--wood); }
.tavern-price-row.stale { font-style: italic; opacity: 0.7; }
.tavern-price-row.stale .tavern-price::after { content: ' (old)'; font-weight: 400; font-size: 0.85em; color: var(--ink-light); }

/* Feature 7: active rumor block sits above the price listings */
.tavern-rumor-group { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(92, 58, 42, 0.25); }
.tavern-rumor-group-title { font-family: var(--font-heading); font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.1em; color: var(--wood); margin-bottom: 8px; }
.tavern-rumor-row { margin-bottom: 8px; padding: 6px 8px; background: rgba(92, 58, 42, 0.04); border-radius: 4px; }
.tavern-rumor-cat { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--wood); font-weight: 700; }
.tavern-rumor-ttl { font-weight: 400; opacity: 0.7; font-style: italic; }
.tavern-rumor-text { font-size: 0.9em; color: var(--ink); font-style: italic; line-height: 1.4; margin-top: 3px; }
.tavern-prices-title { font-family: var(--font-heading); font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.1em; color: var(--wood); margin-bottom: 6px; }

/* Leaderboard celebration modal */
.lb-celebrate-box {
    width: min(92vw, 760px);
    max-width: 760px;
    max-height: 82vh;
    padding: 28px 34px 30px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: center;
}
.lb-celebrate-title {
    font-family: var(--font-heading);
    color: var(--gold);
    margin: 0 0 14px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}
.lb-ornament {
    width: clamp(40px, 8vw, 64px);
    height: clamp(40px, 8vw, 64px);
    object-fit: contain;
    flex-shrink: 0;
}
.lb-celebrate-title-text { flex: 0 1 auto; }
.lb-celebrate-name-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.lb-celebrate-name-row label { font-family: var(--font-heading); font-size: 0.9em; color: var(--ink); }
.lb-celebrate-name-row input {
    font-family: var(--font-body); font-size: 1em; padding: 5px 10px;
    border: 1px solid var(--gold-dim); border-radius: 4px;
    background: var(--parchment); color: var(--ink); width: 220px; text-align: center;
}
.lb-celebrate-name-row input.hint-pulse {
    animation: namePulse 1.2s ease-in-out infinite;
}
@keyframes namePulse {
    0%, 100% { border-color: var(--gold-dim); }
    50% { border-color: var(--gold); box-shadow: 0 0 6px rgba(201, 162, 39, 0.4); }
}
.lb-celebrate-actions { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.lb-celebrate-btn { font-family: var(--font-heading); font-size: 0.95em; padding: 8px 20px; }
.lb-celebrate-status { font-size: 0.82em; color: var(--ink-light); }
#lb-celebrate-table {
    min-height: 320px;
    flex: 1 1 auto;
    overflow: auto;
    overflow-x: hidden;
    margin: 0;
    scrollbar-gutter: stable both-edges;
}
#lb-celebrate-table table { width: 100%; }
.leaderboard-you-row { background: rgba(201, 162, 39, 0.15); font-weight: 600; }

/* Settings tabs */
.settings-tabs { display: flex; gap: 0; margin: 0 -20px 12px; border-bottom: 2px solid rgba(92, 58, 42, 0.2); }
.settings-tab { flex: 1; background: none; border: none; padding: 8px 4px 6px; font-family: var(--font-heading); font-size: 0.85em; color: var(--ink-light); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; }
.settings-tab:hover { color: var(--ink); }
.settings-tab.active { color: var(--wood); border-bottom-color: var(--wood); font-weight: 600; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* Narration settings: master select + per-category overrides */
.settings-select { background: var(--parchment); border: 1px solid var(--wood); color: var(--ink); padding: 2px 6px; font-family: inherit; font-size: 0.9em; border-radius: 3px; }
.settings-separator { border-top: 1px dashed rgba(92, 58, 42, 0.25); margin: 6px 0 4px; }
.settings-override-row { padding-left: 8px; font-size: 0.88em; margin: 3px 0; display: flex; align-items: center; gap: 4px; }
.settings-override-row label { display: flex; align-items: center; gap: 5px; cursor: pointer; color: var(--ink); }
.settings-override-row input[type="checkbox"] { width: 13px; height: 13px; accent-color: var(--gold, #c9a227); }

/* ===== Game Modal Backdrop (shared) ===== */

.game-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: safe center;
    justify-content: center;
    background: rgba(10, 6, 2, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: modal-fade-in 0.3s ease forwards;
    overflow-y: auto;
    padding: 20px;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modal-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes modal-zoom-in {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes modal-zoom-out {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}

.game-modal-backdrop.modal-closing {
    animation: modal-fade-out 0.15s ease forwards;
}

.game-modal-backdrop.modal-closing .parchment-modal {
    animation: modal-zoom-out 0.15s ease forwards;
}

#event-modal {
    z-index: var(--z-modal-event);
}

#sound-modal {
    z-index: var(--z-modal-system);
}

.parchment-modal {
    position: relative;       /* anchor .modal-close-x inside any parchment modal */
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 20px rgba(201,162,39,0.2);
    padding: 24px 30px;
    text-align: center;
    width: min(94vw, 500px);
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.parchment-modal.travel-modal-wide {
    width: min(94vw, 800px);
    max-width: 800px;
}

/* Travel map */
#travel-map-container {
    position: relative;
    height: clamp(180px, 30vw, 360px); /* Map scales large — needs room for timeline dots */
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--gold-dim);
    margin: 10px 0 14px;
    background: var(--parchment-deep);
}

#travel-map-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(0.3) brightness(0.9);
}

#travel-ship-icon {
    position: absolute;
    width: clamp(28px, 3vw, 42px);
    transition: left 1.8s ease-in-out;
    transform: translateX(-50%);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    z-index: var(--z-sticky);
    top: -4px;
    pointer-events: none;
}

#travel-ship-icon img {
    width: 100%;
    height: auto;
}

.parchment-modal:not(.travel-modal-wide) {
    animation: modal-zoom-in 0.3s ease forwards;
}

/* ===== Travel Modal ===== */

#travel-route-label {
    font-family: var(--font-heading);
    font-size: 1.3em;
    font-weight: 700;
    color: var(--wood);
    letter-spacing: 1px;
    margin-bottom: 20px;
}

#travel-timeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 12px;
    padding: 22px 10px 0;
    position: relative;
}

.timeline-dot {
    width: clamp(18px, 2vw, 28px);
    height: clamp(18px, 2vw, 28px);
    border-radius: 50%;
    border: 2px solid var(--gold-dim);
    background: var(--parchment-dark);
    flex-shrink: 0;
    transition: all 0.4s ease;
    position: relative;
}

.timeline-dot.completed {
    background: var(--gold);
    border-color: var(--gold-bright);
    box-shadow: 0 0 6px rgba(201,162,39,0.5);
}

.timeline-dot.current {
    border-color: var(--gold-bright);
    animation: dot-pulse 1s ease-in-out infinite alternate;
}

.timeline-dot.event-dot {
    background: var(--danger);
    border-color: #c44;
    box-shadow: 0 0 8px rgba(170,51,51,0.5);
}

.timeline-dot.event-dot.good-event {
    background: var(--success);
    border-color: #5a9c4f;
    box-shadow: 0 0 8px rgba(74,124,63,0.5);
}

.timeline-connector {
    height: 2px;
    flex: 1;
    min-width: 12px;
    max-width: 40px;
    background: var(--parchment-deep);
    transition: background 0.4s ease;
}

.timeline-connector.completed {
    background: var(--gold);
}

.timeline-port {
    width: clamp(120px, 12vw, 150px);
    border-radius: 5px;
    border: 2px solid var(--gold-dim);
    background: var(--parchment-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: clamp(8px, 0.85vw, 11px);
    font-weight: 700;
    color: var(--wood);
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    position: relative;
    z-index: var(--z-base);
    flex-shrink: 0;
    transition: all 0.4s ease;
    white-space: nowrap;
}

.timeline-port .tl-coa {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}

.timeline-port.completed {
    background: var(--gold);
    border-color: var(--gold-bright);
    color: var(--wood);
    box-shadow: 0 0 6px rgba(201,162,39,0.5);
}

.timeline-port.arrived {
    animation: dot-pulse 1s ease-in-out infinite alternate;
    border-color: var(--gold-bright);
}

@keyframes dot-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(201,162,39,0); }
    100% { transform: scale(1.15); box-shadow: 0 0 10px rgba(201,162,39,0.6); }
}

#travel-month-label {
    font-family: var(--font-heading);
    font-size: 0.9em;
    color: var(--ink-light);
    margin-bottom: 6px;
}

#travel-status {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink-light);
    font-style: italic;
    min-height: 1.4em;
}

/* ===== Event Modal — two-column hero layout =====
   Used by showEventModal (travel arrivals), showIntroModal (Spring 1497),
   and showSeasonEndModal (da Gama epilogue). Image on the left as a
   full-bleed portrait, text + button stacked on the right. The modal
   stays under the fold on a 1366×620 effective laptop viewport — the
   single-column predecessor put the Begin button below the fold and
   forced internal scrolling. Falls back to stacked under 720px.

   Image in the left column; a flex-column wrapper (#event-modal-right)
   in the right column holds title + scrollable lines + footer so the
   button and dismiss checkbox are always anchored at the bottom.
*/

#event-modal-content {
    max-width: 720px;
    width: min(94vw, 720px);
    /* Force the modal to a tall fixed share of the viewport so the
       text/decision panel has real estate to expand into instead of
       collapsing to its content height (which makes the lines panel
       scroll inside ~250px while the image hogs everything above). */
    height: min(92vh, 780px);
    padding: 0;                  /* override .parchment-modal's 24px 30px */
    overflow: hidden;            /* image corners are clipped to the modal */
    text-align: left;            /* override .parchment-modal's center */
    display: flex;
    flex-direction: column;
    position: relative;          /* anchor the absolute mute button */
}

/* Narration mute button. Pinned to the top-right inside the modal so
   the player can silence the intro voice-over without leaving the
   modal. Hidden by default via [hidden]; showIntroModal removes the
   attribute when narration starts. The toggled-off state adds .muted
   so the strikethrough on the icon is visible. */
.event-modal-mute {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(20, 14, 8, 0.55);
    border: 1.5px solid var(--gold-dim);
    color: var(--gold-bright);
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.event-modal-mute[hidden] { display: none !important; }
.event-modal-mute:hover {
    background: rgba(20, 14, 8, 0.75);
    border-color: var(--gold);
    transform: scale(1.06);
}
.event-modal-mute:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 2px;
}
.event-modal-mute.muted {
    color: var(--ink-light);
}
.event-modal-mute svg { display: block; }

#event-modal-img {
    width: 100%;
    /* Cap as a share of viewport so the image doesn't crowd the
       narrative + decision buttons on shorter screens. The hard
       260px cap stays so big monitors don't get a wall of image. */
    max-height: min(260px, 32vh);
    object-fit: cover;
    margin: 0;
    border-radius: 6px 6px 0 0;
    border-bottom: 2px solid var(--gold-dim);
    flex-shrink: 0;
}

#event-modal-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

#event-modal-title {
    font-family: var(--font-heading);
    font-size: 1.35em;
    color: var(--wood);
    margin: 28px 32px 12px;
}

#event-modal-lines {
    font-family: var(--font-body);
    font-size: 0.97em;
    color: var(--ink);
    line-height: 1.6;
    text-align: left;
    margin: 0 32px 16px;
    padding-right: 10px;  /* gap between text and scrollbar */
    flex: 1;              /* fill remaining right-column height; content scrolls */
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) transparent;
}

#event-modal-lines::-webkit-scrollbar {
    width: 6px;
}

#event-modal-lines::-webkit-scrollbar-track {
    background: transparent;
}

#event-modal-lines::-webkit-scrollbar-thumb {
    background: var(--gold-dim);
    border-radius: 3px;
}

#event-modal-lines::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

#event-modal-lines p {
    margin: 0 0 10px;
}

#event-modal-lines .event-damage {
    color: var(--danger);
    font-weight: 600;
}

#event-modal-lines .event-gain {
    /* Darker than --success (#4a7c3f) — the light-parchment modal needs a
     * green that clears WCAG AA (4.5:1) for body text. The global --success
     * is calibrated for dark button fills, not for text on parchment. */
    color: #2d5a26;
    font-weight: 600;
}

/* Repeat-player "Don't show this again" row. Hidden by default via
   the [hidden] attribute on the <label>; showIntroModal and
   showSeasonEndModal remove the attribute and populate the checkbox
   from the persisted meta flag. Mid-voyage event modals leave it
   hidden (they're one-shot and shouldn't be dismissible). */
/* Footer area: button stacked above optional dismiss checkbox */
.event-modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 4px 32px 28px;
}

#event-modal-btn {
    font-size: 0.95em;
    padding: 9px 28px;
}

/* Feature 6: decision row replaces the single Continue button when the
   event modal carries a `decisions` array (Royal Inspection contraband).
   Buttons stack vertically on narrow viewports so three options never
   get squeezed into unreadable sizes. */
.event-modal-decisions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 380px;
    margin: 8px auto 0;
}
.event-modal-decision-btn {
    font-family: var(--font-body);
    font-size: 0.92em;
    padding: 10px 16px;
    background: var(--panel-bg);
    color: var(--ink);
    border: 2px solid var(--gold-dim);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, border-color 0.15s;
    text-align: left;
    white-space: pre-line;
    line-height: 1.4;
}
.event-modal-decision-btn:hover {
    background: linear-gradient(160deg, #f8ecd2 0%, #e8d5a3 100%);
    border-color: var(--gold);
    transform: translateY(-1px);
}
.event-modal-decision-btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
.event-modal-decision-btn:active {
    transform: translateY(0);
}
.decision-main { font-weight: 600; font-size: 1em; }
.decision-sub { font-size: 0.8em; color: var(--ink-light); font-weight: 400; margin-top: 2px; font-style: italic; }

/* Blockade reroute variant: reuse the left-panel travel-strip buttons
 * (coat of arms + city + weeks pill) so the player instantly recognizes
 * these as destination choices. The modal container drops its column
 * flex since each .travel-strip is already a row of its own.
 *
 * Width sized to the modal content area so 5-port reroute lists lay out
 * cleanly in 3+2 rows without clipping the weeks pill. The old 420px cap
 * was chosen for narrow 3-option inspection modals and squeezed the wider
 * blockade list until "5w" was cropped off the last button. */
.event-modal-decisions.event-modal-decisions-travel {
    gap: 0;
    max-width: min(600px, 92%);
}
.event-modal-decisions-travel .strip-btn {
    justify-content: center;
    font-size: 0.9em;
    padding: 10px 12px;
    min-width: 0;
}
.event-modal-decisions-travel .travel-coa {
    flex-shrink: 0;
}
.event-modal-decisions-travel .weeks {
    flex-shrink: 0;
}

.event-modal-dismiss {
    font-family: var(--font-body);
    font-size: 0.78em;
    color: var(--ink-light);
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
    opacity: 0.55;
    transition: opacity 0.2s;
}
.event-modal-dismiss[hidden] {
    display: none !important;
}
.event-modal-dismiss input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 13px;
    height: 13px;
}
.event-modal-dismiss:hover {
    opacity: 0.9;
}

/* Mobile / narrow viewport: tighter margins, shorter banner */
@media (max-width: 720px) {
    #event-modal-content { max-width: 96vw; }
    #event-modal-img { max-height: 180px; }
    #event-modal-title { margin: 16px 20px 8px; }
    #event-modal-lines { margin: 0 20px 12px; }
    .event-modal-footer { margin: 4px 20px 18px; }
}

/* ===== Good Detail Modal ===== */
#good-modal {
    z-index: var(--z-modal-detail);
    top: 70px;
    inset: 70px 0 0 0;
    align-items: center;
    padding: 20px;
}

#good-modal-content {
    width: min(94vw, 800px);
    max-width: 800px;
    position: relative;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

#good-modal-left {
    flex: 0 0 auto;
    text-align: center;
}

#good-modal-right {
    flex: 1;
    min-width: 0;
}

#good-modal-img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--gold-dim);
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#good-modal-title {
    font-family: var(--font-heading);
    font-size: 1.3em;
    color: var(--wood);
    margin: 0 0 10px;
}

#good-modal-desc {
    font-family: var(--font-body);
    font-size: 0.95em;
    color: var(--ink);
    line-height: 1.6;
    margin: 0 0 14px;
    text-align: left;
}

#good-modal-meta {
    font-family: var(--font-body);
    font-size: 0.85em;
    color: var(--ink-light);
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#good-modal-meta span {
    background: var(--parchment-dark);
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--gold-dim);
}

#good-modal-trivia {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

#good-modal-trivia li {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink);
    line-height: 1.5;
    padding: 6px 0 6px 20px;
    position: relative;
    border-bottom: 1px solid rgba(139, 105, 20, 0.15);
}

#good-modal-trivia li:last-child {
    border-bottom: none;
}

#good-modal-trivia li::before {
    content: "\2767";
    position: absolute;
    left: 0;
    color: var(--gold-dim);
}

/* ===== End Game Screen ===== */

#end-game-screen {
    font-family: var(--font-body);
    font-size: 1em;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    padding: 80px 30px 30px;
    background: radial-gradient(ellipse at center, rgba(42,26,16,0.95) 0%, rgba(13,8,5,0.98) 100%);
    color: var(--parchment);
    text-align: center;
    z-index: var(--z-modal-system);
}

#end-game-screen::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url('images/med_map_opt.jpg') center center / cover no-repeat;
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

.end-content {
    max-width: min(1100px, 92vw);
    text-align: center;
    width: 100%;
}

/* Season-end hero banner. Wide 16:9 painting (images/season_end.jpg —
   da Gama's caravels arriving at the Malabar Coast) sits above the
   title for season_end runs only. Capped at 280px tall so it doesn't
   eat the score panel on a 1366×768 laptop; cropped horizontally with
   object-position centered which preserves the lead caravel and the
   beach figures. Inserted by showEndGameScreen() conditionally on
   reason === 'season_end' so failure endings skip it. */
.end-hero {
    width: 100%;
    max-width: min(900px, 92vw);
    margin: 0 auto 18px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--gold-dim);
    box-shadow: 0 8px 28px rgba(0,0,0,0.6), 0 0 18px rgba(201,162,39,0.18);
}

.end-hero-img {
    display: block;
    width: 100%;
    height: clamp(160px, 22vh, 220px);
    object-fit: cover;
    object-position: center;
}

/* One-line epilogue sits under the title — long narrative moved to the
   last-turn news modal + Legacy modal, so this is just a pay-off beat. */
.end-tagline {
    font-family: var(--font-body);
    font-size: 1em;
    font-style: italic;
    color: var(--parchment-dark);
    margin: 2px auto 18px;
    max-width: 720px;
    line-height: 1.5;
}

/* Outer tabs: Summary / Achievements / Leaderboard. Reuses the same
   visual language as .end-lb-tab but slightly larger for top-level. */
.end-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 4px 0 18px;
    border-bottom: 1px solid var(--gold-dim);
    padding-bottom: 10px;
}

.end-top-tab {
    font-family: var(--font-heading);
    font-size: 0.95em;
    padding: 8px 20px;
    background: transparent;
    color: var(--parchment-dark);
    border: 1px solid transparent;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.5px;
}

.end-top-tab:hover {
    color: var(--parchment);
    background: rgba(255,255,255,0.05);
}

.end-top-tab.active {
    background: rgba(201,162,39,0.12);
    border-color: var(--gold);
    color: var(--gold-bright);
    font-weight: 700;
}

.end-tab-panel {
    min-height: 260px;
}

.end-tab-panel[hidden] {
    display: none;
}

/* Summary tab: identity card on the left, score card on the right. */
.end-summary {
    display: flex;
    gap: 32px;
    align-items: stretch;
    justify-content: center;
    max-width: 880px;
    margin: 0 auto;
}

.end-identity {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(201,162,39,0.25);
    border-radius: 8px;
}

.end-head-img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid var(--gold);
    object-fit: cover;
    object-position: center 15%;
    background: var(--parchment);
    box-shadow: var(--shadow-portrait);
}

.end-identity-name {
    font-family: var(--font-heading);
    font-size: 1.25em;
    color: var(--gold-bright);
    font-weight: 700;
    text-align: center;
    margin-top: 4px;
}

.end-identity-meta {
    font-size: 0.85em;
    color: var(--parchment-dark);
    text-align: center;
    font-style: italic;
}

.end-score-card {
    flex: 1;
    max-width: 460px;
    padding: 24px 28px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.end-record-badge {
    position: absolute;
    top: -22px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-family: var(--font-heading);
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 1.5px;
}
.end-record-coin {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
}
.end-record-text { white-space: nowrap; }

.end-networth-label {
    font-family: var(--font-heading);
    font-size: 0.82em;
    color: var(--parchment-dark);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.end-networth-value {
    font-family: var(--font-heading);
    font-size: 2.8em;
    font-weight: 700;
    color: var(--gold-bright);
    line-height: 1;
    margin-bottom: 2px;
}

.end-score-meta {
    font-size: 0.85em;
    color: var(--parchment-dark);
    margin-bottom: 6px;
}

.end-score-substats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 20px;
    padding: 10px 0;
    border-top: 1px solid rgba(201,162,39,0.2);
    border-bottom: 1px solid rgba(201,162,39,0.2);
}

.end-sub {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.9em;
}

.end-sub-label {
    color: var(--parchment-dark);
    font-family: var(--font-heading);
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.end-sub-value {
    color: var(--parchment);
    font-family: var(--font-heading);
    font-weight: 600;
}

.end-best-row {
    font-size: 0.88em;
    font-weight: 600;
    text-align: center;
    margin-top: 4px;
}

#end-game-screen h2 {
    font-family: var(--font-heading);
    color: var(--gold-bright);
    font-size: 1.8em;
    margin: 0 0 10px;
}

#end-game-screen h3 {
    font-family: var(--font-heading);
    color: var(--parchment);
    margin-top: 20px;
    margin-bottom: 10px;
}

#end-game-screen button {
    padding: 12px 30px;
    font-size: 1.1em;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    margin-top: 25px;
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: 5px;
    transition: all 0.2s ease;
}

#end-game-screen button:hover {
    background: linear-gradient(180deg, #a07850, var(--leather-light));
    box-shadow: 0 0 12px rgba(201,162,39,0.4);
}

/* ===== Event Image Popup ===== */

.event-image-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    max-width: 280px;
    max-height: 280px;
    z-index: var(--z-modal-system);
    border: 3px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(201,162,39,0.5), 0 0 60px rgba(0,0,0,0.6);
    animation: fadeInOutPopup 4s ease-in-out forwards;
}

@keyframes fadeInOutPopup {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    15%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    85%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* ===== City Detail Modal ===== */

#city-modal {
    z-index: var(--z-modal-detail);
    align-items: center;
    padding: 20px;
}

#city-modal-content {
    width: min(94vw, 700px);
    max-width: 700px;
    position: relative;
    text-align: left;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    max-height: 85vh;
    animation: modal-zoom-in 0.3s ease forwards;
}

.city-modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--parchment);
    cursor: pointer;
    z-index: var(--z-base);
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

.city-modal-close:hover {
    color: var(--gold-bright);
}

#city-modal-left {
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
}

#city-modal-img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 45vh;
    object-fit: cover;
}

#city-modal-right {
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#city-modal-title {
    font-family: var(--font-heading);
    font-size: 1.4em;
    color: var(--wood);
    margin: 0 0 10px;
    letter-spacing: 0.5px;
}

#city-modal-desc {
    font-family: var(--font-body);
    font-size: 0.95em;
    color: var(--ink);
    line-height: 1.6;
    margin: 0 0 12px;
}

#city-modal-meta {
    font-family: var(--font-body);
    font-size: 0.85em;
    color: var(--ink-light);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

#city-modal-meta span {
    background: var(--parchment-dark);
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--gold-dim);
}

#city-modal-goods {
    margin-bottom: 14px;
}

.city-goods-label {
    font-family: var(--font-heading);
    font-size: 0.8em;
    color: var(--gold-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.city-goods-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.city-good-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--parchment-dark);
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    padding: 4px 10px 4px 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.city-good-badge:hover {
    border-color: var(--gold);
    background: var(--parchment-deep);
}

.city-good-badge img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.city-good-badge span {
    font-family: var(--font-body);
    font-size: 0.85em;
    color: var(--ink);
}

#city-modal-trivia {
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid rgba(139, 105, 20, 0.25);
    padding-top: 12px;
}

#city-modal-trivia li {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink);
    line-height: 1.5;
    padding: 6px 0 6px 20px;
    position: relative;
    border-bottom: 1px solid rgba(139, 105, 20, 0.15);
}

#city-modal-trivia li:last-child {
    border-bottom: none;
}

#city-modal-trivia li::before {
    content: "\2767";
    position: absolute;
    left: 0;
    color: var(--gold-dim);
}

/* ===== Market Cost Preview ===== */

.cost-preview {
    display: block;
    font-size: 0.75em;
    font-family: var(--font-body);
    color: var(--ink-light);
    margin-top: 1px;
    min-height: 1.1em;
}

.cost-basis {
    display: inline-block;
    font-size: 0.78em;
    font-family: var(--font-heading);
    font-weight: 600;
    font-style: normal;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    color: var(--ink-light);
}
.cost-basis.profit { color: var(--success); background: rgba(74,124,63,0.12); border: 1px solid rgba(74,124,63,0.3); }
.cost-basis.loss { color: var(--danger); background: rgba(170,51,51,0.1); border: 1px solid rgba(170,51,51,0.25); }

.cost-preview.over-budget {
    color: var(--danger);
    font-weight: 600;
}

/* ===== Trend Arrows ===== */

.trend-up { color: #2d5a26; font-size: 0.8em; }
.trend-down { color: var(--danger); font-size: 0.8em; }
/* Previously #999 — dropped below 3:1 on parchment and was hard to spot.
 * The arrow character (↕/—) is still the primary cue; this is a
 * secondary darker grey so low-vision users can see the glyph. */
.trend-flat { color: #5e5e5e; font-size: 0.7em; }
.col-trend, .col-weight { text-align: center; font-size: 0.85em; color: var(--ink-light); }

/* ===== Embargo & Port Notices ===== */

/* Embargo stamp overlay on sell cell */
/* The sell cell is ALWAYS position:relative (not just when embargoed)
   because the embargo stamp is now permanent markup that toggles via the
   hidden attribute — we need its absolute positioning to be contained
   inside the td regardless of current embargo state. */
#market-table td[data-cell="sell"],
.sell-embargoed {
    position: relative;
}

.sell-embargoed .trade-row {
    opacity: 0.15;
    pointer-events: none;
}

.embargo-stamp {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 0.78em;
    font-weight: 700;
    color: rgba(170, 51, 51, 0.75);
    border: 2px solid rgba(170, 51, 51, 0.5);
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 3px;
    pointer-events: none;
    z-index: var(--z-sticky);
    background: rgba(245, 230, 200, 0.6);
    animation: stamp-in 0.4s ease-out;
}

/* The HTML hidden attribute is equivalent to display:none at user-agent
   specificity, which `.embargo-stamp { display: flex }` above trumps.
   Force it back with attribute-selector specificity so row-cached stamps
   actually hide by default. Same story for the BM button which also
   defaults to hidden in the cached row template. */
.embargo-stamp[hidden],
#market-table .bm-sell-btn[hidden] {
    display: none !important;
}

@keyframes stamp-in {
    0%   { opacity: 0; transform: scale(1.4) rotate(-5deg); }
    60%  { opacity: 1; transform: scale(0.95) rotate(1deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
.port-notice { font-size: 0.82em; font-family: var(--font-heading); padding: 4px 8px; margin-top: 6px; border-radius: 4px; text-align: center; }
.embargo-notice { background: rgba(170,51,51,0.1); color: var(--danger); border: 1px solid rgba(170,51,51,0.3); }
.tax-notice { background: rgba(184,134,11,0.1); color: var(--warning); border: 1px solid rgba(184,134,11,0.3); }

/* ===== Season Badge ===== */

.season-badge { background: rgba(201,162,39,0.15) !important; border-color: var(--gold) !important; }

/* ===== Stacked Action Buttons ===== */

.action-btn-stacked {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 14px 4px;
    min-width: 70px;
}
.action-btn-stacked .btn-label {
    font-size: 0.85em;
    text-transform: capitalize;
}
.action-btn-stacked .btn-cost {
    font-size: 0.65em;
    opacity: 0.75;
    font-family: var(--font-body);
    margin-top: 1px;
}

/* ===== Travel speed strikethrough ===== */

.travel-months { font-size: 0.85em; }
.travel-months s { opacity: 0.5; margin-right: 3px; }
.travel-cost { display: block; font-size: 0.7em; opacity: 0.7; font-family: var(--font-body); }

/* ===== End Game Achievements ===== */

.end-achievements { margin-top: 4px; }
.end-achievements h4 { color: var(--gold); margin-bottom: 8px; }
.achievement-earned { display: inline-block; background: rgba(201,162,39,0.15); border: 1px solid var(--gold-dim); border-radius: 4px; padding: 3px 10px; margin: 3px; font-family: var(--font-heading); font-size: 0.8em; color: var(--gold-bright); }

/* ===== End Game Actions ===== */

.achievement-progress-list { margin-top: 10px; }
.achievement-progress-item { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.8em; }
.ach-prog-name { flex: 0 0 auto; color: var(--parchment-dark); font-family: var(--font-heading); min-width: 100px; text-align: right; }
.ach-prog-bar { flex: 1; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; min-width: 80px; max-width: 150px; }
.ach-prog-fill { height: 100%; background: var(--gold-dim); border-radius: 4px; transition: width 0.3s; }
.ach-prog-text { flex: 0 0 auto; color: var(--gold-dim); font-size: 0.9em; min-width: 40px; }

.end-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.end-actions button { padding: 10px 24px; font-size: 1em; font-family: var(--font-heading); font-weight: 600; cursor: pointer; border-radius: 5px; transition: all 0.2s ease; }
.end-actions button:first-child { background: linear-gradient(180deg, var(--leather-light), var(--leather)); color: var(--parchment); border: 2px solid var(--gold); }
.end-actions button:first-child:hover { background: linear-gradient(180deg, #a07850, var(--leather-light)); box-shadow: 0 0 12px rgba(201,162,39,0.4); }
#share-btn { background: var(--parchment-dark); color: var(--ink); border: 1px solid var(--gold-dim); font-size: 0.85em; }
#share-btn:hover { background: var(--gold); color: var(--wood); }

/* End-screen leaderboard: auto-submit handles score writes + name entry
   via the celebration modal, so the end screen shows only the ranked
   table (no form). */
.end-leaderboard { text-align: center; margin: 0 0 4px; }
.end-play-hook { text-align: center; font-size: 0.9em; color: var(--parchment-dark); margin: 18px 0 8px; font-style: italic; min-height: 1.4em; transition: color 0.4s; }
.end-play-hook.hook-highlight { color: var(--gold); }
.end-lb-table-wrap { margin-top: 14px; max-height: 260px; overflow-y: auto; }
.end-lb-tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }
.end-lb-tab { font-family: var(--font-heading); font-size: 0.8em; padding: 4px 12px; background: rgba(255,255,255,0.06); color: var(--parchment-dark); border: 1px solid var(--gold-dim); border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.end-lb-tab:hover { border-color: var(--gold); color: var(--parchment); }
.end-lb-tab.active { background: var(--leather); border-color: var(--gold); color: var(--parchment); font-weight: 600; }

/* Leaderboard table (start screen + shared) */
.leaderboard-table th { font-size: 0.8em; }
.leaderboard-rank { font-family: var(--font-heading); color: var(--gold); width: 30px; text-align: center; }
.leaderboard-highlight td { background: rgba(201,162,39,0.1); }

/* End-screen leaderboard table — override ink color for dark background */
.end-lb-table-wrap .ss-history-table td { color: var(--parchment-dark); border-bottom-color: rgba(201,162,39,0.12); }
.end-lb-table-wrap .ss-history-table th { color: var(--gold-dim); border-bottom-color: rgba(201,162,39,0.3); }
.end-lb-table-wrap .ss-history-table .leaderboard-rank { color: var(--gold); }

/* End game staggered reveal */
@keyframes end-fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.end-reveal {
    opacity: 0;
    animation: end-fade-up 0.5s ease forwards;
}
.end-reveal:nth-child(1) { animation-delay: 0s; }
.end-reveal:nth-child(2) { animation-delay: 0.12s; }
.end-reveal:nth-child(3) { animation-delay: 0.24s; }
.end-reveal:nth-child(4) { animation-delay: 0.36s; }
.end-reveal:nth-child(5) { animation-delay: 0.48s; }
.end-reveal:nth-child(6) { animation-delay: 0.6s; }

/* ===== Start Screen ===== */

#start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #2a1a10 0%, #0d0805 100%);
    padding: 20px;
    position: relative;
    opacity: 0;
    transition: opacity 0.6s ease-in;
    /* Custom compass-rose-arrow cursor on the start screen only.
       Firefox/Chromium honour SVG cursors; Safari falls back to default
       pointer gracefully. Hotspot at (2,2) = arrow tip. */
    cursor: url('../images/compass_cursor.svg') 2 2, default;
}

/* Buttons in the start screen still use the compass cursor instead of
   the browser's default pointer, so the theming is consistent everywhere
   on the card. Button hover/active states inherit the cursor from
   #start-screen automatically. */
#start-screen button,
#start-screen label,
#start-screen .ss-city-tile,
#start-screen .ss-modifier,
#start-screen a {
    cursor: url('../images/compass_cursor.svg') 2 2, pointer;
}

#start-screen.ss-ready { opacity: 1; }

#start-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../images/med_map_opt.jpg') center center / cover no-repeat;
    opacity: 0.35;
    z-index: 0;
}

#start-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(42,26,16,0.4) 0%, rgba(13,8,5,0.85) 100%);
    z-index: 1;
}

/* Custom scrollbar */
.ss-card::-webkit-scrollbar { width: 7px; }
.ss-card::-webkit-scrollbar-track { background: var(--parchment-dark); border-radius: 4px; }
.ss-card::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 4px; }
.ss-card::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.ss-voyages-collapsible::-webkit-scrollbar { width: 5px; }
.ss-voyages-collapsible::-webkit-scrollbar-track { background: transparent; }
.ss-voyages-collapsible::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

.ss-card {
    position: relative;
    z-index: 10;
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 30px rgba(201,162,39,0.15);
    padding: clamp(16px, 2.5vw, 32px) clamp(20px, 3vw, 44px);
    width: 94%;
    max-width: 860px;
    max-height: 92vh;
    overflow-y: auto;
    scrollbar-color: var(--gold-dim) var(--parchment-dark);
    scrollbar-width: thin;
}

/* Continue-run banner — shown above the step indicator when a resumable
   saved session exists in localStorage. Hidden by the `hidden` attribute
   in index.html until populateContinueRunBanner() flips it on. */
.ss-continue-banner {
    margin-bottom: clamp(12px, 1.6vh, 18px);
    background: linear-gradient(180deg, rgba(201,162,39,0.14), rgba(139,105,20,0.08));
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 0 14px rgba(201,162,39,0.18);
    animation: ss-continue-pulse 2.6s ease-in-out infinite;
}

@keyframes ss-continue-pulse {
    0%, 100% { box-shadow: 0 0 14px rgba(201,162,39,0.18); }
    50%      { box-shadow: 0 0 22px rgba(201,162,39,0.32); }
}

.ss-continue-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.ss-continue-text {
    flex: 1 1 auto;
    min-width: 0;
}

.ss-continue-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05em;
    color: var(--gold-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ss-continue-subtitle {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink-light);
    margin-top: 2px;
}

.ss-continue-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.ss-continue-resume {
    padding: 9px 22px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.98em;
    letter-spacing: 0.5px;
    cursor: pointer;
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.ss-continue-resume:hover {
    background: linear-gradient(180deg, #a07850, var(--leather-light));
    box-shadow: 0 0 15px rgba(201,162,39,0.5);
}

.ss-continue-discard {
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.85em;
    cursor: pointer;
    background: transparent;
    color: var(--parchment);
    border: 1px solid rgba(201,162,39,0.35);
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.ss-continue-discard:hover {
    opacity: 1;
    border-color: var(--gold);
    background: rgba(139,105,20,0.15);
}

@media (max-width: 520px) {
    .ss-continue-inner { flex-direction: column; align-items: stretch; gap: 10px; }
    .ss-continue-actions { justify-content: space-between; }
    .ss-continue-resume { flex: 1 1 auto; }
}

.ss-referral-banner {
    margin-bottom: clamp(12px, 1.6vh, 18px);
    background: linear-gradient(180deg, rgba(201,162,39,0.18), rgba(139,105,20,0.1));
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 0 14px rgba(201,162,39,0.22);
}
.ss-referral-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ss-referral-text {
    flex: 1 1 auto;
    font-family: var(--font-body);
    font-size: 0.95em;
    color: var(--ink);
    line-height: 1.4;
}
.ss-referral-text strong {
    color: var(--wood);
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
}

/* Step indicators */
.ss-steps-indicator {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: clamp(8px, 1vh, 14px);
}

.ss-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid var(--gold-dim);
    background: transparent;
    cursor: pointer;
    transition: all 0.25s ease;
}

.ss-dot.active {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(201,162,39,0.4);
}

/* Step container & transitions */
.ss-step-container {
    position: relative;
}

.ss-step {
    display: none;
    animation: ss-step-in 0.35s ease;
}

.ss-step.active {
    display: block;
}

@keyframes ss-step-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header — title + tagline inline (side-by-side) so the modal saves
   vertical space. Wraps onto two lines on narrow viewports. */
.ss-header {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: clamp(10px, 1.6vw, 22px);
    flex-wrap: wrap;
    margin-bottom: clamp(8px, 1.2vh, 14px);
}

.ss-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8em, 4vw, 2.8em);
    color: var(--wood);
    margin: 0;
    letter-spacing: 3px;
}

.ss-title-ad {
    font-size: 0.5em;
    color: var(--gold);
    letter-spacing: 4px;
    vertical-align: super;
}

.ss-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--ink-light);
    margin: 0;
    font-size: 0.95em;
    /* Pull the tagline up so it sits on the title's true baseline rather
       than the descender — visually anchors next to "1497 AD". */
    align-self: baseline;
    position: relative;
    top: -0.15em;
}

/* City hero image */
.ss-city-hero {
    position: relative;
    height: clamp(140px, 22vh, 240px);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: clamp(10px, 1.5vh, 16px);
    background-size: cover;
    background-position: center;
    background-color: var(--parchment-dark);
    transition: background-image 0.4s ease;
}

.ss-city-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.5) 100%);
}

.ss-city-hero-name {
    position: absolute;
    bottom: 12px;
    left: 16px;
    font-family: var(--font-heading);
    font-size: clamp(1.2em, 2.5vw, 1.8em);
    font-weight: 700;
    color: var(--parchment);
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
    letter-spacing: 1.5px;
}

/* City selector strip */
.ss-city-strip {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.ss-city-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px 6px;
    min-width: 80px;
    flex: 1 1 0;
    max-width: 110px;
    cursor: pointer;
    border: 1.5px solid var(--parchment-deep);
    border-radius: 6px;
    background: var(--parchment-dark);
    transition: all 0.15s ease;
    text-align: center;
}

.ss-city-tile:hover:not(.locked) {
    border-color: var(--gold);
    background: var(--parchment);
}

.ss-city-tile.selected {
    border-color: var(--gold);
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    box-shadow: 0 0 8px rgba(201,162,39,0.35);
}

.ss-city-tile.locked {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.ss-city-tile .ss-city-coa {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.ss-city-tile .ss-city-name {
    font-family: var(--font-heading);
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink);
    line-height: 1.2;
}

.ss-city-tile.selected .ss-city-name {
    color: var(--parchment);
}

/* Nationality panel */
.ss-nationality-panel {
    margin-top: 10px;
    padding: 12px 14px;
    background: rgba(139,105,20,0.08);
    border: 1px solid rgba(201,162,39,0.3);
    border-radius: 6px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.ss-nat-portrait {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold-dim);
    flex-shrink: 0;
    background: var(--parchment-dark);
}

.ss-nat-info {
    flex: 1;
    min-width: 0;
}

.ss-nat-header {
    font-family: var(--font-heading);
    font-size: 0.95em;
    color: var(--wood);
    margin-bottom: 2px;
}

.ss-nat-desc {
    font-size: 0.82em;
    color: var(--ink-light);
    margin-bottom: 6px;
    font-style: italic;
}

.ss-nat-bonuses {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: 0.8em;
}

.ss-nat-bonus { color: #2e7d32; }
.ss-nat-penalty { color: #8b2500; }

/* Continue / step action button */
.ss-step-actions {
    display: flex;
    justify-content: center;
    margin-top: clamp(12px, 1.5vh, 20px);
}

.ss-continue-btn {
    padding: 12px 48px;
    font-family: var(--font-heading);
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: 6px;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.ss-continue-btn:hover {
    background: linear-gradient(180deg, #a07850, var(--leather-light));
    box-shadow: 0 0 15px rgba(201,162,39,0.5);
}

/* Port summary (step 2 header) */
.ss-port-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: clamp(10px, 1.2vh, 16px);
    padding: 8px 12px;
    background: rgba(139,105,20,0.06);
    border: 1px solid rgba(201,162,39,0.2);
    border-radius: 6px;
}

.ss-port-summary img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.ss-port-summary-name {
    font-family: var(--font-heading);
    font-size: 0.9em;
    font-weight: 600;
    color: var(--wood);
}

.ss-port-summary-nat {
    font-size: 0.8em;
    color: var(--ink-light);
    font-style: italic;
}

.ss-port-back {
    margin-left: auto;
    font-family: var(--font-heading);
    font-size: 0.8em;
    color: var(--gold-dim);
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
}

.ss-port-back:hover { color: var(--gold); }

/* Sections */
.ss-section {
    margin-bottom: clamp(10px, 1.2vh, 16px);
}

.ss-section-label {
    font-family: var(--font-heading);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold-dim);
    margin-bottom: 8px;
}

/* Difficulty tier grid */
.ss-tier-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.ss-btn {
    padding: 8px 10px;
    font-family: var(--font-heading);
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid var(--gold-dim);
    background: var(--parchment-dark);
    color: var(--ink);
    transition: all 0.15s ease;
    text-align: center;
}

.ss-btn strong { display: block; font-size: 1.05em; }
.ss-btn-desc { display: block; font-size: 0.8em; font-weight: 400; color: var(--ink-light); margin-top: 2px; font-family: var(--font-body); }

.ss-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--parchment); }

.ss-btn.selected {
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(201,162,39,0.3);
}

.ss-btn.selected .ss-btn-desc { color: var(--parchment-dark); }

.ss-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

/* Nationality badge in-game */
#player-stats .nationality-badge {
    background: rgba(139,105,20,0.25);
    border-color: var(--gold-dim);
    color: var(--parchment);
    font-style: italic;
    cursor: help;
}

/* Nationality tooltip */
.nat-tooltip {
    display: none;
    position: fixed;
    width: clamp(260px, 25vw, 360px);
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 12px rgba(201,162,39,0.15);
    padding: 14px 16px;
    padding-top: 22px;
    z-index: var(--z-tooltip);
    font-style: normal;
    cursor: default;
}

.nat-tooltip.visible {
    display: block;
    animation: tooltip-in 0.15s ease;
}

@keyframes tooltip-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nat-tip-title {
    font-family: var(--font-heading);
    font-size: 1.05em;
    font-weight: 700;
    color: var(--wood);
    margin-bottom: 4px;
}

.nat-tip-desc {
    font-size: 0.88em;
    color: var(--ink-light);
    font-style: italic;
    margin-bottom: 8px;
}

.nat-tip-section {
    margin-bottom: 4px;
}

.nat-tip-bonus {
    font-size: 0.85em;
    color: #2e7d32;
    padding: 1px 0;
}

.nat-tip-penalty {
    font-size: 0.85em;
    color: #8b2500;
    padding: 1px 0;
    margin-bottom: 10px;
}

.nat-tip-teaser {
    font-size: 0.82em;
    color: var(--ink-light);
    font-style: italic;
    line-height: 1.5;
    border-top: 1px solid var(--parchment-deep);
    padding-top: 8px;
    margin-top: 8px;
    font-family: var(--font-body);
}

.nat-tip-hint {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--parchment-deep);
    font-size: 0.78em;
    color: var(--gold-dim);
    font-family: var(--font-heading);
    font-style: italic;
    text-align: center;
    letter-spacing: 0.3px;
}

/* Nationality modal */
.nat-modal-content {
    width: min(94vw, 620px);
    max-width: 620px;
    max-height: 80vh;
    overflow-y: auto;
}

.nat-modal-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.nat-modal-portrait {
    width: 160px;
    flex-shrink: 0;
    border-radius: 6px;
    object-fit: contain;
}

.nat-modal-content h3 {
    font-family: var(--font-heading);
    color: var(--wood);
    margin: 0 0 8px;
}

.nat-modal-desc {
    font-style: italic;
    color: var(--ink-light);
    margin: 0 0 12px;
    font-size: 0.95em;
}

.nat-modal-section-label {
    font-family: var(--font-heading);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold-dim);
    margin: 12px 0 4px;
}

.nat-modal-bonuses {
    margin-bottom: 4px;
}

.nat-modal-history,
.nat-modal-legacy {
    font-size: 0.9em;
    color: var(--ink);
    line-height: 1.6;
    margin: 4px 0 0;
    font-family: var(--font-body);
}

.nat-modal-content .action-btn {
    margin-top: 16px;
}

/* ===== Bank Deposit / Withdraw Modal ===== */
#bank-deposit-content,
#bank-withdraw-content {
    width: min(94vw, 620px);
    max-width: 620px;
    position: relative;
    text-align: left;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.bank-modal-left {
    flex: 0 0 auto;
    text-align: center;
}

.bank-modal-img {
    width: 180px;
    height: 180px;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    border: 2px solid var(--gold-dim);
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.bank-modal-img-caption {
    font-family: var(--font-body);
    font-size: 0.8em;
    color: var(--ink-light);
    margin-top: 8px;
    font-style: italic;
}

.bank-modal-right {
    flex: 1;
    min-width: 0;
}

.bank-modal-title {
    font-family: var(--font-heading);
    font-size: 1.2em;
    color: var(--wood);
    margin: 0 0 6px;
}

.bank-modal-rate {
    font-family: var(--font-body);
    font-size: 0.85em;
    color: var(--ink-light);
    margin: 0 0 16px;
    line-height: 1.5;
}

.bank-modal-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    width: 100%;
}

.bank-amount-input {
    flex: 1;
    min-width: 60px;
    padding: 7px 8px;
    font-size: 1em;
    font-family: var(--font-heading);
    background: var(--parchment-deep);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    color: var(--ink);
    text-align: right;
    scrollbar-width: none;        /* Firefox */
}
.bank-amount-input::-webkit-scrollbar {
    display: none;                /* Chrome / Safari / Edge */
}
.bank-amount-input::placeholder {
    font-family: var(--font-body); /* Cinzel metrics overflow; use body font for placeholder */
    font-size: 0.9em;
    opacity: 0.5;
}

.bank-amount-input:focus {
    outline: none;
    border-color: var(--gold);
}

.bank-modal-unit {
    font-family: var(--font-heading);
    font-size: 0.9em;
    color: var(--ink-muted);
}

.bank-modal-presets {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    width: 100%;
}

.bank-modal-presets .qty-shortcut {
    flex: 1;
}

.bank-modal-preview {
    font-family: var(--font-body);
    font-size: 0.88em;
    color: var(--gold);
    min-height: 1.4em;
    margin: 0 0 16px;
    font-style: italic;
}

.bank-modal-footer {
    flex: 0 0 100%;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--gold-dim);
    padding-top: 14px;
    margin-top: 4px;
}

.bank-modal-footer .action-btn {
    flex: 1;
}

.bank-withdraw-breakdown {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--ink);
    line-height: 2;
    margin: 0 0 16px;
}

.bank-withdraw-breakdown .breakdown-total {
    border-top: 1px solid var(--gold-dim);
    margin-top: 8px;
    padding-top: 8px;
    font-family: var(--font-heading);
    color: var(--gold);
    font-size: 1.1em;
    line-height: 1.4;
}

/* Modifier toggles */
.ss-modifier {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--parchment-deep);
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85em;
    transition: all 0.15s;
}
.ss-modifier:hover { background: rgba(201,162,39,0.08); }
.ss-modifier.active { border-color: var(--gold); background: rgba(201,162,39,0.1); }
.ss-modifier input[type="checkbox"] { accent-color: var(--gold); }
.ss-mod-name { font-weight: 600; font-family: var(--font-heading); font-size: 0.95em; }
.ss-mod-desc { color: var(--ink-light); font-size: 0.9em; }

.ss-empty { color: var(--ink-light); font-style: italic; font-size: 0.9em; margin: 6px 0; }

/* Action buttons */
.ss-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: clamp(12px, 1.5vh, 20px) 0;
    border-top: 1px solid var(--parchment-deep);
    margin-top: clamp(10px, 1.2vh, 16px);
}

.ss-sail-btn {
    padding: 14px 40px;
    font-family: var(--font-heading);
    font-size: 1.3em;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(180deg, var(--leather-light), var(--leather));
    color: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: 6px;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}
.ss-sail-btn:hover { background: linear-gradient(180deg, #a07850, var(--leather-light)); box-shadow: 0 0 15px rgba(201,162,39,0.5); }

.ss-daily-btn {
    padding: 10px 22px;
    font-family: var(--font-heading);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    background: var(--parchment-dark);
    color: var(--ink);
    border: 1px solid var(--gold-dim);
    border-radius: 5px;
    transition: all 0.15s;
}
.ss-daily-btn:hover { border-color: var(--gold); background: var(--parchment); }

.ss-actions-secondary {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-bottom: clamp(6px, 1vh, 12px);
}

.ss-daily-info { font-size: 0.88em; color: var(--ink-light); font-style: italic; }

/* Past voyages collapsible */
.ss-voyages-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 4px;
    font-family: var(--font-heading);
    font-size: 0.82em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold-dim);
    cursor: pointer;
    user-select: none;
}
.ss-voyages-toggle:hover { color: var(--gold); }

.ss-voyages-arrow {
    font-size: 0.7em;
    transition: transform 0.2s ease;
    display: inline-block;
}
.ss-voyages-arrow.open {
    transform: rotate(90deg);
}

.ss-voyages-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.ss-voyages-collapsible.open {
    max-height: 300px;
    overflow-y: auto;
}

/* Active-modifier count pill on the collapsed "Modifiers" toggle so the
   player sees at a glance whether anything's switched on without
   expanding the section. Matches the gold palette. */
.ss-modifiers-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--gold);
    color: var(--ink);
    font-size: 0.75em;
    font-weight: 700;
    border-radius: 10px;
    letter-spacing: 0;
    text-transform: none;
}
.ss-modifiers-badge[hidden] { display: none; }

/* History table */
.ss-history-table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin-top: 6px; }
.ss-history-table th { font-family: var(--font-heading); font-size: 0.88em; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--parchment-deep); color: var(--gold-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.ss-history-table td { padding: 5px 8px; border-bottom: 1px solid rgba(139,105,20,0.15); color: var(--ink); }

/* ===== Start Screen Decorations ===== */

/* Start-screen only — the compass is inside #start-screen which gets
   display:none once the game begins, so it never shows on the game UI.
   Top-right avoids the .ss-card body and the floating sound/feedback
   toggles at bottom-right. */
.ss-compass {
    position: absolute;
    top: 3%;
    right: 2.5%;
    width: clamp(80px, 10vw, 160px);
    height: clamp(80px, 10vw, 160px);
    z-index: 11;
    opacity: 0.6;
    pointer-events: none;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.ss-ship {
    position: absolute;
    bottom: 2%;
    left: 0;
    width: clamp(60px, 10vw, 140px);
    z-index: 11;
    opacity: 0.75;
    pointer-events: none;
    /* Horizontal crossing: slow, ~80s so the ship reads as gliding at
       sea, not zipping past. transform on the outer element. */
    animation: ss-sail 80s linear infinite;
}

.ss-ship img {
    width: 100%;
    /* No sepia — the silhouette is already monochrome. A slight
       brightness knock keeps it sitting inside the vignette instead of
       popping like a UI element. A drop-shadow anchors it to the sea. */
    filter: brightness(0.9) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    /* Vertical bob: swell suggestion, on the inner element so it
       composes with the parent's translateX cleanly (no transform
       conflict, both GPU-accelerated). */
    animation: ss-bob 3.2s ease-in-out infinite;
}

@keyframes ss-sail {
    0%   { transform: translateX(-15vw); }
    100% { transform: translateX(110vw); }
}

@keyframes ss-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}

/* Mobile responsive */
/* ===== Icon Integration ===== */

/* Coat of arms in city banner */
.city-banner-overlay .city-coa {
    width: 28px;
    height: 28px;
    vertical-align: middle;
    margin-right: 6px;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* Coat of arms in city modal title */
#city-modal-title .city-coa {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    margin-right: 8px;
    object-fit: contain;
}

/* Coat of arms in tavern rumors */
.tavern-coa {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 4px;
    object-fit: contain;
}

/* Coat of arms on start screen */
.ss-city-coa {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 4px;
    object-fit: contain;
}

/* Crew badge icons */
.crew-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 2px;
}

/* Achievement badge icons */
.ach-icon {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 4px;
}

.ach-icon-locked {
    opacity: 0.35;
    filter: grayscale(1);
}

/* ===== Toolbar Strips ===== */

/* Strip containers fill parent width */
#travel-buttons,
#other-actions,
#crew-actions,
#shipyard-actions,
#city-services {
    width: 100%;
}

/* Shared strip container */
.travel-strip,
.action-strip {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    background: var(--leather);
    border: 1.5px solid var(--gold-dim);
    border-radius: 0;
    overflow: hidden;
}

/* First strip in a group gets top corners */
.travel-strip:first-child,
.action-strip:first-child {
    border-radius: 4px 4px 0 0;
}

/* Last strip in a group gets bottom corners */
.travel-strip:last-child,
.action-strip:last-child {
    border-radius: 0 0 4px 4px;
}

/* Only strip gets full corners */
.travel-strip:only-child,
.action-strip:only-child {
    border-radius: 4px;
}

/* Merge adjacent strips (no double borders) */
.travel-strip + .travel-strip,
.action-strip + .action-strip {
    border-top: none;
}

/* Strip button base */
.strip-btn {
    border: none;
    border-radius: 0;
    border-right: 1px solid rgba(0,0,0,0.25);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    font-family: var(--font-heading);
    font-weight: 600;
    flex: 1;
    justify-content: center;
    white-space: nowrap;
    background: linear-gradient(180deg, var(--leather-light) 0%, var(--leather) 100%);
    color: var(--parchment);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -1px 0 rgba(0,0,0,0.15);
}

.strip-btn:last-child { border-right: none; }

.strip-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #a07850 0%, var(--leather-light) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), inset 0 -1px 0 rgba(0,0,0,0.15);
}

.strip-btn:active:not(:disabled) {
    background: linear-gradient(180deg, var(--leather) 0%, var(--leather-light) 100%);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

.strip-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.strip-btn.hired {
    background: linear-gradient(180deg, #5a7c4f, #3a5c32);
    cursor: default;
    border-right-color: rgba(0,0,0,0.3);
}

/* Travel strip specifics */
.travel-coa {
    width: 20px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
    object-fit: contain;
}

.weeks {
    font-size: 0.75em;
    color: var(--gold);
    margin-left: 2px;
    opacity: 0.8;
}

.strip-btn.travel-medium {
    border-left: 3px solid var(--warning);
}

.strip-btn.travel-long {
    background: linear-gradient(180deg, #7d4a3a, #5d3a2a);
    border-left: 3px solid var(--danger);
}

.strip-btn.last-trip {
    border-color: var(--warning);
    box-shadow: inset 0 0 6px rgba(184,134,11,0.3);
}
/* Visible "final voyage" flag inside the route button. Used to live
 * only in the hover tooltip, which kept keyboard/screen-reader users
 * in the dark about a decision-critical cue. Small caps + warning
 * color so it doesn't clash with the destination name and weeks. */
.last-trip-flag {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.65em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--warning);
}

/* Action strip specifics */
.strip-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.strip-cost {
    font-size: 0.8em;
    color: var(--gold);
    margin-left: 3px;
    opacity: 0.8;
}

/* ===== Ship's Log Modal ===== */

#log-modal-content {
    max-width: 600px;
    text-align: left;
}

#log-modal-messages {
    max-height: 70vh;
    overflow-y: auto;
    margin-bottom: 16px;
    font-family: var(--font-body);
    font-size: 0.95em;
    line-height: 1.5;
    color: var(--ink);
    padding-right: 8px;               /* gap between text and scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) transparent;
}
#log-modal-messages::-webkit-scrollbar { width: 6px; }
#log-modal-messages::-webkit-scrollbar-track { background: transparent; }
#log-modal-messages::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
#log-modal-messages::-webkit-scrollbar-thumb:hover { background: var(--gold); }

#log-modal-messages p {
    margin: 4px 0;
    padding: 2px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

#log-modal-close {
    display: block;
    margin: 0 auto;
}

/* Clickable log hint */
#message-log {
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}

#message-log:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,162,39,0.25) inset;
}

#message-log h4 .expand-hint {
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 18px;
    color: var(--gold);
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
}

#message-log:hover h4 .expand-hint {
    opacity: 1;
    transform: translate(2px, -2px);
}

/* Footer "View all N entries →" link. Hidden by default (no entries yet);
   addMessage/clearMessageLog toggle it via updateLogFooter() in ui.js.
   The parent panel already has cursor:pointer + click handler, so this
   element is purely a visual affordance — no separate click target. */
.log-footer-link {
    font-family: var(--font-heading);
    font-size: 0.78em;
    color: var(--gold);
    text-align: right;
    padding: 8px 4px 2px;
    margin-top: 6px;
    border-top: 1px solid rgba(139, 105, 20, 0.35);
    letter-spacing: 0.3px;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.log-footer-link[hidden] {
    display: none;
}

#message-log:hover .log-footer-link {
    opacity: 1;
    text-decoration: underline;
}

/* ===== Expand Hints ===== */

.expand-hint {
    font-size: 10px;
    color: var(--gold-dim);
    opacity: 0.4;
    transition: opacity 0.2s;
    cursor: pointer;
    margin-left: 4px;
}

.city-banner-overlay .expand-hint {
    position: absolute;
    top: 4px;
    right: 6px;
    color: var(--parchment);
    font-size: 14px;
}

*:hover > .expand-hint,
td:hover .expand-hint {
    opacity: 0.9;
}

/* ===== Responsive ===== */

/* ===== Welcome Modal ===== */

#welcome-modal {
    z-index: var(--z-modal);
}

.welcome-modal-content {
    /* Wider single-column layout. The previous 520px width forced a
       3-paragraph wall under a tall hero image which dropped the
       Begin button below the fold on a 1366×620 effective laptop
       viewport. Going to 720px lets the paragraphs breathe in fewer
       wrapped lines and keeps the whole modal under ~520px tall. */
    max-width: 720px;
    width: min(94vw, 720px);
    text-align: left;
}

.welcome-map {
    /* Now uses images/intro.jpg (16:9 merchant's-desk painting). The
       previous med_map_opt.jpg is already the start-screen background
       at 35% opacity, so the welcome modal had two views of the same
       map. Switching to the merchant's-desk image gives the welcome
       modal its own visual identity and is thematically tighter ("you
       are a merchant about to start"). */
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center 60%;
    border-radius: 5px;
    border: 1px solid var(--gold-dim);
    margin-bottom: 16px;
    filter: sepia(0.2) brightness(0.92);
}

.welcome-heading {
    font-family: var(--font-heading);
    font-size: 1.4em;
    color: var(--wood);
    text-align: center;
    margin: 0 0 14px;
    letter-spacing: 1px;
}

.welcome-body p {
    font-size: 0.95em;
    line-height: 1.65;
    margin: 0 0 10px;
    color: var(--ink);
}

.welcome-cta {
    font-style: italic;
    color: var(--ink-light);
}

.welcome-dismiss {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: var(--ink-light);
    cursor: pointer;
    margin: 14px 0 6px;
    justify-content: center;
}

.welcome-dismiss input[type="checkbox"] {
    accent-color: var(--gold);
}

.welcome-continue-btn {
    display: block;
    margin: 10px auto 0;
    padding: 10px 36px;
    font-size: 1.05em;
}

/* ===== RESPONSIVE: Mobile (max-width: 768px) ===== */

@media (max-width: 768px) {
    /* Game layout: stack columns vertically */
    #main-content { flex-direction: column; overflow-y: auto; }
    #left-column, #right-column { flex: none; overflow-y: visible; }
    #market-container { max-height: 50vh; }
    #message-log { min-height: 150px; max-height: 200px; }

    /* End game screen */
    .end-summary { flex-direction: column; align-items: center; gap: 16px; }
    .end-identity { flex: 0 0 auto; width: 100%; max-width: 360px; }
    .end-score-card { width: 100%; }

    /* City detail modal */
    #city-modal-content { max-height: 90vh; }
    #city-modal-img { max-height: 35vh; }
    #city-modal-right { padding: 16px 20px; }

    /* Start screen */
    .ss-card { max-width: 100%; padding: 14px 16px; }
    .ss-city-strip { gap: 4px; }
    .ss-city-tile { min-width: 60px; padding: 6px 4px 5px; }
    .ss-city-tile .ss-city-coa { width: 22px; height: 22px; }
    .ss-city-tile .ss-city-name { font-size: 0.65em; }
    .ss-city-hero { height: clamp(100px, 18vh, 160px); }
    .ss-nationality-panel { flex-direction: column; align-items: center; text-align: center; }
    .ss-nat-bonuses { justify-content: center; }
    .ss-tier-grid { grid-template-columns: repeat(2, 1fr); }
    .ss-compass { width: 80px; height: 80px; opacity: 0.35; }
    .ss-ship { width: 50px; opacity: 0.2; }
}

/* ===== Start Screen Footer ===== */
.ss-footer {
    text-align: center;
    padding: 18px 12px 8px;
    font-family: var(--font-body);
    font-size: 0.8em;
    color: var(--ink-light);
    opacity: 0.6;
    line-height: 1.6;
}
.ss-footer p { margin: 0; }
.ss-footer a,
.ss-footer a:visited {
    color: var(--gold-dim);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, color 0.2s;
}
.ss-footer a:hover {
    border-bottom-color: var(--gold);
    color: var(--gold);
}

/* ===== ACCESSIBILITY: Focus Indicators ===== */
/* Visible focus ring for keyboard navigation (gold theme) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.3);
}

/* Suppress outline for mouse clicks */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* ===== ACCESSIBILITY: Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
