/* ============================================================
   TIDES OF VALOR — Master Stylesheet
   Nautical / Maritime Fantasy Theme
   ============================================================ */

/* ── Landscape gate (battle requires landscape) ──────────── */
.rotate-gate {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #142844 0%, #0a1628 100%);
  padding: 24px;
  text-align: center;
}
.rotate-gate.visible { display: flex; }

.rotate-gate-inner {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.rotate-gate-icon {
  width: 88px;
  height: 88px;
  animation: rotateHint 2.4s ease-in-out infinite;
}
@keyframes rotateHint {
  0%, 55%  { transform: rotate(0deg); }
  75%, 100% { transform: rotate(-90deg); }
}
.rotate-gate-title {
  font-family: var(--font-heading, Georgia, serif);
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #f0d8a8;
}
.rotate-gate-text {
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.5;
  color: #b89b6a;
}
/* While the gate blocks the battle, freeze scrolling behind it */
body.battle-portrait-block { overflow: hidden; }

/* --- Design Tokens (CSS Custom Properties) --- */
:root {
  /* Ocean depths */
  --ocean:          #0a1628;
  --ocean-mid:      #0f1f3a;
  --ocean-light:    #162d4f;

  /* Parchment family */
  --parchment:      #d4b896;
  --parchment-light:#e8dcc8;
  --parchment-dark: #b89b6a;

  /* Gold accents */
  --gold:           #c9973f;
  --gold-light:     #dbb264;
  --gold-dark:      #a67c2e;

  /* Semantic colors */
  --damage-red:     #b33a3a;
  --heal-green:     #3a7d44;
  --text-dark:      #2c1810;
  --text-light:     #e8dcc8;

  /* Typography */
  --font-heading:   'Georgia', 'Times New Roman', serif;
  --font-body:      'Georgia', 'Times New Roman', serif;
  /* Cleaner humanist UI font for dense body copy (loadout, stats, descriptions).
     Less serif ornament = easier to read at small sizes on mobile. */
  --font-ui:        'Segoe UI', 'Helvetica Neue', 'Helvetica', Arial, sans-serif;

  /* Spacing */
  --app-max-width:  420px;
  --border-radius:  8px;

  /* Safe area insets (notch, Dynamic Island, home bar) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;          /* remove 300ms tap delay */
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;           /* prevent pull-to-refresh / scroll chaining */
  position: fixed;                     /* prevent iOS bounce */
  font-family: var(--font-body);
  color: var(--parchment);
  background: var(--ocean);
}

button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* --- UI Pattern: Spotlight Select ---
   Pick-one-fade-others. Add .spotlight-group to the container,
   .spotlight-item to each selectable child. JS toggles .selected
   on the item and .has-selection on the group.
   Appearance (borders, glow color) stays on your component class;
   these rules only handle the fade/restore behavior.
   ---------------------------------------------------------------- */
.spotlight-item {
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.spotlight-group.has-selection .spotlight-item:not(.selected) {
  opacity: 0.35;
  filter: grayscale(0.6) brightness(0.6);
  transition: opacity 0.3s ease, filter 0.3s ease, border-color 0.3s ease;
}
.spotlight-group.has-selection .spotlight-item:not(.selected):hover {
  opacity: 0.6;
  filter: grayscale(0.3) brightness(0.8);
}

/* --- Page Container (shared by all screens) --- */
.page {
  width: 100%;
  height: 100dvh;
  max-width: var(--app-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, var(--ocean) 0%, var(--ocean-mid) 40%, var(--ocean-light) 100%);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.page::-webkit-scrollbar {
  display: none;
}

/* Canvas-based screens must not scroll */
.page.b2-screen,
.page.dice-screen {
  overflow: hidden;
}

/* --- Rope Border Frame --- */
.rope-outer {
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(201, 151, 63, 0.15);
  border-radius: var(--border-radius);
  pointer-events: none;
  z-index: 20;
}

.rope-inner {
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(201, 151, 63, 0.08);
  border-radius: 6px;
  pointer-events: none;
  z-index: 20;
}

/* --- Content Wrapper (centered, above backgrounds) --- */
.content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  padding: 24px 24px 40px;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1s ease-out, transform 1s ease-out;
}

.content::-webkit-scrollbar {
  display: none;
}

.content.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Title Screen Background Art --- */
.title-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/images/backside.png') center center / cover no-repeat;
  z-index: 1;
}

/* --- Title Screen Buttons (pinned to bottom) --- */
.title-buttons {
  position: relative;
  width: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  padding: 0 32px 40px;
  background: linear-gradient(to top, rgba(30, 18, 8, 0.85) 0%, rgba(30, 18, 8, 0.4) 60%, transparent 100%);
}

/* --- Typography --- */
.title-line-1 {
  font-family: var(--font-heading);
  font-size: 44px;
  font-weight: bold;
  letter-spacing: 3px;
  color: var(--gold);
  text-align: center;
  line-height: 1.1;
}

.title-line-2 {
  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: bold;
  letter-spacing: 6px;
  color: var(--gold-light);
  text-align: center;
  line-height: 1.1;
}

.tagline {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: normal;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--parchment-dark);
  text-align: center;
}

/* --- Decorative Divider --- */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 10px;
}

.divider-line {
  width: 60px;
  height: 1px;
}

.divider-line-left {
  background: linear-gradient(to right, transparent, var(--gold));
}

.divider-line-right {
  background: linear-gradient(to left, transparent, var(--gold));
}

/* --- Buttons --- */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 48px;
  max-width: 260px;
  width: 100%;
}

