:root {
  color-scheme: dark;
  --bg: #151421;
  --bg-deep: #0f0f1a;
  --panel: #202033;
  --panel-soft: #28283c;
  --panel-line: #34344c;
  --text: #fff8e6;
  --muted: #b8b7ca;
  --cyan: #36d9f7;
  --pink: #ff4f9a;
  --yellow: #ffd65a;
  --orange: #ff9b38;
  --green: #7be36d;
  --red: #ff5d68;
  --shadow: rgba(0, 0, 0, 0.58);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 16px),
    linear-gradient(180deg, rgba(255, 214, 90, 0.045), transparent 26%),
    linear-gradient(180deg, #1b1a2a 0%, var(--bg) 42%, var(--bg-deep) 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 7px),
    linear-gradient(90deg, rgba(255, 214, 90, 0.08), transparent 18%, transparent 82%, rgba(54, 217, 247, 0.08));
  opacity: 0.42;
}

body::after {
  position: fixed;
  inset: auto 0 0;
  z-index: -1;
  height: 34vh;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(7, 7, 12, 0.68));
}

button,
a {
  font: inherit;
}

.gamepad-status,
.fullscreen-toggle,
.gamepad-popup,
.game-tile,
.marquee,
.brand-lockup,
.score-strip span,
.game-best,
.start-chip,
.gamepad-popup button {
  border-radius: 8px;
}

.gamepad-status {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 20;
  width: min(184px, calc(100vw - 28px));
  min-height: 68px;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 8px 10px;
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
  background: rgba(32, 32, 51, 0.92);
  border: 1px solid rgba(123, 227, 109, 0.78);
  box-shadow:
    0 12px 28px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gamepad-status.is-disconnected {
  color: var(--red);
  border-color: rgba(255, 93, 104, 0.78);
}

.gamepad-status:hover,
.gamepad-status:focus-visible {
  color: #fff;
  border-color: var(--yellow);
  transform: translateY(-1px);
}

.gamepad-status:focus-visible,
.fullscreen-toggle:focus-visible,
.brand-lockup:focus-visible,
.game-tile:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

.gamepad-status-icon {
  position: relative;
  width: 44px;
  height: 27px;
  display: block;
  color: currentColor;
  border: 4px solid currentColor;
  border-radius: 6px 6px 10px 10px;
  background: #11111d;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.gamepad-status-icon::before {
  position: absolute;
  left: 7px;
  top: 8px;
  width: 4px;
  height: 4px;
  content: "";
  background: currentColor;
  box-shadow:
    0 -5px 0 currentColor,
    0 5px 0 currentColor,
    -5px 0 0 currentColor,
    5px 0 0 currentColor,
    21px -2px 0 currentColor,
    28px 5px 0 currentColor;
}

.gamepad-status-icon::after {
  position: absolute;
  left: 17px;
  top: 6px;
  width: 10px;
  height: 4px;
  content: "";
  background: currentColor;
}

.gamepad-status.is-disconnected .gamepad-status-icon::after {
  left: -8px;
  top: 10px;
  width: 58px;
  height: 4px;
  background: var(--red);
  transform: rotate(-28deg);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}

.gamepad-status-text {
  font-size: 0.66rem;
  line-height: 1.18;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.72);
}

