:root {
  --bg: #101722;
  --panel: #172131;
  --line: #2a3850;
  --ink: #efe5cc;
  --muted: #9aa6b8;
  --gold: #f2b84b;
  --good: #7fd48a;
  --bad: #ff8577;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
button {
  font: inherit;
  color: var(--ink);
  background: #22304a;
  border: 1px solid #3a4c6e;
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #2b3c5c; }
button:disabled { opacity: 0.4; cursor: default; }
button.on { background: #4a3a17; border-color: var(--gold); }
button.primary { background: var(--gold); color: #24190a; border-color: #ffd68a; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #ffc860; }
button.liked { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
button.liked::after { content: " ♥"; color: var(--good); }
button.hated { border-color: var(--bad); }
button.hated::after { content: " ✕"; color: var(--bad); }
button.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(242, 184, 75, 0.35); } }
a { color: #9cc8ff; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

#app { display: flex; flex-direction: column; height: 100dvh; }

#topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px;
  background: #0b111b;
  border-bottom: 1px solid var(--line);
}
.brand { font: 600 22px var(--serif); color: var(--gold); letter-spacing: 0.02em; margin-right: 4px; }
.pill { padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; white-space: nowrap; }
.pill.bad { border-color: var(--bad); }
.actions { display: flex; gap: 5px; align-items: center; height: 26px; }
.actions i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--gold); }
.actions i.on { background: var(--gold); }
#scores { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip {
  display: flex; gap: 8px; align-items: baseline;
  padding: 3px 10px;
  border-left: 4px solid var(--c);
  background: #151e2d;
  border-radius: 4px;
  font-size: 13px;
}
.chip b { color: var(--c); }
.chip.you { background: #241d10; }
nav { display: flex; gap: 6px; }
nav button { width: 34px; padding: 5px 0; }

#board { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
#mapwrap { position: relative; min-height: 0; background: radial-gradient(ellipse at 50% 45%, #1d3348, #0e1a28 75%); }
#map { width: 100%; height: 100%; display: block; }
#side {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
}
#side h2 { font: 600 22px var(--serif); margin: 0; color: var(--gold); }
#side h3 { font: 600 13px system-ui; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 12px 0 6px; }
#info p { margin: 6px 0; }
.perk { color: #d8c7ff; }
.omen-note { color: #dfe7f1; background: #253247; padding: 5px 8px; border-radius: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.rels { display: grid; gap: 4px; }
.rel { display: grid; grid-template-columns: 90px 1fr 32px; gap: 8px; align-items: center; font-size: 13px; }
.rel.you { font-weight: 600; }
.rel .num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 8px; background: #0e1520; border-radius: 4px; }
.bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #55647c; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }
.btnrow.end { justify-content: flex-end; margin-top: 16px; }
.btnrow.global { padding-top: 10px; border-top: 1px solid var(--line); }
.btnrow.global .primary { margin-left: auto; }
.sub { margin-top: 8px; padding: 10px; background: #111a28; border-radius: 8px; display: grid; gap: 8px; }
.sub p { margin: 0; }
.pick { display: block; cursor: pointer; }

#log { flex: 1; min-height: 140px; }
#log ul { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#log li { padding: 4px 0; border-bottom: 1px solid #1f2b3e; color: #cfd6e2; }
#log li.year { color: var(--gold); font: 600 14px var(--serif); padding-top: 10px; border-bottom-color: #4a3a17; }
#log li.omen { color: #dfe7f1; font-style: italic; }
#log li.you { color: #f4e6c4; }
#log li.good { color: #bfe8c4; }
#log li.bad { color: #ffc2ba; }

/* map */
.label { font: 600 17px var(--serif); fill: #f5ecd3; text-anchor: middle; paint-order: stroke; stroke: #1f2a1c; stroke-width: 4px; pointer-events: none; }
.label.small { font-size: 13px; fill: #e2d6f5; }
.eyrie-label { font-size: 15px; fill: #fff3d6; font-style: italic; }
.glyph { font: 700 13px var(--serif); fill: #f5ecd3; text-anchor: middle; pointer-events: none; }
.site { cursor: pointer; outline: none; }
.site .halo { fill: transparent; }
.site:hover .halo, .site:focus-visible .halo { fill: rgba(255, 240, 200, 0.12); }
.site.selected .halo { fill: rgba(242, 184, 75, 0.22); stroke: var(--gold); stroke-width: 2; }
.site.ruined .label { fill: #9aa0a8; }
.tie { stroke: rgba(242, 184, 75, 0.55); stroke-width: 2; stroke-dasharray: 5 5; }
.omen path { fill: none; stroke: #eef4ff; stroke-width: 2.2; stroke-linecap: round; filter: drop-shadow(0 0 3px #bfe3ff); animation: drop 1s linear infinite; }
.omen.lvl2 path { stroke-width: 2.8; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(26px); opacity: 0; } }

/* modal */
#modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(5, 8, 14, 0.72);
  padding: 16px;
}
#modal[hidden] { display: none; }
.card {
  width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--panel); border: 1px solid #3a4c6e; border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.card h2 { font: 600 26px var(--serif); color: var(--gold); margin: 0 0 10px; }
.card ul { padding-left: 20px; }
.title .tag { font: italic 17px var(--serif); }
.opts { display: grid; gap: 10px; margin: 14px 0; }
.opts button { margin-right: 6px; }
.opts .muted { display: inline-block; width: 56px; }
.fall-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px; margin: 8px 0;
  background: #111a28; border: 1px solid var(--line); border-radius: 10px;
}
.fall-row.lead { border-color: var(--gold); }
.fall-name .muted { font-size: 12.5px; }
.lvl { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: #3a4a62; }
.lvl1 { background: #4f5f7a; }
.lvl2 { background: #7a4a5a; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper span { width: 22px; text-align: center; font: 600 17px var(--serif); }
.stepper button { width: 30px; padding: 3px 0; }
.leadpick { white-space: nowrap; cursor: pointer; }
.res { padding: 8px 0; border-bottom: 1px solid var(--line); }
.standings li { margin: 4px 0; }
.picklist { max-height: 45vh; overflow-y: auto; display: grid; gap: 4px; }

/* flight */
#flight { position: fixed; inset: 0; z-index: 10; background: #05080e; display: grid; place-items: center; }
#flight[hidden] { display: none; }
#sky { width: min(100vw, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9; display: block; }
.touch { display: none; }
@media (pointer: coarse) {
  .touch { display: flex; position: absolute; inset: auto 0 0 0; justify-content: space-between; align-items: flex-end; padding: 12px; pointer-events: none; }
  .stick { pointer-events: auto; width: 45vw; height: 38vh; border: 1px dashed rgba(255, 255, 255, 0.2); border-radius: 16px; display: grid; place-items: center; color: rgba(255, 255, 255, 0.35); touch-action: none; user-select: none; }
  .tbtns { pointer-events: auto; display: grid; grid-template-columns: repeat(2, 72px); gap: 8px; }
  .tbtns button { height: 56px; background: rgba(34, 48, 74, 0.7); touch-action: none; user-select: none; }
  .tbtns .t-flame { background: rgba(242, 120, 40, 0.75); }
}

@media (max-width: 860px) {
  #board { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  #mapwrap { height: 62vw; }
  #side { border-left: none; border-top: 1px solid var(--line); overflow: visible; }
  #scores { margin-left: 0; width: 100%; order: 5; }
}
