:root {
  --void: #06140f;
  --void-2: #0c2218;
  --panel: #10261c;
  --emerald: #147a4a;
  --emerald-glow: #3ee09a;
  --gold: #d4af67;
  --gold-deep: #8a6a2a;
  --ruby: #9e2438;
  --cream: #f4e8c8;
  --dim: #cbb892;
  --ink: #f7efd8;
  --line: rgba(212, 175, 103, 0.42);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(20, 122, 74, 0.28), transparent 58%),
    radial-gradient(700px 280px at 100% 10%, rgba(212, 175, 103, 0.12), transparent 50%),
    var(--void);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

img, canvas, svg { max-width: 100%; }

button { font-family: inherit; touch-action: manipulation; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.veil-gold {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(212, 175, 103, 0.08), transparent 18%),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(212, 175, 103, 0.03) 46px 48px);
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  margin: 0 auto;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  min-width: 0;
}

.crestbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 6px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crest {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 16px rgba(62, 224, 154, 0.35);
}

.brand-copy { min-width: 0; }

.brand-copy h1 {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(0.95rem, 4.2vw, 1.55rem);
  line-height: 1.12;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: 0.02em;
}

.eyebrow, .kicker {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
  line-height: 1.3;
}

.mute {
  margin-left: auto;
  flex: none;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(212, 175, 103, 0.16), rgba(6, 20, 15, 0.8));
  color: var(--cream);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.mute[aria-pressed="true"] {
  color: var(--gold);
  box-shadow: 0 0 14px rgba(212, 175, 103, 0.35);
}

.arcade {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 8px 6px 4px;
  min-width: 0;
  width: 100%;
}

