:root {
  --ink: #101923;
  --paper: #f5efde;
  --acid: #c8f04b;
  --coral: #ff6d52;
  --cyan: #53dfd2;
  --panel: rgba(15, 26, 37, 0.86);
  --line: rgba(245, 239, 222, 0.2);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "DM Mono", monospace;
  touch-action: none;
  user-select: none;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1b2a36;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud {
  position: absolute;
  inset: max(18px, env(safe-area-inset-top)) 20px auto;
  display: grid;
  grid-template-columns: auto 140px 112px 104px 44px;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  pointer-events: none;
}

.brand-mark {
  width: 80px;
  transform: rotate(-2deg);
  font-family: "Archivo Black", sans-serif;
  font-size: 27px;
  line-height: .78;
  letter-spacing: -2px;
  color: var(--ink);
  filter: drop-shadow(3px 4px 0 rgba(0,0,0,.18));
}

.brand-mark span {
  display: block;
  width: max-content;
  padding: 4px 7px 5px;
  background: var(--acid);
}

.brand-mark span:last-child {
  margin: 2px 0 0 13px;
  background: var(--paper);
}

.timer-card, .score-card, .rank-card, .leaderboard {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .14);
  backdrop-filter: blur(8px);
}

.eyebrow {
  display: block;
  color: rgba(245, 239, 222, .55);
  font-size: 9px;
  line-height: 1;
  letter-spacing: .14em;
}

.timer-card strong, .score-card strong, .rank-card strong {
  display: block;
  margin-top: 3px;
  font-family: "Archivo Black", sans-serif;
  font-size: 23px;
  line-height: 1;
}

.timer-track {
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  background: rgba(255,255,255,.12);
}

.timer-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--acid);
  transform-origin: left;
}

#size-label {
  display: block;
  margin-top: 4px;
  color: var(--cyan);
  font-size: 7px;
  letter-spacing: .08em;
}

.rank-card strong { color: var(--acid); }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--paper);
  cursor: pointer;
  pointer-events: auto;
  transition: transform .18s ease, background .18s ease;
}

.icon-button:hover { transform: rotate(5deg) scale(1.05); background: #263a49; }
.icon-button[aria-pressed="false"] { color: #73808a; }

.leaderboard {
  position: absolute;
  top: 108px;
  right: 20px;
  width: 168px;
}

.leaderboard ol { margin: 10px 0 0; padding: 0; list-style: none; }
.leaderboard li {
  display: grid;
  grid-template-columns: 17px 11px 1fr auto;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  color: rgba(245, 239, 222, .68);
  font-size: 10px;
}
.leaderboard li.is-player { color: var(--acid); }
.leaderboard .dot { width: 7px; height: 7px; border-radius: 50%; }
.leaderboard b { font-weight: 500; color: inherit; }

.modal-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(28,44,55,.36), rgba(8,15,21,.76));
  transition: opacity .35s ease, visibility .35s;
}

.modal-layer.is-visible { visibility: visible; opacity: 1; }

.modal-card {
  position: relative;
  width: min(510px, 100%);
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid rgba(245,239,222,.28);
  background: rgba(14, 25, 35, .94);
  box-shadow: 14px 14px 0 rgba(4,9,13,.38);
  transform: translateY(14px) rotate(-.35deg);
  transition: transform .5s cubic-bezier(.2,.9,.2,1);
}

.is-visible .modal-card { transform: translateY(0) rotate(-.35deg); }
.modal-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(245,239,222,.12);
  pointer-events: none;
}

.kicker { margin: 0 0 16px; color: var(--acid); font-size: 10px; letter-spacing: .18em; }
h1, h2 { margin: 0; font-family: "Archivo Black", sans-serif; font-weight: 400; }
h1 { font-size: clamp(43px, 8vw, 74px); line-height: .87; letter-spacing: -.065em; }
h1 em { color: var(--coral); font-style: normal; }
.intro-copy { max-width: 390px; margin: 23px 0; color: rgba(245,239,222,.68); font-size: 12px; line-height: 1.65; }

