:root {
  color-scheme: dark;
  --bg: #070912;
  --panel: #111725;
  --panel-2: #151827;
  --line: #31415c;
  --line-soft: rgba(255, 255, 255, 0.11);
  --text: #edf4ff;
  --muted: #96a6bd;
  --cyan: #25d9ff;
  --gold: #ffd24a;
  --pink: #ff4fb6;
  --green: #57f287;
  --red: #ff6b5f;
  --violet: #9c88ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(37, 217, 255, 0.1), transparent 38%),
    radial-gradient(circle at 18% 74%, rgba(255, 79, 182, 0.08), transparent 30%),
    linear-gradient(180deg, #080912 0%, #0d0b17 44%, #06070c 100%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(238px, 24vw, 300px);
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100svh;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(37, 217, 255, 0.045), transparent 38%),
    linear-gradient(315deg, rgba(255, 79, 182, 0.04), transparent 42%);
}

.hud {
  z-index: 2;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(148px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px clamp(10px, 2.6vw, 26px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 10, 18, 0.88);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
}

.brand,
.stats,
.actions {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand {
  gap: 10px;
  color: var(--text);
  font-size: clamp(0.88rem, 1.5vw, 1rem);
  font-weight: 850;
  text-shadow: 0 0 14px rgba(37, 217, 255, 0.2);
  white-space: nowrap;
}

.brand strong {
  color: var(--gold);
  font-size: 0.78em;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold);
  background: linear-gradient(135deg, #ffe66d, #ff9e44 54%, #ff4fb6);
  border-radius: 2px;
  box-shadow: 0 0 18px rgba(255, 210, 74, 0.46);
}

.stats {
  justify-content: end;
  gap: 7px;
  color: var(--muted);
  font-size: clamp(0.68rem, 1.3vw, 0.9rem);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.stats span,
.speed-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(17, 21, 32, 0.78);
  box-shadow: inset 0 0 16px rgba(37, 217, 255, 0.035);
  white-space: nowrap;
}

#score,
#best-score,
#level-record {
  color: var(--gold);
}

#level-record {
  color: var(--cyan);
}

.lives {
  color: var(--red);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(255, 107, 95, 0.68);
}

.stats span.unlocked {
  color: #05120a;
  border-color: rgba(87, 242, 135, 0.65);
  background: var(--green);
}

.speed-control {
  gap: 7px;
}

.speed-control strong {
  color: var(--gold);
  font-weight: 850;
}

.speed-control input {
  width: 74px;
  accent-color: var(--gold);
  cursor: pointer;
}

.actions {
  justify-content: end;
  gap: 8px;
}

.icon-button,
.primary,
.touch-pad button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(17, 21, 32, 0.96);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  font-weight: 850;
}

.icon-button.is-muted {
  color: var(--muted);
  border-color: rgba(255, 107, 95, 0.45);
}

.arcade-toggle,
.settings-panel {
  display: none;
}

.settings-panel {
  position: fixed;
  top: 74px;
  right: 14px;
  z-index: 6;
  width: min(330px, calc(100vw - 28px));
}

.settings-panel.is-open {
  display: grid;
}

.settings-control {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.settings-control strong {
  color: var(--gold);
}

.settings-control input {
  width: 100%;
  accent-color: var(--gold);
}

.settings-control select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(7, 11, 18, 0.96);
  font-weight: 850;
  cursor: pointer;
}

.settings-stepper {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
}

.settings-stepper button,
.settings-stepper span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(7, 11, 18, 0.96);
}

.settings-stepper button {
  color: var(--text);
  font-weight: 950;
  cursor: pointer;
}

.settings-stepper span {
  min-width: 0;
  padding: 0 8px;
  overflow: hidden;
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-sound-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(17, 21, 32, 0.96);
  font-weight: 850;
  cursor: pointer;
}

.settings-sound-toggle.is-muted {
  color: var(--muted);
  border-color: rgba(255, 107, 95, 0.45);
}

