:root {
  --bg: #2b1d0e;
  --panel: #3d2a14;
  --husk: #4f7a3d;
  --husk-dark: #385928;
  --text: #fff3d6;
  --muted: #c9a877;
  --accent: #f2c94c;
  --leaf: #2f6b2f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
}

.bar {
  width: min(94vw, calc(82vh * 4 / 5));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bar h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; }

.scores { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.score { font-size: 12px; color: var(--muted); white-space: nowrap; }
.score strong { color: var(--accent); margin: 0 3px; }

.board {
  position: relative;
  width: min(94vw, calc(82vh * 4 / 5));
  aspect-ratio: 4 / 5;
  max-height: 82vh;
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.wrap:fullscreen,
.wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  gap: 0;
}
.wrap:fullscreen .bar,
.wrap:-webkit-full-screen .bar {
  width: min(100vw, calc(100vh * 4 / 5));
}
.wrap:fullscreen .board,
.wrap:-webkit-full-screen .board {
  width: min(100vw, calc(100vh * 4 / 5));
  max-height: 100vh;
  border-radius: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(20, 14, 6, 0.9);
  text-align: center;
  padding: 24px;
  transition: opacity 0.15s ease;
  z-index: 5;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-title { font-size: 24px; font-weight: 700; }
.overlay-sub { font-size: 13px; color: var(--muted); line-height: 1.6; max-width: 320px; }

.cta {
  font-size: 16px;
  font-weight: 700;
  color: #2b1d0e;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 10px 28px;
  cursor: pointer;
}
.cta:active { transform: scale(0.97); }

.caption {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 14, 6, 0.85);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 16px;
  border-radius: 999px;
  transition: opacity 0.2s ease;
  z-index: 4;
}
.caption.hidden { opacity: 0; }

.hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  max-width: min(94vw, calc(82vh * 4 / 5));
}

.foot { font-size: 10px; color: var(--muted); }

.mute {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 13px; line-height: 1; color: var(--text);
  border: 1px solid var(--husk-dark); border-radius: 8px; padding: 4px 7px;
  background: transparent; cursor: pointer;
}
.mute:hover { border-color: var(--accent); }
