:root {
  color-scheme: dark;
  --ink: #fff8e7;
  --muted: #bdb8aa;
  --green: #99ed68;
  --green-dark: #345c2f;
  --amber: #ffc567;
  --orange: #e97842;
  --panel: #171b14;
  --line: rgba(255, 255, 255, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 14%, rgba(153, 237, 104, 0.12), transparent 25rem),
    radial-gradient(circle at 86% 8%, rgba(255, 197, 103, 0.1), transparent 28rem),
    linear-gradient(150deg, #11170f, #090c09 52%, #1a120d);
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.game-shell {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding-bottom: max(26px, env(safe-area-inset-bottom));
}

.topbar,
.brand,
.topbar-actions,
.scorebar,
.drop-button {
  display: flex;
  align-items: center;
}

.topbar {
  min-height: 72px;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  gap: 10px;
  text-decoration: none;
}

.brand span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(153, 237, 104, 0.55);
  background: rgba(153, 237, 104, 0.12);
  color: var(--green);
  font-weight: 1000;
}

.brand strong {
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.topbar-actions {
  gap: 12px;
}

.topbar-actions a,
.topbar-actions button {
  border: 0;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.topbar-actions button {
  border: 1px solid var(--line);
}

.topbar-actions a:hover,
.topbar-actions button:hover {
  color: var(--ink);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.7fr) minmax(440px, 1fr);
  gap: clamp(28px, 6vw, 86px);
  align-items: center;
  min-height: calc(100vh - 72px);
  padding: 34px 0;
}

.intro-panel {
  max-width: 470px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--green);
  font-size: clamp(4.6rem, 10vw, 8.8rem);
  font-weight: 1000;
  letter-spacing: -0.085em;
  line-height: 0.72;
  text-transform: uppercase;
  text-shadow: 0 9px 0 rgba(52, 92, 47, 0.68);
}

.lede {
  max-width: 440px;
  margin: 34px 0 30px;
  color: #ded8c7;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  font-weight: 750;
  line-height: 1.45;
}

.how-to {
  border-top: 1px solid var(--line);
}

.how-to div {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.how-to span {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 900;
}

.how-to p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 22px;
  color: #8f8b81;
  font-size: 0.72rem;
  font-weight: 850;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 8px;
  height: 8px;
  display: block;
  border-radius: 50%;
}

.perfect-dot {
  background: var(--green);
  box-shadow: 0 0 12px rgba(153, 237, 104, 0.7);
}

.trim-dot {
  background: var(--orange);
}

.cabinet {
  width: min(100%, 570px);
  justify-self: end;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 18%),
    #20261c;
  box-shadow:
    0 38px 90px rgba(0, 0, 0, 0.5),
    inset 0 0 0 5px rgba(0, 0, 0, 0.15);
}

.scorebar {
  justify-content: space-between;
  min-height: 68px;
  padding: 0 14px 10px;
}

.scorebar div {
  min-width: 74px;
  display: grid;
  gap: 2px;
}

.scorebar div:nth-child(2) {
  text-align: center;
}

.scorebar div:nth-child(3) {
  text-align: right;
}

.scorebar span {
  color: #90978a;
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.scorebar strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.4rem;
}

.screen {
  position: relative;
  overflow: hidden;
  border: 4px solid #090b08;
  border-radius: 12px;
  background: #142017;
  box-shadow:
    inset 0 0 45px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

canvas {
  width: 100%;
  height: auto;
  max-height: min(68vh, 690px);
  display: block;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #142017;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(0, 0, 0, 0.18) 4px 5px);
  mix-blend-mode: multiply;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 28px;
  opacity: 0;
  visibility: hidden;
  background: rgba(10, 15, 10, 0.66);
  backdrop-filter: blur(5px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.overlay-card {
  width: min(100%, 360px);
  border: 1px solid rgba(153, 237, 104, 0.38);
  padding: clamp(22px, 5vw, 38px);
  text-align: center;
  background:
    linear-gradient(145deg, rgba(153, 237, 104, 0.1), transparent 52%),
    rgba(14, 18, 13, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.46);
}

.overlay-card > p:first-child {
  margin: 0 0 10px;
  color: var(--amber);
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.6rem);
  letter-spacing: -0.055em;
  line-height: 0.93;
}

.overlay #overlayCopy {
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.overlay button,
.drop-button {
  border: 0;
  color: #10200e;
  background: var(--green);
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.overlay button {
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  box-shadow: 0 7px 0 #416d35;
}

.overlay button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #416d35;
}

.overlay small {
  display: block;
  margin-top: 17px;
  color: #777d72;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.toast {
  position: absolute;
  top: 15%;
  left: 50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  color: var(--green);
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  font-weight: 1000;
  letter-spacing: -0.04em;
  text-shadow: 0 3px 0 #1d3519, 0 8px 20px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, 12px) scale(0.86);
  transition: none;
}

.toast.show {
  animation: toast-pop 850ms ease-out both;
}

.drop-button {
  width: 100%;
  min-height: 68px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 22px;
  border-radius: 9px 9px 14px 14px;
  box-shadow: inset 0 -7px 0 rgba(41, 82, 34, 0.46);
}

.drop-button small {
  color: rgba(16, 32, 14, 0.65);
  font-size: 0.63rem;
  letter-spacing: 0.03em;
}

.drop-button:active {
  transform: translateY(2px);
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(0.82); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  72% { opacity: 1; transform: translate(-50%, -8px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(0.96); }
}

@media (max-width: 880px) {
  .game-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 28px;
    padding-top: 30px;
  }

  .intro-panel {
    max-width: none;
  }

  h1 {
    font-size: clamp(4.4rem, 21vw, 7rem);
  }

  .lede {
    max-width: 620px;
    margin: 26px 0 22px;
  }

  .how-to,
  .legend {
    display: none;
  }

  .cabinet {
    width: min(100%, 570px);
    justify-self: center;
  }

  canvas {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .game-shell {
    width: min(100% - 16px, 1280px);
  }

  .topbar {
    min-height: 62px;
  }

  .topbar-actions a {
    display: none;
  }

  .game-layout {
    padding-top: 22px;
  }

  .intro-panel {
    padding: 0 4px;
  }

  h1 {
    font-size: clamp(4.2rem, 24vw, 6rem);
  }

  .lede {
    margin-bottom: 8px;
    font-size: 0.98rem;
  }

  .cabinet {
    padding: 9px;
    border-radius: 16px;
  }

  .scorebar {
    min-height: 58px;
    padding-inline: 8px;
  }

  .scorebar strong {
    font-size: 1.15rem;
  }

  .overlay {
    padding: 18px;
  }

  .overlay-card {
    padding: 22px;
  }

  .drop-button {
    min-height: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .toast {
    transition: none;
  }
}
