/* ================================================================
   King & Dragon — Game UI
   Dark medieval aesthetic. Designed to feel like a game, not a web app.
   ================================================================ */

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Core */
  --bg:          #0d0a06;
  --bg-panel:    #161008;
  --bg-surface:  #1c1610;
  --bg-input:    #110d08;
  --text:        #c8b090;
  --text-dim:    #7a6850;
  --text-bright: #ede0c8;

  /* Gold */
  --gold:        #c9a84c;
  --gold-light:  #e0c060;
  --gold-bright: #ffd700;
  --gold-dark:   #8a7030;

  /* Danger / Dragon */
  --red:         #8b2500;
  --danger:      #cc3300;
  --ember:       #ff4500;

  /* Structure */
  --border:      #2a2018;
  --border-hi:   #3a2c20;
  --radius:      4px;

  /* Glow */
  --glow-gold:   0 0 12px rgba(201, 168, 76, 0.2);
  --glow-fire:   0 0 20px rgba(255, 69, 0, 0.3);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body.dark-theme {
  background: var(--bg);
  color: var(--text);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'MedievalSharp', serif;
  color: var(--gold);
  line-height: 1.2;
}

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

a:hover {
  color: var(--gold-light);
}

.muted {
  color: var(--text-dim);
  font-style: italic;
}

.site-wrapper {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem;
  position: relative;
}


/* ================================================================
   BUTTONS — game-style, not web-app-style
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  border: 2px solid var(--gold-dark);
  background: linear-gradient(180deg, #2a2010 0%, #1a1508 100%);
  color: var(--gold);
  font-family: 'MedievalSharp', serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  position: relative;
}

.btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: linear-gradient(180deg, #352818 0%, #2a1f14 100%);
  box-shadow: var(--glow-gold);
}

.btn:active {
  transform: scale(0.97);
}

/* Primary — gold filled */
.btn--primary {
  background: linear-gradient(180deg, var(--gold) 0%, #a88a3c 100%);
  color: #0d0a06;
  border-color: var(--gold);
  font-weight: 700;
}

.btn--primary:hover {
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
  color: #0d0a06;
}

/* Danger — blood red */
.btn--danger {
  border-color: var(--red);
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--danger);
}

/* Decree — royal seal button */
.btn--decree {
  background: linear-gradient(180deg, #6b1800 0%, #4a1000 100%);
  border: 2px solid #8b2500;
  color: var(--gold-bright);
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  padding: 0.8rem 2rem;
}

.btn--decree:hover {
  background: linear-gradient(180deg, #8b2500 0%, #6b1800 100%);
  border-color: var(--gold-dark);
  box-shadow: 0 0 20px rgba(139, 37, 0, 0.5), var(--glow-gold);
}

/* Small button */
.btn--sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

/* Large button */
.btn--lg {
  padding: 0.85rem 2rem;
  font-size: 1.1rem;
  width: 100%;
}

/* Icon-only button (copy, etc) */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: 'Crimson Text', serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}

.btn-icon:hover {
  color: var(--gold);
  border-color: var(--gold-dark);
}

/* Text link button */
.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Crimson Text', serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: var(--gold);
}

/* Submit button — the BIG action button */
.btn-submit {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-family: 'MedievalSharp', serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1rem;
  background: linear-gradient(180deg, var(--gold) 0%, #a88a3c 100%);
  color: #0d0a06;
  border: 2px solid var(--gold);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn-submit:hover {
  box-shadow: 0 0 30px rgba(201, 168, 76, 0.5), 0 4px 16px rgba(0,0,0,0.4);
  transform: translateY(-2px);
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
}

.btn-submit:hover::after {
  transform: translateX(100%);
}

.btn-submit:active {
  transform: translateY(0);
}


/* ================================================================
   FORM INPUTS
   ================================================================ */

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--bg-input);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.25);
}

select option {
  background: var(--bg-panel);
}

.input--code {
  font-family: 'MedievalSharp', monospace;
  letter-spacing: 0.15em;
  font-size: 1.1rem;
  text-align: center;
  text-transform: uppercase;
}


/* ================================================================
   TOP BAR — compact status strip
   ================================================================ */

.top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
}

/* Treasury gold fill behind the bar */
.top-bar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--treasury-pct, 0%);
  background: linear-gradient(90deg,
    rgba(107, 79, 16, 0.4) 0%,
    rgba(201, 168, 76, 0.2) 80%,
    rgba(232, 208, 136, 0.15) 100%
  );
  border-right: 1px solid rgba(201, 168, 76, 0.3);
  transition: width 0.8s ease;
  z-index: 0;
  pointer-events: none;
}

.top-bar > * {
  position: relative;
  z-index: 1;
}

.top-bar__players-toggle {
  display: none;
}

.top-bar__home {
  font-size: 1.1rem;
  opacity: 0.6;
  transition: opacity 0.15s;
  text-decoration: none;
}

.top-bar__home:hover {
  opacity: 1;
  text-decoration: none;
}

.top-bar__spacer {
  flex: 1;
}

