/* Ödland — Brutalist Postapocalyptic Card Roguelite */

:root {
  --bg-0: #120e0a;
  --bg-1: #1a1410;
  --bg-2: #241c14;
  --bg-3: #2e241a;
  --ink-0: #f0e6d2;
  --ink-1: #d8c9a8;
  --ink-2: #a89274;
  --ink-3: #6f5a40;
  --rust: #b35a30;
  --rust-dark: #7a3a1c;
  --acid: #98a040;
  --blood: #8c2828;
  --frame: #3a2c1e;
  --frame-2: #4a3a26;
  --gold: #c9a268;
  --mono: 'Special Elite', 'Courier New', monospace;
  --terminal: 'VT323', 'Courier New', monospace;
  --display: 'IM Fell English SC', 'Special Elite', serif;
  --shadow-deep: 0 8px 24px rgba(0,0,0,0.6), 0 2px 0 rgba(0,0,0,0.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  margin: 0; padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0; padding: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh; /* fallback */
  height: 100dvh;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  position: fixed; /* prevents FF mobile URL-bar overscroll-jumps */
  top: 0; left: 0; right: 0; bottom: 0;
}
body {
  background:
    radial-gradient(ellipse at top, #2a1f15 0%, #120e0a 60%, #0a0805 100%);
  color: var(--ink-1);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#root {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

/* Scanline + grain overlay for postapoc atmosphere */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.0) 0px,
      rgba(0,0,0,0.0) 2px,
      rgba(0,0,0,0.12) 3px,
      rgba(0,0,0,0.0) 4px
    );
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: multiply;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 9998;
}

/* ============ DUST PARTICLES (canvas-less) ============ */
.dust-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.dust {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.18;
  animation: dust-drift 18s linear infinite;
  box-shadow: 0 0 4px rgba(201,162,104,0.4);
}
@keyframes dust-drift {
  0%   { transform: translate(0, 100vh) scale(0.8); opacity: 0; }
  10%  { opacity: 0.3; }
  90%  { opacity: 0.2; }
  100% { transform: translate(40px, -10vh) scale(1.2); opacity: 0; }
}

/* App container — full viewport, internal flex column with scrollable middle */
.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: linear-gradient(180deg, #1a1410 0%, #120e0a 100%);
  border-left: 1px solid #2a1f15;
  border-right: 1px solid #2a1f15;
  box-shadow: 0 0 80px rgba(0,0,0,0.8);
  z-index: 2;
  overflow: hidden;
}