.btn-primary {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dark);
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: 2px solid var(--gold-light);
  border-radius: 6px;
  min-height: 54px;
  padding: 16px 32px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201, 151, 63, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 30px rgba(201, 151, 63, 0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-secondary {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: normal;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--parchment-dark);
  background: transparent;
  border: 1px solid rgba(212, 184, 150, 0.3);
  border-radius: 6px;
  min-height: 46px;
  padding: 12px 32px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: rgba(201, 151, 63, 0.5);
  color: var(--gold);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary:disabled:hover {
  border-color: rgba(212, 184, 150, 0.3);
  color: var(--parchment-dark);
}

/* Battle-style red button (faint transparent red → rich maroon on hover).
   Used on title screen for Resume Game and Rules Reference. */
.btn-battle-red {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: normal;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(230, 180, 180, 0.82);
  background: rgba(139, 26, 26, 0.14);
  border: 1px solid rgba(179, 58, 58, 0.45);
  border-radius: 6px;
  min-height: 46px;
  padding: 12px 32px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn-battle-red:hover:not(:disabled) {
  color: #f8e6e6;
  background: linear-gradient(135deg, #6e1414, #4a0c0c);
  border-color: rgba(220, 110, 110, 0.75);
  box-shadow: 0 4px 18px rgba(139, 26, 26, 0.45), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-battle-red:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Inactive primary button state — fully opaque but faded, no hover bounce */
.btn-primary.btn-inactive {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}

.btn-primary.btn-inactive:hover {
  transform: none;
  box-shadow: 0 4px 20px rgba(201, 151, 63, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* --- Footer Credit --- */
.footer {
  opacity: 0.4;
  text-align: center;
  margin-top: 50px;
}

.footer .credit {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--parchment);
}

.footer .version {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--parchment);
  margin-top: 4px;
}

/* --- Compass Rose (title screen ornament) --- */
.compass-rose {
  margin-bottom: 10px;
  opacity: 0.6;
}

/* ============================================================
   INITIATIVE SCREEN STYLES
   ============================================================ */

/* Parchment background */
.initiative-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/images/background_clean.png') center center / cover no-repeat;
  z-index: 1;
}

.initiative-screen .content {
  justify-content: flex-start;
  padding-top: 60px;
}

.screen-heading {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #3d2208;
  text-align: center;
  margin-bottom: 8px;
}

.screen-subheading {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #5c3a1e;
  text-align: center;
  margin-bottom: 32px;
}

/* Faction selector */
.faction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 300px;
  margin-top: 22px;      /* separates from the commander name input */
  margin-bottom: 32px;
}

.faction-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 2px solid rgba(100, 65, 20, 0.4);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: rgba(140, 100, 45, 0.4);
}

.faction-card:hover {
  border-color: rgba(100, 65, 20, 0.75);
  box-shadow: 0 4px 16px rgba(80, 45, 10, 0.35);
}

.faction-card.selected {
  border: 2px solid #c9973f;
  box-shadow:
    0 0 0 3px #c9973f,
    0 0 18px 8px rgba(201, 151, 63, 0.72),
    0 0 44px 16px rgba(201, 151, 63, 0.42),
    inset 0 0 0 1px rgba(201, 151, 63, 0.30);
}

/* Fade behavior now handled by .spotlight-group / .spotlight-item */
.faction-grid.has-selection .faction-card:not(.selected) {
  border-color: rgba(100, 65, 20, 0.15);
}

.faction-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* keep subject visible when text overlay covers bottom */
  display: block;
}

/* Bottom caption — short (~30% of card), dark, legible.
   Stronger gradient that lives only in the bottom third of the card. */
.faction-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32%;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(
    to top,
    rgba(15, 8, 2, 0.95) 0%,
    rgba(15, 8, 2, 0.88) 55%,
    rgba(15, 8, 2, 0.4) 88%,
    transparent 100%);
  text-align: center;
}

.faction-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
  margin-bottom: 4px;
}

/* Body text — non-condensed, looser kerning, larger size for mobile readability (WCAG body min 14sp) */
.faction-desc {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.2px;
  color: #f0e0c2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
  margin-top: 0;
  line-height: 1.35;
}

/* Override button styles for parchment context */
.initiative-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.initiative-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ============================================================
   WELCOME SCREEN STYLES
   ============================================================ */

.welcome-screen .content {
  justify-content: center;
  padding-top: 48px;
}

.welcome-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
  text-align: center;
  max-width: 300px;
}

.welcome-body p {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  color: #4a2c12;
}

.welcome-body .welcome-motto {
  font-size: 13px;
  font-style: italic;
  letter-spacing: 1px;
  color: #7a4f25;
  margin-top: 4px;
}

.welcome-screen .btn-group {
  margin-top: 32px;
}

/* --- Commander Name Input (Initiative Screen) --- */
.player-turn-label {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-bottom: 4px;
}

.commander-name-input {
  font-family: var(--font-heading);
  font-size: 16px;
  color: #2c1810;
  background: rgba(212, 184, 150, 0.4);
  border: 1px solid rgba(44, 24, 16, 0.35);
  border-radius: 6px;
  padding: 10px 16px;
  width: 100%;
  max-width: 300px;
  margin: 18px 0 0;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
}

.commander-name-input::placeholder {
  color: #8a6040;
  opacity: 1;
}

.commander-name-input:focus {
  border-color: rgba(44, 24, 16, 0.65);
  background: rgba(212, 184, 150, 0.6);
}

/* --- Pass Device Screen --- */
.pass-device-message {
  font-family: var(--font-heading);
  font-size: 16px;
  color: #4a2c12;
  margin-top: 24px;
  letter-spacing: 1px;
  text-align: center;
}

/* "Commander" small prefix label — sits above the player name */
.pass-device-prefix {
  font-family: var(--font-heading);
  font-size: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-top: 8px;
  text-align: center;
}

.pass-device-player {
  font-family: var(--font-heading);
  font-size: 44px;
  font-weight: bold;
  color: #2c1810;
  line-height: 1.05;
  margin-top: 4px;
  padding: 0 12px;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-align: center;
}

.pass-device-sub {
  font-family: var(--font-heading);
  font-size: 14px;
  color: #5c3a1e;
  letter-spacing: 2px;
  margin-top: 4px;
  text-align: center;
}

.pass-device-screen .btn-group {
  margin-top: 40px;
}

/* --- Draft Turn-Order Banner --- */
.draft-banner {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px 0;
  flex-wrap: wrap;
}

.draft-token {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(44, 24, 16, 0.2);
  background: rgba(44, 24, 16, 0.05);
  opacity: 0.45;
  transition: all 0.2s;
  min-width: 52px;
}

.draft-token.active {
  opacity: 1;
  border-color: rgba(44, 24, 16, 0.6);
  background: rgba(44, 24, 16, 0.12);
  box-shadow: 0 2px 8px rgba(44, 24, 16, 0.15);
}

.draft-token-num {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: bold;
  color: #2c1810;
  line-height: 1;
}

.draft-token-name {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #4a2c12;
  text-align: center;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Player Count Screen --- */
.player-count-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
  width: 100%;
  max-width: 320px;
}

.player-count-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 12px;
  background: rgba(44, 24, 16, 0.08);
  border: 1px solid rgba(44, 24, 16, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-heading);
}

.player-count-card:hover {
  background: rgba(44, 24, 16, 0.15);
  border-color: rgba(44, 24, 16, 0.5);
}

.player-count-card.selected {
  background: rgba(44, 24, 16, 0.15);
  border: 2px solid #2c1810;
  box-shadow: 0 0 12px rgba(44, 24, 16, 0.2);
}

.player-count-number {
  font-size: 40px;
  font-weight: bold;
  color: var(--text-dark);
  line-height: 1;
}

.player-count-label {
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4a2c12;
  margin-top: 4px;
}

.player-count-sub {
  font-size: 12px;
  color: #5c3a1e;
  text-align: center;
  line-height: 1.3;
}

.player-count-screen .btn-group {
  margin-top: 28px;
}

