/* Dialmoor — night-observatory identity: ink/indigo + brass + coral, square-cornered panels, star-chart rules,
   Josefin Sans (display) + Atkinson Hyperlegible (text), both self-hosted (OFL). Split layout on desktop. */
@font-face { font-family: "Josefin Sans"; src: url("../fonts/josefin-sans-latin.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-700-latin.woff2") format("woff2"); font-weight: 700; font-display: swap; }
:root {
  --ink: #10152b; --night: #1a2244; --indigo: #263163; --panel: #212b52; --line: #3f4c85;
  --chalk: #e4ebf5; --mist: #b4c3e0; --brass: #e3b04b; --coral: #ff8a5c; --teal: #4fb3a9;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { font-family: "Atkinson Hyperlegible", system-ui, sans-serif; font-size: 16px; color: var(--chalk); background: var(--ink); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(1.5px 1.5px at 20% 30%, #fff8 50%, transparent 51%), radial-gradient(1.5px 1.5px at 70% 60%, #fff6 50%, transparent 51%), radial-gradient(1px 1px at 40% 80%, #fff7 50%, transparent 51%); background-size: 180px 180px, 240px 240px, 130px 130px; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus { outline: 3px solid var(--brass); outline-offset: 3px; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: 3px dashed var(--brass); }

#app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; background: var(--night); overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--night); overflow: hidden; }
.screen.active { display: flex; }
.screen.scroll { overflow-y: auto; }
#title { overflow-y: auto; }

h1, h2, .top-title, .rc-name, .q, .sky-name, .rules dt, .moves span, .tag { font-family: "Josefin Sans", system-ui, sans-serif; }
h1 { font-size: 46px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1.05; color: var(--chalk); }
h2 { font-size: 27px; font-weight: 700; letter-spacing: .02em; line-height: 1.15; color: var(--chalk); }
.tag { font-size: 14px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); }
.lede { font-size: 17px; line-height: 1.55; color: var(--mist); margin: 10px 0 18px; }
.lede.small { font-size: 16px; }
.fine { font-size: 15px; line-height: 1.5; color: var(--mist); margin: 8px 0; }

.pic { position: relative; overflow: hidden; background: var(--ink); }
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light; }
.sky-dusk::after { background: linear-gradient(180deg, rgba(255,138,92,0) 20%, rgba(255,138,92,.75)); mix-blend-mode: overlay; }
.sky-aurora::after { background: linear-gradient(170deg, rgba(79,179,169,.8), rgba(79,179,169,0) 60%); mix-blend-mode: overlay; }
.sky-midnight::after { background: rgba(38,49,99,.15); }
.hero { flex: 0 0 auto; height: 50vh; min-height: 260px; max-height: 520px; border-bottom: 3px solid var(--brass); }
.hero.mid { height: 38vh; min-height: 220px; max-height: 380px; }
.topveil { position: absolute; left: 0; right: 0; top: 0; height: 120px; background: linear-gradient(180deg, rgba(16,21,43,.85), rgba(16,21,43,0)); pointer-events: none; z-index: 1; }
.side { padding: 18px 22px calc(22px + var(--safe-b)); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.mark { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px; }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-top: 12px; font-size: 14px; color: var(--mist); }

.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; padding: 12px 18px; border-radius: 6px; font-size: 17px; font-weight: 700; letter-spacing: .02em; text-align: center; }
.btn + .btn { margin-top: 10px; }
.btn.solid { background: var(--coral); color: var(--ink); }
.btn.outline { border: 2px solid var(--chalk); color: var(--chalk); }
.btn.small { width: auto; min-height: 44px; min-width: 44px; padding: 8px 14px; font-size: 16px; border: 2px solid var(--line); background: var(--ink); color: var(--chalk); }
.textbtn { min-height: 44px; padding: 8px 2px; font-size: 16px; font-weight: 700; color: var(--brass); text-decoration: underline; text-underline-offset: 4px; }
.alink { display: inline-flex; align-items: center; min-height: 44px; font-size: 17px; font-weight: 700; color: var(--brass); }

.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; flex: 0 0 auto; border-bottom: 1px solid var(--line); background: var(--night); }
.top.over { position: absolute; left: 0; right: 0; top: 0; z-index: 2; background: none; border: 0; }
.top-title { flex: 1; text-align: center; font-size: 19px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.top-end { min-width: 64px; text-align: right; }
.count { font-size: 15px; font-weight: 700; color: var(--brass); }
.sheet { padding: 18px 22px calc(26px + var(--safe-b)); }
.sheet > h2 { margin-bottom: 8px; }

.rules { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 14px 0 20px; border-left: 3px solid var(--brass); padding-left: 14px; }
.rules dt { font-size: 16px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brass); margin-top: 10px; }
.rules dd { font-size: 17px; line-height: 1.5; color: var(--mist); }

