/* Masters Survivors. Brand from tokens.css + fusion.css; this file only lays out the game. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--ormus-font-sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
button { font: inherit; color: inherit; }

#stage { position: fixed; inset: 0; display: block; }

/* ── Screens: one overlay at a time over the field ── */
#screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  touch-action: pan-y;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
#screen:empty { display: none; }
.veil { background: color-mix(in srgb, var(--ormus-deep) 82%, transparent); }
.veil-soft { background: radial-gradient(ellipse at center, color-mix(in srgb, var(--ormus-deep) 78%, transparent) 0%, color-mix(in srgb, var(--ormus-deep) 45%, transparent) 70%); }

.panel { width: min(720px, 100%); text-align: center; }
.panel h1 { font-size: clamp(2.6rem, 8vw, 4.6rem); margin: 0.4rem 0 0.6rem; line-height: 1.02; }
.panel h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0.3rem 0 1rem; line-height: 1.1; }
.lede { color: var(--ormus-ink-muted); max-width: 34rem; margin: 0 auto 1.6rem; line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-top: 1.4rem; }
.fusion-btn { min-height: 44px; padding: 0.55rem 1.2rem; }
.keyhint { display: block; margin-top: 1.2rem; }
.foot-links { margin-top: 2rem; display: flex; gap: 1rem; justify-content: center; }
.foot-links a { color: var(--ormus-ink-muted); text-decoration: none; }
.foot-links a:hover { color: var(--ormus-ink); }

/* ── Choosing a master ── */
.select { width: min(1180px, 100%); align-self: start; display: grid; grid-template-columns: 1fr 340px; gap: 1.6rem; }
.select-head { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.select-head h2 { margin: 0.2rem 0 0; font-size: 2.2rem; }
.council { margin: 0 0 1.4rem; }
.council-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; }
.council-head img { width: 34px; height: 34px; }
.council-head h3 { margin: 0; font-size: 1.25rem; }
.council-head .gift { margin-left: auto; text-align: right; }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0.5rem; }
.seat {
  display: grid; justify-items: center; gap: 0.35rem; padding: 0.7rem 0.4rem 0.6rem;
  background: var(--ormus-bg-elevated); border: 1px solid var(--ormus-hairline); border-radius: var(--ormus-radius);
  cursor: pointer; text-align: center; transition: border-color 0.15s ease, transform 0.2s var(--ormus-ease-reveal);
}
.seat:hover { border-color: color-mix(in srgb, var(--ormus-ink) 35%, transparent); transform: translateY(-2px); }
.seat[aria-pressed="true"] { border-color: var(--ormus-ink); background: var(--ormus-bg-muted); }
.seat img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: 50% 42%; border: 1px solid color-mix(in srgb, var(--ormus-ink) 50%, transparent); }
.seat .nm { font-size: 0.82rem; line-height: 1.2; }
.detail { position: sticky; top: 0; align-self: start; text-align: left; padding: 1.2rem; border: 1px solid var(--ormus-hairline); border-radius: var(--ormus-radius); background: color-mix(in srgb, var(--ormus-deep) 88%, transparent); }
.detail-art { position: relative; }
.detail img { width: 100%; aspect-ratio: 1; border-radius: var(--ormus-radius); display: block; }
.figure { position: absolute; right: 6px; bottom: 4px; image-rendering: pixelated; background-repeat: no-repeat; filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--ormus-deep) 80%, transparent)); }
.detail h3 { font-size: 1.8rem; margin: 0.8rem 0 0.2rem; }
.detail .essence { color: var(--ormus-ink-muted); font-style: italic; font-family: var(--ormus-font-display); font-size: 1.15rem; margin: 0 0 0.8rem; }
.detail dl { margin: 0.8rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.8rem; font-size: 0.9rem; }
.detail dt { color: var(--ormus-ink-muted); }
.detail dd { margin: 0; }
.detail .fusion-btn { width: 100%; margin-top: 1rem; }

/* Masters still asleep: dimmed, still selectable so you can read how they wake. */
.seat--asleep img { filter: grayscale(1) brightness(0.55); }
.seat--asleep .nm { color: var(--ormus-ink-muted); }
.seat .mono-label { font-size: 0.62rem; }
.seat .mono-label::before { content: ''; }
.asleep { color: var(--ormus-ink-muted); font-size: 0.88rem; line-height: 1.45; margin: 0.9rem 0 0; }
.note { margin-top: 0.4rem; }