.welcome-screen .btn-primary {
  background: linear-gradient(135deg, #a67c2e, #c9973f);
  border-color: #6b4818;
  color: #2c1810;
}

.welcome-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.welcome-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ============================================================
   SHIP SELECTION SCREEN STYLES
   ============================================================ */

.ship-screen .content {
  justify-content: flex-start;
  padding: 12px 24px 16px;
  gap: 0;
}

/* Card deck — breaks out of content padding to full width.
   Cards sit side by side; neighbors peek in from the edges. */
.ship-deck-outer {
  width: calc(100% + 48px);
  margin-left: -24px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  margin-top: 10px;
  padding: 16px 0 8px;
}

.ship-deck-outer:active { cursor: grabbing; }

.ship-deck-track {
  display: flex;
  gap: 14px; /* must match GAP in mountShipCarousel */
  align-items: stretch;
  will-change: transform;
  /* transition injected by JS */
}

/* A physical card: art top two-thirds, stats lower third */
.ship-card {
  flex: 0 0 auto;
  height: min(56vh, 460px);
  aspect-ratio: 63 / 95;
  max-width: 84vw;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3e7cd 0%, #ead7b2 100%);
  border: 2px solid #7a5224;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4), inset 0 0 0 4px rgba(138, 90, 40, 0.18);
  overflow: hidden;
  position: relative;
  transform: scale(0.9);
  filter: brightness(0.8) saturate(0.85);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), filter 0.4s ease, box-shadow 0.4s ease;
}

.ship-card.active {
  transform: scale(1);
  filter: none;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(138, 90, 40, 0.25);
}

/* Art takes whatever the stats don't need — ~2/3 at phone size,
   shrinks first on short viewports so stats never clip */
.ship-card-art {
  flex: 1 1 auto;
  min-height: 32%;
  overflow: hidden;
  border-bottom: 2px solid #7a5224;
  background: #e8dcc0;
}

.ship-card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
}

.ship-card-lower {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 7px 10px 9px;
  gap: 3px;
}

.ship-card-faction {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #7a4f25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ship-card-name {
  flex-shrink: 0;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 0.4px;
  color: #3d2208;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ship-card-stats {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  margin-top: 2px;
}

.ship-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  background: rgba(122, 82, 36, 0.1);
  border: 1px solid rgba(122, 82, 36, 0.3);
  border-radius: 6px;
  padding: 3px 2px;
}

.chip-label {
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #7a4f25;
}

.chip-value {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: bold;
  color: #3d2208;
  line-height: 1.1;
}

/* Ability footer — tap for the full text in a modal (48px min touch) */
.ship-card-ability {
  flex: 0 0 auto;
  min-height: 44px;
  width: 100%;
  margin-top: 3px;
  background: none;
  border: none;
  border-top: 1px solid rgba(122, 82, 36, 0.3);
  padding: 4px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
}

.ship-card-ability:active { background: rgba(122, 82, 36, 0.08); }

.sca-name {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4a2d10;
}

.sca-desc {
  font-family: var(--font-body);
  font-size: 11px;
  font-style: italic;
  color: #4d3010;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dot indicators */
.ship-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 0;
}

.ship-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(100, 65, 20, 0.3);
  transition: background 0.2s ease, transform 0.2s ease;
}

.ship-dot.active {
  background: #c9973f;
  transform: scale(1.3);
}

/* ── Stat Info Modal ─────────────────────────────────── */
.stat-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 30, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 24px;
}

.stat-info-overlay.visible {
  opacity: 1;
}