.icon-button:hover,
.primary:hover,
.touch-pad button:hover {
  border-color: rgba(37, 217, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(37, 217, 255, 0.12);
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
}

.touch-pad {
  position: absolute;
  right: clamp(12px, 3vw, 26px);
  bottom: clamp(12px, 3vw, 26px);
  display: none;
  grid-template-areas:
    ". up ."
    "left down right";
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 8px;
  opacity: 0.78;
  user-select: none;
}

.touch-pad button {
  width: 48px;
  height: 48px;
  color: #061018;
  border-color: rgba(255, 210, 74, 0.58);
  background: rgba(255, 210, 74, 0.9);
  font-size: 1.05rem;
  font-weight: 950;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.34);
}

.touch-pad button[data-dir="up"] {
  grid-area: up;
}

.touch-pad button[data-dir="left"] {
  grid-area: left;
}

.touch-pad button[data-dir="down"] {
  grid-area: down;
}

.touch-pad button[data-dir="right"] {
  grid-area: right;
}

.level-briefing {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 210, 74, 0.14), transparent 33%),
    rgba(5, 7, 13, 0.46);
}

.level-briefing[hidden] {
  display: none;
}

.level-briefing > div {
  display: grid;
  gap: 11px;
  width: min(440px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid rgba(255, 210, 74, 0.34);
  border-radius: 8px;
  background: rgba(7, 10, 16, 0.9);
  box-shadow: 0 16px 70px rgba(0, 0, 0, 0.42), 0 0 34px rgba(37, 217, 255, 0.14);
  text-align: center;
  text-transform: uppercase;
}

.level-briefing h1,
.level-briefing p {
  margin: 0;
}

.level-briefing h1 {
  color: var(--cyan);
  font-size: clamp(1.3rem, 5vw, 2.6rem);
  line-height: 1;
}

.level-briefing p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.briefing-glyphs {
  display: flex;
  justify-content: center;
  gap: clamp(5px, 1.8vw, 10px);
  max-width: 100%;
  overflow: hidden;
  flex-wrap: nowrap;
  text-transform: none;
}

.briefing-glyph {
  position: relative;
  flex: 0 1 clamp(38px, 8vw, 64px);
  display: grid;
  place-items: center;
  width: clamp(38px, 8vw, 64px);
  min-width: 0;
  aspect-ratio: 1;
  border: max(2px, 0.08em) solid var(--glyph-color, var(--gold));
  border-radius: 8px;
  background: rgba(6, 7, 12, 0.84);
  box-shadow: 0 0 24px color-mix(in srgb, var(--glyph-color, var(--gold)) 46%, transparent);
}

.briefing-glyph::before {
  content: "";
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--glyph-color, var(--gold));
  box-shadow: 0 0 22px color-mix(in srgb, var(--glyph-color, var(--gold)) 58%, transparent);
}

.briefing-glyph-symbol {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1.05rem, 4.7vw, 1.85rem);
  font-weight: 950;
  line-height: 1;
  text-transform: none;
  text-shadow:
    0 2px 0 rgba(5, 7, 13, 0.9),
    0 -2px 0 rgba(5, 7, 13, 0.9),
    2px 0 0 rgba(5, 7, 13, 0.9),
    -2px 0 0 rgba(5, 7, 13, 0.9);
  -webkit-text-stroke: max(1px, 0.08em) rgba(5, 7, 13, 0.9);
}

.level-briefing strong {
  color: var(--gold);
  font-size: clamp(1.4rem, 7vw, 3rem);
  line-height: 1;
}

.arcade-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  border-left: 1px solid var(--line-soft);
  background:
    linear-gradient(180deg, rgba(23, 20, 36, 0.94), rgba(7, 10, 16, 0.94)),
    var(--panel-2);
  overflow: auto;
}

.score-box {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(17, 21, 32, 0.76);
  box-shadow: inset 0 0 22px rgba(37, 217, 255, 0.04);
}