/* Government badge — no pill shape, just text */
.gov-badge {
  font-family: 'MedievalSharp', serif;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.gov-badge--monarchy { color: var(--gold); }
.gov-badge--regency  { color: #b0b0b8; }
.gov-badge--democracy { color: #6aadff; }

/* Treasury compact */
.treasury-compact {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

/* Hide bar elements inside compact treasury (server sends these) */
.treasury-compact .treasury-bar,
.treasury-compact .treasury-milestone {
  display: none;
}

/* Turn timer */
.turn-timer {
  font-family: 'MedievalSharp', serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.timer-val {
  color: var(--gold-bright);
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-block;
  min-width: 2.2em;
  text-align: center;
}

/* Alias for server-rendered timer */
.timer-countdown {
  color: var(--gold-bright);
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-block;
  min-width: 2.2em;
  text-align: center;
}


/* ================================================================
   3-PANEL GAME GRID
   ================================================================ */

.game-grid {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 0;
  height: calc(100vh - 50px);
  overflow: hidden;
}

/* Panels — dark edges */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}

.panel--left {
  overflow-y: hidden;
}

.panel--right {
  border-right: none;
  border-left: 1px solid var(--border);
  overflow-y: hidden;
}

.panel__header {
  font-family: 'MedievalSharp', serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
}


/* ================================================================
   LEFT PANEL — Players & Invite
   ================================================================ */

.invite-strip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.invite-strip__label {
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.invite-strip__code {
  color: var(--gold);
  font-family: 'MedievalSharp', monospace;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  flex: 1;
}

/* Player list */
.player-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.player-row:last-child {
  border-bottom: none;
}

.player-row:hover {
  background: rgba(201, 168, 76, 0.04);
}

.player-row--you {
  background: rgba(201, 168, 76, 0.08);
  border-left: 2px solid var(--gold);
}

.player-row--dead {
  opacity: 0.35;
  text-decoration: line-through;
}

.player-nickname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-gold {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.player-status {
  font-size: 0.75rem;
}

/* Heraldic shield */
.player-shield {
  display: inline-block;
  width: 14px;
  height: 16px;
  clip-path: polygon(0 0, 100% 0, 100% 65%, 50% 100%, 0 65%);
  flex-shrink: 0;
}

.player-shield--king    { background: linear-gradient(180deg, var(--gold), #8a7030); }
.player-shield--prince  { background: linear-gradient(180deg, #7070c0, #404080); }
.player-shield--knight  { background: linear-gradient(180deg, #a0a0a8, #606068); }
.player-shield--citizen { background: linear-gradient(180deg, #6a8a50, #405030); }
.player-shield--peasant { background: linear-gradient(180deg, #8a7050, #5a4830); }

/* Role badge — compact, no pill */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  font-family: 'MedievalSharp', serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge--king    { color: var(--gold-bright); }
.role-badge--prince  { color: #9090d0; }
.role-badge--knight  { color: #b0b0b8; }
.role-badge--citizen { color: #7aaa60; }
.role-badge--peasant { color: var(--text-dim); }

/* Player list details (server wraps in <details>) */
.player-list__details {
  border: none;
  background: transparent;
}

.player-list__header {
  display: none;
}

.player-list__body {
  display: block;
}

/* Player count header */
.player-list__count {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.5rem 0.2rem;
}

/* Role section headers */
.role-section__header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.role-section__header:first-child {
  border-top: none;
}

.role-section__header--dead {
  opacity: 0.4;
}

.role-section__icon {
  font-size: 0.85rem;
  line-height: 1;
}

.role-section__label {
  flex: 1;
  font-family: 'MedievalSharp', serif;
  font-size: 0.75rem;
  color: var(--text);
}

.role-section__count {
  font-family: 'MedievalSharp', serif;
  font-size: 0.75rem;
  color: var(--gold-dark);
}

/* (Help moved to guide overlay — see GUIDE OVERLAY section below) */


/* ================================================================
   CENTER — GAME BOARD (the star of the show)
   ================================================================ */

.game-board {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(42, 31, 20, 0.5) 0%, transparent 60%),
    var(--bg-surface);
}

/* ── Dragon Event — DRAMATIC ───────────────────────────────────── */
.dragon-event {
  display: none;
}

.dragon-event:not(:empty) {
  display: block;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ff8855;
  background:
    radial-gradient(ellipse at center, rgba(139, 37, 0, 0.25) 0%, transparent 70%),
    var(--bg-panel);
  border: 2px solid var(--red);
  border-left: 4px solid var(--ember);
  animation: dragon-pulse 0.8s ease-in-out;
  box-shadow: var(--glow-fire), inset 0 0 40px rgba(204, 51, 0, 0.08);
  text-shadow: 0 0 12px rgba(255, 69, 0, 0.3);
  position: relative;
}

.dragon-event .dragon-icon {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: url('/static/icons/fire.png') center/contain no-repeat;
  vertical-align: middle;
  margin-right: 0.5rem;
  filter: drop-shadow(0 0 4px rgba(255, 69, 0, 0.5));
}

.dragon-event--bribed:not(:empty) {
  border-color: var(--gold-dark);
  border-left-color: var(--gold);
  color: var(--gold);
  text-shadow: none;
  background:
    radial-gradient(ellipse at center, rgba(201, 168, 76, 0.1) 0%, transparent 70%),
    var(--bg-panel);
  box-shadow: var(--glow-gold);
}

.dragon-event--attack:not(:empty) {
  border-color: var(--ember);
  color: #ff6633;
}

@keyframes dragon-pulse {
  0%   { transform: scale(1);    opacity: 0; }
  15%  { transform: scale(1.01); opacity: 1; box-shadow: 0 0 40px rgba(204,51,0,0.6); }
  100% { transform: scale(1);    box-shadow: var(--glow-fire), inset 0 0 40px rgba(204,51,0,0.08); }
}

/* Dragon cinematic overlay */
.dragon-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.game-page:has(#dragon-event:not(:empty)) .dragon-overlay {
  opacity: 1;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(139, 37, 0, 0.2) 100%);
  animation: dragon-vignette 3s ease-out forwards;
}

.game-page:has(.dragon-event--attack:not(:empty)) .game-grid {
  animation: screen-shake 0.4s ease-out;
}

@keyframes dragon-vignette {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes screen-shake {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(-3px, 2px); }
  30%  { transform: translate(3px, -2px); }
  45%  { transform: translate(-2px, -1px); }
  60%  { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}


/* ── Turn Result ───────────────────────────────────────────────── */
.turn-result {
  font-size: 0.95rem;
  animation: result-enter 0.4s ease-out;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--border-hi);
  background: rgba(22, 16, 8, 0.5);
}

.turn-result:empty {
  display: none;
}

.turn-result h3 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
}

.turn-result p {
  margin-bottom: 0.25rem;
}

.turn-result--good {
  border-left-color: var(--gold-dark);
}

.turn-result--bad {
  border-left-color: var(--danger);
  background: rgba(139, 37, 0, 0.06);
}

.turn-result--revolt {
  border-left-color: #ff9944;
}

.turn-result--death {
  border-left-color: var(--danger);
  background: rgba(139, 37, 0, 0.08);
}

@keyframes result-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Narrative Story Sections ──────────────────────────────────── */
.story-section {
  margin-bottom: 0.75rem;
}

.story-section:last-child {
  margin-bottom: 0;
}

.story-section--personal .story-text {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-bright);
}

.story-section--realm {
  border-top: 1px solid var(--border-hi);
  padding-top: 0.75rem;
}

.story-section__label {
  font-family: 'MedievalSharp', serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.story-section--realm .story-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

/* Inline text highlights used in story */
.text-gold {
  color: var(--gold-bright);
}

.text-tax {
  color: var(--gold);
}

.text-danger {
  color: var(--danger);
}

.text-dim {
  color: var(--text-dim);
  font-size: 0.85em;
}

.text-lg {
  font-size: 1.2rem;
  display: block;
  margin-top: 0.5rem;
  text-align: center;
}


/* ── Declaration Form — the main action center ─────────────────── */
.decl-form,
.declaration-form {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-hi);
  border-top: 3px solid var(--gold-dark);
  background:
    linear-gradient(180deg, rgba(42, 31, 20, 0.4) 0%, var(--bg-surface) 100%);
}

.decl-form h3,
.declaration-form h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Player identity bar — role + gold, prominent center display */
.player-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--gold-dark);
  background:
    linear-gradient(135deg, rgba(201, 168, 76, 0.08) 0%, rgba(201, 168, 76, 0.02) 100%);
}

.player-identity__role {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-identity__icon {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(201, 168, 76, 0.3));
}

.player-identity__label {
  font-family: 'MedievalSharp', serif;
  font-size: 1.3rem;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.player-identity__gold {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.player-identity__coin {
  display: block;
  width: 24px;
  height: 24px;
  background: url('/static/icons/gold-coin.png') center/contain no-repeat;
  flex-shrink: 0;
  filter: drop-shadow(0 0 3px rgba(201, 168, 76, 0.4));
}

.player-identity__amount {
  font-family: 'MedievalSharp', serif;
  font-size: 1.5rem;
  color: var(--gold-bright);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.25);
}

.player-identity__amount--debt {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(204, 51, 0, 0.3);
}

.player-identity__unit {
  font-family: 'MedievalSharp', serif;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Stepper (tax input) */
.stepper {
  display: flex;
  border: 1px solid var(--border-hi);
  overflow: hidden;
  background: var(--bg-input);
}

.stepper:focus-within {
  border-color: var(--gold-dark);
}

.stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  background: var(--bg-panel);
  border: none;
  color: var(--gold);
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.1s;
  font-family: 'MedievalSharp', serif;
  user-select: none;
}

.stepper__btn:hover {
  background: var(--gold-dark);
  color: var(--bg);
}

.stepper__btn--minus { border-right: 1px solid var(--border-hi); }
.stepper__btn--plus  { border-left: 1px solid var(--border-hi); }

.stepper__input {
  flex: 1;
  min-width: 0;
  border: none !important;
  text-align: center;
  font-size: 1.2rem;
  font-family: 'MedievalSharp', serif;
  font-weight: 700;
  color: var(--gold);
  background: transparent !important;
  box-shadow: none !important;
  -moz-appearance: textfield;
}

.stepper__input::-webkit-inner-spin-button,
.stepper__input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Action select */
.action-select {
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}

.action-select option:disabled {
  color: var(--text-dim);
  font-style: italic;
}

/* ── Action Button Cards ────────────────────────────────────────── */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: 'Crimson Text', serif;
}

.btn-action:hover {
  border-color: var(--gold-dark);
  background: rgba(201, 168, 76, 0.06);
}

.btn-action--active {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.12);
  box-shadow: inset 3px 0 0 var(--gold);
}

.btn-action--disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-action__icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 1.5em;
  text-align: center;
  line-height: 1;
}

.btn-action__body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.btn-action__title {
  font-family: 'MedievalSharp', serif;
  font-size: 0.9rem;
  color: var(--text-bright);
}

.btn-action--active .btn-action__title {
  color: var(--gold);
}

.btn-action__desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.3;
}

/* ── King Controls ─────────────────────────────────────────────── */
.king-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Toggle button row (tax rate 1x-4x) */
.btn-row {
  display: flex;
  gap: 0;
}

.btn-toggle {
  flex: 1;
  padding: 0.55rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-family: 'MedievalSharp', serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.btn-toggle:not(:last-child) {
  border-right: none;
}

.btn-toggle:hover {
  background: rgba(201, 168, 76, 0.06);
  color: var(--text);
}

.btn-toggle--active {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold);
  border-color: var(--gold-dark);
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* Collect/Bribe action buttons for King */
.btn-action--collect.btn-action--active {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.12);
  box-shadow: inset 3px 0 0 var(--gold);
}

.btn-action--bribe.btn-action--active {
  border-color: #cc4400;
  background: rgba(204, 68, 0, 0.1);
  box-shadow: inset 3px 0 0 var(--ember);
}

.btn-action--vote.btn-action--active {
  border-color: #6aadff;
  background: rgba(106, 173, 255, 0.08);
  box-shadow: inset 3px 0 0 #6aadff;
}

/* King dashboard */
.king-dashboard {
  border: 1px solid var(--gold-dark);
  border-left: 3px solid var(--gold);
  padding: 1rem;
  margin-top: 1rem;
  background: rgba(201, 168, 76, 0.03);
}

.king-dashboard h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.declaration-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.declaration-table th {
  font-family: 'MedievalSharp', serif;
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-hi);
  text-align: left;
}

.declaration-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.declaration-table tfoot td {
  padding-top: 0.5rem;
  border-bottom: none;
  border-top: 1px solid var(--gold-dark);
  color: var(--gold);
}


/* ================================================================
   RIGHT PANEL — Chat (always visible)
   ================================================================ */

.panel--right {
  display: flex;
  flex-direction: column;
}

.chat-log {
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Alias for server-rendered class */
.chat-messages {
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-message {
  line-height: 1.4;
  padding: 0.15rem 0;
}

.chat-message strong {
  color: var(--gold-dark);
}

.chat-message--system {
  font-style: italic;
  color: var(--text-dim);
  padding-left: 0.8rem;
  border-left: 2px solid var(--border-hi);
}

.chat-message.chat-message--self {
  color: var(--gold-light);
  font-weight: bold;
  font-style: normal;
  padding-left: 0.8rem;
  border-left: 2px solid var(--gold);
}

/* Chat filter bar */
.chat-filter {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0;
}

.chat-filter__btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.72rem;
  padding: 0.35rem 0.2rem;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-filter__btn:hover {
  color: var(--text);
  background: rgba(200, 176, 144, 0.05);
}

.chat-filter__btn--active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: rgba(201, 168, 76, 0.08);
}

/* Chat log wrapper — holds the SSE-replaced #chat-messages inside */
.chat-log-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

/* Filter modes — wrapper class hides child messages via descendant selectors */
.chat-wrap--system-only .chat-message:not(.chat-message--system) {
  display: none;
}

.chat-wrap--chat-only .chat-message--system {
  display: none;
}

.chat-wrap--hidden .chat-message {
  display: none;
}

.chat-input {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--gold-dark);
  padding: 0.5rem;
}

.chat-input input {
  flex: 1;
  border: 2px solid var(--gold-dark);
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  border-radius: 4px 0 0 4px;
}

.chat-input .btn {
  border: 2px solid var(--gold-dark);
  border-left: none;
  border-radius: 0 4px 4px 0;
}

/* Chat toggle btn (hidden on desktop, shown on mobile) */
.chat-toggle-btn {
  display: none;
}


/* ================================================================
   RESULT FLOW — visual turn outcome cards
   ================================================================ */

.result-flow {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-hi);
  animation: result-enter 0.35s ease-out both;
}

.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.2s; }

.result-card__icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 1.4em;
  text-align: center;
}

.result-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}

.result-card__label {
  font-family: 'MedievalSharp', serif;
  font-size: 0.82rem;
  color: var(--text);
}

.result-card__text {
  font-size: 0.95rem;
}

.result-card__amount {
  font-family: 'MedievalSharp', serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-left: auto;
  flex-shrink: 0;
}

.result-card__amount--positive {
  color: #6aad50;
  text-shadow: 0 0 6px rgba(106, 173, 80, 0.25);
}

.result-card__amount--negative {
  color: var(--danger);
}

.result-card--income  { border-left-color: #6aad50; }
.result-card--income.result-card--neutral { border-left-color: var(--text-dim); }
.result-card--income.result-card--neutral .result-card__amount { color: var(--text-dim); }
.result-card--tax     { border-left-color: var(--gold-dark); }
.result-card--tax .result-card__amount--negative { color: var(--gold); text-shadow: none; }
.result-card--penalty { border-left-color: var(--danger); background: rgba(204, 51, 0, 0.04); }
.result-card--death   { border-left-color: var(--danger); background: rgba(204, 51, 0, 0.06); padding: 0.75rem; }
.result-card--death .result-card__text { color: var(--danger); font-weight: 700; }


/* ================================================================
   GAME OVER
   ================================================================ */

.game-over--victory {
  text-align: center;
  padding: 3rem 2rem;
}

.game-over--victory::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.06) 0%, transparent 60%);
  pointer-events: none;
}

.victory-title {
  font-size: 2.2rem;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.4));
  animation: victory-glow 2s ease-in-out infinite alternate;
}

@keyframes victory-glow {
  from { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.3)); }
  to   { filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.6)); }
}