.stat-info-box {
  background: #f5ead6;
  border: 2px solid #c9973f;
  border-radius: 4px;
  padding: 28px 24px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  transform: translateY(8px);
  transition: transform 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.stat-info-overlay.visible .stat-info-box {
  transform: translateY(0);
}

.stat-info-title {
  font-family: var(--font-heading);
  font-size: 18px;
  color: #3d2208;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.stat-info-body {
  font-family: var(--font-body);
  font-size: 13px;
  color: #5a3a1a;
  line-height: 1.6;
  margin-bottom: 20px;
}

.stat-info-close {
  min-width: 100px;
}

/* Parchment context overrides — ship screen is height-constrained */
.ship-screen .screen-heading {
  font-size: 22px;
  margin-bottom: 4px;
}

.ship-screen .screen-subheading {
  margin-bottom: 0;
}

/* Bottom buttons clear the home indicator */
.ship-btns {
  margin-top: 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.ship-screen .btn-group {
  margin-top: 10px;
}

.ship-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.ship-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

.ship-screen .btn-primary {
  background: linear-gradient(135deg, #a67c2e, #c9973f);
  border-color: #6b4818;
  color: #2c1810;
}

/* Drop the navy page gradient on the parchment screens — the parchment
   image already covers the page, but if any uncovered edge shows through
   the user sees blue. Use a parchment-toned solid color underneath instead. */
.page.ship-screen,
.page.card-select-screen {
  background: #d4b896;
}

/* ============================================================
   PLACEHOLDER SCREEN STYLES
   ============================================================ */

.placeholder-screen .content {
  justify-content: center;
}

.placeholder-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 16px;
}

.placeholder-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 8px;
}

.placeholder-desc {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--parchment-dark);
  text-align: center;
  max-width: 240px;
  line-height: 1.5;
  margin-bottom: 32px;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden { display: none; }
.text-gold { color: var(--gold); }
.text-parchment { color: var(--parchment); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }


/* ============================================================
   DICE ROLLER — Polyhedra screen (#dice)
   ============================================================ */

.dice-screen {
  /* No background — uses .page + initiative-bg like other screens */
}

.dice-viewport {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  /* faction tray image set inline by dice.js — no backdrop rectangle */
  background-color: transparent;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  margin-bottom: 14px;
  cursor: grab;
}
.dice-viewport:active { cursor: grabbing; }


.dice-overlay {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-size: 42px;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 28px rgba(201,151,63,0.6), 0 2px 8px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 3;
}
.dice-overlay.visible { opacity: 1; }

/* Visual die picker — replaces old text tabs */
.dice-die-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.dice-pick-die {
  background: rgba(255,255,255,0.12);
  border: 2px solid var(--die-color, rgba(44,24,16,0.3));
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 7px 7px;
  min-width: 56px;
  min-height: 74px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.dice-pick-die .die-icon-svg {
  width: 36px;
  height: 36px;
  display: block;
}
.dpd-label {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--die-color, #2c1810);
  margin-top: 5px;
  letter-spacing: 0.05em;
  display: block;
}
.dice-pick-die.active {
  transform: scale(1.18);
  box-shadow: 0 0 16px var(--die-color, rgba(44,24,16,0.5)), 0 0 6px rgba(0,0,0,0.35);
  border-width: 2.5px;
  z-index: 2;
}

.dice-controls {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 14px;
}
.dice-ctrl { display: flex; align-items: center; gap: 8px; }
.dc-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #4a2c12;
  font-weight: 600;
  font-family: var(--font-heading);
  text-transform: uppercase;
}
.dc-stepper {
  display: flex;
  border: 1px solid rgba(44,24,16,0.3);
  border-radius: 6px;
  overflow: hidden;
}
.dc-stepper button {
  background: rgba(44,24,16,0.1);
  border: none;
  color: #2c1810;
  font-size: 17px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-family: monospace;
}
.dc-stepper #dice-qty-val {
  width: 38px;
  text-align: center;
  font-family: monospace;
  font-size: 15px;
  color: #2c1810;
  background: rgba(44,24,16,0.06);
  border-left: 1px solid rgba(44,24,16,0.2);
  border-right: 1px solid rgba(44,24,16,0.2);
  line-height: 44px;
}
#dice-mod {
  width: 58px;
  height: 44px;
  text-align: center;
  font-family: monospace;
  font-size: 14px;
  color: #2c1810;
  background: rgba(44,24,16,0.06);
  border: 1px solid rgba(44,24,16,0.3);
  border-radius: 6px;
  outline: none;
}
#dice-mod::-webkit-inner-spin-button,
#dice-mod::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.dice-result-box {
  background: rgba(44,24,16,0.07);
  border: 1px solid rgba(44,24,16,0.2);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 10px;
  width: 100%;
}
.drb-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.drb-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #4a2c12;
  font-weight: 600;
  font-family: var(--font-heading);
}
.drb-total {
  font-size: 22px;
  font-weight: 900;
  color: #2c1810;
  font-family: var(--font-heading);
}
.drb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dice-chip {
  width: 40px; height: 40px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid rgba(44,24,16,0.25);
  background: rgba(44,24,16,0.08);
  color: #2c1810;
  animation: diceChipIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.dice-chip.max {
  border-color: #2c7a3a;
  color: #1a5228;
  background: rgba(44,122,58,0.12);
}
.dice-chip.min {
  border-color: var(--damage-red);
  color: var(--damage-red);
  background: rgba(179,58,58,0.1);
}
.dice-empty {
  text-align: center;
  color: #5c3a1e;
  font-style: italic;
  font-size: 13px;
  padding: 6px 0;
  width: 100%;
}

.dice-history-box { margin-top: 6px; width: 100%; }
.dice-history-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #4a2c12;
  margin-bottom: 5px;
  font-weight: 600;
  font-family: var(--font-heading);
}
.dice-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(44,24,16,0.1);
  font-size: 12px;
}
.dh-notation { color: #4a2c12; font-family: monospace; font-size: 12px; }
.dh-rolls    { color: #5c3a1e; font-family: monospace; font-size: 12px; }
.dh-total    { color: #2c1810; font-weight: 700; font-size: 13px; font-family: var(--font-heading); }


@keyframes diceChipIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}


/* ============================================================
   ROLL INITIATIVE SCREEN (Screen 02b)
   Physics d20 roller between faction select and ship select.
   ============================================================ */

.roll-initiative-screen {
  background: var(--ocean);
}

/* Full-height flex frame — header / canvas / result / buttons */
.roll-init-frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 16px 20px;
}

.roll-init-header {
  padding-top: 48px;
  text-align: center;
  flex-shrink: 0;
}

/* Physics dice area — fills available space, centers the tray */
.dice-physics-container {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  margin-bottom: 8px;
  transition: opacity 0.4s ease;
}

/* Faction dice tray — JS sizes this to the tray image's true aspect
   (2528x1696) so the art renders edge-to-edge with no backdrop */
.dice-tray {
  position: relative;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* Physics canvas — inset to the tray's inner felt edge so the dice
   roll path stays on the felt (canvas walls = felt walls) */
.dice-physics-roller {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 24%;
  bottom: 24%;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

/* Rolled number — zooms up off the table toward the player,
   hovers a beat, then fades away */
.dice-zoom-num {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  font-family: var(--font-heading);
  font-size: 110px;
  font-weight: 900;
  color: #ffe9b0;
  -webkit-text-stroke: 2px #1a0f06;
  text-shadow: 0 0 30px rgba(255,214,130,0.8), 0 6px 22px rgba(0,0,0,0.75);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.dice-zoom-num.fumble { color: #d44a3a; }
.dice-zoom-num.show {
  animation: diceZoomUp 2.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes diceZoomUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  18%  { opacity: 1; transform: translate(-50%, -52%) scale(1.05); }
  28%  { transform: translate(-50%, -54%) scale(1.18); }
  70%  { opacity: 1; transform: translate(-50%, -56%) scale(1.22); }
  100% { opacity: 0; transform: translate(-50%, -64%) scale(1.32); }
}

/* Hint text shown before first roll — floats on the lower felt, inside the frame */
.roll-init-hint {
  position: absolute;
  bottom: 27%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 62%;
  color: #d8b97c;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
  pointer-events: none;
  white-space: nowrap;
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 0.3;  }
}

/* Result display */
.roll-init-result {
  flex-shrink: 0;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
}

.roll-init-number {
  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: bold;
  color: var(--gold-dark);
  line-height: 1;
  /* Thin black outline so the number reads cleanly against parchment */
  -webkit-text-stroke: 1px #1a0f06;
  text-shadow:
    0 0 1px #1a0f06,
    0 2px 8px rgba(100,60,10,0.25);
  animation: diceChipIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.roll-init-number.roll-init-fumble {
  color: #8b1a1a;
  text-shadow: 0 2px 8px rgba(100,20,20,0.2);
}

.roll-init-verdict {
  font-family: var(--font-heading);
  font-size: 18px;
  color: #2c1810;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: diceChipIn 0.35s 0.08s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.roll-init-subtext {
  font-family: var(--font-body);
  font-size: 12px;
  color: #5c3a1e;
  font-style: italic;
  letter-spacing: 0.04em;
  animation: diceChipIn 0.35s 0.14s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Button row — Back is always visible, Roll Again + Lock In appear after roll */
.roll-init-btns {
  flex-shrink: 0;
  padding-top: 8px;
}

/* ============================================================
   WELCOME SCREEN — Unified button style
   ============================================================ */

/* Sub-label inside a btn-primary (e.g. tutorial button) */
.btn-primary-sub {
  display: block;
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 0.08em;
  text-transform: none;
  opacity: 0.75;
  margin-top: 2px;
}

.welcome-screen .btn-primary {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   ROLL INITIATIVE SCREEN — player label, faction flag, skin picker
   ============================================================ */

/* Dark brown, high-contrast on parchment — no more washed-out gold */
.roll-init-player-label {
  font-family: var(--font-heading);
  font-size: 13px;
  color: #3d2208;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
  opacity: 1;
}

.roll-init-faction-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 6px auto 4px;
  padding: 5px 20px;
  border-radius: 3px;
  min-width: 120px;
  transition: background 0.3s;
}
.roll-init-faction-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.90);
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}

/* Die skin picker — replaces flat color swatches */
.roll-init-skins {
  flex-shrink: 0;
  width: 100%;
  text-align: center;
  margin-bottom: 4px;
}
.roll-init-skins-label {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4a2c12;
  opacity: 1;
  margin-bottom: 8px;
}
.skins-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* Engraved-gemstone button — one per available skin color */
.skin-die-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
  position: relative;
}
.skin-die-btn .skin-die-svg {
  width: 48px;
  height: 67px;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45));
}
.skin-die-btn.selected {
  transform: scale(1.14);
  border-color: rgba(201,151,63,0.9);
  box-shadow: 0 0 16px rgba(201,151,63,0.6), 0 0 6px rgba(0,0,0,0.35);
  z-index: 2;
}
.skin-die-btn.selected .skin-die-svg {
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.55)) drop-shadow(0 0 4px rgba(255,220,140,0.45));
}
.skin-die-btn.taken {
  opacity: 0.42;
  cursor: not-allowed;
}
.skin-die-btn.taken .skin-die-svg {
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45)) saturate(0.15);
}
.skin-taken {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(30,10,5,0.85);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  letter-spacing: 0.08em;
  color: #e8a0a0;
  text-transform: uppercase;
  font-weight: 700;
}