.control-guide { display: flex; gap: 25px; margin: 0 0 27px; }
.control-guide div { display: flex; align-items: center; gap: 9px; color: rgba(245,239,222,.55); font-size: 9px; }
kbd, .drag-icon {
  padding: 7px 8px;
  border: 1px solid rgba(245,239,222,.38);
  background: #203441;
  color: var(--paper);
  box-shadow: 2px 2px 0 #071016;
  font: 500 9px "DM Mono", monospace;
}
.drag-icon { font-size: 14px; padding: 3px 8px 5px; }

.primary-button {
  position: relative;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  background: var(--acid);
  color: #142017;
  font-family: "Archivo Black", sans-serif;
  font-size: 14px;
  letter-spacing: .05em;
  cursor: pointer;
  box-shadow: 6px 6px 0 #567214;
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-button span { float: right; font-size: 18px; line-height: .8; }
.primary-button:hover { transform: translate(-2px,-2px); box-shadow: 8px 8px 0 #567214; }
.primary-button:active { transform: translate(4px,4px); box-shadow: 2px 2px 0 #567214; }
.microcopy { margin: 15px 0 0; text-align: center; color: rgba(245,239,222,.32); font-size: 8px; }

.city-stamp {
  position: absolute;
  right: 7vw;
  bottom: 7vh;
  padding: 9px 12px;
  border: 2px solid rgba(200,240,75,.38);
  color: rgba(200,240,75,.5);
  font-size: 11px;
  letter-spacing: .2em;
  transform: rotate(-8deg);
}

.result-card { text-align: center; }
.result-rank { margin: 0; color: var(--acid); font-family: "Archivo Black", sans-serif; font-size: 86px; line-height: .9; }
.result-card h2 { margin-bottom: 25px; font-size: clamp(28px, 7vw, 46px); }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 0 26px; background: rgba(245,239,222,.13); }
.result-stats div { padding: 15px; background: #172936; }
.result-stats span { display: block; margin-bottom: 6px; color: rgba(245,239,222,.45); font-size: 8px; letter-spacing: .12em; }
.result-stats strong { font-family: "Archivo Black", sans-serif; font-size: 18px; }

.toast {
  position: absolute;
  top: 46%;
  left: 50%;
  padding: 8px 13px;
  opacity: 0;
  background: var(--coral);
  color: white;
  font-family: "Archivo Black", sans-serif;
  font-size: 11px;
  letter-spacing: .06em;
  pointer-events: none;
  transform: translate(-50%, 8px) rotate(-2deg);
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-2deg); }

.joystick {
  position: absolute;
  width: 86px;
  height: 86px;
  display: none;
  border: 1px solid rgba(245,239,222,.28);
  border-radius: 50%;
  background: rgba(11,22,30,.26);
  pointer-events: none;
}
.joystick i {
  position: absolute;
  left: 27px;
  top: 27px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(200,240,75,.75);
}

.scanlines {
  position: absolute;
  inset: 0;
  opacity: .035;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #fff 4px);
  mix-blend-mode: overlay;
}

@media (max-width: 700px) {
  .hud { inset: max(12px, env(safe-area-inset-top)) 12px auto; grid-template-columns: 66px 104px 86px 38px; gap: 7px; }
  .brand-mark { font-size: 21px; }
  .timer-card, .score-card, .rank-card { padding: 8px; }
  .timer-card strong, .score-card strong, .rank-card strong { font-size: 18px; }
  .rank-card { display: none; }
  .icon-button { width: 38px; height: 38px; }
  .leaderboard { top: 86px; right: 12px; width: 138px; padding: 8px; }
  .leaderboard li { font-size: 8px; padding: 3px 0; }
  .modal-card { padding: 31px 25px; }
  .control-guide { gap: 14px; }
  .city-stamp { display: none; }
}

@media (max-height: 590px) {
  .leaderboard { display: none; }
  .modal-card { padding-block: 24px; }
  .intro-copy { margin: 14px 0; }
  .control-guide { margin-bottom: 17px; }
  h1 { font-size: 40px; }
}

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