.victory-subtitle { color: var(--gold); font-size: 1.1rem; margin: 0.5rem 0 1.5rem; }

.hero-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.75rem auto 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 165, 0, 0.1) 100%);
  border: 2px solid var(--gold);
  border-radius: 0.75rem;
  max-width: 36rem;
}
.hero-banner__icon { font-size: 2rem; }
.hero-banner__text {
  color: var(--gold-bright);
  font-size: 1.15rem;
  line-height: 1.4;
}
.hero-banner__text em {
  color: #fff;
  font-style: normal;
  font-weight: 700;
}

.game-over--defeat {
  text-align: center;
  padding: 3rem 2rem;
}

.game-over--defeat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center bottom, rgba(139, 37, 0, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.defeat-title { font-size: 2.2rem; color: var(--danger); text-shadow: 0 0 20px rgba(204, 51, 0, 0.3); }
.defeat-subtitle { color: var(--text-dim); font-size: 1.1rem; margin: 0.5rem 0 1.5rem; }

/* Rank medals */
.rank { color: var(--text-dim); font-size: 0.85rem; min-width: 2em; font-family: 'MedievalSharp', serif; }
.rank--gold   { color: var(--gold-bright); text-shadow: 0 0 6px rgba(255, 215, 0, 0.4); font-weight: 700; }
.rank--silver { color: #c0c0c0; }
.rank--bronze { color: #cd7f32; }


/* ================================================================
   DEATH MEMORIAL — dramatic "you have perished" screen
   ================================================================ */

.death-memorial {
  text-align: center;
  padding: 2.5rem 2rem;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(139, 37, 0, 0.12) 0%, transparent 60%),
    linear-gradient(180deg, rgba(42, 31, 20, 0.4) 0%, var(--bg-surface) 100%);
}

.death-memorial__icon {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 20px rgba(204, 51, 0, 0.4));
  animation: skull-fade-in 1s ease-out;
}

@keyframes skull-fade-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.death-memorial__title {
  font-size: 1.8rem;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(204, 51, 0, 0.3);
  margin-bottom: 0.4rem;
  font-family: 'MedievalSharp', serif;
}

.death-memorial__epitaph {
  font-style: italic;
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.death-memorial__stats {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 320px;
  margin: 0 auto 2rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-hi);
  background: rgba(0, 0, 0, 0.3);
}

.death-stat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(42, 32, 24, 0.6);
}