/* ============================================================
   INITIATIVE RESULTS SCREEN
   ============================================================ */

.initiative-results-screen .content {
  justify-content: flex-start;
  padding-top: 60px;
}
.init-results-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.init-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(212, 184, 150, 0.18);
  border: 1px solid rgba(100, 65, 20, 0.25);
  border-radius: 6px;
}
.init-result-ordinal {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: bold;
  color: #3d2208;
  min-width: 28px;
  text-align: center;
}
.init-result-flag {
  width: 28px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.init-result-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.init-result-name {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--text-dark);
}
.init-result-faction {
  font-family: var(--font-body);
  font-size: 12px;
  color: #5c3a1e;
  font-style: italic;
}
.init-result-roll {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: bold;
  color: #3d2208;
  -webkit-text-stroke: 0.5px #1a0f06;
  min-width: 36px;
  text-align: right;
}
.init-results-note {
  font-family: var(--font-body);
  font-size: 12px;
  color: #5c3a1e;
  font-style: italic;
  text-align: center;
  margin-bottom: 16px;
}


/* ============================================================
   CARD SELECTION SCREEN STYLES
   ============================================================ */

.card-select-screen {
  overflow: hidden;
}
.card-select-screen .content {
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;        /* Firefox — hide scrollbar */
  -ms-overflow-style: none;     /* IE/Edge — hide scrollbar */
}
.card-select-screen .content::-webkit-scrollbar {
  display: none;                /* Chrome/Safari — hide scrollbar */
}

.card-select-screen .content {
  justify-content: flex-start;
  padding: 40px 16px 16px;
  gap: 0;
  flex: 1;
}

/* ── Tab Bar ─────────────────────────────────────────── */
.card-tab-bar {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 280px;
  margin-bottom: 12px;
  border: 1px solid rgba(100, 65, 20, 0.4);
  border-radius: 6px;
  overflow: hidden;
}

.card-tab {
  flex: 1;
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #7a4f25;
  background: rgba(140, 100, 45, 0.15);
  border: none;
  padding: 14px 0;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.card-tab:first-child {
  border-right: 1px solid rgba(100, 65, 20, 0.3);
}

.card-tab.active {
  background: rgba(201, 151, 63, 0.3);
  color: #3d2208;
  font-weight: bold;
}

.card-tab:hover {
  background: rgba(201, 151, 63, 0.2);
}

/* ── Card Table (tabletop supply) ─────────────────────── */
/* Cards lie flat on the table in front of the player. The table scrolls
   so the whole supply is reachable; tapping a card zooms it to read. */
.card-table-wrap {
  width: calc(100% + 32px);
  margin-left: -16px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* grow to fill the space between the hint and the ship diagram so the
     supply reads like cards spread on the table, not a thin sliver */
  flex: 1 1 auto;
  min-height: 150px;
  padding: 6px 16px 4px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 12px), transparent 100%);
}

.card-table {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  perspective: 700px;
}

/* A card resting on the table — tilted back a touch */
.table-card {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transform: rotateX(8deg);
  transform-origin: bottom center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.table-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  border-radius: 8px;
  border: 2px solid rgba(100, 65, 20, 0.5);
}

.table-card:active {
  transform: rotateX(0deg) scale(1.03);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

/* Cards already in YOUR loadout get a gold ring + corner check */
.table-card.equipped img { border-color: var(--gold); }
.table-card.equipped::after {
  content: "\2713";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  color: #0f2a14;
  background: #4caf50;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Cards drafted by another commander are dimmed + locked */
.table-card.drafted img { opacity: 0.4; filter: grayscale(0.7); }

.table-card-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #fff;
  background: rgba(60, 30, 8, 0.82);
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--gold);
  pointer-events: none;
  white-space: nowrap;
}
.table-card-badge.taken { background: rgba(20, 20, 20, 0.82); border-color: #888; }

.card-table-hint {
  font-family: var(--font-body);
  font-size: 11px;
  font-style: italic;
  color: #7a4f25;
  text-align: center;
  margin: 4px 0 6px;
  letter-spacing: 0.5px;
}

/* ── Card Zoom Overlay (pick it up to read) ───────────── */
.card-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 24, 0.86);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.22s ease;
  padding: 16px;
}
.card-zoom-overlay.visible { opacity: 1; }
.card-zoom-overlay.hidden { display: none; }

.czo-card-wrap {
  position: relative;
  width: min(78vw, 340px);
  aspect-ratio: 5 / 7;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  transform: scale(0.9);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.card-zoom-overlay.visible .czo-card-wrap { transform: scale(1); }

.czo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--gold);
  display: block;
}

/* Card "dealt forward" flick when navigating */
@keyframes czoDeal {
  0%   { transform: translateX(28px) scale(0.96); opacity: 0.4; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}
.czo-card-wrap.czo-deal { animation: czoDeal 0.26s ease both; }

/* The faded green check, top-left — the "take this card" selector */
.czo-check {
  position: absolute;
  top: -14px;
  left: -14px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #2f7d36;
  background: rgba(76, 175, 80, 0.35);
  color: #eafff0;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: background 0.2s, transform 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.czo-check.checked {
  background: #4caf50;
  color: #0f2a14;
  border-color: #6fe07a;
}
.czo-check.pop { transform: scale(1.25); }
.czo-check.hidden { display: none; }

.czo-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 4px;
  color: #fff;
  background: rgba(20, 20, 20, 0.78);
  padding: 8px 22px;
  border-radius: 6px;
  border: 2px solid #999;
  pointer-events: none;
}
.czo-badge.hidden { display: none; }

/* Close + browse arrows */
.czo-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #f5ead6;
  font-size: 28px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.czo-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #f5ead6;
  font-size: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.czo-prev { left: 8px; }
.czo-next { right: 8px; }

/* In-overlay "equip where?" bar */
.czo-slotbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(20, 12, 4, 0.94);
  border-top: 2px solid var(--gold);
  padding: 14px 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
.czo-slotbar.hidden { transform: translateY(110%); }

.czo-slotbar-title {
  font-family: var(--font-heading);
  font-size: 14px;
  color: #f0d8a8;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.czo-slotbar-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.czo-slot-btn {
  position: relative;
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 2px solid var(--gold);
  background: rgba(201, 151, 63, 0.18);
  color: #f5ead6;
  font-family: var(--font-heading);
  font-size: 14px;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.czo-slot-btn.occupied { border-color: #c98a3f; }
.czo-slot-swap {
  display: block;
  font-family: var(--font-body);
  font-size: 9px;
  font-style: italic;
  color: #e0b97c;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Transient toast (e.g. "slots full") */
.tov-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20, 12, 4, 0.95);
  color: #f5ead6;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  z-index: 9500;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.tov-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Ship Loadout Diagram ────────────────────────────── */
.ship-loadout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin: 4px 0;
}

.slot-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ship-top-container {
  width: 80px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  overflow: hidden;
}

/* Clean inline SVG hull — already drawn bow-up, fills its container */
.ship-top-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
}

