@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=IBM+Plex+Sans:wght@400;500;700&display=swap');

:root {
  --boxboard: #F4EFE6;
  --paper-shade: #E6DEC8;
  --ink: #141311;
  --mecha-red: #E02B20;
  --signal-yellow: #F7B500;
  --cobalt-blue: #1858A8;

  --font-display: 'Archivo Black', Impact, 'Arial Black', sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --border-thick: 3px solid var(--ink);
  --border-heavy: 4px solid var(--ink);
  --shadow-hard: 6px 6px 0px var(--ink);
  --shadow-button: 4px 4px 0px var(--ink);

  --max-width: 1180px;
  --gutter: clamp(16px, 4vw, 36px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  background-color: var(--boxboard);
  color: var(--ink);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--boxboard);
  background-image: radial-gradient(var(--paper-shade) 1.25px, transparent 1.25px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 4px solid var(--cobalt-blue);
  outline-offset: 4px;
}

/* ---------- MASTHEAD ---------- */
.masthead {
  border-bottom: var(--border-heavy);
  background: var(--boxboard);
}

.masthead-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.brand-mark {
  display: inline-flex;
  border: var(--border-thick);
  box-shadow: var(--shadow-button);
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.brand-orbit {
  background: var(--mecha-red);
  color: var(--boxboard);
  padding: 9px 13px;
}

.brand-arcade {
  background: var(--signal-yellow);
  color: var(--ink);
  padding: 9px 13px;
  border-left: var(--border-thick);
}

.carton-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-shade);
  border: var(--border-thick);
  padding: 5px 14px 5px 6px;
  font-weight: 700;
  font-size: 0.92rem;
}

.carton-badge img {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
  border: 2px solid var(--ink);
  background: #ffffff;
}

.tab-link,
.punch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  background: var(--boxboard);
  border: var(--border-thick);
  box-shadow: 3px 3px 0px var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.tab-link:hover,
.punch-btn:hover {
  background: var(--signal-yellow);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px var(--ink);
}

.tab-link:active,
.punch-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0px 0px 0px var(--ink);
}

/* ---------- TWO-COLUMN CATALOG LAYOUT ---------- */
.arcade-columns {
  width: min(var(--max-width), 100%);
  margin: 0 auto;
  padding: 32px var(--gutter) 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  align-items: start;
}

.page {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
}

.top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

/* ---------- TABLETOP ELECTRONIC CASING (.stage) ---------- */
.stage {
  background: var(--signal-yellow);
  border: var(--border-heavy);
  box-shadow: var(--shadow-hard);
  padding: 20px;
}

.stage:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--boxboard);
  overflow-y: auto;
}

.stage:fullscreen .casing-header,
.stage:fullscreen .board {
  width: min(90vw, 76vh);
}

.casing-header {
  margin-bottom: 16px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
}

.score-window {
  background: var(--ink);
  color: var(--boxboard);
  border: var(--border-thick);
  padding: 8px 16px;
  min-width: 128px;
  box-shadow: inset 0 0 0 2px #2b2927;
}

.window-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--signal-yellow);
}

.hud b {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: 0.03em;
}

.hud-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--boxboard);
  border: var(--border-thick);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.95rem;
}

.status-lamp {
  width: 14px;
  height: 14px;
  background: var(--cobalt-blue);
  border: 2px solid var(--ink);
}

.status-lamp.paused {
  background: var(--signal-yellow);
}

.status-lamp.dead {
  background: var(--mecha-red);
}

/* ---------- RECESSED SCREEN BEZEL (.board) ---------- */
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--ink);
  border: var(--border-heavy);
  box-shadow: inset 0 0 0 4px #2b2927;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- DIE-CUT INSTRUCTION OVERLAY ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 19, 17, 0.72);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  max-width: 350px;
  width: 100%;
  background: var(--boxboard);
  color: var(--ink);
  border: var(--border-heavy);
  box-shadow: 8px 8px 0px var(--mecha-red);
  padding: 24px 22px;
  text-align: left;
  transform: rotate(-1deg);
}

.overlay-seal {
  width: 68px;
  height: 68px;
  border: var(--border-thick);
  box-shadow: 3px 3px 0px var(--ink);
  background: #ffffff;
  padding: 4px;
  margin-bottom: 14px;
}

.overlay-seal img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.overlay-card h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  line-height: 1.02;
  margin-bottom: 8px;
}

.overlay-card p {
  font-weight: 500;
  font-size: 0.96rem;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin: 18px 0 10px;
  padding: 12px 20px;
  background: var(--mecha-red);
  color: var(--boxboard);
  border: var(--border-thick);
  box-shadow: var(--shadow-button);
  font-family: var(--font-display);
  font-size: 1.05rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
}

