:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --ink: #fff1cf;
  --muted: #c7a87e;
  --panel: #24110c;
  --panel-raised: #35180f;
  --amber: #f6ac31;
  --cream: #fff0b4;
  --red: #9f341a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0d0706;
}

body {
  min-height: 100vh; /* pasta:ignore consecutive_dup */
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(170, 62, 21, 0.36), transparent 48%),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.012) 0,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 5px
    ),
    #0d0706;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
[role="slider"]:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 7px;
  width: min(100%, 560px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(7px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
}

.brand {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 1px;
  color: var(--amber);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.65rem, 6vw, 2.2rem);
  font-weight: 500;
  letter-spacing: 0.055em;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #6f2714;
}

.header-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.utility-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #68402d;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(38, 18, 12, 0.85);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  cursor: pointer;
}

.utility-button:active {
  transform: translateY(1px);
}

.utility-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.machine {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #5d2c1c;
  border-radius: 15px;
  background: linear-gradient(145deg, #321810, #170c09);
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 234, 192, 0.09);
}

.scoreboard {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 0.85fr 1.25fr 1.05fr 0.95fr;
  min-height: 43px;
  border-bottom: 1px solid #5d2c1c;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025), transparent),
    #1b0d09;
}

.score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid rgba(132, 72, 43, 0.4);
}

.score-cell:last-child {
  border-right: 0;
}

.score-label {
  color: #af8a67;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

.score-cell strong {
  margin-top: 3px;
  color: #ffc85e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.75rem, 3.3vw, 0.98rem);
  letter-spacing: 0.025em;
  line-height: 1;
}

.score-main strong {
  color: #fff0aa;
}

.lives-cell strong {
  color: #e8e0cf;
  letter-spacing: 0.12em;
}

.playfield-frame {
  position: relative;
  align-self: center;
  height: min(100%, calc((100vw - 24px) * 1.5));
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border: 5px solid #31140b;
  border-radius: 5px;
  background: #8e3e13;
  box-shadow:
    inset 0 0 0 2px #b46122,
    inset 0 0 30px rgba(42, 10, 2, 0.78);
}

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

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12%;
  text-align: center;
  background:
    linear-gradient(rgba(33, 10, 4, 0.74), rgba(20, 7, 4, 0.91)),
    radial-gradient(circle, transparent, #1c0804);
  backdrop-filter: blur(3px);
}

.overlay-kicker {
  color: #ffc34f;
  font-size: clamp(0.57rem, 2.4vw, 0.76rem);
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.screen-overlay h2 {
  max-width: 11ch;
  margin: 8px 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.2rem, 10vw, 4.2rem);
  font-weight: 500;
  letter-spacing: 0.035em;
  line-height: 0.94;
  text-transform: uppercase;
  text-shadow: 0 4px 0 #6f2714;
}

.screen-overlay p {
  max-width: 31ch;
  margin: 0;
  color: #dec7a7;
  font-size: clamp(0.72rem, 3vw, 0.92rem);
  line-height: 1.45;
}

.mini-controls {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: clamp(12px, 4vh, 24px) 0 12px;
  color: #ffd06b;
  font-size: 1.35rem;
  font-weight: 900;
}

.mini-controls i {
  display: block;
  width: 68px;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(180deg, #f4f1df, #747b78);
  box-shadow: 0 5px 6px rgba(0, 0, 0, 0.4);
  transform: rotate(-7deg);
}

.start-button {
  min-height: 46px;
  padding: 0 26px;
  border: 1px solid #ffe1a2;
  border-radius: 7px;
  color: #301205;
  background: linear-gradient(#ffe69d, #f6a927);
  box-shadow:
    0 5px 0 #8c3f14,
    0 9px 20px rgba(0, 0, 0, 0.35);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.start-button:active {
  box-shadow:
    0 2px 0 #8c3f14,
    0 5px 14px rgba(0, 0, 0, 0.35);
  transform: translateY(3px);
}

.message-panel {
  display: flex;
  align-items: center;
  min-height: 35px;
  padding: 5px 10px;
  border-top: 1px solid #5d2c1c;
  background: #1a0d09;
}

.status-light {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #ffbd3d;
  box-shadow: 0 0 9px #ff9d22;
  animation: status-pulse 1.2s ease-in-out infinite alternate;
}

.message-panel p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #cbb497;
  font-size: clamp(0.6rem, 2.7vw, 0.75rem);
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 7px;
  min-height: 115px;
  padding: 7px;
  border: 1px solid #5e3425;
  border-radius: 15px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.045), transparent 45%),
    #25120d;
  box-shadow:
    inset 0 1px 0 rgba(255, 242, 215, 0.08),
    0 8px 22px rgba(0, 0, 0, 0.3);
}

.touch-control {
  --knob-y: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 99px;
  padding: 6px 6px 5px;
  overflow: hidden;
  border: 1px solid #704029;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 45%, rgba(245, 167, 50, 0.12), transparent 50%),
    #32180f;
  cursor: ns-resize;
  touch-action: none;
}

.touch-control::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0 rgba(255, 191, 67, 0);
  content: "";
  pointer-events: none;
  transition: box-shadow 120ms ease;
}