/* Compact ship diagram in upgrade phase — armament slots are hidden,
   the ship is just visual context for the upgrade slots below it. */
.card-select-screen.phase-upgrade .ship-loadout {
  margin: 0;
}
.card-select-screen.phase-upgrade .ship-top-container {
  width: 60px;
  height: 120px;
}

.card-select-screen.phase-upgrade .slot-col-port,
.card-select-screen.phase-upgrade .slot-col-starboard,
.card-select-screen.phase-upgrade .slot-col-extra-port,
.card-select-screen.phase-upgrade .slot-col-extra-starboard {
  display: none !important;
}

/* Armament phase — armament slots sit in the TOP two corners above the ship.
   Optional extra-port / extra-starboard only appear if the player picked the
   Additional Weapon upgrade (handled by the existing .hidden class in markup). */
.card-select-screen.phase-armament .ship-loadout {
  display: grid;
  grid-template-columns: repeat(4, 56px);
  grid-template-rows: auto auto;
  justify-content: center;
  align-items: center;
  gap: 8px 6px;
}
.card-select-screen.phase-armament .slot-col-extra-port    { grid-column: 1; grid-row: 1; }
.card-select-screen.phase-armament .slot-col-port          { grid-column: 2; grid-row: 1; }
.card-select-screen.phase-armament .slot-col-starboard     { grid-column: 3; grid-row: 1; }
.card-select-screen.phase-armament .slot-col-extra-starboard { grid-column: 4; grid-row: 1; }
/* Re-assert hide for optional extra slots when not unlocked by an upgrade pick */
.card-select-screen.phase-armament .slot-column.hidden { display: none !important; }
.card-select-screen.phase-armament .ship-top-container {
  grid-column: 1 / 5;
  grid-row: 2;
  justify-self: center;
  width: 64px;
  height: 140px;
}
.card-select-screen.phase-armament .ship-top-img {
  width: 140px;
  height: 64px;
}
/* Upgrade slots are no longer needed on the armament screen — they were a
   leftover from the unified layout. Hide them here. */
.card-select-screen.phase-armament .upgrade-slots-row {
  display: none !important;
}

/* ── Card Slots ──────────────────────────────────────── */
.card-slot {
  width: 54px;
  height: 72px;
  border: 2px dashed rgba(100, 65, 20, 0.45);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  background: rgba(140, 100, 45, 0.08);
  position: relative;
  overflow: hidden;
}

.card-slot:hover {
  border-color: rgba(201, 151, 63, 0.6);
  background: rgba(140, 100, 45, 0.15);
}

.card-slot.filled {
  border-style: solid;
  border-color: var(--gold);
  background: rgba(201, 151, 63, 0.1);
  box-shadow: 0 0 8px rgba(201, 151, 63, 0.25);
}

.slot-icon {
  width: 24px;
  height: 24px;
  opacity: 0.4;
  pointer-events: none;
}

.slot-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 3px;
  pointer-events: none;
  transform: scale(1.6);
  transform-origin: center 30%;
}

/* Extra armament slots — blue dashed border */
.extra-slot {
  border-color: rgba(80, 120, 200, 0.5);
  background: rgba(80, 120, 200, 0.06);
}

.extra-slot:hover {
  border-color: rgba(80, 120, 200, 0.7);
  background: rgba(80, 120, 200, 0.12);
}

.extra-slot.filled {
  border-color: rgba(80, 120, 200, 0.8);
  box-shadow: 0 0 8px rgba(80, 120, 200, 0.2);
}

/* ── Upgrade Slots Row ───────────────────────────────── */
.upgrade-slots-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 4px 0 0;
}

/* ── Side Picker Modal ───────────────────────────────── */
.side-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 30, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
}

.side-picker-overlay.hidden {
  display: none;
}

.side-picker-box {
  background: #f5ead6;
  border: 2px solid #c9973f;
  border-radius: 4px;
  padding: 28px 24px 20px;
  max-width: 300px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.side-picker-title {
  font-family: var(--font-heading);
  font-size: 16px;
  color: #3d2208;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.side-picker-btns {
  display: flex;
  gap: 12px;
}

.side-picker-btns .btn-secondary {
  flex: 1;
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.side-picker-btns .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ── Card Select Button Overrides ────────────────────── */
.card-select-btns {
  margin-top: 10px;
}

.card-select-screen .btn-primary {
  background: linear-gradient(135deg, #a67c2e, #c9973f);
  border-color: #6b4818;
  color: #2c1810;
}

.card-select-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.card-select-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ============================================================
   06 — LOADOUT CONFIRMATION SCREEN
   ============================================================ */

.loadout-screen .content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  padding-bottom: 80px;
}

.loadout-screen .screen-heading {
  color: #2c1810;
}

/* Scrollable panel list */
.lo-panels {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 4px;
}

/* Each player's panel */
.lo-panel {
  width: 100%;
  background: rgba(255, 248, 232, 0.5);
  border: 1px solid #b89b6a;
  border-radius: 6px;
  padding: 12px;
  color: #2c1810;
  box-sizing: border-box;
}

.lo-loading {
  font-family: var(--font-ui);
  font-size: 13px;
  color: #5c3a1e;
  text-align: center;
  padding: 8px 0;
  font-style: italic;
}

/* Panel header: badge + faction */
.lo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(184, 155, 106, 0.5);
}

.lo-player-badge {
  font-family: var(--font-heading);
  font-size: 14px;
  letter-spacing: 1px;
  color: #a67c2e;
  background: rgba(201, 151, 63, 0.12);
  border: 1px solid rgba(201, 151, 63, 0.5);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lo-faction-info {
  flex: 1;
  min-width: 0;
}

.lo-faction-name {
  display: block;
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #3d2208;
}

.lo-faction-bonus {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  color: #5c3a1e;
  font-style: italic;
  margin-top: 2px;
  line-height: 1.35;
}

/* Ship block */
.lo-ship-block {
  margin-bottom: 10px;
}

.lo-ship-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.lo-ship-name {
  font-family: var(--font-heading);
  font-size: 17px;
  letter-spacing: 1.5px;
  color: #2c1810;
}

.lo-ship-trait {
  font-family: var(--font-ui);
  font-size: 13px;
  color: #5c3a1e;
  font-style: italic;
}

/* Stat boxes */
.lo-stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.lo-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(201, 151, 63, 0.08);
  border: 1px solid rgba(184, 155, 106, 0.6);
  border-radius: 4px;
  padding: 4px 12px;
  min-width: 52px;
}

.lo-stat-val {
  font-family: var(--font-heading);
  font-size: 22px;
  color: #2c1810;
  line-height: 1;
}

.lo-stat-lbl {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-top: 2px;
  font-weight: 600;
}

/* Ship ability */
.lo-ability {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
}

.lo-ability-name {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 0.6px;
  color: #3d2208;
  text-transform: uppercase;
  font-weight: bold;
}

.lo-ability-sep {
  color: #b89b6a;
}

.lo-ability-desc {
  color: #3d2208;
}

/* Sections (upgrades / armaments) */
.lo-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(184, 155, 106, 0.3);
}

