:root {
  color-scheme: dark;
  --ink: #f2efe9;
  --muted: #b3aca1;
  --panel: #201c18;
  --panel-deep: #100e0b;
  --orange: #f5872b;
  --orange-hot: #f5a623;
  --green: #6aa882;
  --line: #554d44;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #16130f;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 15% 15%, rgba(106, 168, 130, 0.1), transparent 28rem),
    radial-gradient(circle at 85% 85%, rgba(245, 135, 43, 0.09), transparent 30rem),
    #16130f;
  background-size: 100% 5px, auto, auto, auto;
}

button {
  color: inherit;
  font: inherit;
}

.prototype-shell {
  width: min(100%, 1440px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 24px 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.prototype-header,
.prototype-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup > span:last-child {
  display: grid;
  gap: 1px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid #161b17;
  border-radius: 50%;
  color: #151711;
  font: 900 17px/1 var(--display);
  letter-spacing: -0.03em;
  background: linear-gradient(145deg, #ffe061 0%, var(--orange) 58%, #d74609 100%);
  box-shadow: 0 0 0 3px #f4f0df, 0 0 0 5px #171a17;
}

.brand-lockup strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.brand-lockup small,
.prototype-footer {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.utility-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  min-height: 38px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 3px;
  color: #d4cec5;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  border-color: rgba(255, 157, 24, 0.65);
  color: #fff;
  transform: translateY(-1px);
}

.game-frame {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 134px);
  aspect-ratio: 16 / 9;
  align-self: center;
  overflow: hidden;
  isolation: isolate;
  border: 2px solid var(--line);
  border-radius: 3px;
  background: #122c22;
  box-shadow:
    5px 5px 0 #100e0b,
    8px 8px 0 #554d44,
    0 34px 90px rgba(0, 0, 0, 0.38);
}

.game-frame,
.game-frame * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px rgba(16, 14, 11, 0.34);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  background: #8dd9ed;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 34px;
  opacity: 0;
  visibility: hidden;
  background:
    linear-gradient(90deg, rgba(16, 14, 11, 0.96) 0%, rgba(22, 19, 15, 0.8) 52%, rgba(16, 14, 11, 0.22) 100%);
  transition: opacity 220ms ease, visibility 220ms ease;
}

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

.overlay-card {
  position: relative;
  z-index: 2;
  width: min(560px, 88%);
  margin-right: auto;
  padding-left: clamp(8px, 3vw, 44px);
}

.loss-guy {
  position: absolute;
  right: clamp(8px, 3vw, 48px);
  bottom: -4%;
  z-index: 1;
  width: min(37vw, 475px);
  max-height: 96%;
  object-fit: contain;
  object-position: right bottom;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  filter: drop-shadow(-14px 10px 0 rgba(10, 8, 6, 0.34)) drop-shadow(0 20px 30px rgba(0, 0, 0, 0.38));
  transform: translateX(34px) scale(0.97);
  transform-origin: right bottom;
  transition: opacity 240ms ease, transform 320ms cubic-bezier(.2,.75,.2,1), visibility 240ms ease;
}

.game-overlay.is-visible.is-loss .loss-guy {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
}

.overlay-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--green);
  font-size: clamp(9px, 1.05vw, 13px);
  font-weight: 950;
  letter-spacing: 0.2em;
}

.overlay-eyebrow::before {
  content: "";
  width: 28px;
  height: 3px;
  background: var(--orange);
}

.overlay-card h1 {
  margin: 0;
  color: #fbf7e9;
  font: 900 clamp(54px, 8.6vw, 124px)/0.75 var(--display);
  letter-spacing: -0.045em;
  text-transform: uppercase;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.16);
}

.overlay-card h1 em {
  color: var(--orange-hot);
  font-style: normal;
  -webkit-text-stroke: 1px rgba(80, 32, 0, 0.3);
}

.overlay-copy {
  max-width: 510px;
  margin: 24px 0 20px;
  color: #d2ddd5;
  font-size: clamp(12px, 1.25vw, 16px);
  line-height: 1.55;
}

.overlay-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.overlay-stats span {
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 3px;
  color: #b3aca1;
  font-size: clamp(8px, 0.78vw, 10px);
  font-weight: 850;
  letter-spacing: 0.08em;
  background: #201c18;
}

.overlay-stats strong {
  color: var(--orange-hot);
  font-size: 1.15em;
}

.primary-button {
  width: min(330px, 100%);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 22px;
  border: 2px solid #17140f;
  border-radius: 3px;
  color: #18150c;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.13em;
  background: linear-gradient(135deg, #ffc638 0%, var(--orange) 72%);
  box-shadow: 4px 4px 0 #17140f;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button b {
  font-size: 24px;
}

.primary-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #17140f;
}

.primary-button:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.key-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 23px;
  color: #819589;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.key-guide span {
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  min-width: 22px;
  padding: 4px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 3px;
  border-radius: 4px;
  color: #dfe8e1;
  font: 800 8px/1 var(--sans);
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
}