.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 16px; }
.room-card { position: relative; display: flex; flex-direction: column; text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: 6px; overflow: hidden; min-height: 44px; }
.room-card .pic { aspect-ratio: 4 / 3; }
.rc-num { position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--brass); font-weight: 700; font-size: 16px; border: 2px solid var(--brass); }
.rc-name { font-size: 18px; font-weight: 700; padding: 10px 12px 0; letter-spacing: .02em; }
.rc-state { font-size: 14px; font-weight: 700; padding: 2px 12px 12px; color: var(--teal); }
.room-card.lit { border-color: var(--brass); }
.room-card.lit .rc-state { color: var(--brass); }
.room-card.locked { opacity: .55; }
.room-card.locked .rc-state { color: var(--mist); }
.room-card.locked .pic img { filter: grayscale(.8) brightness(.6); }
.house-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.confirm { width: 100%; border: 2px solid var(--coral); border-radius: 6px; padding: 14px; background: var(--ink); margin: 6px 0; }
.confirm p { font-size: 16px; margin-bottom: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .btn + .btn { margin-top: 0; }

.goal-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.goal-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 6px; font-size: 16px; font-weight: 700; background: var(--panel); }
.gi { display: inline-block; width: 24px; height: 24px; flex: 0 0 24px; }
.gi svg { width: 100%; height: 100%; display: block; }
.crate-i { border: 3px solid #c79a55; background: repeating-linear-gradient(90deg, #8a6a3a 0 5px, #a37d45 5px 10px); border-radius: 3px; }

/* Table */
.table-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.moves { min-width: 64px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid var(--brass); border-radius: 6px; line-height: 1; padding: 4px 8px; }
.moves b { font-size: 22px; }
.moves span { font-size: 14px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); margin-top: 3px; }
.moves.low { border-color: var(--coral); }
.moves.low span { color: var(--coral); }
.board-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px 10px 6px; container-type: size; }
.board { width: min(100cqw, 100cqh); aspect-ratio: 1; display: grid; grid-template-rows: repeat(7, 1fr); gap: 5px; padding: 7px; background: var(--ink); border: 2px solid var(--line); border-radius: 8px;
  background-image: radial-gradient(circle at 50% 50%, transparent 58%, rgba(227,176,75,.18) 59%, transparent 60%); }