.gamepad-popup {
  position: fixed;
  top: max(96px, calc(env(safe-area-inset-top) + 88px));
  right: max(14px, env(safe-area-inset-right));
  bottom: 16px;
  z-index: 30;
  width: min(380px, calc(100vw - 28px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 14px;
  color: var(--text);
  background: rgba(24, 24, 39, 0.96);
  border: 1px solid rgba(54, 217, 247, 0.78);
  box-shadow:
    0 22px 50px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.045) inset;
  backdrop-filter: blur(12px);
}

.gamepad-popup[hidden] {
  display: none;
}

.gamepad-popup h2 {
  margin: 0;
  color: var(--yellow);
  font-size: 1.1rem;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}

.gamepad-readout {
  min-height: 0;
  margin: 0;
  overflow: auto;
  color: #dcf9ff;
  font: 700 0.78rem/1.38 "Courier New", Courier, monospace;
  white-space: pre-wrap;
}

.gamepad-popup button,
.fullscreen-toggle {
  min-height: 38px;
  padding: 9px 13px;
  color: #141421;
  font-weight: 900;
  text-transform: uppercase;
  background: var(--yellow);
  border: 0;
  box-shadow:
    0 9px 0 rgba(0, 0, 0, 0.36),
    inset 0 -4px 0 rgba(0, 0, 0, 0.14);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fullscreen-toggle {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 19;
  min-width: 166px;
  font-size: 0.76rem;
}

.gamepad-popup button:hover,
.gamepad-popup button:focus-visible,
.fullscreen-toggle:hover,
.fullscreen-toggle:focus-visible {
  color: #fff;
  background: var(--orange);
}

.fullscreen-toggle.is-active {
  background: var(--green);
}

.arcade {
  width: min(1480px, calc(100% - 44px));
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(88px, 9vw, 118px) 0 clamp(28px, 4vw, 54px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(18px, 3vw, 34px);
}

.marquee {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "brand title status"
    "brand subtitle status";
  align-items: center;
  gap: 6px clamp(18px, 3vw, 34px);
  min-height: 112px;
  padding: clamp(14px, 2.2vw, 22px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 214, 90, 0.13), transparent 34%),
    linear-gradient(270deg, rgba(54, 217, 247, 0.1), transparent 38%),
    rgba(32, 32, 51, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 22px 45px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 -5px 0 rgba(0, 0, 0, 0.13);
}

.marquee::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 96px);
}

.brand-lockup {
  position: relative;
  z-index: 1;
  grid-area: brand;
  width: fit-content;
  min-width: 178px;
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  color: #151421;
  background: linear-gradient(180deg, #ffe48a, var(--yellow));
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.34),
    0 0 24px rgba(255, 214, 90, 0.18),
    inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.brand-lockup:hover,
.brand-lockup:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 13px 0 rgba(0, 0, 0, 0.34),
    0 0 30px rgba(255, 214, 90, 0.3),
    inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.pear-logo {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  image-rendering: auto;
}

.brand-name {
  font-size: clamp(1.02rem, 2vw, 1.3rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.48);
}

.kicker {
  position: relative;
  z-index: 1;
  grid-area: subtitle;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.74rem, 1.35vw, 0.92rem);
  font-weight: 700;
  text-transform: uppercase;
  animation: insertCoinBlink 1.15s steps(2, end) infinite;
}

@keyframes insertCoinBlink {
  0%,
  46% {
    color: var(--yellow);
    text-shadow:
      2px 2px 0 rgba(0, 0, 0, 0.72),
      0 0 14px rgba(255, 214, 90, 0.36);
    opacity: 1;
  }

  47%,
  100% {
    color: rgba(184, 183, 202, 0.54);
    text-shadow: none;
    opacity: 0.52;
  }
}

h1 {
  position: relative;
  z-index: 1;
  grid-area: title;
  margin: 0;
  color: #fff;
  font-size: clamp(1.85rem, 5.1vw, 4.35rem);
  line-height: 0.96;
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow:
    3px 0 0 rgba(255, 79, 154, 0.8),
    -3px 0 0 rgba(54, 217, 247, 0.75),
    0 6px 0 rgba(0, 0, 0, 0.54);
}

.score-strip {
  position: relative;
  z-index: 1;
  grid-area: status;
  width: min(360px, 28vw);
  display: grid;
  gap: 8px;
  color: var(--green);
  font-size: clamp(0.66rem, 1.1vw, 0.78rem);
  font-weight: 900;
  text-transform: uppercase;
}

.score-strip span {
  min-width: 0;
  padding: 8px 10px;
  text-align: center;
  border: 1px solid rgba(123, 227, 109, 0.5);
  background: rgba(8, 19, 12, 0.72);
  box-shadow: inset 0 0 18px rgba(123, 227, 109, 0.09);
}

.selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 2.5vw, 30px);
  align-content: start;
}

.game-tile {
  position: relative;
  min-width: 0;
  min-height: clamp(500px, 44vw, 620px);
  padding: clamp(14px, 1.7vw, 20px);
  display: grid;
  grid-template-rows: minmax(250px, 1fr) auto auto;
  gap: clamp(14px, 1.7vw, 18px);
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.072), transparent 30%),
    linear-gradient(160deg, rgba(255, 214, 90, 0.07), transparent 38%),
    rgba(32, 32, 51, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 18px 32px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 -5px 0 rgba(0, 0, 0, 0.13);
  outline: 0;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.game-tile::before {
  position: absolute;
  inset: 9px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 6px;
}

.game-tile::after {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 68px;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--yellow), var(--cyan));
  opacity: 0.64;
}

.game-tile:hover,
.game-tile:focus-visible,
.game-tile.is-selected {
  border-color: rgba(255, 214, 90, 0.74);
  transform: translateY(-5px);
  box-shadow:
    0 24px 38px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 214, 90, 0.22),
    0 0 28px rgba(255, 214, 90, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 -5px 0 rgba(0, 0, 0, 0.14);
}

