@font-face{font-family:"Press Start 2P";font-style:normal;font-weight:400;font-display:swap;src:url("/assets/fonts/press-start-2p-latin-400.woff2") format("woff2")}
@font-face{font-family:"VT323";font-style:normal;font-weight:400;font-display:swap;src:url("/assets/fonts/vt323-latin-400.woff2") format("woff2")}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0612;
  --text: #f0e6ff;
  --muted: rgba(232, 210, 255, 0.55);
  --neon-pink: #ff4ecd;
  --neon-cyan: #3df0ff;
  /* Soft retro green — less glow, easier on the eyes */
  --neon-green: #86efac;
  --neon-green-mid: #4ade80;
  --neon-green-dim: #22c55e;
  --neon-green-deep: #14532d;
  --wood-hi: #86efac;
  --wood-mid: #166534;
  --wood-lo: #0a2e18;
  --cell: #1e1440;
  --cell-empty: #140c28;
  --cell-given: #2a1a52;
  --cell-hi: #3a2468;
  --given: #f5e8ff;
  --entry: #5ef0ff;
  --note: rgba(192, 132, 252, 0.85);
  --conflict: #ff4ecd;
  --sel: #86efac;
  --same: rgba(74, 222, 128, 0.28);
  --peer: rgba(168, 85, 247, 0.18);
  --grid-line: #6b4a9e;
  --box-line: #86efac;
  --pixel: "Press Start 2P", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "VT323", "Courier New", ui-monospace, monospace;
  --digit-font: "VT323", "Press Start 2P", ui-monospace, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  /* Explicit size for Safari — avoid aspect-ratio-only collapse */
  --board-size: min(560px, calc(calc(100vh - var(--rg-bar)) - 10rem), calc(100vw - 20rem));
}

html {
  height: 100%;
}

html,
body {
  height: 100%;
  min-height: calc(100vh - var(--rg-bar));
  min-height: calc(100dvh - var(--rg-bar));
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  font-size: 20px;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  height: 100%;
  min-height: calc(100vh - var(--rg-bar));
  min-height: calc(100dvh - var(--rg-bar));
  max-height: calc(100vh - var(--rg-bar));
  max-height: calc(100dvh - var(--rg-bar));
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, rgba(61, 240, 255, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 100% 80%, rgba(255, 78, 205, 0.1), transparent 50%),
    radial-gradient(ellipse 45% 35% at 0% 70%, rgba(192, 132, 252, 0.12), transparent 50%),
    #0a0612;
  overflow: hidden;
}

.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: var(--rg-bar) 0 0 0;
  z-index: 80;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.1) 2px,
      rgba(0, 0, 0, 0.1) 3px
    ),
    radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.4) 100%);
  mix-blend-mode: multiply;
  opacity: 0.5;
}

/* HUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.55rem + var(--safe-top)) max(0.85rem, var(--safe-right)) 0.55rem
    max(0.85rem, var(--safe-left));
  flex-shrink: 0;
  border-bottom: 3px solid var(--wood-hi);
  box-shadow: 0 3px 0 var(--wood-lo), 0 8px 24px rgba(0, 0, 0, 0.35);
  background: linear-gradient(180deg, #2a1848 0%, #160c28 100%);
  z-index: 5;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.hud-center {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.marquee {
  font-family: var(--pixel);
  font-size: clamp(0.5rem, 1.3vw, 0.68rem);
  letter-spacing: 0.08em;
  color: var(--neon-green);
  text-shadow: 1px 1px 0 #0a2e18;
  margin-bottom: 0.15rem;
}

.hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 2.8rem;
  padding: 0.2rem 0.45rem;
  border: 2px solid rgba(134, 239, 172, 0.45);
  background: rgba(0, 0, 0, 0.35);
}

.hud-block .label {
  font-family: var(--pixel);
  font-size: 0.4rem;
  letter-spacing: 0.08em;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px rgba(61, 240, 255, 0.45);
  margin-bottom: 0.08rem;
}

.hud-block span:last-child {
  font-family: var(--pixel);
  font-size: 0.72rem;
  line-height: 1.2;
  color: #e9d5ff;
}

.message {
  font-family: var(--display);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  letter-spacing: 0.04em;
  color: rgba(240, 230, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn,
.btn {
  font-family: var(--pixel);
  font-size: 0.52rem;
  cursor: pointer;
  border: 3px solid var(--wood-hi);
  background: linear-gradient(180deg, #3b1f6e 0%, #1e0f3a 100%);
  color: var(--neon-green);
  text-shadow: none;
  border-radius: 0;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  box-shadow: 3px 3px 0 #0a2e18;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1rem;
  font-family: system-ui, sans-serif;
  flex-shrink: 0;
}

.btn {
  padding: 0.55rem 0.95rem;
  letter-spacing: 0.06em;
}

.btn.primary {
  background: linear-gradient(180deg, #3df0ff 0%, #0891b2 100%);
  border-color: #a5f3fc;
  color: #0a0612;
}

.btn.ghost {
  background: linear-gradient(180deg, #2a1848 0%, #12081f 100%);
}

.icon-btn:hover,
.btn:hover {
  filter: brightness(1.12);
  transform: translate(-1px, -1px);
}

.icon-btn:active,
.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #2a1508;
}

/* Stage */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(5.5rem, 1fr) auto minmax(8rem, 1fr);
  align-items: center;
  justify-items: center;
  gap: 0.75rem 1rem;
  padding: 0.65rem max(0.75rem, var(--safe-right)) 0.4rem max(0.75rem, var(--safe-left));
}

.side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: 8rem;
  position: relative;
  padding: 0.6rem 0.5rem;
  border: 3px solid rgba(134, 239, 172, 0.5);
  background: linear-gradient(180deg, rgba(42, 24, 72, 0.85), rgba(16, 8, 32, 0.9));
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}

.side-name {
  font-family: var(--pixel);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
}

.squipy-name {
  color: #e9d5ff;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.65);
}

