* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* touch-action does not inherit, so setting it on html/body alone leaves the
     board, HUD, and canvases on the default `auto` — which is what iOS uses to
     double-tap zoom. none (not manipulation): the whole page is a gesture
     surface, so the browser must never claim a drag for panning/zooming. */
  touch-action: none;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

button {
  /* manipulation rather than none: still no double-tap zoom, but the tap ->
     click path stays intact for the buttons that listen for click. */
  touch-action: manipulation;
}

body {
  background: #0d0f1a;
  color: #e8eaf2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  justify-content: center;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  padding: 8px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

#hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.hud-item {
  flex: 1;
  background: #171a2b;
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a90ad;
}

.hud-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#btnPause {
  flex-shrink: 0;
  width: 44px;
  font-size: 18px;
  color: #e8eaf2;
  background: #171a2b;
  border: 1px solid #2c3252;
  border-radius: 10px;
  cursor: pointer;
}

#btnPause:active {
  background: #2c3252;
}

#playarea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-height: 0;
  width: 100%;
}

#previewbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a90ad;
}

.side canvas {
  background: #171a2b;
  border-radius: 10px;
}

#hold { width: 48px; height: 48px; }
#next { width: 144px; height: 48px; }

#boardwrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

#board {
  background: #10132090;
  border: 2px solid #262b45;
  border-radius: 6px;
  display: block;
}

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 22, 0.88);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
}

#overlay.hidden { display: none; }

#overlayTitle {
  font-size: 28px;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #4fc3f7, #ab47bc, #ffa726);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#overlayMsg {
  font-size: 14px;
  color: #b8bdd4;
  white-space: pre-line;
}

#overlayBtn {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3949ab, #5e35b1);
  border: none;
  border-radius: 12px;
  padding: 12px 36px;
  cursor: pointer;
}

#overlayBtn:active { transform: scale(0.96); }

#overlayActions {
  display: flex;
  gap: 10px;
}

.overlay-secondary {
  font-size: 14px;
  font-weight: 600;
  color: #b8bdd4;
  background: #1d2138;
  border: 1px solid #2c3252;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}

.overlay-secondary:active { transform: scale(0.96); }

.overlay-secondary.hidden { display: none; }

#controls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
}

.ctl {
  font-size: 22px;
  color: #e8eaf2;
  background: #1d2138;
  border: 1px solid #2c3252;
  border-radius: 12px;
  padding: 14px 0;
  cursor: pointer;
  touch-action: none;
}

.ctl:active {
  background: #2c3252;
}

@media (min-width: 700px) and (hover: hover) {
  #controls { display: none; }
}