.death-stat:last-child {
  border-bottom: none;
}

.death-stat__icon {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.death-stat__label {
  color: var(--text-dim);
  flex: 1;
  text-align: left;
}

.death-stat__value {
  color: var(--gold);
  font-family: 'MedievalSharp', serif;
  font-size: 1rem;
  text-align: right;
}

.death-memorial__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.death-memorial__btn {
  display: inline-block;
  text-decoration: none;
}


/* ================================================================
   EVENT TEXT
   ================================================================ */

.danger       { color: var(--danger); }
.event-revolt { color: #ff9944; font-weight: 600; }
.event-dragon { font-weight: 600; }
.event-win {
  color: var(--gold);
  font-size: 1.3rem;
  font-family: 'MedievalSharp', serif;
  text-align: center;
  padding: 1rem;
  text-shadow: 0 0 15px rgba(201, 168, 76, 0.4);
}


/* ================================================================
   CONNECTION BANNER
   ================================================================ */

.connection-banner {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: linear-gradient(135deg, #6b3410, #4b2008);
  color: var(--gold-bright);
  text-align: center;
  padding: 0.4rem 1.5rem;
  font-family: 'MedievalSharp', serif;
  font-size: 0.85rem;
  border: 1px solid var(--gold-dark);
  animation: banner-pulse 2s infinite;
}

@keyframes banner-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}


/* ================================================================
   LOBBY PAGE
   ================================================================ */

.lobby-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  min-height: 100vh;
  padding: 2rem 1rem;
  position: relative;
}

/* Vignette */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(10, 6, 2, 0.7) 100%);
}

/* Title — pushed below splash image on all pages */
.lobby-header {
  text-align: center;
  padding: clamp(200px, 30vw, 380px) 0 2rem;
}

/* Splash hero variant — lobby-specific tweaks */
.lobby-header--splash {
  padding-bottom: 0;
  width: 100%;
  position: relative;
  z-index: 1;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* Parallax background */
.lobby-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg) url('/static/dragon-splash.webp') top center / contain no-repeat;
  z-index: -1;
}
.lobby-page::after {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(13,10,6,0) 0%,
    rgba(13,10,6,0.1) 30%,
    rgba(13,10,6,0.55) 48%,
    rgba(13,10,6,0.88) 58%,
    rgba(13,10,6,1) 68%
  );
  z-index: -1;
}

.lobby-header__crest {
  width: 50px;
  height: 50px;
  margin: 0 auto 0.75rem;
  background: radial-gradient(circle, var(--gold-dark) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.4;
}

.game-title {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  text-shadow: 0 0 40px rgba(201, 168, 76, 0.3), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.04em;
}

.game-title__icon {
  display: inline-block;
  animation: dragon-float 4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(255, 69, 0, 0.4));
}

.game-title__text {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes dragon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.game-subtitle-line {
  width: 200px;
  height: 1px;
  margin: 0.75rem auto;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.game-subtitle {
  color: var(--text);
  font-style: italic;
  font-size: 1.15rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

.version-badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.7rem;
  font-family: 'Crimson Text', serif;
  font-size: 0.8rem;
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  border-radius: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Lobby main content */
.lobby-main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
  max-width: 900px;
}

/* Lobby sections */
.lobby-section {
  padding: 1.5rem;
  border: 1px solid var(--border-hi);
  background: var(--bg-panel);
}

/* Section heading */
.section-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.6rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.section-heading__ornament {
  display: inline-block;
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

/* Lobby columns */
.lobby-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* How to play grid */
@keyframes htp-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes htp-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(201, 168, 76, 0.3)); }
  50%      { filter: drop-shadow(0 0 12px rgba(201, 168, 76, 0.6)); }
}

@keyframes htp-fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.how-to-play__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.how-to-play__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  padding: 1.5rem 1.25rem;
  background: linear-gradient(160deg, rgba(28, 22, 16, 0.8), rgba(13, 10, 6, 0.6));
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
  animation: htp-fadeUp 0.6s ease-out both;
}

.how-to-play__item:nth-child(2) { animation-delay: 0.1s; }
.how-to-play__item:nth-child(3) { animation-delay: 0.2s; }
.how-to-play__item:nth-child(4) { animation-delay: 0.3s; }
.how-to-play__item:nth-child(5) { animation-delay: 0.4s; }
.how-to-play__item:nth-child(6) { animation-delay: 0.5s; }

.how-to-play__item:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(201, 168, 76, 0.15);
}

.how-to-play__icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: htp-float 3s ease-in-out infinite, htp-glow 3s ease-in-out infinite;
  margin-bottom: 0.25rem;
}

.how-to-play__item:nth-child(2) .how-to-play__icon { animation-delay: 0.4s; }
.how-to-play__item:nth-child(3) .how-to-play__icon { animation-delay: 0.8s; }
.how-to-play__item:nth-child(4) .how-to-play__icon { animation-delay: 1.2s; }
.how-to-play__item:nth-child(5) .how-to-play__icon { animation-delay: 1.6s; }
.how-to-play__item:nth-child(6) .how-to-play__icon { animation-delay: 2.0s; }

.how-to-play__item strong {
  color: var(--gold-light);
  font-family: 'MedievalSharp', serif;
  font-size: 1.5rem;
}

.how-to-play__item p {
  font-size: 1.1rem;
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}

