[hidden] { display: none !important; }
/* Tessella 12 (SIL OFL 1.1, licence + source notices in /fonts/tessella/). Drawn for 12px: use only 12, 24 or 36px.
   Split by script: Korean + Latin + symbols load on every page (~0.1 MB); Japanese/Chinese only when such characters appear. */
@font-face { font-family: "Tessella"; src: url("/fonts/tessella/tessella12-ko.woff2") format("woff2"); font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+2000-206F, U+20A0-20BF, U+2100-214F, U+2190-22FF, U+2460-24FF, U+2500-27BF, U+3000-303F, U+3130-318F, U+AC00-D7A3, U+FF00-FFEF; }
@font-face { font-family: "Tessella"; src: url("/fonts/tessella/tessella12-cjk.woff2") format("woff2"); font-display: swap;
  unicode-range: U+3040-30FF, U+31F0-31FF, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF; }

/* One narrow phone-like column: night sea outside, letter-paper cards inside. A single committed dark look. */
:root {
  color-scheme: dark;
  --night: #121931;
  --deep: #1B2547;
  --line: #2C3866;
  --sea: #1E4E79;
  --foam: #8CC8F0;
  --paper: #F4E9CF;
  --paper-2: #E6D7B3;
  --paper-3: #FFF8E7;
  --ink: #2A1F2D;
  --ink-soft: #6B5C66;
  --wood: #3B2A20;
  --gold: #FFD966;
  --coral: #F07A5C;
  --teal: #2E6D78;
  --teal-dark: #1F4F58;
  --danger: #B4302A;
  --ok: #2F6E2C;
  --muted: #A7B2D4;
  --pixel: "Tessella", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--paper); font-family: var(--pixel); font-size: 12px; line-height: 20px; font-synthesis: none; -webkit-font-smoothing: none; font-smooth: never;
  word-break: keep-all; overflow-wrap: anywhere;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) calc(40px + env(safe-area-inset-bottom, 0px)); }
a { color: var(--gold); }
.app { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

header.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 20px; }
.brand { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; }
.logo { font-size: 24px; color: var(--paper); text-shadow: 2px 2px 0 var(--teal); }
.logo .fade { opacity: 0.45; }
.slogan { font-size: 12px; color: var(--gold); }
.me-chip { font-size: 12px; color: var(--muted); text-decoration: none; text-align: right; min-height: 32px; display: flex; flex-direction: column; justify-content: flex-end; }
.me-chip b { color: var(--paper); font-weight: normal; }

nav.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
nav.tabs a { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; background: var(--deep); color: var(--muted); border: 2px solid var(--line); text-decoration: none; font-size: 12px; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25); }
nav.tabs a[aria-current="page"] { background: var(--paper); color: var(--ink); border-color: var(--wood); box-shadow: inset 0 -3px 0 var(--paper-2), 3px 3px 0 var(--wood); }
.badge { display: inline-block; min-width: 18px; padding: 0 4px; background: var(--coral); color: var(--ink); font-size: 12px; line-height: 16px; }

.card { background: var(--paper); color: var(--ink); border: 3px solid var(--wood); box-shadow: 4px 4px 0 var(--wood); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card h2 { margin: 0; font-size: 24px; text-wrap: balance; }
.card h3 { margin: 0; font-size: 12px; }
.sub { color: var(--ink-soft); font-size: 12px; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 3px solid var(--wood); }
.seg button { font-family: inherit; font-size: 12px; min-height: 44px; border: 0; background: var(--paper-3); color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--wood); color: var(--paper); }

.board-wrap { width: 100%; max-width: 400px; margin: 0 auto; position: relative; }
canvas.board { display: block; width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; border: 3px solid var(--wood); background: var(--paper-3); touch-action: none; cursor: crosshair; }
canvas.board.view { cursor: default; touch-action: auto; }