.score-box h2 {
  margin: 0;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 210, 74, 0.24);
  font-size: 0.78rem;
  letter-spacing: 0;
}

#top-scores,
#level-records {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

#top-scores li,
#level-records li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(5, 7, 13, 0.5);
  color: var(--muted);
  font-size: 0.8rem;
}

#top-scores strong,
#level-records strong {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#top-scores b,
#level-records b {
  color: var(--gold);
  font-weight: 850;
}

#level-records li {
  grid-template-columns: 32px 1fr auto;
}

#level-records b {
  color: var(--cyan);
}

.rules-box,
.shape-box {
  color: var(--muted);
  font-size: 0.82rem;
}

.rule-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 32px;
  color: var(--muted);
}

.rule-demo {
  position: relative;
  width: 92px;
  height: 28px;
  overflow: hidden;
}

.rule-demo::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 4px;
  left: 4px;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(37, 217, 255, 0.22), transparent);
}

.rule-shape {
  position: absolute;
  top: 50%;
  display: inline-block;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  background: var(--rule-color, var(--violet));
  box-shadow: 0 0 14px var(--rule-glow, rgba(156, 136, 255, 0.56));
}

.rule-shape.actor {
  left: 3px;
  z-index: 2;
  animation: rule-cross-square-circle 3.1s ease-in-out infinite;
}

.rule-shape.target {
  left: 43px;
  z-index: 1;
  animation: rule-target-eaten 3.1s ease-in-out infinite;
}

.rule-demo-square-circle .actor,
.rule-demo-triangle-square .target {
  --rule-color: var(--violet);
  --rule-glow: rgba(156, 136, 255, 0.58);
  border-radius: 3px;
  clip-path: inset(0 round 3px);
}

.rule-demo-square-circle .target,
.rule-demo-circle-triangle .actor {
  --rule-color: var(--cyan);
  --rule-glow: rgba(37, 217, 255, 0.58);
  border-radius: 50%;
  clip-path: inset(0 round 50%);
}

