:root {
  --ink: #1a1612;
  --panel: #2a241c;
  --panel-2: #342c22;
  --line: #5a4a32;
  --gold: #e2c078;
  --gold-dim: #a68445;
  --paper: #f3e6c8;
  --muted: #cbb892;
  --blood: #a14a3c;
  --pine: #7d9a72;
  --danger: #e07a68;
  color: var(--paper);
  background: var(--ink);
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-height: 100vh; background: #141910; }
body:not(.playing) {
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(226, 192, 120, 0.14), transparent 62%),
    #141910;
}
body.playing, body.intro-open { overflow: hidden; height: 100%; height: 100dvh; overscroll-behavior: none; }
body:not(.playing) { overflow-x: hidden; }
.play { position: fixed; inset: 0; }
button, .btn { touch-action: manipulation; }
#realm { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: #141910; }
#realm.pointing { cursor: pointer; }
#realm.dragging { cursor: grabbing; }
#clock { color: var(--gold); font-size: 22px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.hud-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-chip, .hud-card, .hud-log, #mini {
  background: rgba(16, 13, 10, 0.72);
  border: 1px solid rgba(226, 192, 120, 0.38);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}
.hud-chip { padding: 6px 10px; }
.hud-chip b, .hud-chip span { display: block; }
.hud-chip span { color: var(--muted); font-size: 12px; }
.hud-card {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(460px, calc(100vw - 20px));
  max-height: 46vh;
  overflow: auto;
  padding: 12px;
}
.hud-log {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: min(320px, calc(100vw - 500px));
  max-height: 32vh;
  overflow: auto;
  padding: 8px 10px;
}
.hud-card h2 { margin: 0 0 6px; color: var(--gold); font-size: 22px; }
#mini {
  position: absolute;
  top: 78px;
  right: 10px;
  width: 168px;
  height: 168px;
  cursor: crosshair;
}
.veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 8, 0.55);
}
.veil[hidden] { display: none; }
.veil-card {
  width: min(460px, calc(100% - 24px));
  background: rgba(20, 16, 12, 0.94);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 16px;
}
.veil-card h2 { color: var(--gold); margin: 0 0 8px; }
.sheet { display: contents; }
.sheet-handle { display: none; }
@media (max-width: 760px) {
  .hud-top {
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 8px;
    background: rgba(12, 10, 8, 0.78);
  }
  .hud-top .brand { display: none; }
  .hud-chip, .hud-top .btn { flex: 0 0 auto; }
  .hud-top .btn, .sheet-handle, .hud-card .btn { min-height: 44px; }
  #clock { font-size: 16px; }
  #mini {
    top: calc(env(safe-area-inset-top) + 62px);
    width: 96px;
    height: 96px;
  }
  #hud-age { display: none; }
  #hud-hour span, #hud-purse span {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hud-log {
    display: block;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 40px;
    overflow: hidden;
    padding: 6px 10px;
  }
  .hud-log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hud-log li + li { display: none; }
  body.sheet-open .hud-log { display: none; }
  .sheet {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    transition: transform 180ms ease;
    transform: translateY(calc(100% - 72px - env(safe-area-inset-bottom)));
  }
  body.sheet-open .sheet { transform: none; }
  .sheet-handle {
    display: block;
    margin: 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    padding: 8px 12px 10px;
  }
  .sheet-handle::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    margin: 0 auto 6px;
    border-radius: 4px;
    background: var(--gold-dim);
  }
  .hud-card {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    max-height: min(62dvh, 560px);
    border-radius: 0;
    border-top: 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .hud-card .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }
  .hud-card .btn {
    width: 100%;
    white-space: normal;
    text-align: left;
    line-height: 1.25;
  }
  .hud-card .row .btn:only-child { grid-column: 1 / -1; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .hud-card .row { grid-template-columns: 1fr; }
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.gate {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 18px 72px;
}
.gate-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.gate-wallet { margin-top: 0; }
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: center;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(226, 192, 120, 0.35);
  background:
    radial-gradient(600px 240px at 20% 0%, rgba(226, 192, 120, 0.16), transparent 70%),
    rgba(16, 13, 10, 0.72);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.hero-film { position: relative; margin: 0; }
.hero-art {
  width: 100%;
  height: min(460px, 62vh);
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(226, 192, 120, 0.28);
  background: #120e0b;
}
.hero-sound {
  position: absolute;
  left: 12px;
  bottom: 12px;
}
.earn-line {
  color: var(--paper);
  margin: 0 0 10px;
  line-height: 1.45;
}
.hero-copy { padding: 8px 8px 8px 4px; }
.eyebrow {
  margin: 12px 0 0;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}
.gate h1, .brand {
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.gate h1 { font-size: clamp(40px, 6vw, 64px); margin: 6px 0 8px; color: var(--gold); }
.lede { color: var(--paper); max-width: 46ch; line-height: 1.5; }
.pillars {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 8px;
}
.pillars li {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(226, 192, 120, 0.2);
}
.pillars b { display: block; color: var(--gold); }
.pillars span { color: var(--muted); font-size: 14px; }
.wallet-line { margin: 0 0 8px; color: var(--paper); }
.found { margin-top: 18px; }
.found-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 10px;
}
.gate img.coin-hero, .coin-hero {
  width: 96px;
  height: 96px;
  margin: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 6px rgba(226, 192, 120, 0.15);
}
.card, .panel, .side, header.app {
  background: rgba(26, 22, 18, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card { padding: 16px; margin-top: 16px; }
label { display: block; margin: 10px 0; color: var(--muted); }
input, select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: #140f0c;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn {
  background: #3d3224;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 4px;
  padding: 8px 12px;
}
.btn.primary { background: #6d5424; color: #fff8e8; }
.btn.danger { border-color: var(--blood); color: #ffd0c8; }
.btn:hover { filter: brightness(1.14); }
.hud-card h2 { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.app { max-width: 1180px; margin: 0 auto; padding: 14px; }
header.app {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, auto);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.brand { color: var(--gold); letter-spacing: 0.16em; }
.stat { text-align: right; }
.stat b { display: block; color: var(--gold); font-size: 18px; }
.stat span { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
nav button[aria-current="page"] { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 10px; }
.panel { padding: 14px; }
.panel h2 { margin: 0 0 8px; font-size: 22px; color: var(--gold); }
.muted { color: var(--muted); }
.advisor {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  background: rgba(226, 192, 120, 0.08);
  color: var(--paper);
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.tile b { color: var(--gold); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #3d3328; }
th { color: var(--gold-dim); font-weight: 600; font-size: 13px; }
.side { padding: 10px; }
.side h3 { margin: 8px 0; color: var(--gold); font-size: 16px; }
.log { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow: auto; }
.log li { padding: 6px 0; border-bottom: 1px solid #3a3128; color: var(--muted); font-size: 14px; }
.log b { color: var(--paper); font-weight: 600; }
canvas.sky { width: 100%; height: 90px; background: #120e0b; border-radius: 6px; }
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #140f0c;
  border: 1px solid var(--gold);
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 6px;
  max-width: min(520px, 92vw);
}
.brand-row, .coin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.coin-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.coin-hero {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  object-fit: cover;
  margin: 16px 0 0;
  border: 1px solid var(--line);
}
.map {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.warn { color: var(--danger); }
.ok { color: var(--pine); }

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
}
.intro-film { width: 100%; height: 100%; object-fit: cover; display: block; }
.intro-chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 36px 18px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
}
.intro-mark {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.intro-actions { display: flex; gap: 8px; }
.home {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 22px;
  align-items: start;
}
.steps {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 10px;
  counter-reset: step;
}
.steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(226, 192, 120, 0.2);
}
.steps li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  color: var(--gold);
  letter-spacing: 0.08em;
  grid-row: 1 / span 2;
  align-self: center;
}
.steps b { display: block; color: var(--gold); }
.steps span { color: var(--muted); }
.home-seat { position: sticky; top: 16px; }

@media (max-width: 860px) {
  header.app { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .hero, .found-grid, .home { grid-template-columns: 1fr; }
  .hero-art { height: 220px; }
  .gate { padding: 12px 14px calc(32px + env(safe-area-inset-bottom)); }
  .gate h1 { font-size: clamp(32px, 11vw, 46px); }
  .gate-bar { align-items: flex-start; flex-wrap: wrap; }
  .gate-wallet { width: 100%; }
  .gate-wallet .btn, .home-seat .btn { flex: 1; text-align: center; min-height: 48px; }
  .home-seat { position: static; }
  .home-seat .row { display: grid; grid-template-columns: 1fr; }
  .intro-chrome { flex-direction: column; align-items: stretch; }
  .intro-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .intro-actions .btn { min-height: 48px; }
  input, select, .gate .btn { font-size: 16px; }
  .steps span { font-size: 15px; line-height: 1.4; }
}
