:root {
  --bg: #FAF6EF;
  --paper: #FFFDF7;
  --ink: #22252B;
  --accent: #E5573F;
  --county: #2E8F83;
  --muted: #8A8577;
  --dot: rgba(34, 37, 43, 0.07);
  --line: rgba(34, 37, 43, 0.14);
}

* { box-sizing: border-box; }

/* Beats .actions/.result's display:flex (author vs UA display:none). */
[hidden] { display: none !important; }

html, body { margin: 0; overflow-x: hidden; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, -apple-system, "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

.game {
  width: 100%;
  max-width: 560px;
  padding: clamp(20px, 5vw, 40px) 20px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.head { text-align: center; }

.title {
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 3.1rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.prompt {
  margin: 4px 0 0;
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  font-weight: 500;
}

.name {
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline wavy var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

/* The sheet is the hero: sketch-paper you draw on. */
.sheet {
  position: relative;
  width: min(100%, 58vh);
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid var(--line);
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  background-position: 11px 11px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 18px 40px -24px rgba(34, 37, 43, 0.5);
  overflow: hidden;
  animation: settle 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes settle {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* #share-canvas is the read-only share-page canvas; same box, no input. */
#board, #share-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#board {
  touch-action: none;
  cursor: crosshair;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn {
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 26px;
  border-radius: 13px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

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

.btn.solid {
  background: var(--accent);
  color: var(--paper);
  box-shadow: 0 10px 18px -12px var(--accent);
}

.btn.solid:hover { transform: translateY(-2px); }
.btn.solid:active { transform: translateY(0); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.ghost:hover { background: rgba(34, 37, 43, 0.05); }

.btn:disabled {
  background: var(--muted);
  color: var(--paper);
  box-shadow: none;
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: rise 0.4s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.score {
  margin: 0;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 22vw, 6rem);
}

.pct { font-size: 0.5em; margin-left: 0.05em; }

/* Share page's hero stat: label + number together, smaller than .score. */
.share-score {
  margin: 4px 0 0;
  font-weight: 900;
  color: var(--accent);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
}

.tier {
  margin: 2px 0 10px;
  min-height: 1.5em;
  font-size: 1.25rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tier.show { opacity: 1; transform: none; }

.toast {
  margin: 4px 0 0;
  color: var(--county);
  font-weight: 700;
}

.colophon {
  margin-top: auto;
  padding-top: 22px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-align: center;
}

.colophon a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  transition: color 0.12s ease, text-decoration-color 0.12s ease;
}

.colophon a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.colophon .heart { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .result { animation: none; }
  .tier { transition: none; }
  .btn { transition: none; }
}
