:root {
  --bg: #f6f1e4;
  --field: #f3ecd9;
  --ink: #1f1d1a;
  --muted: #7a7266;
  --line: #e2d8c3;
  --blue: #2f6fdf;
  --red: #e04848;
  --title: 'Black Han Sans', 'Gowun Dodum', sans-serif;
  --body: 'Gowun Dodum', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.app { height: 100vh; height: var(--app-h, 100dvh); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.stage, .dock { min-width: 0; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.home-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.top h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 26px; letter-spacing: .01em; }
.top h1 small { font-family: var(--body); font-size: 13px; color: var(--muted); margin-left: 6px; }

.stage { position: relative; margin: 0 16px; border-radius: 18px; overflow: hidden; background: var(--field);
  background-image: radial-gradient(circle at 1px 1px, rgba(120,100,60,.13) 1px, transparent 0); background-size: 22px 22px;
  box-shadow: inset 0 0 0 2px var(--line); }
#field { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.hint { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; margin: 0; pointer-events: none; color: var(--muted); font-size: 18px; line-height: 1.6; }
.hint b { color: var(--ink); }
.hint small { font-size: 14px; }
.hint[hidden] { display: none; }

.counts { position: absolute; left: 12px; bottom: 12px; display: grid; gap: 6px; pointer-events: none; }
.counts[hidden] { display: none; }
.count-team { background: rgba(255,255,255,.92); border-radius: 12px; padding: 6px 10px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 10px; max-width: min(320px, 60vw); box-shadow: 0 2px 10px rgba(0,0,0,.08); border-left: 5px solid; }
.count-team.blue { border-color: var(--blue); }
.count-team.red { border-color: var(--red); }
.count-team b { width: 100%; font-size: 14px; }
.count-team span { color: var(--muted); }

.side { position: absolute; right: 12px; top: 12px; display: grid; gap: 10px; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); font-size: 22px; display: grid; place-items: center; transition: transform .1s; }
.round:hover:not(:disabled) { transform: scale(1.06); }
.round:disabled { opacity: .35; cursor: not-allowed; }
.round.big { width: 64px; height: 64px; font-size: 28px; background: var(--ink); }
.round.big.active { background: var(--red); }
.round:focus-visible, .unit:focus-visible, .tab:focus-visible, .team-btn:focus-visible, .banner button:focus-visible { outline: 3px solid #3b6fe0; outline-offset: 2px; }

.banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); background: #fff; border-radius: 20px; padding: 20px 28px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.2); border-top: 8px solid var(--ink); animation: pop .35s ease-out; max-width: calc(100% - 32px); }
.banner.blue { border-color: var(--blue); }
.banner.red { border-color: var(--red); }
.banner[hidden] { display: none; }
.banner p { margin: 0 0 12px; font-family: var(--title); font-size: clamp(26px, 6vw, 38px); }
.banner button { border: 0; border-radius: 999px; background: var(--ink); color: #fff; padding: 10px 18px; font-weight: 700; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.7); opacity: 0; } }

.flash { position: absolute; left: 50%; top: 16px; transform: translate(-50%, -20px); margin: 0; background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; }
.flash.show { opacity: 1; transform: translate(-50%, 0); }

.dock { padding: 10px 16px 14px; }
.dock-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.teams { display: flex; background: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.team-btn { border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; font-weight: 700; color: var(--muted); }
.team-btn.blue.on { background: var(--blue); color: #fff; }
.team-btn.red.on { background: var(--red); color: #fff; }
.tabs { display: flex; gap: 4px; background: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.tab { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; color: var(--muted); }
.tab.on { background: #efe8d6; color: var(--ink); font-weight: 700; }
.palette { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: thin; }
.unit { flex: 0 0 auto; width: 84px; border: 2px solid transparent; background: #fff; border-radius: 14px; padding: 4px 4px 6px; display: grid; justify-items: center; gap: 0; font-size: 13px; box-shadow: 0 1px 6px rgba(0,0,0,.07); }
.unit img { width: 56px; height: 56px; }
.unit.on { border-color: var(--ink); background: #fffaf0; }
.erase-icon { font-size: 30px; height: 56px; display: grid; place-items: center; }

@media (max-width: 640px) {
  .top { padding: 8px 12px; }
  .top h1 { font-size: 22px; }
  .top h1 small { display: none; }
  .stage { margin: 0 8px; border-radius: 14px; }
  .side { right: 8px; top: 8px; gap: 6px; display: flex; }
  .round { width: 40px; height: 40px; font-size: 17px; }
  .round.big { width: 40px; height: 40px; font-size: 18px; }
  .flash { top: 56px; }
  .dock { padding: 8px 8px 10px; }
  .tab { padding: 6px 10px; }
  .team-btn { padding: 6px 12px; }
  .unit { width: 72px; font-size: 12px; }
  .unit img { width: 48px; height: 48px; }
  .erase-icon { height: 48px; }
  .count-team { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