.primary:hover {
  background: var(--ink);
  color: var(--signal-yellow);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px var(--ink);
}

.primary:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0px var(--ink);
}

.overlay-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cobalt-blue);
}

/* ---------- TOUCH DIRECTIONAL KEYPAD ---------- */
.mobile-controls {
  display: none;
  margin-top: 18px;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mobile-row {
  display: flex;
  gap: 8px;
}

.mobile-controls button {
  min-width: 78px;
  min-height: 52px;
  padding: 8px 14px;
  background: var(--boxboard);
  color: var(--ink);
  border: var(--border-thick);
  box-shadow: 3px 3px 0px var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  touch-action: manipulation;
}

.mobile-controls button:active {
  background: var(--mecha-red);
  color: var(--boxboard);
  transform: translate(3px, 3px);
  box-shadow: 0px 0px 0px var(--ink);
}

@media (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
}

/* ---------- MECHANICAL SWITCH PANEL (.settings) ---------- */
.settings {
  margin-top: 28px;
  background: var(--boxboard);
  border: var(--border-heavy);
  box-shadow: var(--shadow-hard);
}

.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.setting + .setting {
  border-top: var(--border-thick);
}

.setting-copy b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.setting-copy p {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Interlocking push buttons for speed */
.seg {
  display: inline-flex;
  border: var(--border-thick);
  box-shadow: 3px 3px 0px var(--ink);
  background: var(--paper-shade);
}

.seg button {
  min-height: 44px;
  padding: 6px 14px;
  border: 0;
  border-right: 2px solid var(--ink);
  background: transparent;
  font-weight: 700;
  font-size: 0.9rem;
}

.seg button:last-child {
  border-right: 0;
}

.seg button:hover {
  background: var(--boxboard);
}

.seg button.active {
  background: var(--mecha-red);
  color: var(--boxboard);
}

/* Rectangular mechanical rocker switch (No pill toggles!) */
.rocker-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 108px;
  min-height: 44px;
  padding: 0;
  border: var(--border-thick);
  box-shadow: 3px 3px 0px var(--ink);
  background: var(--paper-shade);
  font-family: var(--font-display);
  font-size: 0.85rem;
}

.rocker-switch span {
  display: grid;
  place-items: center;
  padding: 6px 10px;
}

.rocker-switch.on .switch-state-on {
  background: var(--signal-yellow);
  color: var(--ink);
  border-right: 2px solid var(--ink);
}

.rocker-switch:not(.on) .switch-state-off {
  background: var(--ink);
  color: var(--boxboard);
  border-left: 2px solid var(--ink);
}

/* ---------- PRINTED MANUAL SECTION (.info) ---------- */
.info {
  margin-top: 28px;
  background: var(--paper-shade);
  border: var(--border-heavy);
  box-shadow: var(--shadow-hard);
  padding: 24px;
}

.info h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin-bottom: 10px;
}

.info p {
  font-weight: 500;
  max-width: 62ch;
}

.info p + p {
  margin-top: 10px;
}

/* ---------- SIDEBAR: OTHER CARTONS ON THE SHELF ---------- */
.other-games {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.other-games h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
  padding-bottom: 10px;
  border-bottom: var(--border-thick);
}

.other-game {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--boxboard);
  border: var(--border-thick);
  box-shadow: var(--shadow-button);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.other-game:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--ink);
}

.other-game:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0px var(--ink);
}

.other-game.iron-orbit {
  border-left: 10px solid var(--mecha-red);
}

.other-game.x-zero {
  border-left: 10px solid var(--cobalt-blue);
}

.other-game.g-2048 {
  border-left: 10px solid var(--signal-yellow);
}

.game-thumb {
  flex: 0 0 60px;
  height: 60px;
  border: 2px solid var(--ink);
  background: #ffffff;
  padding: 3px;
  display: grid;
  place-items: center;
}

.game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.game-link-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-link-text strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.1;
}

.game-link-text small {
  font-size: 0.88rem;
  font-weight: 700;
}

/* ---------- FOOTER ---------- */
.sheet-footer {
  width: min(var(--max-width), 100%);
  margin: auto auto 0;
  padding: 24px var(--gutter) 36px;
  border-top: var(--border-thick);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 700;
  font-size: 0.95rem;
}

.sheet-footer a {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */
@media (max-width: 920px) {
  .arcade-columns {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .other-games {
    max-width: 660px;
    width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  .stage {
    padding: 14px;
  }

  .setting {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud-status {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
