:root {
  color-scheme: dark;
  --ink: #eef9ed;
  --muted: #9bb1a8;
  --glass: rgba(6, 18, 18, .86);
  --line: rgba(192, 236, 212, .16);
  --blue: #4ee6e0;
  --red: #ff6b72;
  --gold: #f5c66a;
  --violet: #bd91ff;
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #071010; }
body { color: var(--ink); }
/* Cover generated labels/cards too; WebKit selection is not reliably inherited. */
html, body, #app, #app * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
html, body, #app { touch-action: none; overscroll-behavior: none; }
#app img, #app canvas { -webkit-user-drag: none; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button { font: inherit; color: inherit; }
#game, #game canvas { width: 100%; height: 100%; display: block; }
#game { position: absolute; inset: 0; }
.is-hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: max(18px, var(--safe-top)) max(18px, var(--safe-right)) max(18px, var(--safe-bottom)) max(18px, var(--safe-left));
  background: radial-gradient(circle at 50% 35%, rgba(42, 94, 77, .34), transparent 34%), linear-gradient(145deg, rgba(4, 13, 14, .96), rgba(12, 24, 22, .92));
}
.screen--active { display: grid; }
#boot-screen { text-align: center; }
.brand-mark {
  width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 18px;
  border: 1px solid rgba(245, 198, 106, .58); transform: rotate(45deg); color: var(--gold);
  font-weight: 900; letter-spacing: -.08em; box-shadow: 0 0 36px rgba(245, 198, 106, .2);
}
.brand-mark::first-line { transform: rotate(-45deg); }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .28em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(38px, 8cqw, 74px); line-height: .9; letter-spacing: -.07em; }
h1 span { color: transparent; -webkit-text-stroke: 1px var(--gold); }
#boot-copy, .select-status, #result-hint { color: var(--muted); font-size: 13px; }
.loader { width: 160px; height: 2px; margin: 24px auto 0; overflow: hidden; background: rgba(255,255,255,.08); }
.loader i { display: block; width: 44%; height: 100%; background: var(--gold); animation: load 1.2s ease-in-out infinite alternate; }
@keyframes load { to { transform: translateX(205%); } }

.panel { width: min(980px, 100%); border: 1px solid var(--line); background: var(--glass); box-shadow: 0 30px 90px rgba(0,0,0,.45); backdrop-filter: blur(18px); }
.select-panel { padding: clamp(18px, 3cqw, 34px); max-height: 100%; overflow-y: auto; touch-action: pan-y; }
.hero-kit, .game-guide { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 8px 0; }
.hero-kit { color: #e1d5a5; min-height: 16px; }
.game-guide { border-top: 1px solid var(--line); padding-top: 8px; }
.select-panel header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.select-panel h2, .result-panel h2 { margin-bottom: 0; font-size: clamp(26px, 4cqw, 44px); letter-spacing: -.05em; }
.chip { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.06); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.chip:active { transform: scale(.96); }

.hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 24px 0 18px; }
.hero-card { position: relative; min-height: 250px; padding: 0; overflow: hidden; text-align: left; border: 1px solid var(--line); background: #0c1a19; cursor: pointer; }
.hero-card::after { content: ""; position: absolute; inset: 38% 0 0; background: linear-gradient(transparent, rgba(3,9,10,.98)); }
.hero-card img { width: 100%; height: 176px; object-fit: cover; object-position: top center; filter: saturate(.78) contrast(1.08); transition: .2s ease; }
.hero-card:hover img, .hero-card:focus-visible img { transform: scale(1.04); filter: saturate(1.05); }
.hero-card div { position: absolute; z-index: 1; inset: auto 14px 14px; }
.hero-card strong { display: block; font-size: 18px; letter-spacing: -.03em; }
.hero-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.hero-card small { display: inline-block; margin-top: 9px; color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.hero-card.is-selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 32px rgba(245,198,106,.14); }
.draft-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.draft-connection { display: inline-flex; align-items: center; gap: 7px; }
.draft-connection i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 9px currentColor; }
.draft-connection.online i { background: #60ef9a; }
.draft-connection.poor i { background: var(--red); }
.draft-meta + .select-status { margin: 10px 0 4px; color: var(--ink); }
.draft-auto { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }
.draft-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 10px; }
.draft-action { min-width: 170px; transition: opacity .18s, transform .18s, background .18s; }
.draft-action:disabled { opacity: .38; cursor: not-allowed; }
.draft-action:not(:disabled):active { transform: scale(.97); }
.draft-action.is-ready { border: 1px solid rgba(96,239,154,.5); background: rgba(96,239,154,.12); color: #a9f8c7; }
.draft-retry { margin-top: 12px; border-color: rgba(255,107,114,.48); }

.result-panel { max-width: 520px; padding: 38px; text-align: center; }
.result-panel h2 { font-size: clamp(46px, 9cqw, 88px); }
.result-panel p { color: var(--muted); }
.primary { min-height: 52px; padding: 0 26px; border: 0; background: var(--gold); color: #1d170b; font-weight: 900; letter-spacing: .04em; cursor: pointer; }
#toast { position: absolute; z-index: 80; left: 50%; bottom: 18%; max-width: 80%; padding: 10px 16px; transform: translate(-50%, 20px); opacity: 0; border: 1px solid var(--line); background: rgba(5,14,14,.92); transition: .2s; pointer-events: none; }
#toast.on { transform: translate(-50%, 0); opacity: 1; }