/* ── Wider panels: workshop, codex, today's seed ── */
.panel--wide { width: min(880px, 100%); align-self: start; }
.panel--codex { text-align: left; }
.panel--daily .daily-art { position: relative; width: 200px; margin: 0 auto 1rem; }
.panel--daily .daily-art img { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; display: block; border: 1px solid color-mix(in srgb, var(--ormus-ink) 40%, transparent); }
.panel--daily .figure { right: -46px; bottom: -6px; }
.ledger--shop { width: 100%; }
.ledger--shop td { vertical-align: middle; }
.ledger--shop .fusion-btn { min-height: 34px; padding: 0.25rem 0.8rem; font-size: 0.85rem; white-space: nowrap; }
.ledger--shop td:last-child { width: 1%; padding-left: 0.8rem; }
.ledger--wide { width: 100%; }
.pips { display: inline-flex; gap: 3px; margin-left: 0.6rem; vertical-align: middle; }
.pips i { width: 7px; height: 7px; border: 1px solid color-mix(in srgb, var(--ormus-ink) 45%, transparent); border-radius: 50%; }
.pips i.on { background: var(--ormus-ink); }
.tabs { display: flex; gap: 0.4rem; margin: 0.8rem 0 1.2rem; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid var(--ormus-hairline); border-radius: var(--ormus-radius); padding: 0.4rem 0.8rem; cursor: pointer; color: var(--ormus-ink-muted); font-size: 0.88rem; }
.tab[aria-selected="true"] { color: var(--ormus-ink); border-color: color-mix(in srgb, var(--ormus-ink) 55%, transparent); }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.6rem; }
.codex-card { display: grid; grid-template-columns: 56px 1fr; gap: 0.7rem; padding: 0.7rem; border: 1px solid var(--ormus-hairline); border-radius: var(--ormus-radius); background: var(--ormus-bg-elevated); }
.codex-card img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; object-position: 50% 42%; }
.codex-card h3 { margin: 0; font-size: 1.15rem; }
.codex-card p { margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--ormus-ink-muted); line-height: 1.4; }
.codex-card .mono-label { font-size: 0.62rem; }
.codex-h { font-size: 1.4rem; margin: 1.6rem 0 0.3rem; }
.panel--codex .lede { margin: 0 0 0.6rem; max-width: none; }
.woke { font-family: var(--ormus-font-display); font-size: 1.3rem; margin: 0.3rem 0; }

