.arcade-stage {
  padding: clamp(0.8rem, 2.5vw, 1.75rem) 0 clamp(2rem, 5vw, 4rem);
}

.arcade-layout {
  width: min(100%, 70rem);
}

.arcade-back-link {
  display: inline-block;
  margin-bottom: 0.7rem;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 14px rgba(33, 37, 41, 0.14);
  color: #0056b3;
  font-weight: 700;
}

.arcade-back-link:hover {
  color: #003f84;
  text-decoration: none;
}

.arcade-panel {
  padding: clamp(0.9rem, 2.7vw, 1.8rem);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 44px rgba(33, 37, 41, 0.22);
}

.arcade-header {
  max-width: 44rem;
  margin: 0 auto;
  text-align: center;
}

.arcade-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
}

.arcade-header p:last-child {
  margin: 0.45rem 0 0;
  color: #4d5761;
}

.arcade-kicker {
  margin: 0 0 0.1rem;
  color: #0069d9;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.arcade-stats {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem auto 0;
}

.arcade-stat {
  min-width: 6.5rem;
  padding: 0.48rem 0.7rem;
  border: 1px solid #d6dde3;
  border-radius: 9px;
  background: #f8f9fa;
  text-align: center;
}

.arcade-stat span {
  display: block;
  color: #68727c;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.arcade-stat output {
  display: block;
  margin-top: 0.05rem;
  color: #212529;
  font-size: 1rem;
  font-weight: 700;
}

.arcade-status {
  min-height: 1.5rem;
  margin: 0.85rem auto;
  color: #495057;
  font-weight: 700;
  text-align: center;
}

.arcade-status[data-state="success"] {
  color: #176b32;
}

.arcade-status[data-state="danger"] {
  color: #a33b20;
}

.arcade-canvas-wrap {
  width: min(100%, 48rem);
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid #527181;
  border-radius: 14px;
  background: #d9f3ff;
  box-shadow: 0 7px 18px rgba(34, 56, 67, 0.18);
}

.arcade-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #d9f3ff;
  touch-action: none;
}

.arcade-actions,
.arcade-touch-controls {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.arcade-button,
.arcade-touch-button {
  min-width: 6.5rem;
  min-height: 44px;
  padding: 0.62rem 1rem;
  border: 1px solid #0069d9;
  border-radius: 9px;
  background: #007bff;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.arcade-button:hover,
.arcade-touch-button:hover {
  border-color: #005cbf;
  background: #0069d9;
}

.arcade-button-secondary {
  border-color: #68727c;
  background: #fff;
  color: #3f4851;
}

.arcade-button-secondary:hover {
  border-color: #41484f;
  background: #edf0f2;
  color: #212529;
}

.arcade-button:disabled,
.arcade-touch-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.arcade-back-link:focus-visible,
.arcade-button:focus-visible,
.arcade-touch-button:focus-visible,
.grid-edge:focus-visible,
.says-pad:focus-visible,
.maze-cell:focus-visible {
  outline: 3px solid #80bdff;
  outline-offset: 3px;
}

.arcade-help {
  max-width: 44rem;
  margin: 0.85rem auto 0;
  color: #65707a;
  font-size: 0.85rem;
  text-align: center;
}

.grid-war-board {
  --dot-count: 5;
  --grid-track-count: 9;
  display: grid;
  grid-template-columns: repeat(var(--grid-track-count), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-track-count), minmax(0, 1fr));
  width: min(88vw, 32rem);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 0.6rem;
  border: 2px solid #4e6470;
  border-radius: 14px;
  background: #f7fcff;
  box-shadow: 0 7px 18px rgba(34, 56, 67, 0.16);
}

.grid-dot {
  width: clamp(0.65rem, 2vw, 0.95rem);
  height: clamp(0.65rem, 2vw, 0.95rem);
  place-self: center;
  border-radius: 50%;
  background: #253640;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.grid-edge {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.grid-edge-horizontal {
  width: 88%;
  height: 0.52rem;
  place-self: center;
}

.grid-edge-vertical {
  width: 0.52rem;
  height: 88%;
  place-self: center;
}

.grid-edge:hover {
  background: #b8d9e8;
}

.grid-edge.is-player-one {
  background: #1976d2;
}

.grid-edge.is-player-two {
  background: #d32f2f;
}

.grid-box {
  display: flex;
  margin: 0.16rem;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: clamp(0.75rem, 2.4vw, 1.25rem);
  font-weight: 700;
}

.grid-box.is-player-one {
  background: rgba(25, 118, 210, 0.78);
}

.grid-box.is-player-two {
  background: rgba(211, 47, 47, 0.78);
}

.player-one-text {
  color: #155fa8;
}

.player-two-text {
  color: #b32626;
}

.says-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: min(90vw, 28rem);
  margin: 0 auto;
}

.says-pad {
  min-height: clamp(6.5rem, 20vw, 9rem);
  border: 4px solid rgba(31, 44, 51, 0.25);
  border-radius: 28px;
  color: rgba(0, 0, 0, 0.72);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.78;
  transition: filter 120ms ease, opacity 120ms ease, transform 120ms ease;
}

.says-pad[data-pad="0"] { background: #55b96a; }
.says-pad[data-pad="1"] { background: #f2cc4d; }
.says-pad[data-pad="2"] { background: #eb6b66; }
.says-pad[data-pad="3"] { background: #5ca9e6; }

.says-pad:hover:not(:disabled),
.says-pad.is-lit {
  filter: brightness(1.28) saturate(1.25);
  opacity: 1;
  transform: scale(1.025);
}

.maze-board {
  --maze-size: 5;
  display: grid;
  grid-template-columns: repeat(var(--maze-size), minmax(0, 1fr));
  width: min(88vw, 34rem);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 3px solid #314b56;
  background: #f1fbf3;
}

.maze-cell {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-color: #314b56;
  border-style: solid;
  border-width: 0;
  align-items: center;
  justify-content: center;
  background: rgba(238, 250, 240, 0.92);
  font-size: clamp(0.8rem, 4vw, 2rem);
}

.maze-cell.is-goal {
  background: #fff4c6;
}

.maze-dpad {
  display: grid;
  grid-template-columns: repeat(3, 3.2rem);
  grid-template-rows: repeat(2, 3.2rem);
  gap: 0.35rem;
  justify-content: center;
  margin-top: 1rem;
}

.maze-dpad .arcade-touch-button {
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.maze-up { grid-column: 2; }
.maze-left { grid-column: 1; grid-row: 2; }
.maze-down { grid-column: 2; grid-row: 2; }
.maze-right { grid-column: 3; grid-row: 2; }

@media (max-width: 575.98px) {
  .arcade-stage {
    padding-top: 0.65rem;
  }

  .arcade-panel {
    padding: 0.9rem 0.55rem 1.15rem;
    border-radius: 15px;
  }

  .arcade-stat {
    min-width: 5.5rem;
  }

  .arcade-touch-controls {
    position: sticky;
    bottom: 0.35rem;
    z-index: 2;
    width: fit-content;
    margin-right: auto;
    margin-left: auto;
    padding: 0.35rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .says-pad {
    transition: none;
  }
}
