:root {
  --gold: #ffc400;
  --gold-dark: #a66b00;
  --orange: #f47b20;
  --ink: #08090b;
  --panel: #111318;
  --line: #2b2e34;
  --muted: #a6a8ad;
  --white: #f7f4ec;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  color: var(--white);
  font-family: "Courier New", Courier, monospace;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,196,0,.16), transparent 38%),
    linear-gradient(180deg, #0d0e10 0%, #050607 100%);
  padding: 20px 14px 28px;
  overflow-x: hidden;
}

.page-shell { width: min(520px, 100%); margin: 0 auto; }
.return-button { position: sticky; top: 10px; z-index: 20; display: flex; align-items: center; justify-content: center; min-height: 48px; margin-bottom: 14px; padding: 12px 18px; border: 1px solid #ffe16e; border-radius: 999px; color: var(--ink); background: var(--gold); box-shadow: 0 4px 18px #0008; text-decoration: none; font: 800 15px/1.3 system-ui, sans-serif; }
.return-button:hover { background: #ffe16e; }
.return-button:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }
.back-link {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px 2px;
  color: var(--white);
  text-decoration: none;
}
.back-link img { border-radius: 10px; }
.back-link span { display: grid; gap: 1px; }
.back-link b { font-size: 13px; letter-spacing: .05em; }
.back-link small { color: var(--gold); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }

.game-frame {
  padding: 15px;
  border: 1px solid #34363b;
  border-radius: 20px;
  background: linear-gradient(145deg, #181a1e, #0c0d10);
  box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 55px rgba(255,196,0,.09);
}

.hud { display: flex; gap: 7px; margin-bottom: 11px; }
.hud-block {
  min-width: 0;
  flex: 1;
  padding: 7px 3px 6px;
  text-align: center;
  background: #0b0c0e;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.hud-label {
  display: block;
  color: var(--gold);
  font-size: 9px;
  line-height: 1.1;
  letter-spacing: .13em;
}
.hud-value {
  display: block;
  margin-top: 3px;
  color: var(--white);
  font-size: 21px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .04em;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 480 / 640;
  overflow: hidden;
  border: 2px solid #3a3c40;
  border-radius: 12px;
  background: #08090b;
  box-shadow: inset 0 0 50px rgba(0,0,0,.75);
}
#game { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(8,9,11,.78), rgba(8,9,11,.94)),
    radial-gradient(circle at 50% 28%, rgba(255,196,0,.18), transparent 45%);
  backdrop-filter: blur(2px);
  animation: fade-in .28s ease;
}
.hidden { display: none !important; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.eyebrow {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
}
.title {
  color: var(--white);
  font-size: clamp(48px, 13vw, 68px);
  line-height: .78;
  font-weight: 1000;
  letter-spacing: -.07em;
  text-shadow: 5px 6px 0 rgba(0,0,0,.6);
}
.title span { color: var(--gold); }
.title.small { font-size: clamp(42px, 12vw, 58px); }
.subtitle {
  margin: 18px 0 19px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}
.instructions {
  display: grid;
  gap: 8px;
  max-width: 410px;
  margin-bottom: 20px;
  color: #d5d5d2;
  font-size: 11px;
  line-height: 1.45;
}
.ctrl-p1 b { color: var(--gold); }
.ctrl-p2 b { color: var(--orange); }
.gamepad-hint { color: var(--muted); }
.ctrl-touch { display: none; color: var(--gold); }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.arcade-btn {
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid #ffe16e;
  border-radius: 999px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffd42d, var(--gold));
  box-shadow: 0 7px 0 var(--gold-dark), 0 12px 30px rgba(255,196,0,.22);
  font: 900 14px/1 "Courier New", monospace;
  letter-spacing: .04em;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.arcade-btn:hover { transform: translateY(-2px); }
.arcade-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--gold-dark); }
.arcade-btn.alt {
  color: var(--white);
  border-color: #55585f;
  background: #1d1f23;
  box-shadow: 0 7px 0 #070809;
}
.hint { max-width: 380px; margin-top: 16px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.final-line { margin-top: 22px; color: var(--gold); font-size: 10px; letter-spacing: .2em; }
.final-score { margin: 2px 0 16px; color: var(--white); font-size: 62px; line-height: 1; font-weight: 1000; }
.final-score.duel { font-size: 44px; }
.new-best { margin-bottom: 17px; color: var(--gold); font-size: 14px; font-weight: 900; letter-spacing: .08em; }
.winner-line { margin-top: 17px; font-size: 21px; font-weight: 1000; }

.foot { min-height: 27px; padding-top: 11px; text-align: center; }
.message { color: var(--gold); font-size: 13px; font-weight: 900; letter-spacing: .13em; }
.message.flash { color: var(--orange); }
.credit { margin: 13px 8px 0; color: #777a80; font-size: 9px; line-height: 1.5; text-align: center; }
.credit a { color: #a5a7aa; }

.play-guide { margin-top: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); font: 14px/1.6 system-ui, sans-serif; color: #d5d5d2; }
.play-guide h2 { color: var(--white); font-size: 22px; line-height: 1.2; }
.play-guide p { margin-top: 14px; }
.play-guide strong { color: var(--white); }
.guide-lead { color: var(--gold); }
.guide-players { display: grid; gap: 12px; margin-top: 18px; }
.guide-player { padding: 14px; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; background: #0b0c0e; }
.guide-player h3 { margin-bottom: 8px; font-size: 15px; color: var(--gold); }
.guide-p2 { border-left-color: var(--orange); }
.guide-p2 h3 { color: var(--orange); }
.guide-player dl > div { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; margin-top: 6px; }
.guide-player dt { color: var(--muted); }
.guide-player dd { margin: 0; }
.play-guide kbd { display: inline-block; padding: 0 5px; border: 1px solid #55585f; border-bottom-width: 2px; border-radius: 4px; color: var(--white); font: 12px/1.6 monospace; }
body.is-touch .guide-keyboard { display: none; }

.hud-p1 { border-color: var(--gold); }
.hud-p1 .hud-label, .hud-p1 .hud-value { color: var(--gold); }
.hud-p2 { border-color: var(--orange); }
.hud-p2 .hud-label, .hud-p2 .hud-value { color: var(--orange); }

body.is-touch .ctrl-touch { display: block; }
body.is-touch .ctrl-p1,
body.is-touch .ctrl-p2,
body.is-touch .gamepad-hint,
body.is-touch #startBtn2,
body.is-touch .hint { display: none; }

.touch-controls {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 7px;
  padding: 10px 11px 14px;
  pointer-events: none;
}
.touch-cluster { display: flex; gap: 8px; pointer-events: none; }
.touch-cluster.touch-arc { flex-direction: column-reverse; }
.touch-btn {
  width: 55px;
  height: 55px;
  pointer-events: auto;
  border: 1px solid rgba(255,196,0,.78);
  border-radius: 13px;
  color: var(--gold);
  background: rgba(8,9,11,.72);
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
  font: 900 20px/1 "Courier New", monospace;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-btn.pressed { transform: scale(.92); background: rgba(255,196,0,.2); }
.touch-shoot {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  color: var(--ink);
  background: radial-gradient(circle at 40% 30%, #ffae57, var(--orange) 58%, #a6420d);
  border-color: #ffbd77;
  font-size: 14px;
}

@media (max-width: 430px) {
  body { padding: 10px 8px 20px; }
  .back-link { margin-bottom: 8px; }
  .back-link img { width: 38px; height: 38px; }
  .game-frame { padding: 9px; border-radius: 14px; }
  .hud { gap: 4px; margin-bottom: 7px; }
  .hud-block { padding-inline: 1px; }
  .hud-label { font-size: 8px; letter-spacing: .07em; }
  .hud-value { font-size: 18px; }
  .overlay { padding: 18px 15px; }
  .instructions { font-size: 10px; margin-bottom: 15px; }
  .arcade-btn { min-height: 44px; font-size: 12px; }
}

@media (max-height: 780px) and (min-width: 431px) {
  body { padding-block: 10px; }
  .page-shell { width: 440px; }
  .back-link img { width: 36px; height: 36px; }
  .game-frame { padding: 10px; }
}

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