.side-role {
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.squipy-avatar {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 0;
  background: linear-gradient(160deg, #e9d5ff, #a855f7 50%, #5b21b6);
  border: 3px solid #fff;
  box-shadow: 3px 3px 0 #3b0764, 0 0 16px rgba(168, 85, 247, 0.5);
  display: grid;
  place-items: center;
  animation: sq-bob 1.2s steps(2, end) infinite;
  image-rendering: pixelated;
}

@keyframes sq-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.sq-face {
  position: relative;
  width: 1.65rem;
  height: 1.1rem;
}
.sq-face .brow {
  position: absolute;
  top: -0.05rem;
  width: 0.42rem;
  height: 0.1rem;
  background: #0f172a;
}
.sq-face .brow.left {
  left: 0.12rem;
}
.sq-face .brow.right {
  right: 0.12rem;
}
.sq-face .eye {
  position: absolute;
  top: 0.14rem;
  width: 0.3rem;
  height: 0.3rem;
  background: #0f172a;
}
.sq-face .eye.left {
  left: 0.14rem;
}
.sq-face .eye.right {
  right: 0.14rem;
}
.sq-face .eye::after {
  content: "";
  position: absolute;
  top: 0.04rem;
  right: 0.04rem;
  width: 0.08rem;
  height: 0.08rem;
  background: rgba(255, 255, 255, 0.7);
}
.sq-face .mouth {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0.65rem;
  height: 0.22rem;
  border-bottom: 2.5px solid #0f172a;
  transform: translateX(-50%);
}
.sq-face .cheek {
  position: absolute;
  bottom: 0.22rem;
  width: 0.22rem;
  height: 0.14rem;
  background: rgba(244, 114, 182, 0.7);
  opacity: 0.7;
}
.sq-face .cheek.left {
  left: -0.04rem;
}
.sq-face .cheek.right {
  right: -0.04rem;
}

.squipy-avatar[data-mood="think"] .brow.left {
  transform: rotate(12deg);
}
.squipy-avatar[data-mood="think"] .brow.right {
  transform: rotate(-12deg);
}
.squipy-avatar[data-mood="think"] .eye {
  height: 0.1rem;
  top: 0.26rem;
}
.squipy-avatar[data-mood="think"] .eye::after {
  display: none;
}

.squipy-avatar[data-mood="hype"] .eye {
  width: 0.38rem;
  height: 0.38rem;
  top: 0.06rem;
  background: #fff;
  box-shadow: inset 0 0 0 0.08rem #0f172a;
}
.squipy-avatar[data-mood="hype"] .eye::after {
  top: 0.1rem;
  right: 0.08rem;
  width: 0.1rem;
  height: 0.1rem;
  background: #0f172a;
}
.squipy-avatar[data-mood="hype"] .mouth {
  width: 0.48rem;
  height: 0.45rem;
  border: 2.5px solid #0f172a;
  bottom: -0.08rem;
}

.speech {
  position: absolute;
  top: -0.3rem;
  left: 50%;
  transform: translate(-50%, -100%);
  min-width: 5rem;
  max-width: 8.5rem;
  padding: 0.4rem 0.5rem;
  background: #fff8dc;
  color: #1c1917;
  border: 3px solid #1c1917;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
  font-family: var(--pixel);
  font-size: 0.42rem;
  line-height: 1.45;
  text-align: center;
  z-index: 4;
}

.speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  margin-left: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #1c1917;
}

/* Board cabinet */
.board-cabinet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.7rem 0.65rem;
  background: linear-gradient(180deg, #0f4a28 0%, var(--wood-mid) 40%, var(--wood-lo) 100%);
  border: 4px solid var(--wood-hi);
  box-shadow:
    6px 6px 0 #041a0c,
    0 16px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(180, 255, 160, 0.12);
}

.cabinet-label {
  font-family: var(--pixel);
  font-size: 0.38rem;
  letter-spacing: 0.1em;
  color: var(--neon-green);
  text-shadow: none;
}

.board-wrap {
  width: var(--board-size);
  height: var(--board-size);
  min-width: 260px;
  min-height: 260px;
  position: relative;
  flex-shrink: 0;
}

/*
 * Board = 3×3 boxes. Gaps paint the thick neon-green box lines.
 * Inner box gaps paint thin cell lines. Avoids 1px border drop on Safari.
 */
.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  border: 4px solid #041a0c;
  background: var(--box-line);
  box-shadow:
    inset 0 0 0 2px #14532d,
    0 0 0 1px rgba(134, 239, 172, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.25);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.board.loading {
  opacity: 0.7;
}

.box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  min-width: 0;
  min-height: 0;
  background: var(--grid-line);
  /* Force a visible box even if cells lag */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.cell {
  position: relative;
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
  -webkit-box-pack: center;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  background: var(--cell-empty);
  cursor: pointer;
  /* Hard edges — no radius so lines stay crisp */
  border-radius: 0;
  overflow: hidden;
}

/* Blank playable cells — slightly darker “hole” */
.cell.empty {
  background: var(--cell-empty);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* Prefilled givens — lighter purple well so they read as fixed */
.cell.given {
  background: var(--cell-given);
  box-shadow: inset 0 0 0 1px rgba(233, 213, 255, 0.12);
  cursor: default;
}

.cell .digit {
  display: block;
  font-family: var(--digit-font);
  font-size: clamp(1.15rem, 5.2vmin, 2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  color: var(--entry);
  text-shadow: 0 0 10px rgba(61, 240, 255, 0.45);
  -webkit-font-smoothing: antialiased;
  pointer-events: none;
}

.cell.given .digit {
  color: var(--given);
  text-shadow: 0 0 8px rgba(245, 232, 255, 0.4);
  font-weight: 700;
}

.cell.peer {
  background: #2a1850;
}

.cell.peer.given {
  background: #34205e;
}

.cell.same-num {
  background: #1a3d2a !important;
  box-shadow: inset 0 0 0 2px rgba(134, 239, 172, 0.65);
}

.cell.same-num .digit {
  color: #bbf7d0;
  text-shadow: none;
}

.cell.paint-target {
  box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.25);
}

.cell.selected {
  background: var(--cell-hi) !important;
  box-shadow: inset 0 0 0 3px var(--sel);
  z-index: 2;
}

.cell.conflict .digit {
  color: var(--conflict);
  text-shadow: 0 0 10px rgba(255, 78, 205, 0.75);
}

.cell.conflict {
  background: rgba(255, 78, 205, 0.18) !important;
}

.cell.selected.conflict {
  box-shadow: inset 0 0 0 3px var(--conflict);
}

.cell .notes {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  left: 1px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-family: var(--display);
  font-size: clamp(0.5rem, 1.8vmin, 0.75rem);
  line-height: 1;
  color: var(--note);
  pointer-events: none;
}

.cell .notes span {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.25;
}

.cell .notes span.on {
  opacity: 1;
  color: #d8b4fe;
  text-shadow: 0 0 4px rgba(192, 132, 252, 0.55);
  font-weight: 700;
}

/* Number pad */
.controls-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  max-width: 12rem;
  width: 100%;
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  width: min(11.5rem, 100%);
}

.pad-btn {
  font-family: var(--pixel);
  font-size: 0.85rem;
  aspect-ratio: 1;
  min-height: 2.6rem;
  border: 3px solid var(--wood-hi);
  background: linear-gradient(180deg, #3b1f6e 0%, #1a0c30 100%);
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(61, 240, 255, 0.45);
  cursor: pointer;
  box-shadow: 3px 3px 0 #0a2e18;
  border-radius: 0;
  transition: transform 0.08s ease, filter 0.1s ease;
}

.pad-btn:hover {
  filter: brightness(1.12);
  transform: translate(-1px, -1px);
}

.pad-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #1a0c04;
}

.pad-btn.active {
  background: linear-gradient(180deg, #86efac 0%, #22c55e 100%);
  color: #052e16;
  text-shadow: none;
  border-color: #bbf7d0;
  box-shadow: 2px 2px 0 #0a2e18, inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.pad-btn.erase {
  color: var(--neon-pink);
  font-size: 0.75rem;
}

.pad-btn.erase.active {
  background: linear-gradient(180deg, #ff4ecd 0%, #9d174d 100%);
  color: #fff;
  border-color: #f9a8d4;
}

.pad-btn.notes {
  color: var(--neon-green);
  font-size: 0.85rem;
}

.pad-btn.notes.on {
  background: linear-gradient(180deg, #86efac 0%, #15803d 100%);
  color: #052e16;
  text-shadow: none;
  border-color: #bbf7d0;
}

.pad-btn.check {
  color: #86efac;
  font-size: 0.9rem;
}

.pad-btn.done {
  opacity: 0.35;
  pointer-events: none;
}

.pad-hint {
  font-family: var(--pixel);
  font-size: 0.34rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* Footer */
.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem max(0.85rem, var(--safe-right)) calc(0.45rem + var(--safe-bottom))
    max(0.85rem, var(--safe-left));
  flex-shrink: 0;
  border-top: 3px solid var(--wood-hi);
  background: linear-gradient(180deg, #160c28 0%, #0a0612 100%);
}

.hint {
  font-family: var(--pixel);
  font-size: 0.38rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.version {
  font-family: var(--pixel);
  font-size: 0.36rem;
  color: rgba(232, 210, 255, 0.3);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: var(--rg-bar) 0 0 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(5, 2, 12, 0.78);
  padding: 1rem;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(24rem, 100%);
  padding: 1.5rem 1.35rem;
  border: 4px solid var(--wood-hi);
  background: linear-gradient(180deg, #2a1848 0%, #12081f 100%);
  box-shadow: 6px 6px 0 #041a0c, 0 0 24px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.panel-tag {
  font-family: var(--pixel);
  font-size: 0.48rem;
  letter-spacing: 0.14em;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(61, 240, 255, 0.55);
  margin-bottom: 0.6rem;
}

.panel h1 {
  font-family: var(--pixel);
  font-size: clamp(0.8rem, 3vw, 1.1rem);
  line-height: 1.4;
  color: var(--neon-green);
  text-shadow: 2px 2px 0 #0a2e18;
  margin-bottom: 0.45rem;
}

.subtitle {
  font-family: var(--display);
  color: var(--muted);
  font-size: 1.15rem;
  margin-bottom: 1.15rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.actions .btn {
  min-width: 8rem;
}

@media (min-width: 1100px) and (min-height: 800px) {
  :root {
    --board-size: min(620px, calc(calc(100vh - var(--rg-bar)) - 9.5rem), calc(100vw - 22rem));
  }
}

/* Mobile */
@media (max-width: 820px) {
  :root {
    --board-size: min(
      calc(100vw - 1rem - var(--safe-left) - var(--safe-right)),
      calc(calc(100vh - var(--rg-bar)) - 13.5rem - var(--safe-top) - var(--safe-bottom)),
      calc(calc(100dvh - var(--rg-bar)) - 13.5rem - var(--safe-top) - var(--safe-bottom))
    );
  }

  #hud {
    padding: calc(0.4rem + var(--safe-top)) max(0.5rem, var(--safe-right)) 0.4rem
      max(0.5rem, var(--safe-left));
  }

  .icon-btn,
  .btn {
    min-height: 2.5rem;
  }

  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.35rem;
    padding: 0.3rem max(0.35rem, var(--safe-right)) 0.15rem max(0.35rem, var(--safe-left));
    min-height: 0;
    flex: 1;
  }

  .squipy-panel {
    flex-direction: row;
    max-width: none;
    width: 100%;
    justify-content: center;
    padding: 0.3rem 0.45rem;
    order: 0;
  }

  .side-role {
    display: none;
  }

  .board-cabinet {
    order: 1;
    padding: 0.35rem 0.4rem;
    width: auto;
    max-width: 100%;
  }

  .board {
    gap: 3px;
    padding: 3px;
  }

  .box {
    gap: 1px;
  }

  .board-wrap {
    width: var(--board-size);
    height: var(--board-size);
    min-width: 200px;
    min-height: 200px;
  }

  .cell .digit {
    font-size: clamp(1rem, 6.5vw, 1.65rem);
  }

  .controls-panel {
    order: 2;
    max-width: none;
    width: min(24rem, 100%);
  }

  .pad {
    width: 100%;
    max-width: 24rem;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.28rem;
  }

  .pad-btn {
    min-height: 2.85rem;
    aspect-ratio: auto;
    font-size: 0.8rem;
  }

  .pad-btn.erase,
  .pad-btn.notes,
  .pad-btn.check {
    font-size: 0.72rem;
  }

  .cabinet-label {
    font-size: 0.32rem;
  }

  .message {
    white-space: normal;
    font-size: 0.95rem;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .footer-bar {
    padding: 0.28rem max(0.5rem, var(--safe-right)) calc(0.35rem + var(--safe-bottom))
      max(0.5rem, var(--safe-left));
  }

  .marquee {
    font-size: 0.45rem;
  }

  .footer-bar .hint {
    font-size: 0.32rem;
  }

  .crt-overlay {
    opacity: 0.32;
  }

  .speech {
    left: auto;
    right: 0.5rem;
    transform: translateY(-100%);
  }
}

@media (max-width: 400px) {
  .squipy-panel .side-name {
    display: none;
  }

  .pad-hint {
    display: none;
  }

  :root {
    --board-size: min(
      calc(100vw - 0.8rem),
      calc(calc(100vh - var(--rg-bar)) - 13rem - var(--safe-top) - var(--safe-bottom)),
      calc(calc(100dvh - var(--rg-bar)) - 13rem - var(--safe-top) - var(--safe-bottom))
    );
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  :root {
    --board-size: min(
      calc(calc(100vh - var(--rg-bar)) - 5.5rem - var(--safe-top) - var(--safe-bottom)),
      calc(calc(100dvh - var(--rg-bar)) - 5.5rem - var(--safe-top) - var(--safe-bottom)),
      calc(100vw - 16rem)
    );
  }

  .stage {
    grid-template-columns: auto auto auto;
    grid-template-rows: 1fr;
  }

  .squipy-panel {
    flex-direction: column;
    width: auto;
  }

  .board-cabinet {
    order: 0;
  }

  .controls-panel {
    order: 0;
  }

  .pad {
    grid-template-columns: repeat(3, 1fr);
    width: 7.5rem;
  }

  .pad-btn {
    min-height: 2.1rem;
    font-size: 0.65rem;
  }

  .footer-bar,
  .cabinet-label,
  .marquee {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .squipy-avatar {
    animation: none;
  }
}