.touch-control.is-active::after {
  box-shadow:
    inset 0 0 0 2px #f9b43c,
    inset 0 0 24px rgba(248, 145, 26, 0.18);
}

.control-name,
.control-hint {
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.control-name {
  color: #f8c55e;
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.control-hint {
  color: #99785f;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.control-track {
  position: relative;
  display: block;
  width: 100%;
  min-height: 58px;
}

.control-track::before {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 50%;
  width: 5px;
  border: 1px solid #744229;
  border-radius: 99px;
  background: #100806;
  box-shadow: inset 1px 0 2px #000;
  content: "";
  transform: translateX(-50%);
}

.control-arrow {
  position: absolute;
  left: calc(50% + 20px);
  color: #8b6043;
  font-size: 0.52rem;
}

.control-arrow.up {
  top: 3px;
}

.control-arrow.down {
  bottom: 3px;
}

.control-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 28px;
  border: 2px solid #d6d9ce;
  border-radius: 7px;
  color: #1b1e1d;
  background: linear-gradient(180deg, #f5f4e7, #777f7c);
  box-shadow:
    0 5px 7px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 950;
  transform: translate(-50%, calc(-50% + var(--knob-y)));
  transition: transform 45ms linear;
}

.touch-control.is-active .control-knob {
  border-color: #fff0b3;
  box-shadow:
    0 0 16px rgba(255, 186, 56, 0.35),
    0 5px 7px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 #fff;
}

.deck-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  color: #8d6c54;
  font-size: 0.46rem;
  font-weight: 850;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}

.deck-center i {
  display: block;
  width: 35px;
  height: 2px;
  margin: 7px 0;
  background: #68402e;
}

.keyboard-help {
  margin: 0;
  overflow: hidden;
  color: #715848;
  font-size: 0.59rem;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

kbd {
  padding: 1px 4px;
  border: 1px solid #503426;
  border-radius: 3px;
  color: #a98b75;
  background: #1d0f0b;
  font: inherit;
}

@keyframes status-pulse {
  from {
    opacity: 0.62;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-height: 700px) and (orientation: portrait) {
  .game-shell {
    gap: 5px;
  }

  .control-deck {
    min-height: 94px;
    padding: 5px;
  }

  .touch-control {
    min-height: 82px;
    padding-top: 4px;
  }

  .control-track {
    min-height: 45px;
  }

  .control-knob {
    width: 34px;
    height: 24px;
  }

  .keyboard-help {
    display: none;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .game-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
    gap: 9px 12px;
    width: min(100%, 1000px);
  }

  .machine {
    grid-row: 1 / 4;
    grid-column: 1;
  }

  .topbar {
    grid-row: 1;
    grid-column: 2;
  }

  .control-deck {
    grid-row: 2;
    grid-column: 2;
    min-height: 0;
  }

  .keyboard-help {
    grid-row: 3;
    grid-column: 2;
  }

  .playfield-frame {
    height: 100%;
  }
}

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

  .control-knob {
    transition: none;
  }
}