.lancet {
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.lancet .pane {
  width: min(44px, 100%);
  height: 48px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(#3a2e16, #12100a);
  clip-path: polygon(50% 0, 100% 26%, 100% 100%, 0 100%, 0 26%);
  box-shadow: inset 0 0 0 1.5px rgba(212, 175, 103, 0.55);
}

.lancet svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.lancet .label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lancet.on { color: var(--cream); }

.lancet.on .pane {
  background: radial-gradient(circle at 50% 80%, rgba(62, 224, 154, 0.95), #0d3d28 68%);
  box-shadow:
    inset 0 0 0 1.5px #f0d48a,
    0 0 16px rgba(62, 224, 154, 0.45);
  color: var(--gold);
}

.panel { display: none; }
.panel.on { display: block; }

.sheet {
  margin: 0 12px 12px;
  padding: 14px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(18, 44, 32, 0.96), rgba(8, 20, 14, 0.96)) padding-box,
    linear-gradient(145deg, #f0d48a, #6e4a16 40%, #147a4a 78%, #f0d48a) border-box;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.sheet h2, .sheet h3 {
  margin: 0 0 6px;
  line-height: 1.3;
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  max-width: 100%;
}

.sheet h2 { font-size: clamp(1.25rem, 5.6vw, 1.9rem); }

.sheet h3 { font-size: clamp(1.05rem, 4.4vw, 1.35rem); }

.lead, .sheet p { color: var(--dim); overflow-wrap: break-word; }

.sheet p { margin: 0 0 10px; }
.sheet p:last-child { margin-bottom: 0; }

.frame, .portrait {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.frame { aspect-ratio: 16 / 10; margin-bottom: 12px; }

.portrait { aspect-ratio: 3 / 4; max-height: 340px; margin-inline: auto; margin-bottom: 12px; }

.play { position: relative; }

.hud-top h2 { font-size: clamp(1.2rem, 5.4vw, 1.75rem); }

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.annals-meters {
  margin: 0 12px 12px;
}

.meter {
  min-width: 0;
  padding: 7px 5px;
  border-radius: 12px;
  background: rgba(4, 12, 8, 0.55);
  border: 1px solid rgba(212, 175, 103, 0.22);
}

.meter span {
  display: block;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
}

.meter strong {
  display: block;
  color: var(--gold);
  font-size: clamp(0.8rem, 3.4vw, 1.05rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.stage-wrap {
  display: grid;
  place-items: center;
  margin: 10px 0 8px;
}

.stage {
  width: min(100%, 520px);
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(212, 175, 103, 0.16), transparent 46%),
    #040a08;
  box-shadow:
    0 0 0 2px rgba(212, 175, 103, 0.35),
    0 0 28px rgba(20, 122, 74, 0.28);
  overflow: hidden;
}

.stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ghost {
  position: fixed;
  width: 56px;
  height: 56px;
  pointer-events: none;
  z-index: 40;
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(212, 175, 103, 0.55);
  background: rgba(8, 24, 16, 0.9);
  display: none;
  place-items: center;
  transform: translate(-50%, -50%);
}

.ghost.is-on {
  display: grid;
}

.note {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.88rem;
  min-height: 2.4em;
}

.shard-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.shard-rail::-webkit-scrollbar { display: none; }

.shard {
  flex: none;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: radial-gradient(circle at 40% 30%, #1a3a2a, #07140f);
  padding: 0;
  position: relative;
}

.shard canvas { width: 100%; height: 100%; display: block; }

.shard.on {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(212, 175, 103, 0.55);
}

.shard.used { opacity: 0.28; }

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.controls button, .veil-actions button, .solid, .danger {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(212, 175, 103, 0.12), rgba(8, 20, 14, 0.9));
  color: var(--cream);
  padding: 6px 4px;
  min-width: 0;
}

button:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.controls button b {
  display: block;
  color: var(--gold);
  font-size: 1rem;
  line-height: 1.1;
}

.controls button span {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.solid {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(180deg, #f0d48a, #b88832);
  color: #0a1a12;
  border: 0;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 0 18px rgba(212, 175, 103, 0.35);
}

.danger {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(180deg, #c44a5c, #7a1828);
  color: var(--cream);
  border: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.help {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.help summary {
  color: var(--gold);
  cursor: pointer;
  font-size: 0.92rem;
}

.help ol {
  margin: 8px 0 0;
  padding-left: 1.15rem;
  color: var(--dim);
}

.help li { margin-bottom: 6px; }

.complete {
  position: absolute;
  inset: 0;
  display: none;
  place-content: center;
  padding: 18px;
  text-align: center;
  background: rgba(4, 12, 8, 0.88);
  backdrop-filter: blur(6px);
  z-index: 5;
}

.complete.is-on {
  display: grid;
}

.complete h2 { color: var(--cream); }

.stars {
  color: var(--gold);
  letter-spacing: 0.2em;
  font-size: 1.2rem;
}

.veil-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.card-top {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.card-top img {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
}

.status {
  margin: 4px 0 0;
  color: var(--emerald-glow);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status.lock { color: #8a6a2a; }

.flora-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.flora-card {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: rgba(8, 20, 14, 0.92);
  border: 1px solid var(--line);
}

.flora-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
}

.flora-card.lock img {
  filter: grayscale(1) brightness(0.28);
}

.flora-card h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-family: Palatino, Georgia, serif;
}

.flora-card p {
  margin: 0;
  color: var(--dim);
  font-size: 0.8rem;
}

.runs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.runs li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(212, 175, 103, 0.16);
  min-width: 0;
}

.runs span { overflow-wrap: break-word; }

@media (max-width: 380px) {
  .meters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lancet .label { font-size: 0.55rem; }
  .card-top { grid-template-columns: 76px minmax(0, 1fr); }
  .card-top img { width: 76px; height: 76px; }
  .flora-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 520px) {
  .flora-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .arcade { padding: 10px 16px 8px; }
}

@media (min-width: 720px) {
  .shell { padding-bottom: 28px; }
  .arcade {
    position: sticky;
    top: 0;
    z-index: 8;
    background: linear-gradient(180deg, rgba(6, 20, 15, 0.96), rgba(6, 20, 15, 0.88));
  }
}

@media (max-width: 719px) {
  .arcade {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, rgba(10, 28, 20, 0.2), rgba(6, 20, 15, 0.96) 24%),
      #06140f;
    border-top: 1px solid var(--line);
  }
}