a.how-to-play__item {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.how-to-play__more {
  margin-top: auto;
  padding-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--gold);
  opacity: 0.55;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

a.how-to-play__item:hover .how-to-play__more {
  opacity: 1;
}

.how-to-play__footer {
  text-align: center;
  margin: 1.5rem 0 0.25rem;
}

.how-to-play__link {
  color: var(--gold);
  font-size: 1.05rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
  padding-bottom: 2px;
}

.how-to-play__link:hover {
  color: #fff;
  border-bottom-style: solid;
}

/* Lobby cards — decree / notice / registry / parchment */
.lobby-card {
  padding: 1.5rem;
  border: 1px solid var(--border-hi);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-card h2 {
  font-size: 1.15rem;
}

.lobby-card--full {
  width: 100%;
}

/* Nickname section */
.lobby-nickname {
  text-align: center;
  padding: 0;
  overflow: hidden;
}

/* Collapsed toggle bar */
.nickname-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  font-size: 1rem;
  transition: color 0.2s;
}
.nickname-toggle:hover {
  color: var(--gold);
}
.nickname-toggle__label {
  font-size: 0.9rem;
}
.nickname-toggle__name {
  color: var(--gold);
  font-size: 1.1rem;
}
.nickname-toggle__arrow {
  font-size: 0.8rem;
  transition: transform 0.25s;
  display: inline-block;
}
.nickname-toggle__arrow.rotated {
  transform: rotate(180deg);
}

/* Expandable drawer */
.nickname-drawer {
  padding: 0 1.5rem 1rem;
}

.nickname-form {
  max-width: 400px;
  margin: 0 auto;
}
.nickname-row {
  display: flex;
  gap: 0.5rem;
}
.nickname-input {
  flex: 1;
  background: rgba(0,0,0,0.35);
  border: 2px solid var(--gold);
  border-radius: 6px;
  color: var(--text);
  font-family: 'MedievalSharp', cursive;
  font-size: 1.3rem;
  padding: 0.6rem 1rem;
  text-align: center;
}
.nickname-input:focus {
  outline: none;
  border-color: #e0c060;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.3);
}
.nickname-save {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
}
.nickname-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.4rem;
}
.nickname-saved {
  display: inline-flex;
  align-items: center;
  color: #6a6;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 0.6rem;
  white-space: nowrap;
  animation: nick-flash 2s ease-out forwards;
}
@keyframes nick-flash {
  0%   { opacity: 0; transform: translateY(3px); }
  15%  { opacity: 1; transform: translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

.lobby-card--parchment {
  background: var(--bg-panel);
  border-color: var(--gold-dark);
}

.lobby-card--decree {
  border: 1px solid var(--red);
  border-top: 3px solid var(--red);
  position: relative;
}

.lobby-card--notice {
  border: 1px solid var(--border-hi);
}

.lobby-card--registry {
  border-color: var(--border-hi);
}

/* Found a Kingdom — central prominent form */
.lobby-found {
  text-align: center;
}
.found-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 540px;
  margin: 0 auto;
}
.found-form__fields {
  display: flex;
  gap: 1rem;
}
.found-form__fields .form-group {
  flex: 1;
  text-align: left;
}
.found-form__btn {
  padding: 0.75rem 2rem;
  font-size: 1.15rem;
}

/* Private multiplayer toggle — custom ornate checkbox */
.mp-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  margin: 0 auto;
  max-width: 440px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.mp-toggle:hover {
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
}
.mp-toggle__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.mp-toggle__box {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--gold-dark);
  border-radius: 3px;
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mp-toggle:hover .mp-toggle__box {
  border-color: var(--gold);
}
.mp-toggle__input:focus-visible + .mp-toggle__box {
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.35);
}
.mp-toggle__input:checked + .mp-toggle__box {
  background: var(--gold);
  border-color: var(--gold);
}
.mp-toggle__input:checked + .mp-toggle__box::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid #1a0f08;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.mp-toggle__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: 0.95rem;
}
.mp-toggle__text strong {
  font-family: 'MedievalSharp', serif;
  color: var(--gold);
  font-weight: normal;
  font-size: 1rem;
}
.mp-toggle__hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Join code bar inside Active Kingdoms */
.join-code-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.join-code-bar__label {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.join-code-bar__input {
  flex: 0 1 180px;
  min-width: 0;
}

/* Decree ribbon */
.decree-ribbon {
  position: absolute;
  top: -1px;
  right: 16px;
  width: 24px;
  height: 40px;
  background: linear-gradient(180deg, var(--red), #4a1000);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  z-index: 1;
}

/* Notice pin */
.notice-pin {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #8b6914, #5a4010);
  border-radius: 50%;
  z-index: 1;
}


/* ================================================================
   CHANGELOG + ROADMAP
   ================================================================ */

.lobby-columns--info {
  margin-top: 1rem;
}

.lobby-card--scroll {
  max-height: 400px;
  overflow-y: auto;
}

/* Changelog */
.changelog__entry {
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.changelog__entry:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.changelog__version {
  font-family: 'MedievalSharp', serif;
  color: var(--gold);
  font-size: 1rem;
  margin-right: 0.5rem;
}

.changelog__date {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.changelog ul, .roadmap ul {
  margin: 0.5rem 0 0 1.2rem;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}

.changelog li::marker, .roadmap li::marker {
  color: var(--gold-dark);
}

/* Roadmap */
.roadmap__item {
  margin-bottom: 1.2rem;
}

.roadmap__item:last-child {
  margin-bottom: 0;
}

.roadmap__label {
  display: inline-block;
  font-family: 'MedievalSharp', serif;
  font-size: 0.9rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.15rem;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.roadmap__item--next .roadmap__label {
  color: var(--gold);
  border-color: var(--gold-dark);
}

/* ================================================================
   FOOTER — Illuminated Colophon
   Styled like the signed end of a medieval manuscript.
   ================================================================ */

.site-footer {
  position: relative;
  margin-top: 5rem;
  padding: 4rem 1.5rem 3rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  background:
    radial-gradient(ellipse at top, rgba(201, 168, 76, 0.035), transparent 60%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.25));
}

/* Top-centered ornament, cut into the border */
.site-footer::before {
  content: "⚜ ✦ ⚜";
  position: absolute;
  top: -0.9rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 1.25rem;
  background: var(--bg);
  color: var(--gold-dark);
  font-size: 0.95rem;
  letter-spacing: 0.6em;
}

.site-footer__grid {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem 3rem;
  align-items: start;
}

@media (min-width: 780px) {
  .site-footer__grid {
    grid-template-columns: 1fr 1.1fr 1fr;
    text-align: left;
  }
}

.site-footer__col {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.site-footer__heading {
  font-family: 'MedievalSharp', serif;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
  text-wrap: balance;
  margin-bottom: 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.site-footer__heading::before,
.site-footer__heading::after {
  content: "";
  width: 1.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.site-footer__title {
  font-family: 'MedievalSharp', serif;
  font-size: 1.35rem;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  text-wrap: balance;
}

.site-footer__title .version {
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  margin-left: 0.3rem;
}

.site-footer__subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.05em;
}

.site-footer__credit {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

.site-footer__credit-link {
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(201, 168, 76, 0.35);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.25s ease, text-decoration-color 0.25s ease, text-shadow 0.25s ease;
}

.site-footer__credit-link:hover,
.site-footer__credit-link:focus-visible {
  color: var(--gold-bright);
  text-decoration-color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
  outline: none;
}

.site-footer__credit-rocket {
  display: inline-block;
  transition: transform 0.35s ease;
}

.site-footer__credit-link:hover .site-footer__credit-rocket {
  transform: translate(2px, -3px) rotate(-12deg);
}

.site-footer__hint {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.site-footer__hint a {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(201, 168, 76, 0.4);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-footer__hint a:hover,
.site-footer__hint a:focus-visible {
  color: var(--gold-light);
  text-decoration-color: var(--gold);
  outline: none;
}


/* Feedback forms */
.feedback-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 440px;
}

.feedback-form__input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.95rem;
}

.feedback-form__input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.feedback-form__input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.25);
  outline: none;
}

.feedback-status {
  font-size: 0.9rem;
  color: var(--gold);
  margin-top: 0.5rem;
  text-align: center;
  min-height: 1.2em;
}

.feedback-compact {
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
}

.feedback-compact__input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  border-radius: var(--radius);
}

.feedback-compact__input:focus {
  border-color: var(--gold-dark);
  outline: none;
}

/* Submit error */
.submit-error {
  text-align: center;
  padding: 0.5rem;
  color: var(--danger);
  font-size: 0.85rem;
  animation: fade-in 0.3s;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ================================================================
   VIBE JAM PORTALS
   ================================================================ */

.portal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.4rem;
  border: 1px solid #6a3fbf;
  border-radius: 4px;
  background: linear-gradient(135deg, rgba(106, 63, 191, 0.15), rgba(147, 51, 234, 0.1));
  color: #c4a6f0;
  text-decoration: none;
  font-family: 'MedievalSharp', serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  transition: all 0.25s ease;
}

.portal-link:focus-visible {
  outline: 2px solid #9333ea;
  outline-offset: 3px;
}

.portal-link:hover {
  border-color: #9333ea;
  background: linear-gradient(135deg, rgba(106, 63, 191, 0.3), rgba(147, 51, 234, 0.2));
  color: #e0ccff;
  box-shadow: 0 0 12px rgba(147, 51, 234, 0.3);
}

.portal-link__icon {
  font-size: 1.2rem;
  animation: portal-spin 3s linear infinite;
}

@keyframes portal-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.portal-link__text {
  letter-spacing: 0.03em;
}

.portal-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem;
  flex-wrap: wrap;
}

.portal-link--return {
  border-color: #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
  color: #93c5fd;
}

.portal-link--return:hover {
  border-color: #60a5fa;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(59, 130, 246, 0.15));
  color: #bfdbfe;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}


/* ================================================================
   PUBLIC GAMES LIST
   ================================================================ */

#public-games {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.game-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.game-row:hover {
  border-color: var(--gold-dark);
}

.game-row__info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.game-row__name {
  font-family: 'MedievalSharp', serif;
  color: var(--text-bright);
}

.game-row__meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.btn-join {
  font-family: 'MedievalSharp', serif;
  letter-spacing: 0.05em;
}


/* ================================================================
   TREASURY (full version, for non-compact display)
   ================================================================ */

.treasury-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
}

.treasury-amount { display: block; }

.treasury-display--compact {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  white-space: nowrap;
}

.treasury-display--compact .treasury-amount {
  font-size: 0.8rem;
  color: var(--gold);
}

.treasury-display--compact .treasury-bar,
.treasury-display--compact .treasury-milestone {
  display: none;
}

.treasury-bar {
  margin-top: 0.5rem;
  height: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.treasury-bar__fill {
  height: 100%;
  background: linear-gradient(180deg, #e8d088 0%, #c9a84c 40%, #8a7030 100%);
  transition: width 0.6s ease;
  position: relative;
}

.treasury-bar__fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
  background-size: 200% 100%;
  animation: gold-shimmer 3s infinite;
}

@keyframes gold-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.treasury-milestone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(201, 168, 76, 0.25);
}

.treasury-milestone::after {
  content: attr(data-label);
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  color: var(--text-dim);
  white-space: nowrap;
}


/* ================================================================
   SCROLLBARS
   ================================================================ */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hi); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }


/* ================================================================
   LOBBY LIVE (ready states)
   ================================================================ */

.ready-indicator   { font-size: 0.8rem; }
.ready-yes         { color: #6aad50; }
.ready-no          { color: var(--text-dim); }


/* ================================================================
   RESPONSIVE
   ================================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .game-grid {
    grid-template-columns: 200px 1fr 240px;
  }
}

/* Small tablet / large phone */
@media (max-width: 768px) {
  .site-wrapper {
    padding: 0;
  }

  .game-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr minmax(160px, 28vh);
    height: calc(100vh - 50px);
    margin-top: 50px;
  }

  .panel--left {
    position: fixed;
    top: 50px;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
    overflow-y: auto;
  }

  .panel--left--open {
    transform: translateX(0);
  }

  .panel-backdrop {
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 19;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(1px);
  }

  .top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 21;
  }

  .top-bar__players-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    height: 32px;
    padding: 0 0.5rem;
    flex-shrink: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border-hi);
    background: transparent;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-family: 'MedievalSharp', cursive;
    cursor: pointer;
    white-space: nowrap;
  }

  .top-bar__players-toggle:hover,
  .top-bar__players-toggle--active {
    color: var(--gold);
    border-color: var(--gold-dark);
    background: rgba(201, 168, 76, 0.15);
  }

  .panel--right {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .panel--right > .panel__header {
    display: none;
  }

  .panel--right > .feedback-compact,
  .panel--right > .feedback-status {
    display: none;
  }

  .game-board {
    padding: 1rem;
  }

  .vignette {
    background: radial-gradient(ellipse at center, transparent 60%, rgba(10, 6, 2, 0.4) 100%);
  }

  .lobby-columns {
    grid-template-columns: 1fr;
  }

  .found-form {
    flex-direction: column;
    align-items: stretch;
  }
  .found-form__fields {
    flex-direction: column;
  }

  .join-code-bar {
    flex-wrap: wrap;
  }

  .how-to-play__grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Buttons touch targets */
  .btn {
    min-height: 44px;
    padding: 0.6rem 1.2rem;
  }

  input[type="text"],
  input[type="number"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .declaration-form .form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    cursor: pointer;
  }

  .declaration-form input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .stepper__btn {
    width: 52px;
    min-height: 44px;
  }
}

/* Phone */
@media (max-width: 480px) {
  html { font-size: 15px; }

  .top-bar {
    padding: 0.3rem 0.5rem;
    gap: 0.4rem;
    font-size: 0.8rem;
  }

  .gov-badge { font-size: 0.7rem; }
  .treasury-compact { font-size: 0.7rem; }
  .treasury-display--compact .treasury-amount { font-size: 0.7rem; }
  .turn-timer { font-size: 0.8rem; }
  .timer-val, .timer-countdown { font-size: 0.95rem; }

  .game-title { font-size: clamp(1.8rem, 9vw, 3rem); }

  .lobby-page { padding: 1rem 0.5rem; gap: 1.5rem; }
  .lobby-card { padding: 1rem; }

  .game-board { padding: 0.75rem; }
  .decl-form, .declaration-form { padding: 1rem; }

  .dragon-event:not(:empty) {
    font-size: 1rem;
    padding: 1rem;
  }

  .player-purse__amount { font-size: 1.1rem; }
  .player-purse { padding: 0.5rem 0.75rem; }

  .result-card { padding: 0.4rem 0.6rem; }
  .result-card__icon { font-size: 1.1rem; }
  .result-card__amount { font-size: 1rem; }

  .lobby-header { padding-top: clamp(160px, 28vw, 300px); padding-bottom: 1rem; }
  .lobby-header__crest { width: 35px; height: 35px; }
  .decree-ribbon { width: 20px; height: 34px; right: 12px; }
}

/* ================================================================
   HELP BUTTON — prominent "?" in top bar
   ================================================================ */