.lo-section-label {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-bottom: 8px;
  font-weight: bold;
}

/* Upgrade rows */
.lo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 5px;
  margin-bottom: 7px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
}

.lo-card-name {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 0.3px;
  color: #2c1810;
  white-space: nowrap;
  font-weight: bold;
}

.lo-row-sep {
  color: #b89b6a;
}

.lo-card-desc {
  color: #3d2208;
}

.lo-empty {
  font-family: var(--font-ui);
  font-size: 13px;
  color: #7a5030;
  font-style: italic;
}

/* Armaments grid */
.lo-arms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lo-arm-slot {
  background: rgba(201, 151, 63, 0.06);
  border: 1px solid rgba(184, 155, 106, 0.4);
  border-radius: 4px;
  padding: 7px 8px;
}

.lo-arm-empty {
  opacity: 0.5;
}

.lo-arm-side {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-bottom: 4px;
  font-weight: bold;
}

.lo-arm-name {
  font-family: var(--font-heading);
  font-size: 14px;
  letter-spacing: 0.4px;
  color: #2c1810;
  line-height: 1.25;
  margin-bottom: 3px;
  font-weight: bold;
}

.lo-arm-dice {
  font-family: var(--font-ui);
  font-size: 12px;
  color: #5c3a1e;
  margin-bottom: 4px;
  font-weight: 600;
}

.lo-arm-desc {
  font-family: var(--font-ui);
  font-size: 12px;
  color: #3d2208;
  line-height: 1.4;
}

/* Button group pinned at bottom */
.lo-btn-group {
  margin-top: 8px;
  width: 100%;
}

.loadout-screen .btn-primary {
  background: linear-gradient(135deg, #a67c2e, #c9973f);
  border-color: #6b4818;
  color: #2c1810;
}

.loadout-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.loadout-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ============================================================
   PASS THE HELM SCREEN (#pass)
   ============================================================ */

.pass-helm-screen .initiative-bg {
  /* inherits initiative-bg background */
}

.pass-helm-screen .content {
  justify-content: flex-start;
  padding-top: 52px;
  gap: 0;
}

.pass-subtitle {
  font-family: var(--font-body);
  font-size: 14px;
  color: #5c3a1e;
  font-style: italic;
  text-align: center;
  margin: 14px 0 16px;
  padding: 0 16px;
  line-height: 1.5;
}

/* Single-player commander block */
.pass-anchor-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
  opacity: 0.7;
}

.pass-commander-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(212, 184, 150, 0.18);
  border: 1px solid rgba(100, 65, 20, 0.25);
  border-radius: 8px;
  padding: 16px 24px;
  width: calc(100% - 32px);
  margin: 0 16px;
}

.pass-commander-name {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: bold;
  color: var(--text-dark);
  letter-spacing: 1px;
  text-align: center;
}

.pass-commander-detail {
  font-family: var(--font-body);
  font-size: 13px;
  color: #5c3a1e;
  font-style: italic;
  text-align: center;
}

.pass-ready-line {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--gold-dark);
  letter-spacing: 1px;
  text-align: center;
  margin-top: 16px;
}

/* Multiplayer roster */
.pass-roster {
  width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 16px 12px;
}

.pass-roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(212, 184, 150, 0.13);
  border: 1px solid rgba(100, 65, 20, 0.2);
  border-radius: 6px;
}

.pass-roster-row.pass-roster-first {
  background: rgba(201, 151, 63, 0.18);
  border-color: rgba(100, 65, 20, 0.4);
}

.pass-roster-flag {
  width: 26px;
  height: 18px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.pass-roster-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pass-roster-name {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--text-dark);
}

.pass-roster-detail {
  font-family: var(--font-body);
  font-size: 11px;
  color: #5c3a1e;
  font-style: italic;
}

.pass-roster-lead {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: bold;
  color: var(--gold-dark);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pass-roster-rank {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: bold;
  color: rgba(92, 58, 30, 0.5);
  min-width: 20px;
  text-align: center;
}

.pass-hand-label {
  font-family: var(--font-body);
  font-size: 13px;
  color: #5c3a1e;
  font-style: italic;
  text-align: center;
  margin-bottom: 4px;
  padding: 0 16px;
}

.pass-helm-screen .btn-group {
  margin-top: auto;
  padding-bottom: 8px;
}

.pass-helm-screen .btn-primary {
  background: linear-gradient(135deg, #a67c2e, #c9973f);
  border-color: #6b4818;
  color: #2c1810;
}

.pass-helm-screen .btn-secondary {
  color: #5c3a1e;
  border-color: rgba(100, 65, 20, 0.4);
}

.pass-helm-screen .btn-secondary:hover {
  color: #3d2208;
  border-color: rgba(100, 65, 20, 0.7);
}

/* ============================================================
   VICTORY SCREEN (#victory)
   ============================================================ */

.victory-screen {
  background: linear-gradient(180deg, #0a0c10 0%, #0d1628 40%, #0a1628 100%);
}

.victory-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(201, 151, 63, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.victory-screen .content {
  justify-content: flex-start;
  padding-top: 56px;
  align-items: center;
}

.victory-flag-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.victory-flag {
  width: 56px;
  height: 40px;
  border-radius: 3px;
  box-shadow: 0 0 24px rgba(201, 151, 63, 0.5), 0 2px 8px rgba(0,0,0,0.6);
}

.victory-heading {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 30px rgba(201, 151, 63, 0.6), 0 2px 6px rgba(0,0,0,0.8);
  margin-bottom: 4px;
}

.victory-screen .divider {
  margin: 8px 0 16px;
}

.victory-winner {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--parchment-light);
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 6px;
}

.victory-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-bottom: 16px;
}

.victory-faction {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--parchment-dark);
  font-style: italic;
}

.victory-sep {
  font-size: 13px;
  color: var(--gold-dark);
  margin: 0 4px;
}

.victory-ship {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--parchment-dark);
  font-style: italic;
}

.victory-tagline {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--gold-dark);
  letter-spacing: 1px;
  text-align: center;
  font-style: italic;
  margin-bottom: 0;
}

.victory-anchor {
  display: flex;
  justify-content: center;
  margin: 20px 0 8px;
  opacity: 0.5;
}

.victory-screen .btn-group {
  margin-top: auto;
  padding-bottom: 8px;
}

.victory-btn {
  background: linear-gradient(135deg, #a67c2e, #c9973f) !important;
  border-color: #6b4818 !important;
  color: #2c1810 !important;
}

/* ============================================================
   BATTLE SCREEN (#game)
   Canvas hex grid + floating HUD overlay
   ============================================================ */

.battle-screen {
  padding: 0 !important;
  max-width: none !important;
  overflow: hidden;
}

#battle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ── HUD Overlay ── */

.battle-hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  z-index: 10;
}

.battle-hud > * {
  pointer-events: auto;
}

/* Top bar: ship info (left) + turn info (right) */
.battle-hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 10px 0;
  gap: 8px;
}