/* Quiet settings: two text switches under the menu. */
.settings { display: flex; gap: 1.2rem; justify-content: center; margin-top: 0.8rem; }
.link { background: none; border: 0; padding: 0.3rem 0; cursor: pointer; color: var(--ormus-ink-muted); font-family: var(--ormus-font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.link:hover, .link:focus-visible { color: var(--ormus-ink); }
button:focus-visible { outline: 1px solid color-mix(in srgb, var(--ormus-ink) 70%, transparent); outline-offset: 2px; }

/* ── Level up ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 230px)); justify-content: center; gap: 0.7rem; margin-top: 1rem; }
.card {
  text-align: left; padding: 1rem 1rem 0.9rem; cursor: pointer; display: grid; gap: 0.35rem; align-content: start;
  background: color-mix(in srgb, var(--ormus-deep) 90%, transparent);
  border: 1px solid var(--ormus-hairline); border-top-color: color-mix(in srgb, var(--ormus-ink) 40%, transparent); border-radius: var(--ormus-radius);
  transition: transform 0.2s var(--ormus-ease-reveal), border-color 0.15s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: color-mix(in srgb, var(--ormus-ink) 50%, transparent); outline: none; }
.card--gold, .card--gold:hover, .card--gold:focus-visible { border-color: var(--ormus-gold); }
.card--gold .ttl { color: var(--ormus-gold); }
.actions--quiet { margin-top: 1rem; }
.actions--quiet .fusion-btn { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.85rem; color: var(--ormus-ink-muted); }
.fusion-btn:disabled { opacity: 0.4; cursor: default; }
.card .ttl { font-family: var(--ormus-font-display); font-size: 1.45rem; line-height: 1.1; }
.card .txt { color: var(--ormus-ink-muted); font-size: 0.9rem; line-height: 1.45; }
.card { position: relative; }
.card .key { position: absolute; top: 0.8rem; right: 0.9rem; font-family: var(--ormus-font-mono); font-size: 0.72rem; color: var(--ormus-ink-muted); }
@media (hover: none) { .card .key { display: none; } }

/* ── End of a run ── */
.big-time { font-family: var(--ormus-font-mono); font-size: clamp(2.4rem, 9vw, 3.6rem); margin: 0.2rem 0 0.6rem; }
.tally { display: flex; justify-content: center; gap: 1.6rem; margin: 0 0 1.2rem; flex-wrap: wrap; }
.tally div { display: grid; gap: 0.15rem; }
.tally b { font-family: var(--ormus-font-mono); font-weight: 400; font-size: 1.3rem; }
.ledger { width: min(420px, 100%); margin: 0 auto; border-collapse: collapse; font-size: 0.9rem; }
.ledger td { padding: 0.35rem 0; border-top: 1px solid var(--ormus-hairline); text-align: left; }
.ledger td:last-child { text-align: right; font-family: var(--ormus-font-mono); color: var(--ormus-ink-muted); }

/* ── HUD ── */
#hud { position: fixed; inset: 0 0 auto 0; pointer-events: none; padding-top: env(safe-area-inset-top); }
.xp { height: 6px; background: color-mix(in srgb, var(--ormus-deep) 85%, transparent); border-bottom: 1px solid var(--ormus-hairline); }
.xp-fill { height: 100%; width: 0; background: var(--ormus-gold); transition: width 0.12s linear; }
.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 14px; font-family: var(--ormus-font-mono); font-size: 0.8rem; color: var(--ormus-ink); }
.hud-time { font-size: 1.25rem; letter-spacing: 0.04em; }
.hud-right { justify-self: end; display: flex; align-items: center; gap: 0.4rem; }
.hud-unit { color: var(--ormus-ink-muted); }
.hud-pause {
  pointer-events: auto; margin-left: 0.6rem; min-height: 32px; padding: 0 0.7rem; cursor: pointer;
  background: transparent; border: 1px solid color-mix(in srgb, var(--ormus-ink) 25%, transparent); border-radius: var(--ormus-radius);
  font-family: var(--ormus-font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
}

#hud-gold { margin-left: 0.6rem; }
.boss { width: min(520px, 80vw); margin: 2px auto 0; text-align: center; }
.boss .mono-label::before { content: ''; }
.boss-bar { height: 5px; margin-top: 4px; background: color-mix(in srgb, var(--ormus-deep) 85%, transparent); border: 1px solid var(--ormus-hairline); }
.boss-fill { height: 100%; width: 100%; background: var(--ormus-danger); transition: width 0.15s linear; }

/* Toasts sit at the edge, never in the middle of the field. */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 0.55rem 1rem; border: 1px solid var(--ormus-hairline); border-radius: var(--ormus-radius);
  background: color-mix(in srgb, var(--ormus-deep) 92%, transparent);
  font-family: var(--ormus-font-display); font-size: 1.2rem; color: var(--ormus-ink); pointer-events: none;
  animation: toast-in 0.4s var(--ormus-ease-reveal);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ── Touch stick ── */
#stick { position: fixed; left: -48px; top: -48px; width: 96px; height: 96px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ormus-ink) 25%, transparent); pointer-events: none; }
#stick span { position: absolute; left: 30px; top: 30px; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--ormus-ink) 22%, transparent); }

.noscript { position: fixed; inset: 40% 1rem auto; text-align: center; }

@media (max-width: 860px) {
  .select { grid-template-columns: 1fr; padding-bottom: 200px; }
  .detail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 2; border-radius: 0; border-width: 1px 0 0;
    padding: 0.8rem 16px max(0.8rem, env(safe-area-inset-bottom)); background: var(--ormus-deep);
    display: grid; grid-template-columns: 64px 1fr; gap: 0.1rem 0.8rem; align-items: center;
  }
  .detail-art { grid-row: span 2; }
  .detail img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: 50% 42%; }
  .figure { display: none; }
  .detail h3 { margin: 0; font-size: 1.35rem; }
  .detail .essence { margin: 0; font-size: 1rem; }
  .detail dl { grid-column: 1 / -1; margin-top: 0.5rem; font-size: 0.82rem; }
  .detail dl dt:nth-of-type(n+2), .detail dl dd:nth-of-type(n+2) { display: none; }
  .detail .fusion-btn { grid-column: 1 / -1; margin-top: 0.6rem; }
  .seats { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .seat img { width: 52px; height: 52px; }
  .council-head .gift { display: none; }
  .hud-unit { display: none; }
}
