:root {
  --ink: #0b0b0b;
  --red: #a81a1a;
  --paper: #ffffff;
  --line: rgba(0, 0, 0, .14);
  --pixel: "Silkscreen", monospace;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --cell: 30px;                         /* set from JS to fit the screen */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- header (mirrors the game menu) ---------- */
.top {
  position: fixed; inset: 0 0 auto 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px;
  z-index: 5;
}
.brand { font: 500 clamp(14px, 1.35vw, 26px)/1 var(--sans); }
.calli { width: clamp(90px, 9vw, 172px); filter: brightness(0); }
.switch {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  display: flex; border: 1px solid var(--ink);
  font: 9px/1 var(--pixel); letter-spacing: .03em;
}
.switch > * { padding: 8px 10px 7px; }
.switch .is-on { background: var(--ink); color: #fff; }
.switch a { border-left: 1px solid var(--ink); transition: background .2s; }
.switch a:hover { background: #f2efe8; }

/* ---------- layout ---------- */
.game {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(18px, 3vw, 54px);
  padding: 70px 20px 30px;
}
.side { width: 150px; display: flex; flex-direction: column; gap: 22px; align-self: center; }
.box h2, .stats span, .keys { font: 10px/1 var(--pixel); letter-spacing: .04em; }
.box h2 { margin-bottom: 10px; }
.box canvas {
  display: block; width: 120px;
  border: 1px solid var(--line);
  background: repeating-conic-gradient(#fafafa 0 25%, #fff 0 50%) 0 0 / 12px 12px;
  image-rendering: pixelated;
}
#hold { height: 80px; }
#next { height: 260px; }
.stats { display: grid; gap: 14px; }
.stats div { display: flex; flex-direction: column; gap: 6px; }
.stats b { font: 500 26px/1 var(--sans); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stats b.bump { animation: bump .45s cubic-bezier(.3, 1.8, .4, 1); }
@keyframes bump { 0% { transform: scale(1.25); color: var(--red); } 100% { transform: none; } }
.keys { display: grid; gap: 9px; opacity: .6; line-height: 1.2; }
kbd {
  font: inherit; display: inline-block;
  border: 1px solid var(--ink); padding: 2px 4px 1px; margin-right: 2px;
  box-shadow: 2px 2px 0 var(--ink);
}
.sound { margin-top: 10px; text-align: left; font: 10px/1 var(--pixel); opacity: .9; }

/* ---------- the well ---------- */
.well {
  position: relative;
  width: calc(var(--cell) * 10 + 16px);
  height: calc(var(--cell) * 20 + 16px);
  padding: 8px;
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--red);
  background: #fff;
}
.well.shake { animation: shake .3s steps(3); }
@keyframes shake { 33% { transform: translate(-3px, 2px); } 66% { transform: translate(3px, -1px); } }
#board { display: block; width: calc(var(--cell) * 10); height: calc(var(--cell) * 20); image-rendering: pixelated; }

.overlay {
  position: absolute; inset: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(255, 255, 255, .9);
  text-align: center;
  opacity: 0; visibility: hidden;
  transition: opacity .35s, visibility 0s .35s;
}
.overlay.is-on { opacity: 1; visibility: visible; transition: opacity .35s, visibility 0s; }
.ov-title { font: 500 clamp(22px, calc(var(--cell) * 1.1), 34px)/1 var(--sans); letter-spacing: -.01em; }
.ov-sub { font: 10px/1.6 var(--pixel); opacity: .6; max-width: 80%; }
.ov-btn {
  font: 11px/1 var(--pixel);
  padding: 12px 16px 11px;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--red);
  background: #fff;
  animation: pulse 1.2s steps(2) infinite;
  transition: transform .15s, box-shadow .15s;
}
.ov-btn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--red); }
.ov-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--red); }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- touch pad ---------- */
.pad { display: none; }
@media (pointer: coarse), (max-width: 760px) {
  .side--right .keys { display: none; }
  .pad {
    position: fixed; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line);
    z-index: 6;
  }
  .pad button {
    height: 52px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
    font: 14px/1 var(--pixel);
  }
  .pad button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
}
@media (max-width: 760px) {
  .game { padding: 64px 10px 92px; gap: 10px; align-items: flex-start; }
  .side { width: 76px; gap: 12px; }
  .box canvas { width: 76px; }
  #hold { height: 51px; }
  #next { height: 165px; }
  .stats b { font-size: 16px; }
  .side--right .keys { display: none; }
  .switch { top: 18px; }
  .top { padding: 18px 14px; }
  .brand { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ov-btn { animation: none; }
  .well.shake { animation: none; }
}