.top-bar__help {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold-bright);
  font-family: 'MedievalSharp', serif;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.top-bar__help:hover {
  background: rgba(201, 168, 76, 0.35);
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.4);
  transform: scale(1.1);
}

/* Pulsing glow animation for first 30 seconds to draw attention */
@keyframes help-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0); }
  50% { box-shadow: 0 0 0 6px rgba(201, 168, 76, 0.3); }
}

.top-bar__help {
  animation: help-pulse 2s ease-in-out 5;
}


/* ================================================================
   TOOLTIPS — native title attribute, no custom CSS needed.
   Browser handles rendering. Works on mobile with long-press.
   ================================================================ */


/* ================================================================
   GUIDE OVERLAY — the "How to Play" panel
   ================================================================ */

.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}

.guide-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.guide-panel {
  position: relative;
  width: 90%;
  max-width: 560px;
  max-height: calc(100vh - 100px);
  background: var(--bg-panel);
  border: 1px solid var(--gold-dark);
  border-top: 3px solid var(--gold);
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8), var(--glow-gold);
  animation: guide-enter 0.25s ease-out;
}

@keyframes guide-enter {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.guide-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  z-index: 1;
}

.guide-panel__header h2 {
  font-size: 1.3rem;
  margin: 0;
}

.guide-panel__close {
  background: none;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.guide-panel__close:hover {
  color: var(--text-bright);
  border-color: var(--gold-dark);
}

.guide-panel__body {
  padding: 1.25rem;
}

.guide-section {
  margin-bottom: 1.5rem;
}

.guide-section:last-child {
  margin-bottom: 0;
}

.guide-section h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--gold);
}