/* ============ TITLE ============ */
.title {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  position: relative;
  z-index: 2;
}
.title-logo {
  font-family: var(--display);
  font-size: clamp(48px, 14vw, 80px);
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 0;
  text-shadow:
    0 4px 0 #000,
    0 0 30px rgba(201,162,104,0.3),
    0 0 60px rgba(201,162,104,0.15);
  line-height: 1;
  animation: logo-glow 4s ease-in-out infinite alternate;
}
@keyframes logo-glow {
  from { text-shadow: 0 4px 0 #000, 0 0 20px rgba(201,162,104,0.2); }
  to   { text-shadow: 0 4px 0 #000, 0 0 40px rgba(201,162,104,0.45), 0 0 80px rgba(179,90,48,0.2); }
}
.title-sub {
  font-family: var(--terminal);
  color: var(--rust);
  font-size: 22px;
  letter-spacing: 0.2em;
  margin: 6px 0 0;
  text-transform: uppercase;
}
.title-tagline {
  margin-top: 28px;
  color: var(--ink-2);
  font-size: 14px;
  max-width: 320px;
  line-height: 1.6;
}
.title-btns {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}
.title-footer {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--terminal);
  color: var(--ink-3);
  font-size: 14px;
  letter-spacing: 0.15em;
}
.title-aside {
  position: absolute;
  top: 14px;
  right: 14px;
  font-family: var(--terminal);
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

/* ============ BUTTONS ============ */
.btn {
  background: linear-gradient(180deg, var(--frame-2) 0%, var(--frame) 100%);
  color: var(--ink-0);
  font-family: var(--mono);
  font-size: 17px;
  padding: 14px 20px;
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.04em;
  position: relative;
  transition: transform 80ms ease, background 120ms ease, box-shadow 120ms ease;
  min-height: 48px;
  box-shadow: 0 3px 0 #000, 0 0 0 1px rgba(0,0,0,0.4);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.btn:hover { background: linear-gradient(180deg, #5a4632 0%, var(--frame-2) 100%); }
.btn.primary {
  background: linear-gradient(180deg, var(--rust) 0%, var(--rust-dark) 100%);
  border-color: var(--gold);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.btn.primary:hover { background: linear-gradient(180deg, #c8683c 0%, var(--rust) 100%); box-shadow: 0 3px 0 #000, 0 0 20px rgba(179,90,48,0.3); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--ink-3);
  color: var(--ink-2);
  font-size: 14px;
  min-height: 36px;
  padding: 6px 12px;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============ HUD ============ */
.hud {
  padding: 10px 14px 10px;
  border-bottom: 1px solid #2a1f15;
  background: linear-gradient(180deg, #1a1410 0%, #14100c 100%);
  flex: 0 0 auto;
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--terminal);
  margin-bottom: 10px;
}
.hud-day {
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 0.08em;
}
.hud-shelter {
  font-size: 16px;
  color: var(--ink-2);
  letter-spacing: 0.1em;
}
.hud-actions {
  display: flex;
  gap: 6px;
}
.hud-pause, .hud-icon-btn {
  background: transparent;
  border: 1px solid var(--ink-3);
  color: var(--ink-1);
  width: 32px; height: 32px;
  font-family: var(--terminal);
  font-size: 18px;
  cursor: pointer;
  border-radius: 2px;
  transition: background 100ms, border-color 100ms;
}
.hud-icon-btn:hover { background: var(--frame); border-color: var(--gold); }
.hud-scrap {
  font-family: var(--terminal);
  color: var(--gold);
  font-size: 16px;
  padding: 0 8px;
  align-self: center;
}

.bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  position: relative;
}
.bar-icon {
  font-size: 16px;
  width: 18px;
  display: inline-block;
  text-align: center;
  filter: sepia(0.4) saturate(0.8);
}
.bar-label {
  font-family: var(--terminal);
  font-size: 14px;
  color: var(--ink-2);
  min-width: 52px;
  letter-spacing: 0.06em;
}
.bar-track {
  flex: 1;
  height: 14px;
  background: #2a1f15;
  border: 1px solid #4a3a26;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
.bar-track::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg, transparent 0, transparent 9px,
    rgba(0,0,0,0.35) 9px, rgba(0,0,0,0.35) 10px
  );
  z-index: 2;
  pointer-events: none;
}
.bar-fill {
  height: 100%;
  transition: width 380ms cubic-bezier(0.4, 0.0, 0.2, 1);
  position: relative;
}
.bar-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 50%);
}
.bar-fill.food { background: linear-gradient(90deg, #6a5028 0%, #b48a3a 100%); }
.bar-fill.energy { background: linear-gradient(90deg, #4a6028 0%, #8aa83a 100%); }
.bar-fill.morale { background: linear-gradient(90deg, #6b2828 0%, #b85a3a 100%); }
.bar-fill.defense { background: linear-gradient(90deg, #344a5a 0%, #5a82a8 100%); }
.bar-num {
  font-family: var(--terminal);
  font-size: 16px;
  color: var(--ink-1);
  min-width: 28px;
  text-align: right;
  letter-spacing: 0.05em;
}
.bar.low .bar-num { color: var(--blood); animation: pulse-low 0.8s ease-in-out infinite alternate; }
.bar.low .bar-fill { animation: pulse-fill-low 1.1s ease-in-out infinite alternate; }
.bar.low .bar-icon { color: var(--blood); animation: pulse-low 0.8s ease-in-out infinite alternate; }
.bar.low .bar-label { color: var(--blood); }
.bar.changed .bar-num { animation: num-pop 0.35s ease; }
@keyframes num-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); color: var(--gold); }
  100% { transform: scale(1); }
}
@keyframes pulse-low {
  0% { text-shadow: 0 0 0 transparent; }
  100% { text-shadow: 0 0 10px var(--blood); }
}
@keyframes pulse-fill-low {
  0%   { box-shadow: 0 0 0 transparent, inset 0 0 0 transparent; filter: brightness(1); }
  100% { box-shadow: 0 0 8px rgba(200,112,96,0.6), inset 0 0 6px rgba(255,80,60,0.3); filter: brightness(1.25); }
}
.bar-float {
  position: absolute;
  right: 4px;
  top: -2px;
  font-family: var(--terminal);
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  animation: float-up 1100ms ease-out forwards;
  text-shadow: 0 1px 0 #000, 0 0 6px rgba(0,0,0,0.6);
  z-index: 5;
}
.bar-float.pos { color: var(--acid); }
.bar-float.neg { color: var(--blood); }
@keyframes float-up {
  0%   { opacity: 0; transform: translateY(0); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ============ DAY STAGE — Scrollable middle ============ */
.day-stage {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 20px;
  gap: 12px;
  position: relative;
  z-index: 2;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.day-headline {
  font-family: var(--display);
  font-size: 22px;
  color: var(--ink-1);
  text-align: center;
  letter-spacing: 0.1em;
  margin: 0;
  text-shadow: 0 2px 0 #000;
}
.day-sub {
  font-family: var(--terminal);
  font-size: 16px;
  color: var(--ink-3);
  text-align: center;
  letter-spacing: 0.12em;
  margin: -6px 0 6px;
  font-style: italic;
}
.day-narrative {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  margin: -2px 0 4px;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.card-slot {
  position: relative;
  transition: max-height 360ms ease, opacity 360ms ease, transform 360ms ease;
  max-height: 600px;
}
.card-slot.resolved {
  opacity: 0.4;
  transform: translateX(0) scale(0.97);
}
.card-slot.resolved .card { filter: grayscale(0.6) brightness(0.7); pointer-events: none; }
.card-slot.resolved::after {
  content: 'ERLEDIGT';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  font-family: var(--terminal);
  font-size: 22px;
  color: var(--rust);
  letter-spacing: 0.3em;
  border: 2px solid var(--rust);
  padding: 4px 14px;
  background: rgba(20,16,12,0.85);
  pointer-events: none;
  z-index: 5;
}
.card-slot.just-resolved .card { animation: card-flash 380ms ease; }
@keyframes card-flash {
  0%   { box-shadow: var(--shadow-deep); }
  40%  { box-shadow: 0 0 24px rgba(201,162,104,0.6), var(--shadow-deep); }
  100% { box-shadow: var(--shadow-deep); }
}

/* Card-reveal flip animation */
.card-slot.fresh .card {
  animation: card-flip-in 480ms cubic-bezier(0.4, 0.0, 0.2, 1);
  transform-style: preserve-3d;
  perspective: 800px;
}
@keyframes card-flip-in {
  0%   { transform: rotateY(-72deg) translateY(8px); opacity: 0; }
  100% { transform: rotateY(0) translateY(0); opacity: 1; }
}

/* Day-transition slide */
.day-stage.transition-in {
  animation: day-slide-in 360ms ease;
}
@keyframes day-slide-in {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Day-headline number bump */
.day-headline.changed {
  animation: day-num-bump 460ms ease;
}
@keyframes day-num-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.16); color: var(--gold); }
  100% { transform: scale(1); }
}

.card {
  background:
    linear-gradient(180deg, #2a2018 0%, #1e1610 100%);
  border: 1px solid var(--frame);
  border-top: 1px solid var(--ink-3);
  border-radius: 2px;
  padding: 12px 14px 12px;
  position: relative;
  box-shadow: var(--shadow-deep);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0px,
      transparent 6px,
      rgba(0,0,0,0.04) 6px,
      rgba(0,0,0,0.04) 7px
    );
  pointer-events: none;
}

.card.boss {
  background: linear-gradient(180deg, #3a1812 0%, #1a0a08 100%);
  border: 2px solid var(--blood);
  border-top: 2px solid var(--rust);
  padding: 16px 18px 14px;
  box-shadow: 0 0 30px rgba(140,40,40,0.4), var(--shadow-deep);
  animation: boss-pulse 1.4s ease-in-out infinite alternate;
}
.card.boss .card-title-text {
  font-size: 22px;
  color: var(--blood);
  letter-spacing: 0.12em;
}
.card.boss .card-tag { color: var(--rust); font-weight: bold; }
.card.boss .card-flavor { color: var(--ink-1); font-size: 15px; }
@keyframes boss-pulse {
  from { box-shadow: 0 0 20px rgba(140,40,40,0.3), var(--shadow-deep); }
  to   { box-shadow: 0 0 40px rgba(180,60,60,0.7), var(--shadow-deep); }
}

/* Card header row with stamp + tag */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  position: relative;
  z-index: 2;
}
.card-stamp {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20,16,12,0.5);
  transform: rotate(-6deg);
  position: relative;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.6);
}
.stamp-glyph {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.6));
}
.card.boss .card-stamp { width: 48px; height: 48px; border-width: 2px; }
.card.boss .stamp-glyph { font-size: 26px; }

.card-tag {
  font-family: var(--terminal);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: block;
}
.card-title-text {
  font-family: var(--display);
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 0.05em;
  line-height: 1.1;
  margin-top: 1px;
}

.card-flavor {
  color: var(--ink-2);
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
  margin: 4px 0 12px;
  min-height: 38px;
  position: relative;
  z-index: 2;
}
.card-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: relative;
  z-index: 2;
}
.choice {
  background: linear-gradient(180deg, var(--frame-2) 0%, var(--frame) 100%);
  border: 1px solid var(--ink-3);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-0);
  border-radius: 2px;
  transition: transform 80ms ease, background 120ms;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  box-shadow: 0 2px 0 #000;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.choice input, .choice select, .choice textarea { font-size: 16px; }
.choice:active { transform: translateY(2px); box-shadow: 0 0 0 #000; }
.choice:hover { background: linear-gradient(180deg, #5a4632 0%, var(--frame-2) 100%); border-color: var(--gold); }
.choice-label {
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-0);
}
.choice-effects {
  font-family: var(--terminal);
  font-size: 14px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  letter-spacing: 0.04em;
}
.eff { display: inline-flex; align-items: center; gap: 2px; }
.eff-pos { color: var(--acid); }
.eff-neg { color: var(--blood); }
.eff-rand { color: var(--gold); }

/* Day controls — sticky at bottom of scrollable day-stage */
.day-controls {
  display: flex;
  gap: 10px;
  padding-top: 10px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(26,20,16,0) 0%, var(--bg-1) 25%, var(--bg-1) 100%);
  z-index: 20;
  margin-top: auto;
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: 10px;
}
.day-controls .btn { flex: 1; min-height: 50px; }

/* ============ STATUS-BAND (active multi-day effects) ============ */
.status-band {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 0;
  min-height: 22px;
}
.status-chip {
  font-family: var(--terminal);
  font-size: 12px;
  padding: 2px 8px 2px 6px;
  border: 1px solid currentColor;
  border-radius: 2px;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.3);
}

/* ============ LOG ============ */
.log {
  font-family: var(--terminal);
  font-size: 14px;
  color: var(--ink-2);
  background: #0a0805;
  border: 1px solid #2a1f15;
  padding: 8px 10px;
  max-height: 76px;
  overflow-y: auto;
  letter-spacing: 0.04em;
}
.log-line { margin: 2px 0; }
.log-line.danger { color: var(--blood); }
.log-line.good { color: var(--acid); }
.log-line.system { color: var(--gold); }

/* ============ TOASTS ============ */
.toast-stack {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 50;
  width: 90%;
  max-width: 380px;
}
.toast {
  font-family: var(--terminal);
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--gold);
  background: rgba(20,16,12,0.92);
  color: var(--gold);
  letter-spacing: 0.06em;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  animation: toast-in 0.3s ease, toast-out 0.4s ease 2.6s forwards;
}
.toast.danger { color: var(--blood); border-color: var(--blood); }
.toast.good { color: var(--acid); border-color: var(--acid); }
.toast.achievement {
  background: linear-gradient(180deg, rgba(60,40,20,0.95) 0%, rgba(20,16,12,0.95) 100%);
  color: var(--gold);
  border: 2px solid var(--gold);
  font-weight: bold;
  font-size: 15px;
  padding: 8px 16px;
}
/* C.6 Combo: oversized + glowing + slight scale-in on top of normal toast-in */
.toast.combo-big {
  background: linear-gradient(180deg, rgba(80,50,20,0.96) 0%, rgba(20,12,8,0.96) 100%);
  color: var(--gold);
  border: 2px solid var(--gold);
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 0.12em;
  padding: 12px 22px;
  box-shadow: 0 0 16px rgba(201,162,104,0.55), 0 6px 20px rgba(0,0,0,0.7);
  animation: combo-pop 0.5s cubic-bezier(0.34,1.56,0.64,1), toast-out 0.4s ease 2.6s forwards;
}
@keyframes combo-pop {
  0%   { opacity: 0; transform: scale(0.6) translateY(-16px); }
  60%  { opacity: 1; transform: scale(1.12) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  /* darker bg as fallback when backdrop-filter not supported (FF mobile) */
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 200ms ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
@supports (backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px)) {
  .modal-backdrop {
    background: rgba(0,0,0,0.78);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}
.modal {
  background: linear-gradient(180deg, #241c14 0%, #1a1410 100%);
  border: 1px solid var(--ink-3);
  border-top: 2px solid var(--gold);
  padding: 18px 18px 16px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  position: relative;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: auto;
}
.modal h2 {
  font-family: var(--display);
  font-size: 24px;
  color: var(--gold);
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-align: center;
}
.modal p {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  margin: 6px 0;
}

.reward-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}
.reward-card {
  cursor: pointer;
  background: linear-gradient(180deg, #2a2018 0%, #1e1610 100%);
  border: 1px solid var(--frame);
  padding: 10px 12px;
  transition: border-color 120ms;
}
.reward-card:hover { border-color: var(--gold); }
.reward-card.selected { border-color: var(--gold); background: linear-gradient(180deg, #3a2c1c 0%, #2a2018 100%); }

.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--terminal);
  font-size: 16px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--frame);
}
.stat-row b { color: var(--gold); }

/* ============ GAME OVER ============ */
.gameover {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  position: relative;
  z-index: 2;
}
.gameover h1 {
  font-family: var(--display);
  font-size: 44px;
  color: var(--blood);
  margin: 0 0 8px;
  letter-spacing: 0.1em;
  text-shadow: 0 4px 0 #000;
}
.gameover .epitaph {
  font-family: var(--terminal);
  color: var(--ink-2);
  font-size: 18px;
  letter-spacing: 0.1em;
  margin: 0 0 16px;
  font-style: italic;
}
.gameover .stats {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--frame);
  padding: 12px 18px;
  margin: 0 0 18px;
  font-family: var(--terminal);
  font-size: 15px;
  color: var(--ink-1);
  letter-spacing: 0.04em;
  width: 100%;
  max-width: 300px;
}
.gameover .progression {
  font-family: var(--terminal);
  color: var(--acid);
  font-size: 14px;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  text-align: center;
}
.gameover .progression .danger { color: var(--blood); }

/* ============ TUTORIAL OVERLAY ============ */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 32px 20px;
  align-items: center;
  justify-content: center;
}
.tutorial-card {
  background: linear-gradient(180deg, #241c14 0%, #1a1410 100%);
  border: 1px solid var(--gold);
  padding: 24px 22px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.tutorial-step {
  font-family: var(--terminal);
  font-size: 14px;
  color: var(--rust);
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}
.tutorial-card h3 {
  font-family: var(--display);
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}
.tutorial-card p {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
  margin: 8px 0;
}
.tutorial-icons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 14px 0;
  font-size: 28px;
}
.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.tutorial-dots .dot {
  width: 8px; height: 8px;
  background: var(--ink-3);
  border-radius: 50%;
}
.tutorial-dots .dot.active { background: var(--gold); }

/* ============ TOOLTIPS ============ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 16, 12, 0.97);
  border: 1px solid var(--gold);
  color: var(--ink-0);
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 10px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  max-width: 240px;
  white-space: normal;
  width: max-content;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  opacity: 1;
  transition-delay: 600ms;
}
.tooltip-disabled [data-tooltip]::after { display: none !important; }
@media (hover: none) {
  [data-tooltip]::after { display: none; }
}

/* ============ SETTINGS ============ */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--frame);
  font-size: 14px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.setting-label b { color: var(--gold); font-size: 14px; }
.setting-label span { color: var(--ink-3); font-size: 11px; }
.setting-toggle {
  width: 56px;
  height: 28px;
  background: var(--frame);
  border: 1px solid var(--ink-3);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background 200ms;
}
.setting-toggle.on { background: var(--rust); border-color: var(--gold); }
.setting-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: var(--ink-0);
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.setting-toggle.on::after { transform: translateX(28px); }

.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 8px;
  background: var(--frame);
  border-radius: 4px;
  outline: none;
  touch-action: manipulation;
}
.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--frame);
}
.setting-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--frame);
}