.board.spent .cell { filter: saturate(.3) brightness(.7); }
.brow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; min-height: 0; }
.cell { position: relative; border-radius: 6px; background: var(--panel); display: grid; place-items: center; min-width: 0; min-height: 0; transition: transform .12s ease; user-select: none; -webkit-user-select: none; }
.cell > svg { width: 78%; height: 78%; pointer-events: none; }
.cell .badge { position: absolute; inset: 8%; width: 84%; height: 84%; pointer-events: none; }
.cell.t0 { background: #2c3462; } .cell.t1 { background: #27325c; } .cell.t2 { background: #3a2f55; }
.cell.t3 { background: #30305e; } .cell.t4 { background: #233f55; } .cell.t5 { background: #25425a; }
.cell:focus { outline: 3px solid var(--brass); outline-offset: 1px; z-index: 3; box-shadow: 0 0 0 6px var(--ink); }
.cell.sel { transform: scale(1.08); box-shadow: inset 0 0 0 3px var(--coral); z-index: 2; }
.cell.sel:focus { box-shadow: inset 0 0 0 3px var(--coral), 0 0 0 6px var(--ink); }
.cell.special { box-shadow: inset 0 0 0 2px var(--brass); }
.cell.frost::before { content: ""; position: absolute; inset: 0; border-radius: 6px; background: radial-gradient(circle at 30% 60%, #dfe7f5d0 0 22%, transparent 23%), radial-gradient(circle at 60% 45%, #dfe7f5d0 0 28%, transparent 29%), radial-gradient(circle at 78% 64%, #dfe7f5c0 0 18%, transparent 19%); pointer-events: none; }
.cell.crate::before { content: ""; position: absolute; inset: 2px; border-radius: 4px; border: 4px solid #c79a55; background: repeating-linear-gradient(90deg, rgba(138,106,58,.55) 0 6px, rgba(163,125,69,.55) 6px 12px); pointer-events: none; }
.cell.crate.c1::before { border-style: dashed; background: rgba(138,106,58,.35); }
.cell.aim { cursor: crosshair; }
.table-side { flex: 0 0 auto; padding: 4px 14px calc(12px + var(--safe-b)); }
.goals { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.goal-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 2px solid var(--line); border-radius: 6px; font-size: 15px; background: var(--panel); }
.goal-chip b { font-size: 16px; }
.goal-chip.done { border-color: var(--teal); background: #1f4a4a; }
.hint { font-size: 16px; line-height: 1.4; color: var(--mist); text-align: center; min-height: 44px; margin: 6px 0; display: flex; align-items: center; justify-content: center; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tool { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; text-align: left; min-height: 56px; padding: 6px 8px; border: 2px solid var(--line); border-radius: 6px; background: var(--panel); }
.tool svg { grid-row: 1 / 3; width: 26px; height: 26px; color: var(--brass); }
.tool span { font-size: 16px; font-weight: 700; }
.tool small { font-size: 14px; color: var(--mist); line-height: 1.1; }
.tool.on { border-color: var(--coral); background: #4a2f3a; }
.tool.used { opacity: .45; }
.out { margin-top: 10px; border: 2px solid var(--coral); border-radius: 6px; padding: 12px; background: var(--ink); }
.out p { font-size: 16px; line-height: 1.45; margin-bottom: 10px; }

.skies { display: grid; gap: 10px; margin-bottom: 18px; }
.sky { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; min-height: 60px; border: 2px solid var(--line); border-radius: 6px; background: var(--panel); }
.sky.on { border-color: var(--brass); }
.swatch { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px; border: 2px solid var(--chalk); }
.sw-midnight { background: linear-gradient(180deg, #10152b, #3d3f7a); }
.sw-dusk { background: linear-gradient(180deg, #1a2244, #6c5a9c 55%, #ff8a5c); }
.sw-aurora { background: linear-gradient(160deg, #4fb3a9, #1a2244 70%); }
.sky-name { display: block; font-size: 18px; font-weight: 700; }
.sky-note { display: block; font-size: 15px; color: var(--mist); }

.box { border: 2px solid var(--line); border-radius: 6px; padding: 16px; margin: 14px 0; background: var(--panel); }
.box strong { display: block; font-size: 17px; margin-bottom: 4px; color: var(--brass); }
.box p { font-size: 16px; line-height: 1.5; color: var(--mist); }
.box .btn { margin-top: 12px; }
.q { display: block; font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.qrow { display: flex; gap: 8px; }
.qrow input { flex: 1; min-width: 0; min-height: 52px; font-size: 20px; padding: 8px 12px; border-radius: 6px; border: 2px solid var(--chalk); background: var(--ink); color: var(--chalk); }
.qrow .btn { width: auto; }
.qrow .btn + .btn { margin-top: 0; }
.toast { position: absolute; left: 50%; top: calc(76px + var(--safe-t)); transform: translateX(-50%); max-width: 90%; padding: 10px 16px; border-radius: 6px; background: var(--brass); color: var(--ink); font-weight: 700; font-size: 16px; z-index: 20; text-align: center; pointer-events: none; }

@media (max-height: 700px) { h1 { font-size: 38px; } .hero { height: 40vh; min-height: 200px; } .hero.mid { height: 30vh; min-height: 170px; } .tool small { display: none; } .tool { min-height: 48px; } }
@media (min-width: 900px) {
  #app { max-width: 1120px; height: 92vh; margin-top: 4vh; border: 2px solid var(--line); border-radius: 10px; box-shadow: 0 30px 90px rgba(0,0,0,.5); }
  .screen.split.active { display: grid; grid-template-columns: 1.1fr 1fr; }
  .split > .pic.hero { height: 100%; max-height: none; border-bottom: 0; border-right: 3px solid var(--brass); }
  .split > .side { justify-content: center; padding: 40px 56px; overflow-y: auto; }
  h1 { font-size: 60px; }
  .sheet { max-width: 760px; margin: 0 auto; width: 100%; }
  .room-grid { grid-template-columns: repeat(3, 1fr); }
  .table-body { flex-direction: row; }
  .board-wrap { flex: 1 1 60%; padding: 20px; }
  .table-side { flex: 0 0 360px; display: flex; flex-direction: column; justify-content: center; padding: 20px 28px; border-left: 1px solid var(--line); }
  .goals { justify-content: flex-start; }
  .hint { justify-content: flex-start; text-align: left; }
  .tools { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .cell { transition: none; } }