.cabinet-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #101524;
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.22),
    inset 0 0 0 5px rgba(0, 0, 0, 0.24),
    inset 0 0 44px rgba(0, 0, 0, 0.46);
}

.cabinet-screen::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.075) 0 1px, transparent 1px 7px),
    linear-gradient(120deg, rgba(255, 255, 255, 0.12), transparent 38%);
  opacity: 0.22;
}

.snack-screen {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 100%),
    radial-gradient(circle at 78% 20%, #ffe45c 0 13px, transparent 14px),
    linear-gradient(180deg, #24235f 0%, #315e86 55%, #123b31 56%, #102a1d 100%);
  background-size: 100% 9px, auto, auto;
}

.claw-screen {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, #20183b 0%, #0f1633 54%, #46314a 55%, #211927 100%);
  background-size: 18px 100%, auto;
}

.banana-screen {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, #143150 0%, #1d5078 55%, #263246 56%, #151a25 100%);
  background-size: 20px 100%, auto;
}

.game-preview {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.game-info {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  gap: 9px;
  align-items: start;
}

.game-title {
  min-width: 0;
  color: #fff;
  font-size: clamp(1.15rem, 2.2vw, 1.72rem);
  font-weight: 900;
  line-height: 1.08;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.54);
}

.game-desc {
  min-width: 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 1.15vw, 1rem);
  line-height: 1.42;
}

.game-best {
  width: fit-content;
  grid-column: 1 / -1;
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  color: var(--green);
  font-size: clamp(0.72rem, 1vw, 0.84rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  border: 1px solid rgba(123, 227, 109, 0.5);
  background: rgba(8, 19, 12, 0.72);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 9px 18px rgba(0, 0, 0, 0.18);
}

.game-best strong {
  color: var(--yellow);
  font-size: 1.18em;
}

.start-chip {
  position: relative;
  z-index: 1;
  justify-self: end;
  width: min(210px, 100%);
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 8px 14px;
  color: #151421;
  font-size: clamp(0.86rem, 1.35vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffe48a, var(--yellow));
  box-shadow:
    0 9px 0 rgba(0, 0, 0, 0.34),
    inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.game-tile:hover .start-chip,
.game-tile:focus-visible .start-chip,
.game-tile.is-selected .start-chip {
  background: var(--orange);
  color: #fff;
}

@media (max-width: 1180px) {
  .arcade {
    width: min(960px, calc(100% - 32px));
  }

  .marquee {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "brand title"
      "brand subtitle"
      "status status";
  }

  .score-strip {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 10px;
  }

  .selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-tile {
    min-height: 520px;
  }
}

@media (max-width: 780px) {
  body {
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.032) 0 1px, transparent 1px 14px),
      linear-gradient(180deg, #1b1a2a 0%, #151421 46%, #0f0f1a 100%);
  }

  .gamepad-status {
    width: 96px;
    min-height: 58px;
    padding: 7px 8px;
  }

  .gamepad-status-icon {
    width: 36px;
    height: 23px;
    border-width: 3px;
  }

  .gamepad-status-text {
    font-size: 0.55rem;
  }

  .fullscreen-toggle {
    min-width: 122px;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.62rem;
  }

  .arcade {
    width: min(620px, calc(100% - 24px));
    padding: 84px 0 28px;
    gap: 18px;
  }

  .marquee {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "title"
      "subtitle"
      "status";
    justify-items: stretch;
    min-height: 0;
    padding: 14px;
    text-align: left;
  }

  .brand-lockup {
    min-width: 0;
    justify-self: start;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.6rem);
  }

  .score-strip {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .score-strip span {
    text-align: left;
  }

  .selector {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .game-tile {
    min-height: auto;
    grid-template-rows: auto auto auto;
    padding: 13px;
  }

  .cabinet-screen {
    width: 100%;
    min-height: 0;
  }

  .game-best,
  .start-chip {
    width: 100%;
  }

  .start-chip {
    justify-self: stretch;
  }
}

@media (max-width: 430px) {
  .arcade {
    width: min(100% - 18px, 390px);
    padding-top: 78px;
  }

  .gamepad-status {
    right: 9px;
    width: 82px;
  }

  .fullscreen-toggle {
    left: 9px;
    min-width: 108px;
    font-size: 0.58rem;
  }

  .gamepad-popup {
    top: 86px;
    right: 9px;
    width: calc(100vw - 18px);
  }

  .brand-lockup {
    padding: 7px 10px;
  }

  .pear-logo {
    width: 30px;
    height: 30px;
  }
}

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

  .kicker {
    animation: none;
  }
}
