:root {
  --color-primary: #000000;
  --color-secondary: #000000;
  --color-accent: #000000;
  --color-danger: #000000;
  --color-background: #ffffff;
  --color-background-light: #ffffff;
  --color-surface: #f8f8f8;
  --color-text: #000000;
  --color-text-important: #000000;
  --color-border: #000000;
  --color-digit-positive: #009900;
  --color-digit-negative: #990000;
  --color-digit-neutral: #000099;
}

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

html, body {
  font-family: monospace;
  background-color: var(--color-background);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
  touch-action: manipulation;
}

/* Inline image emoji — drop-in replacement for unicode emojis */
.emoji {
  height: 1.4em;
  width: 1.4em;
  vertical-align: -0.25em;
  display: inline-block;
  object-fit: contain;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-important);
  text-shadow: none;
  margin-bottom: 0.5rem;
  font-weight: normal;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; font-weight: 700; border-bottom: 1px solid var(--color-border); padding-bottom: 0.25rem; margin-top: 1rem; }
h3 { font-size: 1rem; }

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

button {
  cursor: pointer;
  font-family: monospace;
  background: white;
  border: 1px solid black;
  padding: 6px 12px;
  font-size: 0.9rem;
  color: black;
  transition: background-color 0.15s;
}
button:hover { background-color: #f0f0f0; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

input[type="number"] {
  width: 50px;
  padding: 5px;
  border: 1px solid var(--color-border);
  font-family: monospace;
  font-size: 0.9rem;
  background: var(--color-background);
}

ul { list-style-type: none; padding-left: 0; }
li { padding: 4px 0; border-bottom: 1px solid #eee; }

/* ── Layout ─────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  background-color: var(--color-background);
  display: grid;
  grid-template-columns: 65% 35%;
  gap: 1rem;
}

.left-column { padding-right: 1rem; }

.right-column {
  border-left: 1px solid var(--color-border);
  padding-left: 1rem;
}

/* ── Header ─────────────────────────────────────── */
.header {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.header-logo-wrap {
  text-align: center;
  margin-bottom: 0.3rem;
}

.header-logo {
  display: block;
  margin: 0 auto 0.15rem auto;
  height: 90px;
  width: auto;
  object-fit: contain;
}

.header-slogan {
  display: block;
  font-size: 0.72rem;
  color: #a08a5b;
  letter-spacing: 0.04em;
  font-family: monospace;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.user-info p { margin: 0; }
.user-info > div {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.3rem;
}

/* ── Unified topbar buttons ───────────────────── */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  font-family: monospace;
  line-height: 1;
  box-sizing: border-box;
  position: relative;
  color: inherit;
  text-decoration: none;
}
.topbar-btn:hover { background-color: #f0f0f0; }
.topbar-btn-icon { font-size: 1.1rem; padding: 0.35rem 0.5rem; }

.logout-btn {
  background-color: white;
  color: black;
  border-color: black;
}
.logout-btn:hover { background-color: #f0f0f0; }

/* ── Sticky Top Bar (Resources + Kingdom Stats) ─── */
.sticky-top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.sticky-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  font-size: 0.95rem;
  font-weight: bold;
}

.sticky-row + .sticky-row {
  border-top: 1px solid var(--color-border);
}

.sticky-top-bar #gold {
  color: var(--color-digit-positive);
}

/* ── Tabs ───────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  margin-right: 2px;
  font-family: monospace;
  background: none;
}

.tab .emoji {
  height: 1.6em;
  width: 1.6em;
}

.tab:hover { text-decoration: underline; }

.tab.active {
  border: 1px solid var(--color-border);
  border-bottom: 1px solid white;
  margin-bottom: -1px;
  font-weight: bold;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Army ───────────────────────────────────────── */
.army { margin-bottom: 1rem; }

.army ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.army li {
  border: 1px solid var(--color-border);
  padding: 4px 10px;
  flex: 1 0 auto;
  min-width: 140px;
  position: relative;
}
.army li.has-arsenal-tip {
  cursor: pointer;
}
.army li.has-arsenal-tip:hover {
  border-color: var(--color-digit-positive);
}

/* ── Army detail link (hidden — data holder for mobile dialog) ── */
.army-detail-link {
  display: none;
}

/* Make army unit rows with equipment clickable */
li.has-arsenal-tip {
  cursor: pointer;
}

/* ── Unit Rows / Build ──────────────────────────── */
.unit-row {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.unit-row h3 {
  margin-top: 0;
  margin-bottom: 2px;
  font-size: 0.95rem;
}

.unit-row p {
  margin: 2px 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ── Merc auto-recruit countdown bar ──── */
.merc-recruit-bar {
  position: relative;
  width: 100%;
  height: 22px;
  background-color: #eee;
  border: 1px solid var(--color-border);
  overflow: hidden;
  margin-top: 4px;
}
.merc-recruit-fill {
  height: 100%;
  width: 0%;
  background-color: #b8860b;
  transition: width 1s linear;
}
.merc-recruit-text {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  color: #333;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Public Missives / Bulletin Board ─── */
.public-missive-item {
  border: 1px solid #d4a017;
  border-left: 3px solid #d4a017;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #fffbf0;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.public-missive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: #333;
}
.public-missive-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 0.4rem;
  color: #111;
  flex: 1;
}
/* ── Bulletin Board: cover overlay on hover ────── */
.public-missive-cover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s;
  cursor: pointer;
  z-index: 2;
}
/* Desktop: show overlay on hover */
@media (hover: hover) and (pointer: fine) {
  .public-missive-item:hover .public-missive-cover-overlay {
    opacity: 1;
  }
}
/* Mobile: hide overlay entirely, tap opens dialog directly */
@media (max-width: 600px) {
  .public-missive-cover-overlay {
    display: none !important;
  }
}

/* Compose missive modal: center vertically */
#public-missive-compose-modal.show {
  align-items: center;
}
.public-missive-cover-btn {
  background: white;
  color: black;
  border: 1px solid black;
  border-radius: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.public-missive-cover-btn:hover {
  background: #f0f0f0;
}

/* ── Bulletin Board: scroll view ──── */
#bulletin-board-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Bulletin board modal sizing */
#bulletin-board-modal .modal-content {
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ── Bulletin Board: empty placeholder slots ────── */
.public-missive-placeholder {
  border: 2px dashed #ccc;
  border-radius: 4px;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.public-missive-placeholder:hover {
  border-color: #d4a017;
  background: #fffbf0;
}
.public-missive-placeholder .placeholder-icon {
  font-size: 1.4rem;
  opacity: 0.5;
}
.public-missive-placeholder .placeholder-label {
  font-size: 0.8rem;
  color: #999;
  font-family: monospace;
}
.public-missive-placeholder:hover .placeholder-icon {
  opacity: 0.8;
}
.public-missive-placeholder:hover .placeholder-label {
  color: #b8860b;
}

/* Dark mode placeholders */
[data-theme="dark"] .public-missive-placeholder {
  border-color: #444;
}
[data-theme="dark"] .public-missive-placeholder:hover {
  border-color: #b8860b;
  background: #2a2410;
}
[data-theme="dark"] .public-missive-placeholder .placeholder-label {
  color: #666;
}
[data-theme="dark"] .public-missive-placeholder:hover .placeholder-label {
  color: #d4a017;
}

.build-form {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  position: relative;
  z-index: 2;
}
.build-form button {
  position: relative;
  z-index: 2;
  touch-action: manipulation;
  min-height: 36px;
}
.build-form button:active { transform: scale(0.97); }

/* ── Civ Missives Desktop Button ────────────────── */
.civ-missives-desktop-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  transition: background 0.15s, border-color 0.15s;
}
.civ-missives-desktop-btn:hover {
  background: var(--color-background);
  border-color: var(--color-accent);
}
.civ-missives-desktop-btn.has-unread {
  border-color: #cc0000;
}
.civ-missives-unread {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  background: #cc0000;
  color: #fff;
  border-radius: 11px;
  font-size: 0.75rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
/* Mobile: hide desktop button, show mobile topbar icon */
.civ-missives-mobile-only { display: none; }
@media (max-width: 768px) {
  .civ-missives-desktop-btn { display: none !important; }
  .civ-missives-mobile-only.civ-visible { display: inline-flex; }
}
@media (min-width: 769px) {
  .civ-missives-mobile-only { display: none !important; }
}

/* ── Grand Projects Button ────────────────────────── */
.grand-project-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--color-text);
  transition: background 0.15s, border-color 0.15s;
}
.grand-project-btn:hover {
  background: var(--color-background);
  border-color: var(--color-accent);
}
.gp-btn-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.gp-gauge-bar {
  height: 10px;
  background: #e8e0d0;
  border: 1px solid #b8a88a;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .gp-gauge-bar {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.gp-gauge-fill {
  height: 100%;
  background: #d4a017;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.gp-gauge-label {
  font-size: 0.8rem;
  color: #666;
  text-align: right;
}
[data-theme="dark"] .gp-gauge-label {
  color: #aaa;
}
.grand-project-btn.gp-completed {
  border-color: #2a7a2a;
  background: rgba(42, 122, 42, 0.08);
}
.grand-project-btn.gp-all-done {
  border-color: #d4a017;
  background: rgba(212, 160, 23, 0.08);
}
.bug-report-btn {
  border-color: #8b4513;
  background: rgba(139, 69, 19, 0.06);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  min-height: auto;
}
.bug-report-btn:hover {
  background: rgba(139, 69, 19, 0.15);
  border-color: #a0522d;
}
[data-theme="dark"] .bug-report-btn {
  border-color: #6b3410;
  background: rgba(139, 69, 19, 0.12);
}
[data-theme="dark"] .bug-report-btn:hover {
  background: rgba(139, 69, 19, 0.25);
}
.bug-report-mobile-btn { display: none; }
@media (max-width: 768px) {
  .grand-project-btn { display: none !important; }
  .bug-report-mobile-btn { display: inline-flex !important; }
}

/* ── Mobile Gauge Buttons (topbar) ────────────────── */
.mobile-gauge-btn {
  display: none; /* hidden by default, shown by JS on mobile */
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-top: 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--color-text);
  transition: border-color 0.2s;
}
.mobile-gauge-btn:hover { border-color: #888; }
.mobile-gauge-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.8rem;
}
.mobile-gauge-bar {
  height: 10px;
  background: #e8e0d0;
  border: 1px solid #b8a88a;
  border-radius: 5px;
  overflow: hidden;
}
.mobile-gauge-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}
.mobile-gauge-fill.ship-gauge-fill { background: #d4a017; }
.mobile-gauge-fill.gp-gauge-fill-m { background: #d4a017; }
.mobile-gauge-fill.exp-gauge-fill { background: #2196f3; }
.mobile-gauge-fill.exp-done { background: #4caf50; }
.mobile-gauge-label {
  font-size: 0.7rem;
  color: var(--color-text-secondary, #888);
  text-align: right;
}
[data-theme="dark"] .mobile-gauge-bar { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); }
/* Desktop: always hide mobile gauges */
@media (min-width: 769px) {
  .mobile-gauge-btn { display: none !important; }
}

/* ── Grand Projects Modal ─────────────────────────── */
.gp-tier-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--color-surface);
}
.gp-tier-gauge {
  height: 18px;
  background: #e8e0d0;
  border: 1px solid #b8a88a;
  border-radius: 9px;
  overflow: hidden;
  margin: 0.75rem 0 0.5rem;
}
[data-theme="dark"] .gp-tier-gauge {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.gp-tier-gauge-fill {
  height: 100%;
  background: #d4a017;
  border-radius: 8px;
  transition: width 0.4s ease;
}
.gp-tier-gauge-fill.gp-done {
  background: #d4a017;
}
.gp-quick-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
.gp-quick-btn:hover { background: var(--color-background); border-color: var(--color-accent); }
.gp-leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
}
.gp-non-contributors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.gp-non-contributor-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #888;
  font-size: 0.8rem;
}
.gp-completed-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(42, 122, 42, 0.15);
  border: 1px solid #2a7a2a;
  color: #4caf50;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
.gp-bonus-hidden {
  color: #888;
  font-style: italic;
}

/* ── Build Queue ────────────────────────────────── */
.build-queue {
  height: 100%;
  position: sticky;
  top: 1rem;
}

.build-queue h2 {
  margin-top: 0;
  padding-top: 0.5rem;
  position: sticky;
  top: 0;
  background-color: var(--color-background);
  z-index: 10;
}

.queue-clear-btn {
  cursor: pointer;
  font-size: 0.85em;
  opacity: 0.5;
  transition: opacity 0.2s;
  vertical-align: middle;
  background: none;
  border: none;
  padding: 0 0.25rem;
  margin: 0;
  color: inherit;
  font-family: inherit;
  line-height: 1;
}
.queue-clear-btn:hover {
  opacity: 1;
}

#queue-container {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

#queue-container ul { margin-top: 0; }

#queue-container ul li {
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.countdown {
  font-weight: bold;
  color: var(--color-digit-negative);
}

/* ── War Actions ────────────────────────────────── */
.war-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
}
.war-intel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}
.war-spy-info {
  font-size: 0.78rem;
  color: #555;
  font-family: monospace;
  flex: 1 1 auto;
  min-width: 0;
}
.war-reserve-info {
  font-size: 0.82rem;
  flex: 1 1 200px;
  min-width: 180px;
}