.touch-controls {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  z-index: 6;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.touch-controls button {
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  border: 2px solid var(--line);
  border-radius: 3px;
  color: white;
  background: rgba(32, 28, 24, 0.88);
  box-shadow: 2px 2px 0 rgba(16, 14, 11, 0.7);
  backdrop-filter: blur(7px);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button:active,
.touch-controls button.is-pressed {
  border-color: var(--orange-hot);
  background: rgba(205, 73, 8, 0.84);
  transform: translateY(2px);
}

.touch-controls span {
  font-size: 20px;
  line-height: 1;
}

.touch-controls small {
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.touch-controls .boost-control {
  color: #171408;
  background: rgba(255, 166, 24, 0.88);
}

.orientation-gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  place-content: center;
  gap: 9px;
  padding: 28px;
  color: #fbf7e9;
  text-align: center;
  background: rgba(9, 24, 18, 0.96);
}

.orientation-gate span {
  color: var(--orange-hot);
  font-size: 44px;
  line-height: 1;
}

.orientation-gate strong {
  font: 900 clamp(22px, 8vw, 34px)/1 var(--display);
  letter-spacing: 0.025em;
}

.orientation-gate small {
  color: #c5d1c9;
  font-size: 11px;
  font-weight: 750;
}

.prototype-footer p {
  margin: 0;
}

.live-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(182, 227, 52, 0.68);
}

@media (pointer: coarse), (max-width: 820px) {
  body {
    min-height: 100svh;
  }

  .prototype-shell {
    min-height: 100svh;
    padding: 10px;
    gap: 9px;
  }

  .game-frame {
    max-height: none;
    border-radius: 3px;
  }

  .touch-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 64px));
    justify-content: space-between;
    gap: 6px;
  }

  .touch-controls button {
    min-height: 50px;
    border: 1px solid rgba(255, 255, 255, 0.48);
    color: rgba(255, 255, 255, 0.94);
    background: rgba(16, 14, 11, 0.34);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(3px);
  }

  .touch-controls button:active,
  .touch-controls button.is-pressed {
    border-color: var(--orange-hot);
    background: rgba(205, 73, 8, 0.62);
  }

  .touch-controls .boost-control {
    border-color: rgba(255, 198, 56, 0.68);
    color: rgba(255, 255, 255, 0.96);
    background: rgba(245, 135, 43, 0.34);
  }

  .touch-controls span {
    font-size: 18px;
  }

  .touch-controls small {
    font-size: 7px;
  }

  .game-frame:has(.game-overlay.is-visible) .touch-controls {
    opacity: 0;
    pointer-events: none;
  }

  .prototype-footer p:last-child,
  .key-guide {
    display: none;
  }

  .overlay-card {
    width: min(510px, 94%);
  }

  .loss-guy {
    right: -3%;
    width: min(43vw, 400px);
  }

  .overlay-copy {
    margin: 14px 0;
  }

  .overlay-stats {
    margin-bottom: 14px;
  }

  .primary-button {
    min-height: 48px;
  }
}

@media (max-width: 600px) {
  .prototype-shell {
    grid-template-rows: auto auto auto;
    align-content: center;
  }

  .brand-lockup small {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .brand-lockup strong {
    font-size: 12px;
  }

  .icon-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 8px;
  }

  .game-frame {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .touch-controls {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    grid-template-columns: repeat(4, minmax(0, 56px));
    justify-content: space-between;
    gap: 4px;
  }

  .touch-controls button {
    min-height: 50px;
  }

  canvas {
    object-fit: cover;
    object-position: 35% center;
  }

  .game-overlay {
    padding: 14px 12px;
    background: rgba(5, 18, 13, 0.82);
  }

  .overlay-card {
    margin: auto;
    padding: 0;
  }

  .loss-guy {
    right: -9%;
    bottom: -5%;
    width: 56%;
    max-height: 88%;
  }

  .game-overlay.is-visible.is-loss .loss-guy {
    opacity: 0.46;
  }

  .overlay-card h1 {
    font-size: clamp(48px, 18vw, 78px);
  }

  .overlay-copy {
    max-width: 430px;
    font-size: 11px;
  }

  .overlay-stats span {
    padding: 5px 7px;
  }

  .prototype-footer {
    justify-content: center;
    text-align: center;
  }
}

@media (pointer: coarse) and (orientation: portrait),
  (max-width: 600px) and (orientation: portrait) {
  .orientation-gate {
    display: grid;
  }

  .touch-controls {
    display: none;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .prototype-shell {
    padding: 7px 12px;
    gap: 6px;
  }

  .prototype-header,
  .prototype-footer {
    min-height: 27px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .brand-lockup small,
  .prototype-footer {
    display: none;
  }

  .game-frame {
    max-height: calc(100svh - 56px);
  }

  .overlay-card h1 {
    font-size: clamp(48px, 13vh, 82px);
  }

  .overlay-copy {
    margin: 10px 0;
  }

  .overlay-stats,
  .key-guide {
    display: none;
  }

  .primary-button {
    min-height: 42px;
  }
}

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