/* ============ HELPERS ============ */
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.center { text-align: center; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ============ I18N · GOOGLE TRANSLATE WIDGET ============ */
.wl-gt-host {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: 8px;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid var(--frame-2);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.wl-gt-host .goog-te-gadget { font-size: 11px !important; color: var(--ink-2) !important; }
.wl-gt-host .goog-te-gadget a { display: none !important; }
.wl-gt-host select.goog-te-combo {
  background: var(--bg-1);
  color: var(--ink-1);
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  padding: 2px 4px;
  font-family: var(--terminal);
  font-size: 13px;
  max-width: 200px;
}
body.translated-rtl { direction: rtl; }
body { top: 0 !important; }
.skiptranslate { display: none !important; }
iframe.goog-te-banner-frame { display: none !important; }

/* ============ MORE-INFO CHIPS (10/10 polish) ============ */
.info-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--frame);
  border-radius: 2px;
  color: var(--ink-2);
  font-family: var(--terminal);
  font-size: 12px;
  letter-spacing: 0.03em;
}
.info-chip.good { color: var(--acid); border-color: var(--acid); }
.info-chip.bad { color: var(--blood); border-color: var(--blood); }
.info-chip.gold { color: var(--gold); border-color: var(--gold); }

/* Captain card hover effect */
.captain-card:hover { background: rgba(50,40,28,0.4); }

/* Smaller stats-section style for nested modals */
.stats-mini-row {
  display: flex; justify-content: space-between;
  padding: 4px 6px;
  border-bottom: 1px dashed var(--frame);
  font-family: var(--terminal);
  font-size: 13px;
}