.rule-demo-circle-triangle .target,
.rule-demo-triangle-square .actor {
  --rule-color: var(--pink);
  --rule-glow: rgba(255, 79, 182, 0.58);
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.rule-demo-circle-triangle .actor {
  animation-name: rule-cross-circle-triangle;
}

.rule-demo-triangle-square .actor {
  animation-name: rule-cross-triangle-square;
}

.rule-row:nth-child(3) .rule-shape {
  animation-delay: 0.22s;
}

.rule-row:nth-child(4) .rule-shape {
  animation-delay: 0.44s;
}

@keyframes rule-cross-square-circle {
  0%,
  18% {
    left: 3px;
    background: var(--violet);
    border-radius: 3px;
    clip-path: inset(0 round 3px);
    box-shadow: 0 0 14px rgba(156, 136, 255, 0.58);
  }
  39% {
    left: 39px;
    background: var(--violet);
    border-radius: 3px;
    clip-path: inset(0 round 3px);
    box-shadow: 0 0 14px rgba(156, 136, 255, 0.58);
  }
  46% {
    left: 46px;
    background: var(--cyan);
    border-radius: 50%;
    clip-path: inset(0 round 50%);
    box-shadow: 0 0 14px rgba(37, 217, 255, 0.58);
  }
  78% {
    left: 68px;
    background: var(--cyan);
    border-radius: 50%;
    clip-path: inset(0 round 50%);
    box-shadow: 0 0 14px rgba(37, 217, 255, 0.58);
  }
  100% {
    left: 3px;
    background: var(--violet);
    border-radius: 3px;
    clip-path: inset(0 round 3px);
    box-shadow: 0 0 14px rgba(156, 136, 255, 0.58);
  }
}

@keyframes rule-cross-circle-triangle {
  0%,
  18% {
    left: 3px;
    background: var(--cyan);
    border-radius: 50%;
    clip-path: inset(0 round 50%);
    box-shadow: 0 0 14px rgba(37, 217, 255, 0.58);
  }
  39% {
    left: 39px;
    background: var(--cyan);
    border-radius: 50%;
    clip-path: inset(0 round 50%);
    box-shadow: 0 0 14px rgba(37, 217, 255, 0.58);
  }
  46% {
    left: 46px;
    background: var(--pink);
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    box-shadow: 0 0 14px rgba(255, 79, 182, 0.58);
  }
  78% {
    left: 68px;
    background: var(--pink);
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    box-shadow: 0 0 14px rgba(255, 79, 182, 0.58);
  }
  100% {
    left: 3px;
    background: var(--cyan);
    border-radius: 50%;
    clip-path: inset(0 round 50%);
    box-shadow: 0 0 14px rgba(37, 217, 255, 0.58);
  }
}

@keyframes rule-cross-triangle-square {
  0%,
  18% {
    left: 3px;
    background: var(--pink);
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    box-shadow: 0 0 14px rgba(255, 79, 182, 0.58);
  }
  39% {
    left: 39px;
    background: var(--pink);
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    box-shadow: 0 0 14px rgba(255, 79, 182, 0.58);
  }
  46% {
    left: 46px;
    background: var(--violet);
    border-radius: 3px;
    clip-path: inset(0 round 3px);
    box-shadow: 0 0 14px rgba(156, 136, 255, 0.58);
  }
  78% {
    left: 68px;
    background: var(--violet);
    border-radius: 3px;
    clip-path: inset(0 round 3px);
    box-shadow: 0 0 14px rgba(156, 136, 255, 0.58);
  }
  100% {
    left: 3px;
    background: var(--pink);
    border-radius: 0;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    box-shadow: 0 0 14px rgba(255, 79, 182, 0.58);
  }
}

@keyframes rule-target-eaten {
  0%,
  36% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  45%,
  80% {
    opacity: 0;
    transform: translateY(-50%) scale(0.45);
  }
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

.shape-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.shape {
  display: inline-block;
  width: 17px;
  height: 17px;
  background: var(--violet);
  box-shadow: 0 0 14px rgba(156, 136, 255, 0.56);
}

.shape.circle {
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(37, 217, 255, 0.56);
}

.shape.triangle {
  width: 0;
  height: 0;
  border-right: 9px solid transparent;
  border-bottom: 17px solid var(--pink);
  border-left: 9px solid transparent;
  background: transparent;
  box-shadow: none;
}

.shape.player-dot {
  background: var(--gold);
  box-shadow: 0 0 14px rgba(255, 210, 74, 0.6);
}

.shape.triangle.player-dot {
  border-bottom-color: var(--gold);
  background: transparent;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5, 7, 13, 0.76);
  backdrop-filter: blur(4px);
}

.overlay[hidden] {
  display: none;
}

.level-transition {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, rgba(37, 217, 255, 0.16), transparent 34%),
    rgba(5, 7, 13, 0.5);
  animation: transition-fade 920ms ease both;
}

.level-transition[hidden] {
  display: none;
}

.level-transition div {
  display: grid;
  gap: 8px;
  text-align: center;
  text-transform: uppercase;
  filter: drop-shadow(0 0 22px rgba(37, 217, 255, 0.4));
}

.level-transition h1,
.level-transition p {
  margin: 0;
}

.level-transition h1 {
  color: var(--gold);
  font-size: clamp(2rem, 8vw, 5rem);
  line-height: 0.92;
}

.level-transition p {
  color: var(--cyan);
  font-weight: 850;
}

@keyframes transition-fade {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  18%,
  76% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.03);
  }
}

.result {
  display: grid;
  gap: 13px;
  width: min(390px, 100%);
  padding: 24px;
  border: 1px solid rgba(87, 242, 135, 0.48);
  border-radius: 8px;
  background: rgba(17, 21, 32, 0.97);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.46), 0 0 32px rgba(37, 217, 255, 0.12);
  text-align: center;
}