.defense-simulation-btn {
  min-width: 180px;
  height: 40px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  font-size: 0.95rem;
  font-weight: bold;
  font-family: monospace;
  background-color: #111;
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.defense-simulation-btn:hover { background-color: #333; }
.defense-simulation-btn:disabled { opacity: 0.4; cursor: default; }

.defense-simulation-btn .timer {
  display: inline-block;
  margin-left: 5px;
  font-weight: bold;
  color: var(--color-digit-negative);
}

/* ── Castle ─────────────────────────────────────── */
.castle { padding: 0; }

.castle-info {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.castle-info h3 { margin-top: 0; }
.castle-info #castle-level { font-weight: bold; }
.castle-info #defense-bonus { font-weight: bold; color: var(--color-digit-positive); }

.castle-upgrade { margin-top: 1rem; }

.castle-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.castle-table th, .castle-table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

.castle-table th {
  font-weight: bold;
  background-color: #f0f0f0;
}

.castle-table tr:hover { background-color: #fafafa; }

.upgrade-castle-btn {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 12px;
  cursor: pointer;
  font-family: monospace;
  position: relative;
  z-index: 2;
  min-width: 80px;
  touch-action: manipulation;
}
.upgrade-castle-btn:hover { background-color: #e0e0e0; }
.upgrade-castle-btn:active { background-color: #d0d0d0; transform: scale(0.97); }
.upgrade-castle-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Village / Serfs ────────────────────────────── */
.village-info {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  margin-bottom: 1rem;
}
/* Flat variant for Village tab — no box, just spacing */
.village-info--flat {
  border: none;
  padding: 0;
  margin-bottom: 1.5rem;
}

.village-info h3 { margin-top: 0; }
.village-info h2 { margin-top: 0; }

.serf-section {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  border-left: 3px solid black;
  margin-bottom: 1rem;
}
/* Flat variant for Village tab — no box, just spacing */
.serf-section--flat {
  border: none;
  border-left: none;
  padding: 0;
  margin-bottom: 1.5rem;
}

.serf-section h3 { margin-top: 0; }
.serf-section h2 { margin-top: 0; }

/* Village tab section spacing */
#tab-village #vassal-village-section { margin-bottom: 1.5rem; }
#tab-village #pack-leader-section { margin-bottom: 1.5rem; }
#tab-village #camel-enclosure-section { margin-bottom: 1.5rem; }
#tab-village #festival-village-section { margin-bottom: 1.5rem; width: 100%; }
#tab-village #festival-content { margin-top: 0.5rem; }
#tab-village #workshop-guild-section { margin-bottom: 1.5rem; }
#tab-village #garden-section { margin-bottom: 1.5rem; }

/* Village tab — inputs match button height */
#tab-village .build-form input[type="number"] {
  min-height: 36px;
  height: 36px;
  box-sizing: border-box;
}

#serf-build-btn {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 12px;
  cursor: pointer;
  font-family: monospace;
}
#serf-build-btn:hover { background-color: #f0f0f0; }
#serf-build-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.income-info { margin-top: 1rem; }
.income-info h3 { margin-top: 0; }

.income-progress { margin-top: 0.5rem; }

.progress-bar {
  width: 100%;
  height: 10px;
  background-color: #f0f0f0;
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.progress {
  width: 0%;
  height: 100%;
  background-color: black;
  transition: width 1s;
}

/* ── Mana Gauge Section ───────────────────────── */
.mana-gauge-section {
  background: var(--color-surface, #ffffff);
  border: 1px solid #000;
  border-radius: 0;
  padding: 1.25rem;
  margin-top: 1.5rem;
}
[data-theme="dark"] .mana-gauge-section {
  background: #1a1a2e;
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
.mana-gauge-section h3 {
  margin: 0 0 0.5rem 0;
}
.mana-lore {
  font-size: 0.85rem;
  color: var(--color-muted, #999);
  font-style: italic;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}
.mana-gauge-container {
  margin-bottom: 1rem;
}
.mana-gauge-bar {
  width: 100%;
  height: 18px;
  background: var(--color-background, #111);
  border: 1px solid var(--color-border);
  border-radius: 9px;
  overflow: hidden;
}
.mana-gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  border-radius: 9px;
  transition: width 1s ease, background 0.5s ease;
}
.mana-gauge-text {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 0.35rem;
  color: var(--color-muted, #999);
}
.mana-thresholds {
  display: flex;
  gap: 0.5rem;
}
.mana-thresh {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  opacity: 0.4;
  transition: opacity 0.3s, border-color 0.3s;
  font-size: 0.85rem;
}
.mana-thresh-active {
  opacity: 1;
  border-color: #7c3aed;
}

/* ── World Tab / Kingdoms ───────────────────────── */
.world-kingdoms { margin-top: 0.5rem; }

#kingdoms-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

#kingdoms-table th, #kingdoms-table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

#kingdoms-table th {
  font-weight: bold;
  background-color: #f0f0f0;
}

#kingdoms-table tr:hover { background-color: #fafafa; }

.world-gold-cell {
  font-weight: bold;
  color: var(--color-digit-positive);
  white-space: nowrap;
}

.PVP-attack-btn {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 10px;
  cursor: pointer;
  font-family: monospace;
  position: relative;
  min-width: 80px;
}
.PVP-attack-btn:hover { background-color: #f0f0f0; }
.PVP-attack-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.PVP-attack-btn.shielded { background-color: #e8f4f8; color: #2a6496; border-color: #2a6496; font-size: 0.8em; }
[data-theme="dark"] .PVP-attack-btn.shielded { background-color: #1a2a3a; color: #6ab0d6; border-color: #4a7a9a; }

.missive-send-btn-small {
  background: #f5d060;
  color: #3a2600;
  border: 1px solid #b8860b;
  padding: 6px 10px;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.85rem;
  border-radius: 4px;
  min-width: 80px;
}
.missive-send-btn-small:hover { background: #ffe066; }

.slave-market-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: bold;
  font-family: monospace;
  cursor: pointer;
  border: 2px solid #b8860b;
  border-radius: 6px;
  background: #f5d060;
  color: #3a2600;
}
.slave-market-btn:hover { background: #ffe066; }
.slave-market-btn:active { transform: scale(0.97); }

.merc-recruiter-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}
.merc-recruiter-toggle .toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.9rem;
  color: #b8860b;
  font-weight: bold;
}
.merc-recruiter-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #b8860b;
  cursor: pointer;
}

.countdown-number {
  font-weight: bold;
  color: var(--color-digit-negative);
}

/* ── Modals ─────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
  overflow-y: auto;
}

.modal-content, .war-reports-content {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  margin: auto;
}

.war-reports-content {
  max-width: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#war-reports-footer {
  flex-shrink: 0;
}

.close-modal {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 0.25rem 0.5rem;
  z-index: 10;
}
.close-modal:hover { text-decoration: underline; }

/* ── Chest modal layout ── */
#chest-modal.modal.show {
  overflow-y: auto;
}
#chest-modal .modal-content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;          /* kill inner scroll on the wrapper */
}
.chest-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;          /* single scroll lives here */
}
.chest-footer-sticky {
  border-top: 1px solid var(--color-border, #444);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: center;
  margin-top: 0;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  /* Make chest-modal fill the screen properly */
  #chest-modal.modal.show {
    padding: 0;
    padding-top: calc(env(safe-area-inset-top, 0px) + 2.2rem);
    align-items: stretch;
  }
  #chest-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    padding-bottom: 0 !important; /* override generic 7rem padding */
    overflow: hidden;
    border-radius: 0;
  }
  .chest-modal-body {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }
  .chest-footer-sticky {
    background: var(--color-background, #1a1a2e);
    z-index: 20;
    margin-top: 0;
    padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.modal-header h3 { margin: 0; }

.modal-body {
  padding: 1rem 0;
}

.modal-footer {
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
  text-align: right;
}

/* ── Sound settings toggle switches ─────────────── */
.sound-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sound-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-background);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sound-option:active {
  background: rgba(128,128,128,0.1);
}

.sound-option-label {
  font-size: 1rem;
  font-weight: 500;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #666;
  border-radius: 28px;
  transition: background 0.25s;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #4ade80;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Sound settings panel sizing */
.sound-settings-panel {
  max-width: 400px;
}
.sound-settings-panel .modal-body {
  padding: 0.75rem 0;
}
.sound-settings-panel .modal-footer {
  display: flex;
  justify-content: center;
}
.sound-settings-panel .modal-close-btn {
  width: 100%;
}

/* Unified close button style for all modals */
.modal-close-btn {
  display: block;
  padding: 0.55rem 2rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  background: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-align: center;
}

#sound-settings-modal.show {
  align-items: center;
}

[data-theme="dark"] .sound-option {
  background: #1a1a1a;
}

[data-theme="dark"] .toggle-slider {
  background: #444;
}

.btn-danger {
  background-color: white;
  color: black;
  border: 1px solid black;
}
.btn-danger:hover { background-color: #f0f0f0; }

/* ── Rankings ──────────────────────────────────── */
.rankings-content {
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 95%;
  max-width: 700px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  margin: auto;
}

.rankings-content > h2 {
  flex-shrink: 0;
  margin: 0 0 0.25rem 0;
}

.rankings-content .rankings-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.rankings-content .ranking-pagination,
.rankings-content .modal-nav-footer {
  flex-shrink: 0;
}

.ranking-filters {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  margin: 1rem 0;
}

.ranking-filter {
  padding: 0.4rem 1rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.85rem;
  border-radius: 3px;
}

.ranking-filter.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  font-weight: bold;
}

.ranking-filter:hover:not(.active) {
  background: rgba(0, 0, 0, 0.08);
}

.ranking-civ-filters {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.ranking-civ-filters .ranking-filter {
  padding: 0.3rem 0.6rem;
  font-size: 0.9rem;
  min-width: 2.2rem;
  text-align: center;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ranking-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--color-border);
  font-size: 0.8rem;
  color: #999;
  white-space: nowrap;
}

.ranking-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ranking-table tr:hover {
  background: rgba(255,255,255,0.03);
}

.ranking-table tr.ranking-me {
  background: rgba(232, 165, 0, 0.1);
}

.ranking-table tr.ranking-me td {
  color: #e8a500;
}

.ranking-missive-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
  line-height: 1;
}
.ranking-missive-btn:hover {
  background: rgba(201, 162, 39, 0.25);
}

.ranking-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.ranking-pagination button {
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.85rem;
}

.ranking-pagination button:disabled {
  opacity: 0.3;
  cursor: default;
}

.ranking-pagination span {
  font-size: 0.85rem;
  color: #999;
}

/* ── Modal Nav Footer (shared War Reports + Rankings) ── */
.modal-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.nav-footer-btn {
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  border-radius: 4px;
  min-width: 70px;
  text-align: center;
}

.nav-footer-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.nav-footer-close {
  background: var(--color-background);
  color: var(--color-text);
  font-weight: bold;
  padding: 0.55rem 1.2rem;
  font-size: 0.95rem;
}

.nav-footer-prev,
.nav-footer-next {
  white-space: nowrap;
}

/* ── War Results ────────────────────────────────── */
.war-outcome {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.victory-title {
  color: var(--color-digit-positive);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.defeat-title {
  color: var(--color-digit-negative);
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

/* ── Claim Loot Banner ──────────────────────────── */
.claim-loot-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid black;
  padding: 1rem;
  margin: 0 auto 1rem auto;
  max-width: 250px;
  text-align: center;
}

.gold-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.loot-amount {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.75rem;
  color: var(--color-digit-positive);
}

.claim-button {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 16px;
  font-weight: bold;
  cursor: pointer;
  font-family: monospace;
}
.claim-button:hover { background-color: #f0f0f0; }
.claim-button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Gold Close / Claim Button (bottom of battle modals) ── */
.gold-close-btn {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: 14px 24px;
  font-size: 1.1rem;
  font-weight: bold;
  font-family: monospace;
  cursor: pointer;
  border: 2px solid #b8860b;
  border-radius: 6px;
  background: #f5d060;
  color: #3a2600;
  text-shadow: none;
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}
.gold-close-btn:hover {
  background: #ffe066;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.gold-close-btn:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Secrets Book ──────────────────────────────── */
.secrets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.secret-card {
  text-align: center;
  padding: 0.7rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.secret-emoji { font-size: 1.8rem; }
.secret-name { font-size: 0.75rem; font-weight: bold; line-height: 1.2; }
.secret-locked {
  background: var(--color-background);
  border-color: var(--color-border);
  color: var(--color-text);
  opacity: 0.4;
}
.secret-locked .secret-emoji { filter: grayscale(1); }
.secret-unlocked {
  background: var(--color-background);
  border-color: #b8860b;
  color: var(--color-text);
}
.secret-unlocked .secret-name { color: #b8860b; }
.secret-hint { font-size: 0.65rem; color: var(--color-text); opacity: 0.7; margin-top: 2px; line-height: 1.2; font-style: italic; }
.secrets-counter {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text);
  opacity: 0.6;
  margin-top: 0.5rem;
}

/* ── Secrets Badge ────────────────────────────── */
/* ── Unified topbar badge ───────────────────── */
.topbar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: #cc0000;
  color: #fff;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 0.6rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}
.topbar-badge.dot-only {
  min-width: 10px;
  width: 10px;
  height: 10px;
  font-size: 0;
}

/* ── Achievements ─────────────────────────────── */
.achievements-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.achievement-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-align: left;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  font-size: 0.78rem;
}
.achievement-icon { font-size: 1.2rem; flex-shrink: 0; }
.achievement-label { flex: 1; line-height: 1.3; }
.achievement-check { flex-shrink: 0; font-size: 0.85rem; }
.achievement-pending {
  background: var(--color-background);
  border-color: var(--color-border);
  color: var(--color-text);
  opacity: 0.4;
}
.achievement-done {
  background: var(--color-background);
  border-color: #b8860b;
  color: var(--color-text);
}

/* ── Battle Details ─────────────────────────────── */
.battle-details-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0 auto;
  max-width: 100%;
}

.battle-comparison, .casualties-section {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.battle-comparison h3, .casualties-section h3 {
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.25rem;
}

.battle-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.battle-stat {
  border: 1px solid #eee;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 2px;
}

.stat-value {
  font-weight: bold;
  font-size: 1.1rem;
}

.battle-tip {
  margin-top: 0.75rem;
  padding: 0.5rem;
  border: 1px solid #eee;
  font-style: italic;
  font-size: 0.85rem;
  color: #555;
}

.casualties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.casualty-item {
  display: flex;
  justify-content: space-between;
  border: 1px solid #eee;
  padding: 4px 6px;
  font-size: 0.85rem;
}

.unit-name { color: var(--color-text); }
.casualty-count { color: var(--color-digit-negative); font-weight: bold; }

/* ── Defense Alert ──────────────────────────────── */
.defense-alert {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  background-color: var(--color-background);
  color: var(--color-text);
  padding: 1rem;
  border: 2px solid black;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  z-index: 1000;
  max-width: 350px;
  text-align: left;
  animation: slide-in-bottom 0.3s ease-out;
}

.defense-alert-header {
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  width: 100%;
}

.defense-alert-content {
  margin-bottom: 0.5rem;
  width: 100%;
}

.defense-alert-buttons {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.defense-alert button {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: bold;
  font-family: monospace;
}
.defense-alert button:hover { background-color: #f0f0f0; }

.defend-btn { animation: none; }

.give-gold-btn {
  background-color: white !important;
  color: black !important;
  border: 1px solid black !important;
}
.give-gold-btn:hover { background-color: #f0f0f0 !important; }

/* ── War Reports ────────────────────────────────── */
.war-reports-table-container {
  max-height: none;
  overflow-y: auto;
  margin-bottom: 0;
  flex: 1;
  min-height: 0;
}

.war-reports-table {
  width: 100%;
  border-collapse: collapse;
}

.war-reports-table th, .war-reports-table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid var(--color-border);
}

.war-reports-table th {
  background-color: #f0f0f0;
  position: sticky;
  top: 0;
  font-weight: bold;
}

.war-reports-table tr:hover { background-color: #fafafa; }

.victory-row { color: var(--color-digit-positive); }
.defeat-row { color: var(--color-digit-negative); }

.war-report-detail {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  margin-top: 1rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.back-button-sticky {
  position: sticky;
  bottom: 0;
  background: var(--color-background);
  padding: 0.5rem 0;
  text-align: center;
  z-index: 2;
}
.back-button {
  padding: 6px 12px;
  background-color: white;
  color: black;
  border: 1px solid black;
  cursor: pointer;
  font-family: monospace;
}
.back-button:hover { background-color: #f0f0f0; }

/* ── War reports pagination ── */
.war-reports-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
}
.war-reports-pagination .pagination-btn {
  background: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: monospace;
  min-width: 36px;
  min-height: 36px;
}
.war-reports-pagination .pagination-btn:hover:not(:disabled) { background: #f0f0f0; }
.war-reports-pagination .pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.war-reports-pagination .pagination-info {
  font-size: 0.85rem;
  color: var(--color-text);
  font-family: monospace;
}
[data-theme="dark"] .war-reports-pagination .pagination-btn { background: #222; border-color: #555; color: #fff; }
[data-theme="dark"] .war-reports-pagination .pagination-btn:hover:not(:disabled) { background: #333; }

.action-button {
  padding: 4px 8px;
  margin: 0 4px;
  border: 1px solid black;
  background: white;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: monospace;
}

.detail-button { background-color: white; color: black; }
.detail-button:hover { background-color: #f0f0f0; }
.detail-button.detail-unread { background-color: #fff3cd; color: #856404; font-weight: bold; border-color: #ffc107; }
.detail-button.detail-unread:hover { background-color: #ffe69c; }
tr.report-unread td:first-child { font-weight: bold; }
[data-theme="dark"] .detail-button.detail-unread { background-color: #4a3f00; color: #ffc107; border-color: #8a7500; }
[data-theme="dark"] .detail-button.detail-unread:hover { background-color: #5a4d00; }

/* ── War Reports Button ─────────────────────────── */
#war-reports-button {
  position: relative;
  background-color: white;
  color: black;
  border: 1px solid black;
  font-family: monospace;
}

#war-reports-button.has-unclaimed {
  font-weight: bold;
}

/* .unclaimed-badge → replaced by .topbar-badge */

/* ── Notifications ──────────────────────────────── */
.notification-area {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.notification {
  background-color: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  max-width: 300px;
  font-family: monospace;
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.3s, transform 0.3s;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

/* ── Footer Controls ────────────────────────────── */
.actions {
  grid-column: 1 / -1;
  margin-top: 1rem;
  text-align: center;
}

.game-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 360px;
  margin: 0 auto;
}
@media (min-width: 769px) {
  .game-controls { position: relative; z-index: 10; }
  .build-queue  { z-index: 2; }
}

.game-controls button {
  background-color: white;
  color: black;
  border: 1px solid black;
  padding: 6px 10px;
  cursor: pointer;
  font-family: monospace;
  white-space: nowrap;
  font-size: 0.82rem;
  text-align: center;
  border-radius: 3px;
}
.game-controls button:hover { background-color: #f0f0f0; }

#coffee-btn {
  background: transparent;
  border-color: #c9a227;
  color: #c9a227;
  grid-column: 1;
  grid-row: 2;
}
#coffee-btn:hover { background: rgba(201,162,39,0.1); }

/* Row 2: café, logout, admin — 3 columns */
#footer-logout-btn {
  display: none;
  grid-column: 2;
  grid-row: 2;
}
#footer-admin-btn {
  grid-column: 3;
  grid-row: 2;
}

/* On ≤900px: show logout + switch to 3-col for row 2 */
@media (max-width: 900px) {
  .game-controls {
    grid-template-columns: 1fr 1fr auto;
  }
  /* Row 1: provoke spans 2 cols, desktop spans 1 */
  #provoke-btn   { grid-column: 1 / 3; grid-row: 1; }
  #view-mode-toggle { grid-column: 3; grid-row: 1; }
  #footer-logout-btn { display: inline-block; }
}

@media (min-width: 901px) {
  .game-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    max-width: none;
  }
}


/* ── Missives ───────────────────────────────────── */
/* .missives-badge → replaced by .topbar-badge */

.missives-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 2rem;
}
.missives-header-row h2 { margin: 0; }
.missives-toggle-btn {
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: monospace;
  border-radius: 3px;
}
.missives-toggle-btn:hover { background: #f0f0f0; }

.missive-item {
  border: 1px solid var(--color-border);
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.missive-item.missive-sent {
  border-left: 3px solid #2196f3;
  opacity: 0.9;
}

.missive-item.missive-unread {
  border-left: 3px solid #cc0000;
  background: #fefdf5;
}

.missive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.missive-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.missive-reply-btn {
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: monospace;
}
.missive-reply-btn:hover { background: #f0f0f0; }

.missive-gold {
  margin: 0.3rem 0;
  padding: 0.3rem 0.5rem;
  background: #fef9e7;
  border: 1px solid #d4a017;
  border-radius: 3px;
  font-size: 0.8rem;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.missive-claim-btn {
  background: #f5e6a3;
  border: 1px solid #d4a017;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: monospace;
  border-radius: 3px;
}
.missive-claim-btn:hover { background: #ecd96f; }
.missive-claim-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.missive-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-family: monospace;
}
.missive-pagination button {
  background: white;
  color: black;
  border: 1px solid black;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.missive-pagination button:hover { background: #f0f0f0; }
.missive-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.missive-send-icon {
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.6;
}
.missive-send-icon:hover { opacity: 1; }

/* ── Emoji Reactions ────────────────────────────── */
/* Message row needs relative for the hover overlay */
.civ-missive-row { position: relative; }

/* Hover overlay: "Réagir" bar with 5 emojis — only on messages with NO reactions */
.msg-react-hover {
  display: none;
  position: absolute;
  top: 0.2rem;
  right: 0.3rem;
  background: var(--color-background, #1a1a2e);
  border: 1px solid var(--color-border, #444);
  border-radius: 0.5rem;
  padding: 0.15rem 0.3rem;
  gap: 0.1rem;
  align-items: center;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.civ-missive-row:hover > .msg-react-hover,
.civ-missive-row:focus-within > .msg-react-hover,
.civ-missive-row.touch-active > .msg-react-hover { display: inline-flex; }
.msg-react-hover span {
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 0.25rem;
  transition: background 0.12s;
  user-select: none;
}
.msg-react-hover span:hover { background: rgba(255,255,255,0.1); }

/* Reaction pills bar (visible when reactions exist) */
.msg-reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
  align-items: center;
}
.msg-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  background: transparent;
  border: 1px solid var(--color-border, #444);
  border-radius: 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.msg-reaction-pill:hover { border-color: var(--color-gold, #d4a017); }
.msg-reaction-pill.user-reacted {
  background: rgba(212,160,23,0.2);
  border-color: var(--color-gold, #d4a017);
}
.msg-reaction-count { font-weight: 600; font-size: 0.75rem; }
/* Custom tooltip for reaction names */
.rx-tooltip {
  position: fixed;
  pointer-events: none;
  background: #111;
  color: #eee;
  border: 1px solid var(--color-border, #444);
  border-radius: 0.4rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: nowrap;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  max-width: 220px;
  white-space: normal;
  word-break: break-word;
}
/* "+" button inline — exact same shape as .msg-reaction-pill */
.msg-reaction-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--color-border, #444);
  border-radius: 1rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--color-text, #ddd);
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
  user-select: none;
}
.msg-reaction-add:hover { opacity: 1; border-color: var(--color-gold, #d4a017); }
.msg-reaction-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--color-background, #1a1a2e);
  border: 1px solid var(--color-border, #444);
  border-radius: 0.5rem;
  padding: 0.3rem;
  display: flex;
  gap: 0.15rem;
  z-index: 200;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
}
.msg-reaction-picker span {
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 0.25rem;
  transition: background 0.15s;
  user-select: none;
}
.msg-reaction-picker span:hover { background: rgba(255,255,255,0.1); }

/* ── Utility Classes ────────────────────────────── */
.text-positive { color: var(--color-digit-positive); }
.text-negative { color: var(--color-digit-negative); }
.text-muted { color: #666; }
.text-dimmed { color: #999; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85em; }
.font-bold { font-weight: bold; }

.notification.error {
  border-color: var(--color-digit-negative);
}

.notification-special {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1rem;
  border: 2px solid #b8860b;
  background: #fffbe6;
  max-width: 340px;
}
.notif-special-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.notif-special-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notif-special-title {
  font-weight: bold;
  font-size: 0.85rem;
  color: #000;
}
.notif-special-detail {
  font-size: 0.8rem;
  color: #555;
}

.castle-table tr.current-row {
  border-left: 3px solid black;
}

/* ── Login Page ─────────────────────────────────── */
.login-container {
  max-width: 420px;
  margin: 80px auto;
  padding: 30px;
  background-color: var(--color-background);
  border: 1px solid var(--color-border);
}

.login-title {
  text-align: center;
  color: var(--color-text);
  margin-bottom: 8px;
  font-size: 1.5rem;
}

.login-logo {
  display: block;
  margin: 0 auto 0.5rem auto;
  height: 120px;
  width: auto;
  object-fit: contain;
}

.login-subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 25px;
  font-size: 0.85rem;
}

.login-form { display: flex; flex-direction: column; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: bold; color: var(--color-text); }
.form-group input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
  font-size: 14px; box-sizing: border-box; font-family: monospace;
  background: var(--color-background);
}
.form-group input:focus { border-width: 2px; outline: none; }

.login-btn {
  background: white;
  color: black;
  border: 1px solid black;
  padding: 12px;
  font-size: 14px;
  cursor: pointer;
  font-weight: bold;
  font-family: monospace;
}
.login-btn:hover { background-color: #f0f0f0; }
.login-btn:disabled { opacity: 0.4; cursor: wait; }

.error-message {
  color: var(--color-digit-negative);
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid var(--color-digit-negative);
  background: var(--color-background);
}

.login-footer { text-align: center; margin-top: 20px; color: #666; font-size: 0.85rem; }

/* ── Animations (minimal) ───────────────────────── */
@keyframes slide-in-bottom {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Spell Cards ─────────────────────────────────── */
.spell-card {
  background: var(--color-surface);
  transition: border-color 0.2s;
}
.spell-card:hover {
  border-color: var(--color-text) !important;
}
.spell-card button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Siege Units ────────────────────────────────── */
.siege-force-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  background: rgba(232, 165, 0, 0.08);
  border: 1px solid rgba(232, 165, 0, 0.2);
  border-radius: 4px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.siege-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.siege-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.7rem 0.8rem;
  border-radius: 4px;
}

.siege-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.siege-card-header h4 {
  margin: 0;
  font-size: 0.9rem;
}

.siege-card-header .siege-count {
  font-size: 0.8rem;
  color: #999;
}

.siege-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.5rem;
}

.siege-card-stats .stat-total {
  color: #ddd;
  font-weight: bold;
}

.siege-card-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.3rem;
}

.siege-qty-input {
  width: 50px;
}

.siege-card.maxed {
  border-color: rgba(232, 165, 0, 0.3);
}

.siege-masters-section {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

/* ── Arsenal Carrier Filters ───────────────────── */
.arsenal-carrier-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.carrier-filter {
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  min-width: 2.2rem;
  text-align: center;
  border-radius: 3px;
}

.carrier-filter.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  font-weight: bold;
}

.carrier-filter:hover:not(.active) {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .carrier-filter.active {
  background: #000;
  color: #fff;
  border-color: #444;
}

[data-theme="dark"] .carrier-filter:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
}

.emoji-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
  display: inline-block;
}

/* ── Arsenal Grid ──────────────────────────────── */
.arsenal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.arsenal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.7rem 0.8rem;
  border-radius: 4px;
  position: relative;
}

.arsenal-carrier-badge {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.85rem;
  opacity: 0.65;
  pointer-events: none;
}

.arsenal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.arsenal-card-header h4 {
  margin: 0;
  font-size: 0.9rem;
}

.arsenal-card-header .arsenal-count {
  font-size: 0.8rem;
  color: #000;
  font-weight: 600;
}

.arsenal-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #bbb;
  margin-bottom: 0.3rem;
}

.arsenal-slot-info {
  font-size: 0.75rem;
  color: #b8860b;
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.arsenal-cost-preview {
  font-size: 0.75rem;
  color: #666;
  text-align: left;
  margin-top: 2px;
  font-family: monospace;
}

.arsenal-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.arsenal-card-actions .arsenal-cost-preview {
  width: 100%;
  margin-top: 0;
}

.arsenal-full-hint {
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #d4860b;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(212, 134, 11, 0.1);
  border: 1px dashed rgba(212, 134, 11, 0.4);
  transition: background 0.2s;
}
.arsenal-full-hint:hover {
  background: rgba(212, 134, 11, 0.2);
}

.arsenal-card-actions input[type="number"] {
  width: 50px;
}

.arsenal-sell-btn {
  background: rgba(180, 60, 60, 0.15) !important;
  border-color: #b43c3c !important;
  color: #d45555 !important;
}
.arsenal-sell-btn:hover {
  background: rgba(180, 60, 60, 0.3) !important;
}

.arsenal-card.maxed {
  border-color: var(--color-border);
}

.arsenal-cat-header {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0 0;
  font-size: 1rem;
}

/* ── Responsive (tablet) ────────────────────────── */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
  }

  .right-column {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
  }

  .build-queue { position: static; }
  #queue-container { max-height: 300px; }

}

/* ══════════════════════════════════════════════════════════
   MOBILE UI — iPhone / small screens (≤ 600px)
   Desktop is NEVER affected by these rules.
   ══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Prevent horizontal scroll ──────────────── */
  /* NOTE: overflow-x on <html> breaks position:fixed in Safari iOS */
  html {
    width: 100%;
    height: 100%;
    /* Prevent overscroll bounce in standalone web-app mode */
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
  }
  body {
    overflow-x: hidden;
    width: 100%;
    min-height: 100%;
    /* Prevent overscroll bounce that lifts fixed bottom bar in standalone mode */
    overscroll-behavior-y: none;
  }

  /* ── Dynamic Island safe area is handled by the fixed gold/mana bar
       and .header margin-top — no body padding needed ── */

  /* Force all children to respect viewport width */
  *:not(.tabs):not(.modal):not(.notification-area):not(.sticky-top-bar), *::before, *::after {
    max-width: 100vw;
    word-break: break-word;
  }

  /* ── Container: single column, no overflow ──── */
  .container {
    grid-template-columns: 1fr;
    padding: 0.5rem;
    padding-bottom: 13rem; /* space for tab bar + build queue strip + bottom buttons */
    max-width: 100vw;
    overflow-x: hidden;
    width: 100%;
  }

  .left-column,
  .right-column,
  .tab-content,
  .tab-content.active {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ── Header ─────────────────────────────────── */
  .header-logo {
    height: 60px;
    margin-bottom: 0.15rem;
  }

  .user-info {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    align-items: stretch;
  }

  .user-info > div {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
  }

  /* ── Top bar buttons: 2× bigger on mobile ───── */
  .topbar-btn {
    font-size: 1rem;
    padding: 0.6rem 0.8rem;
    min-height: 44px;
    min-width: 44px;
  }
  .topbar-btn-icon {
    font-size: 1.4rem;
    padding: 0.6rem 0.7rem;
  }

  /* ── Logout button: hide from header on mobile ── */
  .logout-btn {
    display: none !important;
  }

  /* ── Fixed gold/mana bar — respects Dynamic Island safe area ── */
  .sticky-top-bar {
    position: static;
    margin-bottom: 0;
    background: var(--color-background);
    border: 1px solid var(--color-border);
  }

  .sticky-top-bar > .sticky-row:first-child {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    padding-top: calc(env(safe-area-inset-top, 0px) + 0.4rem);
    padding-bottom: 0.4rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    /* Force GPU layer — prevents bounce on fast scroll in iOS standalone mode */
    will-change: transform;
  }

  /* Push header below the fixed gold/mana bar */
  .header {
    margin-top: calc(env(safe-area-inset-top, 0px) + 2.8rem);
  }

  /* Small gap between header and ATK/DEF row */
  .sticky-top-bar {
    margin-top: 0.15rem;
  }

  .sticky-row {
    flex-wrap: wrap;
    padding: 0.45rem 0.6rem;
    font-size: 1rem;
    gap: 0.35rem;
    font-weight: bold;
  }
  /* Gold/mana row: single line, horizontally scrollable */
  .sticky-top-bar > .sticky-row:first-child {
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sticky-top-bar > .sticky-row:first-child::-webkit-scrollbar {
    display: none;
  }
  .sticky-row strong {
    font-size: 1.05rem;
  }

  /* ── Tabs → Bottom fixed tab bar (BLACK, high contrast) ── */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: hidden;
    background: #111;
    border-top: none;
    border-bottom: none;
    margin-bottom: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    gap: 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    /* Force GPU layer — prevents bounce on fast scroll in iOS standalone mode */
    will-change: transform;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 1.05rem 0;
    text-align: center;
    font-size: 1.25rem;
    border: none;
    border-radius: 0;
    margin-right: 0;
    white-space: nowrap;
    border-bottom: none;
    color: #888;
    background: transparent;
    transition: color 0.15s, background 0.15s;
  }

  /* Hide the text label on mobile tabs, show only emoji */
  .tab span {
    display: none;
  }

  .tab.active {
    border: none;
    border-top: 3px solid #fff;
    margin-bottom: 0;
    font-weight: bold;
    color: #fff;
    background: #222;
  }

  .tab:hover {
    text-decoration: none;
    color: #ccc;
    background: #1a1a1a;
  }


  /* ── Left / Right columns ─────────────────────── */
  .left-column {
    padding-right: 0;
    position: relative;
    overflow-x: clip;  /* clip sliding tabs without creating a scroll container */
  }

  .right-column {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--color-border);
    padding-top: 0.75rem;
  }

  /* ── All buttons: bigger touch targets ────────── */
  button {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .build-form {
    flex-wrap: wrap;
  }

  .build-form button {
    min-height: 44px;
    font-size: 0.9rem;
    flex: 1 1 auto;
  }

  .build-form input[type="number"] {
    min-height: 40px;
    width: 60px;
    font-size: 1rem;
    padding: 6px;
  }

  .defense-simulation-btn {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }

  .upgrade-castle-btn,
  .PVP-attack-btn,
  .slave-market-btn,
  .missive-send-btn-small,
  #serf-build-btn {
    min-height: 44px;
    font-size: 0.9rem;
  }

  /* ── War actions ─────────────────────────────── */
  .war-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .war-intel-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
  }

  .war-spy-info {
    text-align: center;
  }

  .war-reserve-info {
    min-width: 0;
  }

  /* ── Tables: horizontal scroll wrapper ────────── */
  .castle-table,
  #kingdoms-table,
  .ranking-table {
    display: table;
    table-layout: auto;
    width: 100%;
    font-size: 0.82rem;
  }

  .castle-table th,
  .castle-table td,
  #kingdoms-table th,
  #kingdoms-table td {
    padding: 0.35rem 0.4rem;
    font-size: 0.78rem;
    white-space: normal;
    word-break: break-word;
  }

  /* ── Army list ──────────────────────────────── */
  .army ul {
    flex-direction: column;
    gap: 0.3rem;
  }

  .army li {
    min-width: unset;
    width: 100%;
  }

  /* ── Unit rows ─────────────────────────────── */
  .unit-row {
    padding: 0.4rem 0.5rem;
  }

  .unit-row p {
    font-size: 0.8rem;
  }

  /* ── Modals: full-width on mobile ──────────── */
  .modal.show {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  }
  #equipment-dialog.modal.show {
    align-items: center;
    padding-top: 0;
  }

  .modal-content,
  .war-reports-content {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 1.5rem - env(safe-area-inset-top, 0px));
    padding: 1rem;
    overflow-y: auto;
  }

  .war-reports-content,
  .rankings-content {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 3rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* ── Rankings ──────────────────────────────── */
  .ranking-filters {
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    margin: 0.5rem 0;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }
  .ranking-filters::-webkit-scrollbar {
    display: none;
  }

  .ranking-filter {
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    min-height: 38px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .ranking-civ-filters {
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
    scrollbar-width: none;
  }
  .ranking-civ-filters::-webkit-scrollbar {
    display: none;
  }

  .ranking-civ-filters .ranking-filter {
    min-width: 2.2rem;
    min-height: 38px;
    padding: 0.3rem 0.45rem;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .ranking-table th,
  .ranking-table td {
    padding: 0.35rem 0.3rem;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ranking-player-name {
    display: inline-block;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  .ranking-mobile-actions {
    display: flex;
    gap: 0.3rem;
  }

  .ranking-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0.3rem;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s;
  }

  .ranking-action-attack:active {
    background: rgba(220, 50, 50, 0.2);
  }

  .ranking-action-missive:active {
    background: rgba(201, 162, 39, 0.2);
  }

  .ranking-action-eye:active {
    background: rgba(100, 149, 237, 0.2);
  }

  .ranking-pagination,
  .modal-nav-footer {
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  .ranking-pagination button,
  .modal-nav-footer .nav-footer-btn {
    min-height: 40px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  /* ── Arsenal ──────────────────────────────── */
  .arsenal-carrier-filters {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .carrier-filter {
    min-width: 2.5rem;
    min-height: 36px;
    font-size: 1.1rem;
  }

  .arsenal-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .arsenal-card {
    padding: 0.4rem;
    font-size: 0.8rem;
  }

  .arsenal-card button {
    min-height: 38px;
    width: 100%;
  }

  /* ── Castle info ──────────────────────────── */
  .castle-info {
    padding: 0.5rem;
  }

  /* ── Village / Serf section ────────────────── */
  .serf-section {
    padding: 0.5rem;
  }

  .village-info {
    padding: 0.5rem;
  }

  /* ── Civilization cards ────────────────────── */
  .civ-select-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.4rem;
  }

  /* ── World tab kingdoms ────────────────────── */
  .world-kingdoms {
    overflow-x: hidden;
  }

  /* Castle column compact, gold column gets more room */
  #kingdoms-table th:nth-child(3),
  #kingdoms-table td:nth-child(3) {
    white-space: nowrap;
    width: 2.5rem;
    text-align: center;
  }
  #kingdoms-table th:nth-child(4),
  #kingdoms-table td:nth-child(4) {
    white-space: nowrap;
  }

  /* ── Merc recruiter ─────────────────────────── */
  .merc-recruiter-toggle {
    flex-wrap: wrap;
  }

  /* ── Notification area ──────────────────────── */
  .notification-area {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 9rem; /* above tab bar + build queue */
  }

  .notification {
    font-size: 0.85rem;
  }

  /* ── Progress bars ──────────────────────────── */
  .progress-bar {
    height: 8px;
  }

  /* ── Build queue: horizontal fixed strip above tab bar on mobile ── */
  .right-column {
    order: -1;
    border-left: none;
    border-top: none;
    padding: 0;
    position: fixed;
    bottom: calc(4.0rem + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    z-index: 998; /* just below tab bar (999) */
    background: var(--color-background);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.25);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .build-queue {
    position: static;
  }

  .build-queue h2 {
    font-size: 0.85rem;
    margin: 0;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background);
    position: static;
  }

  #queue-container {
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 0.35rem;
  }

  #queue-container ul {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.4rem 0;
    margin: 0;
  }

  #queue-container ul li {
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 200px;
    font-size: 0.9rem;
    padding: 0.45rem 0.7rem;
    white-space: nowrap;
    border: 1px solid var(--color-border);
    margin-bottom: 0;
  }

  #queue-container ul li .countdown {
    font-size: 0.85rem;
  }

  /* ── Inline styles override for inputs ─────── */
  input[type="number"] {
    max-width: 100%;
    min-height: 36px;
  }

  /* ── Missive gold input ────────────────────── */
  #missive-gold-input {
    width: 5rem !important;
  }

  /* ── Storm banner ──────────────────────────── */
  #storm-banner {
    font-size: 0.8rem;
    padding: 0.3rem !important;
  }

  /* ── Defense alert ─────────────────────────── */
  .defense-alert {
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  /* ── Kingdom stats bar compact ─────────────── */
  #kingdom-stats-bar {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .kingdom-stat-separator {
    display: none;
  }

  .kingdom-stat {
    font-size: 0.95rem;
    font-weight: bold;
  }

  .kingdom-tooltip {
    min-width: 200px;
    font-size: 0.78rem;
    left: auto;
    right: 0;
  }

  /* Disable all arsenal tooltips on mobile — modals replace them */
  .army li.has-arsenal-tip:hover > .army-arsenal-tooltip,
  .army li.has-arsenal-tip.show-tooltip > .army-arsenal-tooltip {
    display: none !important;
  }
  /* Disable ALL kingdom-tooltip hovers on mobile — modals replace them */
  .kingdom-stat:hover .kingdom-tooltip,
  .kingdom-stat.show-tooltip .kingdom-tooltip,
  #army-cap-wrapper:hover .kingdom-tooltip,
  #army-cap-wrapper .kingdom-tooltip {
    display: none !important;
  }

  /* ── Bulletin board: single column on mobile ──── */
  #bulletin-board-items {
    grid-template-columns: 1fr;
  }

  .public-missive-item {
    padding: 0.4rem 0.5rem;
  }

  .public-missive-body {
    font-size: 0.8rem;
  }

  /* ── hr spacing ─────────────────────────────── */
  hr {
    margin: 1rem 0 !important;
  }

  /* ── War reports modal: full height on mobile ── */
  .war-reports-content {
    max-height: calc(100vh - 3rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden;
  }
  .war-reports-table-container {
    max-height: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* ── War reports table: compact mobile layout ── */
  .war-reports-table {
    table-layout: fixed;
    width: 100%;
  }
  .war-reports-table th,
  .war-reports-table td {
    padding: 0.3rem 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Column widths: Date, Type, Result, Loot, Details */
  .war-reports-table th:nth-child(1),
  .war-reports-table td:nth-child(1) { width: 22%; }
  .war-reports-table th:nth-child(2),
  .war-reports-table td:nth-child(2) { width: 28%; max-width: 0; }
  .war-reports-table th:nth-child(3),
  .war-reports-table td:nth-child(3) { width: 16%; }
  .war-reports-table th:nth-child(4),
  .war-reports-table td:nth-child(4) { width: 18%; }
  .war-reports-table th:nth-child(5),
  .war-reports-table td:nth-child(5) { width: 16%; }

  /* ── Battle report detail: prevent overflow ── */
  .war-report-detail {
    overflow-x: hidden;
    word-break: break-word;
  }
  .battle-details-container {
    max-width: 100%;
    overflow: hidden;
  }
  .battle-stats {
    grid-template-columns: 1fr;
  }
  .battle-stat {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.5rem;
  }
  .battle-stat .stat-label {
    font-size: 0.75rem;
    margin-bottom: 0;
  }
  .battle-stat .stat-value {
    font-size: 0.85rem;
    text-align: right;
  }
  .battle-comparison, .casualties-section {
    padding: 0.5rem;
  }
  .casualties-grid {
    grid-template-columns: 1fr 1fr;
  }
  .casualty-item {
    font-size: 0.78rem;
    padding: 3px 5px;
  }
  .war-reports-table .claim-button {
    font-size: 0.7rem;
    padding: 3px 6px;
    white-space: nowrap;
  }
  .war-reports-table .detail-button {
    display: block;
    width: 100%;
    font-size: 0.85rem;
    padding: 4px 0;
    text-align: center;
    box-sizing: border-box;
  }
  .war-report-detail h3 {
    font-size: 0.95rem;
  }
  .war-report-detail p {
    font-size: 0.82rem;
    word-break: break-word;
  }
  .war-report-detail {
    padding-bottom: 4rem;
  }
  .war-reports-pagination {
    margin-bottom: 4rem;
  }

  /* ── Modals: hide X cross on mobile ────────── */
  .modal-content .close-modal,
  .war-reports-content .close-modal,
  .rankings-content .close-modal {
    display: none !important;
  }

  .modal-content {
    padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  .war-reports-content,
  .rankings-content {
    padding-bottom: 1rem !important;
  }

  /* ── Floating close button (injected via JS) ── */
  .mobile-modal-close {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-background);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 0.55rem 3rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    z-index: 1010;
    letter-spacing: 0.02em;
    border-radius: 4px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
  }
  .mobile-modal-close:hover {
    opacity: 0.8;
  }

}

/* ── Dark mode overrides for mobile ─────────────── */
@media (max-width: 600px) {
  /* Tab bar is already black — just tweak dark mode sticky bar */
  [data-theme="dark"] .sticky-top-bar {
    background: #1a1a1a;
  }
  [data-theme="dark"] .sticky-top-bar > .sticky-row:first-child {
    background: #1a1a1a;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  }

  /* Notification above bottom bar in dark mode */
  [data-theme="dark"] .notification-area {
    bottom: 9rem;
  }
}

/* ── Geôles (Dungeon / Prisoners) ────────────── */
.prisoner-row {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}
.prisoner-row .unit-name {
  font-weight: bold;
  color: var(--color-text);
}
.prisoner-row .prisoner-converts-to {
  color: #b45309;
  margin-left: 0.5rem;
  font-size: 0.9rem;
}
.prisoner-row .prisoner-timer {
  display: block;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 4px;
}
.prisoner-row.hiding {
  opacity: 0.5;
  border-style: dashed;
}

/* ── Kingdom Stats Bar ─────────────────────────────── */
.kingdom-stat-separator {
  color: var(--color-muted);
}
.kingdom-stat {
  display: inline-block;
}
.kingdom-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  min-width: 260px;
  font-size: 0.85rem;
  color: #ddd;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.kingdom-stat:hover .kingdom-tooltip {
  display: block;
}
.kingdom-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.kingdom-tooltip .tt-row.tt-total {
  border-top: 1px solid #444;
  margin-top: 4px;
  padding-top: 6px;
  font-weight: bold;
  color: #fff;
}

/* ── Stat modal .tt-row (used in showStatModal) ────────────── */
.modal .tt-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  gap: 1rem;
}
.modal .tt-row.tt-total {
  font-weight: bold;
  color: #fff;
}

/* ── Army Arsenal Tooltip ─────────────────────────────────── */
.army-arsenal-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  min-width: 280px;
  font-size: 0.85rem;
  color: #ddd;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  white-space: nowrap;
  margin-top: 4px;
}
.army li.has-arsenal-tip:hover > .army-arsenal-tooltip,
.army li.has-arsenal-tip.show-tooltip > .army-arsenal-tooltip {
  display: block;
}
.army-arsenal-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  gap: 1.5rem;
}
.army-arsenal-tooltip .tt-row.tt-total {
  border-top: 1px solid #444;
  margin-top: 4px;
  padding-top: 6px;
  font-weight: bold;
  color: #fff;
}

/* ── In-dialog tooltip (light background) ─────────── */
.army-arsenal-tooltip.in-dialog {
  display: block;
  position: static;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  min-width: 0;
  color: var(--color-text);
}
.army-arsenal-tooltip.in-dialog .tt-row {
  color: var(--color-text);
}
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color:#4ade80"],
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color: #4ade80"] {
  color: #16a34a !important;
}
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color:#b8860b"],
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color: #b8860b"] {
  color: #92610a !important;
}
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color:#888"],
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color: #888"] {
  color: #555 !important;
}
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color:#a8a29e"],
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color: #a8a29e"] {
  color: #6b6560 !important;
}
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color:#e8a500"],
.army-arsenal-tooltip.in-dialog .tt-row span[style*="color: #e8a500"] {
  color: #b07d00 !important;
}
.army-arsenal-tooltip.in-dialog .tt-row.tt-total {
  border-top-color: #ddd;
  color: var(--color-text-important);
}

/* ── Arsenal Tab ─────────────────────────────────────────── */
/* Arsenal now uses standard .unit-row / .build-form / .serf-section styles */

/* ══════════════════════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --color-primary: #e0e0e0;
  --color-secondary: #e0e0e0;
  --color-accent: #e0e0e0;
  --color-danger: #ff6b6b;
  --color-background: #1a1a1a;
  --color-background-light: #1a1a1a;
  --color-surface: #2a2a2a;
  --color-text: #d4d4d4;
  --color-text-important: #f0f0f0;
  --color-border: #444444;
  --color-digit-positive: #4ade80;
  --color-digit-negative: #f87171;
  --color-digit-neutral: #60a5fa;
}

/* Buttons */
[data-theme="dark"] button {
  background: #2a2a2a;
  border-color: #555;
  color: #d4d4d4;
}
[data-theme="dark"] button:hover { background-color: #3a3a3a; }

/* Inputs */
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}

/* Active tab: border-bottom must match dark bg to "erase" the line */
[data-theme="dark"] .tab.active {
  border-bottom: 1px solid #1a1a1a;
}

/* Tables */
[data-theme="dark"] .castle-table th,
[data-theme="dark"] #kingdoms-table th {
  background-color: #2a2a2a;
}
[data-theme="dark"] .castle-table tr:hover,
[data-theme="dark"] #kingdoms-table tr:hover {
  background-color: #2a2a2a;
}

/* Li borders */
[data-theme="dark"] li {
  border-bottom-color: #333;
}

/* Progress bar background */
[data-theme="dark"] .progress-bar {
  background-color: #333;
}
[data-theme="dark"] .progress {
  background-color: #d4d4d4;
}

/* Merc recruit countdown bar */
[data-theme="dark"] .merc-recruit-bar { background-color: #333; }
[data-theme="dark"] .merc-recruit-text { color: #d4d4d4; }

/* Upgrade / build buttons */
[data-theme="dark"] .upgrade-castle-btn,
[data-theme="dark"] #serf-build-btn,
[data-theme="dark"] .PVP-attack-btn,
[data-theme="dark"] .claim-button,
[data-theme="dark"] .logout-btn,
[data-theme="dark"] .btn-danger {
  background-color: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}
[data-theme="dark"] .upgrade-castle-btn:hover,
[data-theme="dark"] #serf-build-btn:hover,
[data-theme="dark"] .PVP-attack-btn:hover,
[data-theme="dark"] .claim-button:hover,
[data-theme="dark"] .logout-btn:hover,
[data-theme="dark"] .btn-danger:hover {
  background-color: #3a3a3a;
}

/* Defense simulation button (already dark-ish, invert for dark mode) */
[data-theme="dark"] .defense-simulation-btn {
  background-color: #f0f0f0;
  color: #111;
  border-color: #333;
}
[data-theme="dark"] .defense-simulation-btn:hover { background-color: #ddd; }

[data-theme="dark"] .war-intel-row {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .war-spy-info {
  color: #aaa;
}

/* Claim loot banner */
[data-theme="dark"] .claim-loot-banner {
  border-color: #555;
}

/* Gold close button */
[data-theme="dark"] .gold-close-btn {
  background: #3a2600;
  color: #f5d060;
}

/* Serf section left border */
[data-theme="dark"] .serf-section {
  border-left-color: #888;
}
[data-theme="dark"] .serf-section--flat {
  border-left-color: transparent;
}

/* Village tab flat sections — no background in dark mode */
[data-theme="dark"] .village-info--flat {
  border: none;
  background: transparent;
}
[data-theme="dark"] #tab-village #garden-section.serf-section {
  border: none;
  border-left: none;
  padding: 0;
}

/* Notification toast */
[data-theme="dark"] .notification {
  background: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}

/* Scrollbar */
/* War reports table */
[data-theme="dark"] .war-reports-table th {
  background-color: #2a2a2a;
}
[data-theme="dark"] .war-reports-table tr:hover { background-color: #2a2a2a; }

/* Topbar buttons dark mode */
[data-theme="dark"] .topbar-btn {
  background-color: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}
[data-theme="dark"] .topbar-btn:hover { background-color: #3a3a3a; }
[data-theme="dark"] .logout-btn { background-color: #2a2a2a; color: #d4d4d4; border-color: #555; }
[data-theme="dark"] .logout-btn:hover { background-color: #3a3a3a; }

/* Detail / expand buttons */
[data-theme="dark"] .detail-button,
[data-theme="dark"] .game-controls button,
[data-theme="dark"] .defense-alert button,
[data-theme="dark"] #war-reports-button,
[data-theme="dark"] .login-btn {
  background-color: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}
[data-theme="dark"] .detail-button:hover,
[data-theme="dark"] .game-controls button:hover,
[data-theme="dark"] .defense-alert button:hover,
[data-theme="dark"] .login-btn:hover {
  background-color: #3a3a3a;
}

/* Give gold button (uses !important) */
[data-theme="dark"] .give-gold-btn {
  background-color: #2a2a2a !important;
  color: #d4d4d4 !important;
  border-color: #555 !important;
}
[data-theme="dark"] .give-gold-btn:hover { background-color: #3a3a3a !important; }

/* Secret & achievement cards (dark mode) */
[data-theme="dark"] .secret-unlocked .secret-name { color: #f5d060; }
[data-theme="dark"] .achievement-done { border-color: #b8860b; }

/* Badge borders */
[data-theme="dark"] .topbar-badge { border-color: #1a1a1a; }

/* Special notifications (yellow bg) */
[data-theme="dark"] .notification-special {
  background: #3a2e00;
  color: #f0e0a0;
}
[data-theme="dark"] .notif-special-title {
  color: #ffe082;
}
[data-theme="dark"] .notif-special-detail {
  color: #d4c88a;
}

/* Ranking active filter */
[data-theme="dark"] .ranking-filter.active {
  background: #000;
  color: #fff;
  border-color: #444;
}
[data-theme="dark"] .ranking-filter:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .ranking-action-btn {
  background: #222;
  border-color: #555;
  color: #fff;
}

/* Login screen */
[data-theme="dark"] .form-group input {
  background: #2a2a2a;
  color: #d4d4d4;
  border-color: #555;
}

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar { width: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #1a1a1a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #555; }

/* Battle / war reports dark mode */
[data-theme="dark"] .battle-stat {
  border-color: #3a3a3a;
  background: #1e1e1e;
}
[data-theme="dark"] .stat-label {
  color: #999;
}
[data-theme="dark"] .stat-value {
  color: #e0e0e0;
}
[data-theme="dark"] .battle-comparison,
[data-theme="dark"] .casualties-section {
  border-color: #3a3a3a;
}
[data-theme="dark"] .battle-comparison h3,
[data-theme="dark"] .casualties-section h3 {
  border-bottom-color: #3a3a3a;
}
[data-theme="dark"] .casualty-item {
  border-color: #3a3a3a;
  background: #1e1e1e;
}
[data-theme="dark"] .battle-tip {
  border-color: #3a3a3a;
  background: #1e1e1e;
  color: #999;
}

/* Battle lore (inline style override) */
[data-theme="dark"] .battle-lore {
  color: #aaa !important;
  border-left-color: #666 !important;
}

/* Auth tabs on login page */
[data-theme="dark"] .auth-tab { color: #999; }
[data-theme="dark"] .auth-tab.active { color: #e0e0e0; border-bottom-color: #e0e0e0; }
[data-theme="dark"] .success-message { background: #1a2e1a; border-color: #2a4a2a; color: #4ade80; }
[data-theme="dark"] .error-message { background: #2e1a1a; border-color: #4a2a2a; }

/* Login container */
[data-theme="dark"] .login-container { background: #1a1a1a; border-color: #444; }
[data-theme="dark"] .login-title { color: #e0e0e0; }
[data-theme="dark"] .login-subtitle { color: #999; }
[data-theme="dark"] .login-footer { color: #666; }
[data-theme="dark"] .back-to-login { color: #e8a500; }

/* Admin toggle button */
[data-theme="dark"] #footer-admin-btn { color: #999; border-color: #555; }

/* Arsenal cards */
[data-theme="dark"] .arsenal-card { background: #2a2a2a; }
[data-theme="dark"] .arsenal-card-header .arsenal-count { color: #e0e0e0; }
[data-theme="dark"] .arsenal-cost-preview { color: #999; }
[data-theme="dark"] .arsenal-slot-info { color: #d4a017; }

/* Bulletin Board dark mode */
[data-theme="dark"] .public-missive-item { background: #2a2410; border-color: #8b7020; }
[data-theme="dark"] .public-missive-header { color: #ccc; }
[data-theme="dark"] .public-missive-body { color: #d4d4d4; }
[data-theme="dark"] .public-missive-cover-overlay { background: rgba(0, 0, 0, 0.65); }

/* Private missives dark mode */
[data-theme="dark"] .missives-toggle-btn { color: #ccc; border-color: var(--color-border); }
[data-theme="dark"] .missives-toggle-btn:hover { background: #2a2a2a; color: #fff; }
[data-theme="dark"] .missive-item { background: var(--color-bg); border-color: var(--color-border); }
[data-theme="dark"] .missive-item.missive-sent { border-left-color: #42a5f5; }
[data-theme="dark"] .missive-item.missive-unread { background: #1a1a2e; border-left-color: #ff4444; }
[data-theme="dark"] .missive-header { color: #e0e0e0; }
[data-theme="dark"] .missive-body { color: #d4d4d4; }
[data-theme="dark"] .missive-reply-btn { color: #ccc; border-color: var(--color-border); }
[data-theme="dark"] .missive-reply-btn:hover { background: #2a2a2a; color: #fff; }
[data-theme="dark"] .missive-gold { background: #2a2410; border-color: #8b7020; color: #f0d060; }
[data-theme="dark"] .missive-claim-btn { background: #3d3210; border-color: #8b7020; color: #f0d060; }
[data-theme="dark"] .missive-claim-btn:hover { background: #4d4220; }
[data-theme="dark"] .missive-pagination button { background: var(--color-bg); color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .missive-pagination button:hover { background: #2a2a2a; }
[data-theme="dark"] .missive-send-icon { color: #ccc; }

/* ══════════════════════════════════════════════════════════
   CIVILIZATION SYSTEM STYLES
   ══════════════════════════════════════════════════════════ */

/* Civilization Selection Grid */
.civ-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.civ-card {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.85rem;
    line-height: 1.35;
}

.civ-card:hover {
    border-color: #c9a227;
    background: rgba(201, 162, 39, 0.05);
}

.civ-card-active {
    border-color: #c9a227;
    background: rgba(201, 162, 39, 0.1);
}

.civ-card-header {
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

.civ-emoji {
    font-size: 1.1rem;
}

/* Civilization modal overrides — tighter padding */
#civilization-select-modal .modal-content {
    padding: 1rem 1.25rem;
}
#civilization-panel-modal .modal-content {
    padding: 0;
    max-width: 500px;
    max-height: 95vh;
}
#civ-panel-content {
    overflow-y: auto;
    max-height: calc(95vh - 2rem);
}
#civilization-select-modal .modal-content h2 {
    margin-top: 0;
    margin-bottom: 0.15rem;
}
#civilization-select-modal .modal-content > p {
    margin-bottom: 0;
}

/* Offline Summary Modal */
.offline-summary-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.offline-summary-box {
    background: var(--color-background);
    border: 2px solid #b8860b;
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    font-family: monospace;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}
.offline-summary-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.3rem;
}
.offline-summary-time {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 1rem;
}
.offline-summary-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    text-align: left;
}
.offline-summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.offline-summary-gain { border-left: 3px solid var(--color-digit-positive); }
.offline-summary-loss { border-left: 3px solid var(--color-digit-negative); }
.offline-summary-mana { border-left: 3px solid #a78bfa; }
.offline-summary-net {
    border-left: 3px solid #b8860b;
    font-weight: bold;
    border-top: 1px solid var(--color-border);
    margin-top: 0.2rem;
}
.offline-summary-value { font-weight: bold; }
.offline-summary-value.positive { color: var(--color-digit-positive); }
.offline-summary-value.negative { color: var(--color-digit-negative); }
.offline-summary-btn {
    display: block;
    width: 100%;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    font-family: monospace;
    cursor: pointer;
    border: 2px solid #b8860b;
    border-radius: 6px;
    background: #f5d060;
    color: #3a2600;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}
.offline-summary-btn:hover {
    background: #ffe066;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.offline-summary-btn:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .offline-summary-btn {
    background: #3a2600;
    color: #f5d060;
}

/* Blood Moon Norse Banner */
.blood-moon-banner {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.25), rgba(80, 0, 0, 0.35));
    border: 1px solid rgba(200, 30, 30, 0.5);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin: 0.25rem 1.25rem 0;
    font-weight: bold;
    text-align: center;
    color: #ff6b6b;
    font-size: 0.9rem;
    animation: bloodMoonPulse 3s ease-in-out infinite;
}

@keyframes bloodMoonPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(200, 30, 30, 0.3); }
    50% { box-shadow: 0 0 16px rgba(200, 30, 30, 0.6); }
}

/* ── Civilization Panel ── */
.civ-panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem 0.75rem;
}
.civ-panel-emoji {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.civ-panel-title-block {
    min-width: 0;
}
.civ-panel-name {
    margin: 0 0 0.15rem;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
}
.civ-panel-desc {
    margin: 0;
    font-size: 0.8rem;
    color: #888;
    line-height: 1.35;
}
.civ-panel-section {
    padding: 0.5rem 1.25rem;
}
.civ-section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
    margin-bottom: 0.35rem;
    font-weight: bold;
}
.civ-panel-weather {
    border-top: 1px solid var(--color-border);
    font-size: 0.82rem;
}
.civ-weather-line {
    padding: 0.15rem 0;
}
.civ-weather-hint {
    font-size: 0.72rem;
    color: #888;
    font-style: italic;
}
.civ-weather-nbm {
    color: #e74c3c;
}
.civ-mod-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem 0.75rem;
    font-size: 0.82rem;
}
.civ-mod-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.civ-mod-emoji {
    flex-shrink: 0;
    width: 1.2em;
    text-align: center;
}
.civ-mod-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.civ-mod-value {
    font-weight: bold;
    white-space: nowrap;
}
.civ-mod-positive { color: var(--color-digit-positive); }
.civ-mod-negative { color: var(--color-digit-negative); }
.civ-panel-unit {
    border-top: 1px solid var(--color-border);
}
.civ-unit-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}
/* ── Vanity Stats Section ── */
.civ-panel-vanity {
    border-top: 1px solid var(--color-border);
}
.vanity-stat-group {
    margin-bottom: 0.6rem;
}
.vanity-stat-group-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid var(--color-border);
}
.vanity-stat-row {
    display: flex;
    align-items: center;
    padding: 0.15rem 0;
    font-size: 0.8rem;
}
.vanity-stat-icon {
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}
.vanity-stat-label {
    flex: 1;
    color: var(--color-text-secondary);
}
.vanity-stat-value {
    font-family: monospace;
    font-weight: bold;
    color: var(--color-text);
    text-align: right;
}

.civ-panel-footer {
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 1.25rem;
    text-align: center;
}
.civ-change-btn {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: monospace;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-background-light);
    color: var(--color-text);
    transition: background 0.15s;
}
.civ-change-btn:hover:not(:disabled) {
    background: rgba(201, 162, 39, 0.1);
}
.civ-change-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.civ-cooldown-text {
    margin: 0.3rem 0 0;
    font-size: 0.75rem;
    color: #999;
}
/* Dark theme overrides for civ panel */
[data-theme="dark"] .civ-panel-desc,
[data-theme="dark"] .civ-section-label,
[data-theme="dark"] .civ-weather-hint,
[data-theme="dark"] .civ-cooldown-text {
    color: #aaa;
}
[data-theme="dark"] .civ-change-btn {
    background: #222;
    border-color: #555;
    color: #e0d6b8;
}
[data-theme="dark"] .civ-change-btn:hover:not(:disabled) {
    background: rgba(201, 162, 39, 0.15);
}
/* Mobile: center civ panel modal vertically */
@media (max-width: 600px) {
    #civilization-panel-modal.show {
        align-items: center;
    }
    #civilization-panel-modal .modal-content {
        max-height: 95vh;
        margin: auto 0;
    }
    #civ-panel-content {
        padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }
    .civ-mod-grid {
        grid-template-columns: 1fr;
    }
}

/* Civilization Equipment Items */
.civ-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono, 'Courier New', monospace);
    font-size: 0.85rem;
}

.civ-item-owned {
    border-color: #c9a227;
    background: rgba(201, 162, 39, 0.05);
}

/* Dark mode */
[data-theme="dark"] .civ-card { background: #1a1a1a; border-color: #444; }
[data-theme="dark"] .civ-card:hover { background: #2a2410; border-color: #c9a227; }
[data-theme="dark"] .civ-card-active { background: #2a2410; border-color: #c9a227; }
[data-theme="dark"] .civ-item { background: #1a1a1a; border-color: #444; }
[data-theme="dark"] .civ-item-owned { background: #2a2410; border-color: #c9a227; }

/* Username tooltip */
.username-tooltip-wrap {
    position: relative;
    display: inline;
}
.username-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    top: 120%;
    transform: translateX(-50%);
    background: #1a1a2e;
    border: 1px solid #c9a227;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #e8dcc8;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    line-height: 1.5;
    font-weight: normal;
}
.username-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #c9a227;
}
.username-tooltip-wrap:hover .username-tooltip {
    display: block;
}
@media (max-width: 600px) {
    .username-tooltip-wrap:hover .username-tooltip {
        display: none !important;
    }
}
#lord-detail-modal.show {
    align-items: center;
}
#lord-detail-body {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text);
}
#lord-detail-body strong {
    color: var(--color-text-important);
}
[data-theme="dark"] #lord-detail-body {
    color: #e0d6b8;
}
[data-theme="dark"] #lord-detail-body span[style*="color:#c9a227"] {
    color: #c9a227 !important;
}

/* ── Army Cap Counter ─────────────────────────────────── */
#army-cap-wrapper {
    display: inline-block;
    position: relative;
}
#army-counter {
    font-family: monospace;
    transition: color 0.3s;
}
#army-counter.cap-warning {
    color: #F39C12;
}
#army-counter.cap-full {
    color: #E74C3C;
    animation: army-cap-pulse 1.5s infinite;
}
@keyframes army-cap-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
#army-cap-wrapper:hover .kingdom-tooltip {
    display: block;
}
/* Caserne population gauge */
.army-cap-gauge {
    width: 100%;
    height: 14px;
    background: #333;
    border-radius: 7px;
    overflow: hidden;
    margin: 0.5rem 0;
    border: 1px solid #555;
    display: flex;
}
.army-cap-gauge-fill {
    height: 100%;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
}
.army-cap-gauge-fill-expedition {
    height: 100%;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #3498db, #2980b9);
}
.army-cap-gauge-fill.warning {
    background: linear-gradient(90deg, #F39C12, #e67e22);
}
.army-cap-gauge-fill.full {
    background: linear-gradient(90deg, #E74C3C, #c0392b);
}
.army-cap-gauge-fill-expedition.warning {
    background: linear-gradient(90deg, #e67e22, #d35400);
}
.army-cap-gauge-fill-expedition.full {
    background: linear-gradient(90deg, #c0392b, #a93226);
}

/* ── Prevent iOS zoom on input focus ─────────────── */
@media (max-width: 768px) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ══════════════════════════════════════════════════ */
/*  MARKET / MARCHÉ                                  */
/* ══════════════════════════════════════════════════ */
.market-tab { opacity:0.6; transition:opacity 0.2s; border:1px solid var(--color-border, #444); }
.market-tab.active { opacity:1; font-weight:bold; border-bottom:2px solid var(--color-gold, #c9a227); }
.market-card { padding:0.75rem; margin-bottom:0.5rem; }
.market-card-header { display:flex; align-items:center; gap:0.5rem; font-weight:bold; margin-bottom:0.25rem; }
.market-item-qty { opacity:0.7; font-size:0.85rem; margin-left:auto; }
.market-card-stats { font-size:0.8rem; opacity:0.7; margin-bottom:0.25rem; }
.market-card-price { font-weight:bold; margin-bottom:0.5rem; font-size:0.9rem; }
.market-card-footer { display:flex; align-items:center; justify-content:space-between; font-size:0.85rem; gap:0.5rem; flex-wrap:wrap; }
.market-seller { opacity:0.7; display:flex; align-items:center; gap:0.3rem; }
.market-missive-btn { padding:0.15rem 0.35rem !important; font-size:0.85rem !important; min-width:unset !important; opacity:0.7; transition:opacity 0.2s; }
.market-missive-btn:hover { opacity:1; }
.market-expires { opacity:0.6; font-size:0.8rem; }
.market-filters { display:flex; gap:0.3rem; margin-bottom:0.75rem; flex-wrap:wrap; }
.market-filter-btn { padding:0.3rem 0.6rem; font-size:0.85rem; cursor:pointer; }
.market-filter-btn.active { font-weight:bold; background:var(--color-surface, #1a1a2e); border-color:var(--color-gold, #c9a227); }
/* Market modal layout: flex column so sticky form stays at bottom */
.market-modal-content { display:flex; flex-direction:column; max-height:85vh; }
.market-scroll-area { flex:1 1 auto; overflow-y:auto; min-height:120px; }
.market-sell-sticky { flex:0 0 auto; }
.market-sell-form { display:flex; flex-direction:column; gap:0.5rem; padding:0.75rem; border-top:1px solid var(--color-border, #444); background:var(--color-surface, #1a1a2e); border-radius:0 0 6px 6px; }
.market-sell-form label { display:flex; align-items:center; gap:0.5rem; font-size:0.9rem; flex-wrap:wrap; }
.market-sell-form input { padding:0.4rem; font-size:0.9rem; background:var(--color-background, #0a0a1a); color:var(--color-text, #e0e0e0); border:1px solid var(--color-border, #444); }
.market-sell-preview { padding:0.5rem; background:var(--color-background, #0a0a1a); font-size:0.85rem; line-height:1.6; border-radius:4px; }
.market-pagination { display:flex; justify-content:center; align-items:center; gap:0.5rem; margin-top:0.75rem; }

/* ── @Mention autocomplete dropdown ─── */
#mention-autocomplete { position:fixed; z-index:99999; background:var(--color-surface, #1a1a2e); border:1px solid var(--color-border, #444); border-radius:6px; max-height:260px; overflow-y:auto; display:none; box-shadow:0 4px 12px rgba(0,0,0,0.5); }
#mention-autocomplete.show { display:block; }
.mention-item { padding:0.5rem 0.75rem; cursor:pointer; border-bottom:1px solid var(--color-border, #333); display:flex; align-items:center; gap:0.5rem; }
.mention-item:last-child { border-bottom:none; }
.mention-item:hover { background:rgba(255,215,0,0.1); }
.mention-item strong { color:var(--color-gold, #ffd700); }
.mention-item .mention-civ { font-size:0.75rem; opacity:0.6; margin-left:auto; }
.mention-link { color:var(--color-gold, #ffd700); font-weight:600; cursor:pointer; }
.mention-link:hover { text-decoration:underline !important; filter:brightness(1.2); }
/* #Item autocomplete dropdown */
#item-autocomplete { position:fixed; z-index:99999; background:var(--color-surface, #1a1a2e); border:1px solid var(--color-border, #444); border-radius:6px; max-height:260px; overflow-y:auto; display:none; box-shadow:0 4px 12px rgba(0,0,0,0.5); }
#item-autocomplete.show { display:block; }
.item-autocomplete-item { padding:0.5rem 0.75rem; cursor:pointer; border-bottom:1px solid var(--color-border, #333); display:flex; align-items:center; justify-content:space-between; gap:0.5rem; }
.item-autocomplete-item:last-child { border-bottom:none; }
.item-autocomplete-item:hover { background:rgba(255,255,255,0.06); }
/* Item inline link in chat */
.item-link { transition:filter 0.15s; }
.item-link:hover { filter:brightness(1.3); }
