:root {
  --navy: #0d1726;
  --navy2: #152338;
  --ink: #e7edf3;
  --dim: #8fa1b5;
  --un: #5b92e5;
  --egg: #b5dcd6;
  --egg-d: #6fa7a0;
  --red: #e0604f;
  --gold: #f0c75e;
  --top: 44px;
  --tick: 34px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font: 15px/1.45 system-ui, "Segoe UI", sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  position: fixed; inset: var(--top) 0 0 0;
  display: grid; grid-template-columns: 1fr 320px; grid-template-rows: 1fr var(--tick);
  background: radial-gradient(ellipse at 40% 45%, #1d3150 0%, var(--navy) 70%);
}
#table { grid-column: 1; grid-row: 1; position: relative; min-width: 0; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: manipulation; }

#panel {
  grid-column: 2; grid-row: 1; overflow-y: auto; padding: 16px 16px 10px;
  background: linear-gradient(180deg, #13213a, #0f1a2c); border-left: 1px solid #263a58;
  display: flex; flex-direction: column; gap: 12px;
}
.crest { font-size: 11px; letter-spacing: .16em; color: var(--un); font-weight: 700; }
#panel h1 { margin: 2px 0 0; font-size: 21px; line-height: 1.15; }
.where { color: var(--dim); font-size: 13px; }

#stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
#stats div { background: #0b1422; border: 1px solid #22344f; border-radius: 6px; padding: 6px 8px; }
#stats dt { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
#stats dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

#mob { display: grid; gap: 5px; }
.mob { display: grid; grid-template-columns: 44px 1fr 28px; align-items: center; gap: 8px; font-size: 13px; }
.mob .bar { height: 8px; background: #0b1422; border-radius: 4px; overflow: hidden; border: 1px solid #22344f; }
.mob .bar i { display: block; height: 100%; width: 0; transition: width .3s; border-radius: 4px; }
.mob.w .bar i { background: #e9e1cf; }
.mob.b .bar i { background: #6a6a78; }
.mob b { text-align: right; font-variant-numeric: tabular-nums; }
.mob.next .lbl { color: var(--gold); font-weight: 700; }
.mob.next .lbl::before { content: "▶ "; font-size: 9px; vertical-align: 1px; }
.mob-note { margin: 0; font-size: 12px; color: var(--dim); }

#prompt { min-height: 66px; padding: 10px 12px; border-radius: 8px; background: #0b1422; border: 1px solid #22344f; font-size: 14px; }
#prompt.you { border-color: var(--egg); box-shadow: 0 0 0 1px var(--egg) inset; }
#prompt.danger { border-color: var(--red); box-shadow: 0 0 0 1px var(--red) inset; animation: throb .8s infinite alternate; }
#prompt b { color: var(--egg); }
#prompt.danger b { color: #ffb3a8; }
@keyframes throb { to { background: #2a1416; } }

#buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#buttons button, .row button {
  background: #1a2b45; border: 1px solid #2f4870; border-radius: 6px; padding: 7px 10px;
}
#buttons button:hover:not(:disabled), .row button:hover { background: #22385a; }
#buttons button:disabled { opacity: .4; cursor: default; }
#b-pause { border-color: var(--egg-d); }
.pips { display: inline-flex; gap: 4px; vertical-align: -1px; margin: 0 4px; }
.pips i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--egg-d); }
.pips i.on { background: var(--egg); border-color: var(--egg); box-shadow: 0 0 6px var(--egg); }
#b-threats[aria-pressed="false"] { opacity: .6; }
button.primary { background: var(--un) !important; border-color: #7eaaf0 !important; color: #fff; font-weight: 700; }

#log { list-style: none; margin: 0; padding: 0; font: 13px/1.6 ui-monospace, Consolas, monospace; color: var(--dim);
  columns: 2; column-gap: 12px; flex: 1; min-height: 60px; overflow-y: auto; }
#log li { break-inside: avoid; }
#log li.u { color: var(--egg); }
#log li.cap { color: #f3b6a6; }

#ticker { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: stretch; background: #070d17; border-top: 1px solid #263a58; overflow: hidden; }
#ticker .tag { background: var(--un); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .1em; padding: 0 12px; display: flex; align-items: center; flex: none; }
#ticker .crawl { flex: 1; overflow: hidden; position: relative; display: flex; align-items: center; }
#crawl { white-space: nowrap; font: 14px ui-monospace, Consolas, monospace; color: #cfe0f2; padding-left: 100%; animation: crawl linear infinite; animation-duration: var(--dur, 40s); }
@keyframes crawl { to { transform: translateX(-100%); } }

.overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 11, 20, .78); backdrop-filter: blur(3px); overflow-y: auto; }
.overlay[hidden] { display: none; }
.card { background: linear-gradient(180deg, #172741, #101c30); border: 1px solid #2f4870; border-radius: 12px; padding: 22px 26px;
  width: min(640px, 100%); box-shadow: 0 20px 60px #000a; max-height: 100%; overflow-y: auto; }
.big { font: 900 clamp(40px, 8vw, 72px)/1 "Arial Black", Impact, system-ui, sans-serif; letter-spacing: .04em; margin: 8px 0 4px;
  color: var(--egg); text-shadow: 0 3px 0 #2c5b56, 0 8px 24px #0008; }
.card .tag { font-size: 17px; margin: 0 0 14px; }
.how { display: grid; gap: 4px; font-size: 14px; color: #c9d5e2; background: #0b1422; border-radius: 8px; padding: 10px 14px; border: 1px solid #22344f; }
.how p { margin: 0; }
.how b { color: var(--ink); }
#missions { list-style: none; padding: 0; margin: 14px 0 6px; display: grid; gap: 6px; }
#missions button { width: 100%; text-align: left; display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  background: #1a2b45; border: 1px solid #2f4870; border-radius: 8px; padding: 9px 12px; }
#missions button:hover:not(:disabled) { background: #22385a; border-color: var(--egg-d); }
#missions button:disabled { opacity: .45; cursor: default; }
#missions .n { font-weight: 800; color: var(--un); font-size: 18px; text-align: center; }
#missions .t b { display: block; }
#missions .t small { color: var(--dim); }
#missions .st { color: var(--gold); letter-spacing: 2px; font-size: 16px; }
#missions .st .off { color: #3a4c66; }
.fine { font-size: 12px; color: var(--dim); margin: 6px 0 0; }

.card h2 { margin: 6px 0 8px; font-size: 26px; }
.terms { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; list-style: none; color: #c9d5e2; }
.terms b { color: var(--egg); }
.tip { background: #0b1422; border-left: 3px solid var(--egg); padding: 8px 12px; border-radius: 4px; font-size: 14px; color: #c9d5e2; }
.stars-key { color: var(--gold); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.stars { font-size: 44px; letter-spacing: 6px; color: var(--gold); text-shadow: 0 2px 12px #f0c75e55; }
.stars .off { color: #2c3c55; text-shadow: none; }

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 58vh) auto var(--tick); overflow-y: auto; }
  #table { grid-row: 1; }
  #panel { grid-column: 1; grid-row: 2; border-left: 0; border-top: 1px solid #263a58; overflow: visible; }
  #ticker { grid-row: 3; position: sticky; bottom: 0; }
  #log { max-height: 140px; }
}