/* Ship info panel */
.battle-ship-info {
  background: rgba(10,18,32,0.82);
  border: 1px solid rgba(201,151,63,0.25);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 180px;
  max-width: 220px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.bh-name {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--parchment-light);
  padding-left: 8px;
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: 0.5px;
}

.bh-hp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.bh-hp-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  overflow: hidden;
}

.bh-hp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.bh-hp-txt {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--parchment-dark);
  min-width: 48px;
  text-align: right;
}

.bh-stats {
  display: flex;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--gold-dark);
  letter-spacing: 0.5px;
}

/* Turn info panel */
.battle-turn-info {
  background: rgba(10,18,32,0.82);
  border: 1px solid rgba(201,151,63,0.25);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: right;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.bh-round {
  font-family: var(--font-heading);
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
}

.bh-phase {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--parchment-dark);
  margin-top: 2px;
}

/* ── Bottom Bar ── */

.battle-hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 10px 10px;
  gap: 8px;
}

.battle-actions {
  display: flex;
  gap: 6px;
  background: rgba(10,18,32,0.82);
  border: 1px solid rgba(201,151,63,0.25);
  border-radius: 10px;
  padding: 6px 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ba-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  background: rgba(201,151,63,0.12);
  border: 1px solid rgba(201,151,63,0.3);
  border-radius: 8px;
  color: var(--parchment-light);
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.5px;
  cursor: pointer;
  min-width: 56px;
  transition: background 0.15s, border-color 0.15s;
}

.ba-btn:hover:not(:disabled) {
  background: rgba(201,151,63,0.25);
  border-color: rgba(201,151,63,0.5);
}

.ba-btn:active:not(:disabled) {
  background: rgba(201,151,63,0.35);
}

.ba-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.ba-btn svg {
  opacity: 0.85;
}

.ba-end {
  background: rgba(201,151,63,0.22);
  border-color: rgba(201,151,63,0.45);
}

/* Menu button */
.battle-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(10,18,32,0.82);
  border: 1px solid rgba(201,151,63,0.25);
  color: var(--gold);
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.battle-menu-btn:hover {
  background: rgba(10,18,32,0.92);
  border-color: rgba(201,151,63,0.5);
}

/* Battle log */
.battle-log-line {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--parchment-dark);
  padding: 2px 0;
  border-bottom: 1px solid rgba(201,151,63,0.1);
}

/* ============================================================
   RULES REFERENCE SCREEN
   Parchment accordion — dark text on parchment per brand rules.
   ============================================================ */

.rules-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 10px) + 10px);
}

.rules-tagline {
  text-align: center;
  font-style: italic;
  font-size: 13px;
  color: #5c3a1e;
  margin: 2px 0 10px;
}

.rules-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding-right: 2px;
}

.rules-section {
  border: 1.5px solid rgba(90,58,30,0.45);
  border-radius: 10px;
  background: rgba(255,250,240,0.35);
  margin-bottom: 8px;
  overflow: hidden;
}
.rules-section[open] {
  background: rgba(255,250,240,0.55);
}

.rules-summary {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 44px;
  justify-content: center;
  padding: 8px 14px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.rules-summary::-webkit-details-marker { display: none; }
.rules-summary::after {
  content: '';
  position: absolute;
}
.rules-section .rules-summary { position: relative; }
.rules-section .rules-summary::after {
  content: '\276F'; /* ❯ */
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  color: #8a6a3a;
  font-size: 12px;
  transition: transform 0.2s;
}
.rules-section[open] .rules-summary::after {
  transform: translateY(-50%) rotate(270deg);
}

.rules-sec-title {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dark);
}
.rules-sec-sub {
  font-size: 12px;
  font-style: italic;
  color: #5c3a1e;
}

.rules-body {
  padding: 2px 14px 12px;
  color: #3d2208;
  font-size: 13px;
  line-height: 1.5;
}

.rules-lede {
  margin: 4px 0 8px;
  font-style: italic;
  color: #4a2c12;
}

.rules-stat-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(90,58,30,0.18);
}
.rules-stat-row:last-of-type { border-bottom: none; }
.rules-stat-abbr {
  flex-shrink: 0;
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.8px;
  color: var(--text-dark);
  background: rgba(201,151,63,0.25);
  border: 1px solid rgba(138,106,58,0.5);
  border-radius: 6px;
  padding: 2px 6px;
}
.rules-stat-text {
  font-size: 13px;
  color: #3d2208;
}
.rules-stat-text strong { color: var(--text-dark); }

.rules-note {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(201,151,63,0.14);
  border-left: 3px solid var(--gold-dark);
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: #4a2c12;
}

.rules-steps {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.rules-steps li { margin: 6px 0; }

.rules-list {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.rules-list li { margin: 5px 0; }

.rules-compare {
  display: flex;
  gap: 8px;
  margin: 6px 0;
}
.rules-compare-col {
  flex: 1;
  border: 1px solid rgba(138,106,58,0.45);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255,250,240,0.4);
}
.rules-compare-head {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 4px;
}
.rules-compare .rules-list { margin-left: 14px; }

.rules-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.rules-chip {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.5px;
  color: var(--text-dark);
  background: rgba(201,151,63,0.22);
  border: 1px solid rgba(138,106,58,0.5);
  border-radius: 14px;
  padding: 4px 12px;
}

.rules-kv {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(90,58,30,0.18);
}
.rules-kv:last-of-type { border-bottom: none; }
.rules-kv-label {
  flex-shrink: 0;
  min-width: 118px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.6px;
  color: #5c3a1e;
}
.rules-kv-value {
  font-size: 13px;
  color: #3d2208;
}

.rules-btns {
  margin-top: 10px;
  flex-shrink: 0;
}

/* ============================================================
   CARD DESCRIPTION LISTS
   Multi-sentence card text renders as short bullets, not prose.
   ============================================================ */

.card-desc-list {
  margin: 3px 0 0 16px;
  padding: 0;
}
.card-desc-list li {
  margin: 2px 0;
}

.lo-row .lo-card-desc {
  display: block;
}

/* Tappable stat chips (open the stat info modal) */
.ship-chip[role="button"] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ship-chip[role="button"]:active {
  transform: scale(0.95);
  background: rgba(201,151,63,0.3);
}

/* ============================================================
   DICE ROLLER — ARMAMENT PRESETS
   One-tap chips that arm the roller with an equipped weapon's dice.
   ============================================================ */

.dice-presets {
  width: 100%;
  margin: 6px 0 2px;
  text-align: center;
}
.dice-presets-label {
  display: block;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #5c3a1e;
  margin-bottom: 5px;
}
.dice-presets-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.dice-preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-height: 44px;
  padding: 5px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(138,106,58,0.55);
  background: rgba(201,151,63,0.16);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dice-preset:active { transform: scale(0.96); }
.dice-preset.active {
  background: rgba(201,151,63,0.35);
  border-color: var(--gold-dark);
}
.dice-preset-name {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-dark);
}
.dice-preset-dice {
  font-size: 12px;
  color: #5c3a1e;
  font-variant-numeric: tabular-nums;
}
