:root {
  color-scheme: dark;
  --bg: #1c1714;
  --bg-raise: #2a211c;
  --ink: #f6efe4;
  --muted: #b7a89a;
  --line: #5c4a40;
  --gold: #e4c27a;
  --bad: #ff5d6c;
  --ok: #b7d7a8;
  --btn: #3c2f29;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif SC", serif;
  user-select: none;
  -webkit-user-select: none;
}

.yarn-app {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.hud {
  flex: none;
  padding: 12px 16px 8px;
  background: linear-gradient(180deg, #261e1a 0%, var(--bg) 100%);
  border-bottom: 1px solid rgba(228, 194, 122, 0.18);
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", sans-serif;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", sans-serif;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.stat { color: var(--ink); }
.stat.bad { color: var(--bad); }
.stat.ok { color: var(--ok); }
.stat.best { color: var(--gold); }

.message {
  margin: 8px 0 0;
  min-height: 1.2em;
  color: var(--gold);
  font-size: 13px;
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", sans-serif;
}

.board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

canvas.board {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

canvas.board:active { cursor: grabbing; }

.tools {
  flex: none;
  padding: 8px 12px 12px;
  background: #211b18;
  border-top: 1px solid rgba(228, 194, 122, 0.14);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row + .row { margin-top: 8px; }

.btn {
  flex: 1 1 22%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--ink);
  font: 15px/1.2 "Source Han Sans SC", "Noto Sans SC", "PingFang SC", sans-serif;
  letter-spacing: 0.04em;
  touch-action: manipulation;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.38;
  transform: none;
}

.btn.ghost {
  flex: 1 1 40%;
  background: transparent;
  color: var(--muted);
}

.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (max-height: 640px) {
  .hud { padding: 8px 12px 4px; }
  h1 { font-size: 18px; }
  .sub { display: none; }
  .message { margin-top: 4px; }
  .tools { padding: 6px 10px 8px; }
  .btn { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}