.guide-section p,
.guide-section li {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

.guide-section ol,
.guide-section ul {
  padding-left: 1.2rem;
}

.guide-section ol li {
  margin-bottom: 0.5rem;
}

.guide-section strong {
  color: var(--gold-light);
}

/* Roles list in guide */
.guide-roles {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.guide-role {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.25rem 0;
}

.guide-role span:first-child {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.guide-role strong {
  color: var(--gold);
  min-width: 5rem;
}


/* ================================================================
   RESPONSIVE — guide overlay + help + tooltips
   ================================================================ */

@media (max-width: 768px) {
  .guide-panel {
    width: 95%;
    max-height: calc(100vh - 80px);
  }

  .guide-overlay {
    padding-top: 48px;
  }

  .top-bar__help {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
  }
}


/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ================================================================
   INVENTORY SECTION — bow parts + followers display
   ================================================================ */

.inventory-section {
  background: linear-gradient(135deg, #1a1205 0%, #120e06 100%);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.inventory-section__title {
  font-family: 'MedievalSharp', serif;
  color: var(--gold-dark);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
  color: var(--text-bright);
}

.inventory-item__icon {
  font-size: 1rem;
  flex-shrink: 0;
  min-width: 1.5rem;
  text-align: center;
}

.inventory-item__label {
  color: var(--gold);
}

/* ================================================================
   PAWN SHOP — lombard / item marketplace
   ================================================================ */

.pawn-shop {
  background: linear-gradient(135deg, #18100a 0%, #100c06 100%);
  border: 1px solid #3a2c1a;
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-top: 0.75rem;
}

.pawn-shop__title {
  font-family: 'MedievalSharp', serif;
  color: var(--gold);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.pawn-shop__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.pawn-shop__item:last-child {
  border-bottom: none;
}

.pawn-shop__icon {
  font-size: 1rem;
  flex-shrink: 0;
  min-width: 1.5rem;
  text-align: center;
}

.pawn-shop__name {
  flex: 1;
  color: var(--text-bright);
}

.pawn-shop__buy {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
}

.pawn-shop__buy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ================================================================
   SLAY DRAGON BUTTON — dramatic gold/red gradient
   ================================================================ */

.btn-action.btn-action--slay {
  background: linear-gradient(135deg, #5a1000 0%, #6b3a10 50%, #5a1000 100%);
  border-color: var(--gold);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  box-shadow: 0 0 16px rgba(201, 168, 76, 0.3), inset 0 0 8px rgba(255, 100, 0, 0.2);
  font-size: 1.05rem;
  animation: slay-pulse 2s ease-in-out infinite;
}

.btn-action.btn-action--slay:hover {
  background: linear-gradient(135deg, #7a1500 0%, #8a5020 50%, #7a1500 100%);
  box-shadow: 0 0 28px rgba(255, 215, 0, 0.5), 0 0 12px rgba(255, 69, 0, 0.4);
  border-color: var(--gold-bright);
  transform: scale(1.02);
}

.btn-action.btn-action--slay .btn-action__title {
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.btn-action.btn-action--slay .btn-action__desc {
  color: #ede0c8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

@keyframes slay-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(201, 168, 76, 0.3), inset 0 0 8px rgba(255, 100, 0, 0.2); }
  50%       { box-shadow: 0 0 28px rgba(255, 215, 0, 0.5), inset 0 0 14px rgba(255, 69, 0, 0.3); }
}

/* ================================================================
   FOREST NARRATIVE — turn result forest events
   ================================================================ */

.turn-result--death .story-text strong.text-danger {
  font-size: 1.05rem;
}

.story-text .text-gold {
  color: var(--gold-bright);
  font-weight: 600;
}

/* Dragon slain — huge announcement */
.text-lg {
  font-size: 1.15rem;
  display: block;
  text-align: center;
  padding: 0.5rem 0;
  letter-spacing: 0.03em;
}

/* ================================================================
   PLAYER FOLLOWERS — follower icons in player grid
   ================================================================ */

.player-followers {
  font-size: 0.75rem;
  letter-spacing: -0.1em;
  vertical-align: middle;
  margin-left: 0.15rem;
  opacity: 0.85;
  cursor: default;
}

/* ── X Login Button ─────────────────────────────────────────────── */

.btn--x {
  background: #000;
  color: #fff;
  border: 1px solid #333;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.btn--x:hover {
  background: #1a1a1a;
  border-color: #555;
}

/* X inline link (inside nickname drawer) */
.x-link-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-decoration: none;
  margin-top: 0.5rem;
  transition: color 0.2s;
}
.x-link-inline:hover {
  color: var(--gold-light);
}
.x-link-inline svg {
  opacity: 0.6;
}
.x-link-inline:hover svg {
  opacity: 1;
}

/* X badge in nickname toggle (logged-in) */
.nickname-toggle__x {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: normal;
  margin-left: 0.5rem;
}

.x-login-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}
.x-login-cta--game-over {
  margin: 1.5rem auto 0;
  max-width: 500px;
}
.x-login-cta__icon {
  color: #e0d5c0;
  flex-shrink: 0;
}
.x-login-cta__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.x-login-cta__text strong {
  color: var(--gold-light);
  font-size: 0.9rem;
}
.x-login-cta__text span {
  color: var(--text-dim);
  font-size: 0.8rem;
}
.x-login-cta__btn {
  flex-shrink: 0;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
}

.x-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
}
.x-profile-badge__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold-dark);
}
.x-profile-badge__name {
  color: var(--gold-light);
  font-weight: 600;
}

.flash-message {
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  animation: flash-fade 5s forwards;
}
.flash-message--success {
  background: rgba(34, 139, 34, 0.2);
  border: 1px solid rgba(34, 139, 34, 0.4);
  color: #7cfc7c;
}
.flash-message--error {
  background: rgba(200, 50, 50, 0.2);
  border: 1px solid rgba(200, 50, 50, 0.4);
  color: #ff8888;
}
@keyframes flash-fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Leaderboard & Profile ──────────────────────────────────────────────────── */

.lobby-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: center;
}

.lb-back-btn {
  margin-top: 0.5rem;
}

.lb-tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.lb-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.lb-tab:hover {
  color: var(--text);
}
.lb-tab--active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}

.lb-table-wrap {
  overflow-x: auto;
}
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.lb-table th {
  text-align: left;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.lb-table tbody tr:hover {
  background: rgba(201, 168, 76, 0.05);
}
.lb-rank {
  width: 2.5rem;
  text-align: center;
}
.lb-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
}
.lb-gold {
  color: var(--gold-light);
  font-weight: 600;
}
.lb-dim {
  color: var(--text-dim);
  font-size: 0.85rem;
  white-space: nowrap;
  width: 1%;
}
.lb-empty {
  text-align: center;
  padding: 2rem;
}
.lb-player-link {
  color: var(--text-bright);
  text-decoration: none;
}
.lb-player-link:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

.lb-row--you {
  background: rgba(201, 168, 76, 0.08);
}
.lb-row--you td {
  color: var(--gold-light);
}
.lb-row--top3 td {
  color: var(--text-bright);
}

/* Profile page */

.profile-x {
  color: var(--text-dim);
}
.profile-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: center;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  padding: 0.5rem 0;
}
.profile-stat {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.profile-stat--gold {
  border-color: var(--gold-dark);
}
.profile-stat__value {
  display: block;
  font-family: 'MedievalSharp', cursive;
  font-size: 1.8rem;
  color: var(--text-bright);
  line-height: 1.2;
}
.profile-stat--gold .profile-stat__value {
  color: var(--gold-light);
}
.profile-stat__label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.profile-row--won td:first-child {
  border-left: 3px solid var(--gold-dark);
}
.profile-row--lost td:first-child {
  border-left: 3px solid var(--red);
}

.profile-outcome {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.profile-outcome--won { color: var(--gold-light); }
.profile-outcome--lost { color: #cc5544; }
.profile-outcome--timeout { color: var(--text-dim); }

.profile-slayer {
  margin-left: 0.25rem;
  font-size: 1rem;
}
.profile-fn {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-left: 0.25rem;
}

/* Achievement toast */
.achievement-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #1a1408, #2a1c10);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  box-shadow: var(--glow-gold), 0 4px 20px rgba(0,0,0,0.6);
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s, transform 0.4s;
  max-width: 360px;
  pointer-events: none;
}
.achievement-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.achievement-toast__icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.achievement-toast__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.achievement-toast__body strong {
  color: var(--gold-light);
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1rem;
}
.achievement-toast__body span {
  color: var(--text);
  font-size: 0.85rem;
}

/* Achievement grid (profile) */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.achievement-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}
.achievement-card--earned {
  border-color: var(--gold-dark);
}
.achievement-card--locked {
  opacity: 0.4;
}
.achievement-card__icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.achievement-card__info {
  display: flex;
  flex-direction: column;
}
.achievement-card__name {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-bright);
  font-size: 0.95rem;
}
.achievement-card--locked .achievement-card__name {
  color: var(--text-dim);
}
.achievement-card__desc {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.achievement-card__date {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* Achievement progress bar */
.achievement-progress {
  width: 100%;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 0.25rem;
  overflow: hidden;
}
.achievement-progress__fill {
  height: 100%;
  background: var(--gold-dark);
  border-radius: 2px;
  transition: width 0.3s;
}


/* ═══════════════════════════════════════════════════════════════════
   FOREST MAP MINIGAME
   ═══════════════════════════════════════════════════════════════════ */

.forest-map-wrap {
  width: 100%;
  max-width: 600px;
  margin: 1rem auto;
}

.forest-map--hidden {
  display: none;
}

.forest-map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.forest-title {
  font-family: 'MedievalSharp', cursive;
  color: var(--gold);
  font-size: 1rem;
  text-shadow: 0 0 12px rgba(201, 168, 76, 0.2);
}

.forest-stats {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.forest-map-container {
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  background: #0d1a0d;
}

.forest-map {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}

.forest-map .area {
  fill: rgba(8, 16, 8, 0.7);
  stroke: rgba(80, 110, 70, 0.4);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.4s ease, stroke 0.3s ease, stroke-width 0.15s ease, opacity 0.4s ease;
}

.forest-map .area:hover {
  fill: rgba(15, 30, 15, 0.45);
  stroke: rgba(80, 130, 60, 0.7);
}

.forest-map .area.selected {
  fill: rgba(30, 70, 30, 0.5);
  stroke: #5a9a5a;
  stroke-width: 2.5;
  animation: pulse-forest-selected 1.2s ease-in-out infinite alternate;
}

.forest-map .area.empty {
  fill: rgba(10, 20, 10, 0.08);
  stroke: rgba(80, 110, 70, 0.25);
  stroke-width: 0.8;
  cursor: default;
}
.forest-map .area.empty:hover {
  fill: rgba(10, 20, 10, 0.08);
  stroke: rgba(80, 110, 70, 0.25);
}

.forest-map .area.found {
  fill: rgba(201, 168, 76, 0.35);
  stroke: #ffd700;
  stroke-width: 2;
  cursor: default;
  filter: url(#gold-glow);
  animation: glow-forest-gold 2s ease-in-out infinite alternate;
}
.forest-map .area.found:hover {
  fill: rgba(201, 168, 76, 0.35);
}

@keyframes pulse-forest-selected {
  from { stroke-opacity: 0.6; fill-opacity: 0.8; }
  to { stroke-opacity: 1; fill-opacity: 1; }
}

@keyframes glow-forest-gold {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

.forest-map .part-icon {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: drop-shadow(0 0 6px rgba(201, 168, 76, 0.8));
}
.forest-map .part-icon.visible {
  opacity: 1;
}

.forest-map-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.85rem;
}

.forest-clicks {
  color: var(--text-dim);
}

.forest-held {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--gold);
  font-size: 0.85rem;
}

.forest-held-icon {
  width: 20px;
  height: 36px;
  filter: drop-shadow(0 0 4px rgba(201, 168, 76, 0.6));
}

/* Mobile responsive */
@media (max-width: 600px) {
  .forest-map-wrap {
    margin: 0.5rem auto;
  }
  .forest-map-header,
  .forest-map-footer {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
  .forest-title {
    font-size: 0.9rem;
  }
}

/* ── Knight glory pip + injury banner (V5-Tuned tournament) ── */
.knight-glory {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  margin: 0.5rem 0;
  background: rgba(245, 212, 133, 0.08);
  border: 1px solid rgba(245, 212, 133, 0.25);
  border-radius: 4px;
  font-size: 0.9rem;
}
.knight-glory__icon { font-size: 1.1rem; }
.knight-glory__label {
  color: #d4b87a;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 0.75rem;
}
.knight-glory__pip {
  margin-left: auto;
  font-family: "SF Mono", monospace;
  color: #f5d485;
  font-weight: bold;
}
.knight-injury {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  margin: 0.5rem 0;
  background: rgba(192, 57, 43, 0.15);
  border-left: 3px solid #c0392b;
  border-radius: 4px;
  color: #e8866d;
  font-size: 0.9rem;
}
.knight-injury__icon { font-size: 1.2rem; }
.knight-injury__text b { color: #f5d485; }