.result h1,
.result p {
  margin: 0;
}

.result h1 {
  font-size: clamp(1.38rem, 5vw, 2rem);
  line-height: 1.08;
}

.result p {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score-entry {
  display: grid;
  gap: 8px;
  margin: 0;
}

.score-entry[hidden] {
  display: none;
}

.score-entry label {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 850;
}

.score-entry div {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

.score-entry input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #070b12;
  color: var(--text);
  text-align: center;
  text-transform: uppercase;
  font-weight: 950;
  letter-spacing: 0;
}

.primary {
  min-height: 42px;
  padding: 0 16px;
  color: #06130a;
  border-color: transparent;
  background: var(--green);
  font-weight: 850;
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .arcade-panel {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: minmax(0, 1.2fr) minmax(190px, 0.8fr);
    padding: 10px;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
    max-height: 28svh;
  }
}

@media (max-width: 720px), (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  .game-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .stage {
    --mobile-board-size: min(100vw, calc(100svh - 256px), 720px);
    display: grid;
    place-items: center;
    padding-inline: 0;
    padding-bottom: calc(156px + env(safe-area-inset-bottom));
  }

  #game {
    width: var(--mobile-board-size);
    height: var(--mobile-board-size);
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
  }

  .hud {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 9px;
    min-height: 0;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .brand {
    display: none;
  }

  .actions {
    grid-row: 1;
    justify-content: end;
    gap: clamp(10px, 4vw, 16px);
    width: 100%;
  }

  .actions .icon-button {
    width: 52px;
    height: 52px;
    min-width: 52px;
    font-size: 1.28rem;
  }

  .stats {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: center;
    gap: 6px;
    width: 100%;
  }

  .stats > * {
    display: none;
  }

  #lives,
  #score,
  #timer {
    display: inline-flex;
    min-height: 34px;
    min-width: 0;
    padding: 0 10px;
    font-size: clamp(0.72rem, 3.3vw, 0.86rem);
    line-height: 1;
  }

  #lives {
    font-size: clamp(0.86rem, 4vw, 1rem);
  }

  .touch-pad {
    display: grid;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    justify-content: center;
    grid-template-areas:
      ". up ."
      "left . right"
      ". down .";
    grid-template-columns: repeat(3, 58px);
    grid-template-rows: repeat(3, 42px);
    gap: 6px 10px;
    padding: 8px 0 max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-soft);
    background: rgba(9, 10, 18, 0.9);
    backdrop-filter: blur(14px);
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.26);
    opacity: 0.98;
  }

  .touch-pad button {
    width: 58px;
    height: 42px;
    font-size: 1.22rem;
  }

  .arcade-toggle {
    display: inline-grid;
  }

  .arcade-panel,
  .settings-panel {
    position: fixed;
    top: calc(112px + env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    z-index: 6;
    display: none;
    grid-template-columns: 1fr;
    max-height: min(58svh, 430px);
    padding: 10px;
    border: 1px solid rgba(37, 217, 255, 0.28);
    border-radius: 8px;
    background:
      linear-gradient(180deg, rgba(23, 20, 36, 0.97), rgba(7, 10, 16, 0.98)),
      var(--panel-2);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 210, 74, 0.08);
    overflow: auto;
  }

  .arcade-panel.is-open,
  .settings-panel.is-open {
    display: grid;
  }

  .shape-box {
    display: none;
  }
}

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

@media (max-width: 440px) {
  .brand {
    font-size: 0.82rem;
  }

  .mark {
    width: 16px;
    height: 16px;
  }

  .actions .icon-button {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }

  .touch-pad {
    grid-template-columns: repeat(3, 54px);
    grid-template-rows: repeat(3, 40px);
    gap: 6px 8px;
  }

  .touch-pad button {
    width: 54px;
    height: 40px;
  }
}