.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tool { font-family: inherit; font-size: 12px; min-height: 40px; border: 2px solid var(--wood); background: var(--paper-3); color: var(--ink); cursor: pointer; }
.tool[aria-pressed="true"] { background: var(--wood); color: var(--paper); }
.tool:disabled { opacity: 0.4; cursor: default; }
.tool { white-space: nowrap; padding: 0 2px; }
.tool.undo { font-size: 12px; }
body:has(.devbar) { padding-bottom: 90px; }
.palbox { display: flex; flex-direction: column; gap: 8px; }
.palette { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); border: 2px solid var(--wood); }
.palette.mp { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; border: 0; }
.swatch { aspect-ratio: 1; min-height: 24px; border: 0; padding: 0; cursor: pointer; position: relative; }
.palette.mp .swatch { border: 2px solid var(--wood); min-height: 34px; }
.swatch[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: -3px; box-shadow: inset 0 0 0 5px var(--paper-3); z-index: 1; }
.swatch .left { position: absolute; right: 1px; bottom: 0; font-size: 12px; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.recent { display: grid; grid-template-columns: repeat(8, 26px); gap: 4px; min-height: 26px; }
.recent .swatch { border: 2px solid var(--wood); }
.cur { width: 28px; height: 28px; border: 2px solid var(--wood); display: inline-block; flex: none; }
.pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; min-height: 36px; padding: 0 8px; border: 2px solid var(--wood); background: var(--paper-3); }
.pick input { width: 26px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }

.btn { font-family: inherit; font-size: 12px; min-height: 48px; padding: 0 14px; border: 3px solid #1E140F; cursor: pointer; background: var(--paper-2); color: var(--ink); box-shadow: inset -3px -3px 0 #C9B88F, inset 3px 3px 0 var(--paper-3); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--teal); color: #fff; box-shadow: inset -3px -3px 0 var(--teal-dark), inset 3px 3px 0 #4C93A0; }
.btn.warn { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini { font-family: inherit; font-size: 12px; min-height: 36px; padding: 0 10px; border: 2px solid var(--wood); background: var(--paper-3); color: var(--ink); cursor: pointer; flex: none; text-decoration: none; display: inline-flex; align-items: center; }
.mini.danger { color: var(--danger); }
.mini.solid { background: var(--danger); color: #fff; }
.mini[aria-pressed="true"] { background: var(--wood); color: var(--paper); }
:is(.btn, .mini, .tool, .swatch, .chip, .seg button, nav.tabs a, .thumb, .mp-card):focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.meter { height: 12px; background: #D8C9A6; border: 2px solid var(--wood); position: relative; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--teal); }
.count { font-variant-numeric: tabular-nums; }
.themes { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: inherit; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; background: var(--paper-3); color: var(--ink); border: 2px solid var(--wood); cursor: pointer; text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--wood); color: var(--paper); }
.chip canvas { width: 16px; height: 16px; image-rendering: pixelated; }
.status { font-size: 12px; min-height: 18px; margin: 0; }
.status.err { color: var(--danger); }
.status.ok { color: var(--ok); }

.mp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.mp-card { font-family: inherit; text-align: left; background: var(--paper-3); color: var(--ink); border: 2px solid var(--wood); padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; position: relative; }
.mp-card[aria-pressed="true"] { background: var(--wood); color: var(--paper); }
.mp-card canvas { width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; border: 2px solid var(--wood); }
.mp-card .t { font-size: 12px; line-height: 16px; }
.mp-card .a { font-size: 12px; opacity: 0.75; }
.today { position: absolute; top: 10px; left: 10px; background: var(--gold); color: var(--ink); font-size: 12px; padding: 1px 5px; border: 2px solid var(--wood); }
details.rights { background: var(--paper-3); border: 2px dashed var(--paper-2); padding: 8px 10px; font-size: 12px; }
details.rights summary { cursor: pointer; color: var(--ok); }
details.rights dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 10px; }
details.rights dt { color: var(--ink-soft); }
details.rights dd { margin: 0; overflow-wrap: anywhere; }

.layers { display: flex; flex-direction: column; gap: 6px; }
.layer { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-top: 2px dashed var(--paper-2); padding-top: 6px; flex-wrap: wrap; }
.layer .who { display: flex; flex-direction: column; min-width: 0; }
.layer .who span { overflow-wrap: anywhere; }
.tiny { font-size: 12px; color: var(--ink-soft); }
.hidden-tag { font-size: 12px; color: var(--danger); }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }

.sea-box { position: relative; border: 3px solid var(--wood); box-shadow: 4px 4px 0 var(--wood); background: var(--sea); }
.sea-box canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.sea-box .over { position: absolute; inset: auto 0 0 0; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; background: linear-gradient(transparent, rgba(18,25,49,0.92) 35%); }
.sea-box .over p { margin: 0; color: var(--paper); text-align: center; }
.sea-box .counts { color: var(--muted); font-size: 12px; text-align: center; }

.list { display: flex; flex-direction: column; gap: 10px; }
.section-title { margin: 6px 0 0; font-size: 24px; color: var(--paper); font-weight: normal; }
.thumb { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; font-family: inherit; background: var(--paper); color: var(--ink); border: 3px solid var(--wood); box-shadow: 3px 3px 0 var(--wood); padding: 8px; cursor: pointer; width: 100%; text-decoration: none; }
.thumb canvas { width: 84px; height: 84px; image-rendering: pixelated; border: 2px solid var(--wood); }
.thumb .meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.route { font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gallery .thumb { grid-template-columns: 1fr; justify-items: stretch; text-align: center; }
.gallery .thumb canvas { width: 100%; height: auto; aspect-ratio: 1; }
.pill { display: inline-block; font-size: 12px; padding: 1px 6px; border: 2px solid var(--wood); width: fit-content; }
.pill.sea { background: #CFE7F7; } .pill.held { background: #FBE3CC; } .pill.returned { background: var(--gold); } .pill.sunk { background: #D9D2C6; color: #5A4A55; } .pill.mp { background: #EADFF2; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; border: 2px dashed var(--line); }
.empty b { color: var(--paper); font-weight: normal; display: block; font-size: 24px; margin-bottom: 4px; }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compare figure { margin: 0; display: flex; flex-direction: column; gap: 4px; text-align: center; font-size: 12px; color: var(--ink-soft); }
.compare canvas { width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; border: 2px solid var(--wood); }
.notice { background: #2C2035; border: 2px solid var(--coral); color: var(--paper); padding: 12px; }
.intro ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }

.foot { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.rules { border: 2px solid var(--line); padding: 12px; color: var(--muted); font-size: 12px; }
.rules h3 { margin: 0 0 6px; font-size: 12px; font-weight: normal; color: var(--paper); }
.rules ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.credits { color: var(--muted); font-size: 12px; margin: 0; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
label.field input { font-family: inherit; font-size: 24px; padding: 10px; border: 3px solid var(--wood); background: #fff; color: var(--ink); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--gold); color: var(--ink); border: 3px solid var(--wood); padding: 10px 14px; width: max-content; max-width: min(92vw, 420px); z-index: 20; box-shadow: 3px 3px 0 var(--wood); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* DEV_MODE only: switch between test players */
.devbar { position: fixed; left: 8px; bottom: 8px; z-index: 50; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: calc(100vw - 16px);
  padding: 6px 8px; background: #2A1F2D; color: #FFF1C9; border: 2px dashed #E4A672; font-size: 12px; }
.devbar select, .devbar button { font: inherit; font-size: 12px; padding: 3px 6px; }

/* Count + gauge right above the board; sticks to the top of the screen while you scroll to the palette. */
.board-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; background: var(--paper);
  margin: -4px -6px -6px; padding: 8px 6px 6px; border-bottom: 2px dashed var(--paper-2); }
.board-bar .count { font-size: 12px; white-space: nowrap; }
.board-bar .count b { font-size: 24px; color: var(--teal-dark); }
.board-bar .count.low b { color: var(--danger); }
.board-bar .grow { flex: 1; min-width: 40px; }

/* Home */
body.is-home header.top, body.is-home nav.tabs, body.is-home .rules { display: none; }
.home { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding-top: 36px; text-align: center; }
.home-head { display: flex; flex-direction: column; gap: 6px; }
.home-kicker { margin: 0; color: var(--gold); font-size: 24px; line-height: 32px; }
.home-title { margin: 0; font-size: 36px; line-height: 48px; color: var(--paper); text-shadow: 3px 3px 0 var(--teal), 6px 6px 0 rgba(0,0,0,0.35); }
.home-title .fade { opacity: 0.45; }
.home-slogan { margin: 0; color: var(--muted); font-size: 12px; }
.home-sea { border: 3px solid var(--wood); box-shadow: 4px 4px 0 var(--wood); background: var(--sea); }
.home-sea canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.home-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.home-steps li { background: var(--paper); color: var(--ink); border: 3px solid var(--wood); box-shadow: 3px 3px 0 var(--wood); padding: 10px 6px 9px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; }
.home-steps b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; background: var(--teal); color: #fff; border: 2px solid var(--wood); font-size: 12px; }
.btn.big { min-height: 58px; font-size: 24px; }
.home-hint { margin: -8px 0 0; color: var(--gold); font-size: 12px; }
.home-links { margin: 0; font-size: 12px; color: var(--muted); }

/* 24px text sits on a 32px line so two sizes share one pixel rhythm */
.card h2, .empty b, .board-bar .count b, .btn.big, .section-title, .logo, label.field input { line-height: 32px; }
/* emphasis without bold: Tessella has one weight */
b, strong { font-weight: normal; }
.card h3 { color: var(--teal-dark); }

/* Masterpiece: the original in the counter bar, tap to see it big */
.ref-wrap { position: relative; flex: none; }
.ref { display: block; padding: 0; border: 2px solid var(--wood); background: var(--paper-3); cursor: zoom-in; line-height: 0; }
.ref canvas { width: 48px; height: 48px; image-rendering: pixelated; }
.ref-big { position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; background: var(--paper); border: 3px solid var(--wood); box-shadow: 4px 4px 0 var(--wood);
  padding: 6px; display: flex; flex-direction: column; gap: 4px; align-items: center; cursor: zoom-out; }
.ref-big canvas { width: 192px; height: 192px; image-rendering: pixelated; display: block; }
.mini.peek:disabled { opacity: 0.5; cursor: default; }
.mini.peek[aria-pressed="true"] { opacity: 1; background: var(--gold); color: var(--ink); }
.pill.mode.hard { background: var(--coral); color: var(--ink); }
.pill.mode.easy { background: #E3EDD5; }

.sea-box .counts.waiting { color: var(--gold); }
.empty.loading { border-style: dotted; opacity: 0.8; }
.cap-note { margin: 0; padding: 6px 8px; background: #FFF3C4; border: 2px dashed var(--gold); color: var(--ink); }

/* v0.6 home */
.home-title { font-size: 48px; line-height: 56px; }
@media (max-width: 340px) { .home-title { font-size: 36px; line-height: 48px; } }
.home-sea, .sea-box { display: flex; justify-content: center; overflow: hidden; }
canvas.scene { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.home-sea { background: #123A5E; }
.home-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.stat { background: var(--deep); border: 2px solid var(--line); padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 0; }
.stat b { font-size: 36px; line-height: 40px; color: var(--paper); }
.stat span { color: var(--muted); }
.home-return { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: var(--gold); color: var(--ink);
  border: 3px solid var(--wood); box-shadow: 3px 3px 0 var(--wood); text-decoration: none; }
.home-return b { font-size: 24px; line-height: 32px; text-align: left; }
.badge.new { background: var(--gold); }
.thumb.is-new { outline: 3px solid var(--gold); outline-offset: 0; }
.pill.fresh { background: var(--gold); }
.notice.good { border-color: var(--gold); }
.card.ask { gap: 8px; }
.card.ask b { font-size: 24px; line-height: 32px; }
.field-label { font-size: 12px; }
.ver { opacity: 0.6; }
