:root {
  --bg: #080d16;
  --panel: rgba(13, 23, 39, 0.72);
  --panel-strong: rgba(12, 20, 34, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f7fbff;
  --muted: #9aa8bb;
  --green: #83e3a3;
  --green-strong: #48c77c;
  --gold: #d6ad4c;
  --navy: #092241;
  --red: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(72, 199, 124, 0.12), transparent 32rem),
    linear-gradient(135deg, #070b12 0%, #0b1524 48%, #10151e 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 24px) 18px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.brand-block {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-block > div {
  min-width: 0;
}

.agency-mark {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid rgba(214, 173, 76, 0.72);
  border-radius: 50%;
  color: var(--gold);
  background:
    radial-gradient(circle, rgba(214, 173, 76, 0.18) 0 38%, transparent 39%),
    #071b33;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.04);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(24px, 3.1vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.status-panel {
  width: min(430px, 100%);
  min-width: 0;
  display: grid;
  gap: 10px;
  justify-items: end;
  justify-self: end;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.stat-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: clamp(17px, 2.2vw, 24px);
  line-height: 1;
  white-space: nowrap;
}

#rateValue {
  font-size: clamp(17px, 2.1vw, 25px);
}

.stage-wrap {
  position: relative;
  height: clamp(420px, 58vh, 540px);
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    #171d27;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud-note {
  position: absolute;
  right: 18px;
  top: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  pointer-events: none;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(131, 227, 163, 0.12);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(180deg, rgba(8, 13, 22, 0.56), rgba(8, 13, 22, 0.78));
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal {
  width: min(520px, 100%);
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  text-align: center;
}

.loader {
  width: 58px;
  height: 26px;
  margin: 0 auto 14px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
}

.loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: bounce 850ms ease-in-out infinite;
}

.loader span:nth-child(2) {
  animation-delay: 120ms;
  background: var(--gold);
}

.loader span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.62;
  }
  45% {
    transform: translateY(-12px);
    opacity: 1;
  }
}

.kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.modal h2 {
  margin: 0;
  font-size: clamp(27px, 5vw, 42px);
  line-height: 1;
}

.modal p:not(.kicker) {
  margin: 14px auto 0;
  max-width: 44rem;
  color: #c9d5e4;
  line-height: 1.55;
}

.key-guide {
  margin: 18px auto 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.key-guide span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #eaf3ff;
  background: rgba(255, 255, 255, 0.07);
  font-size: 13px;
  font-weight: 700;
}

.primary-button,
.control-button,
.music-toggle {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #071421;
  background: linear-gradient(180deg, #f4d675, #d5ad43);
  box-shadow: 0 12px 26px rgba(214, 173, 76, 0.23);
  font-weight: 900;
}

.primary-button {
  min-width: 168px;
  padding: 12px 20px;
}

.music-toggle {
  min-height: 32px;
  padding: 0 12px;
  color: #eaf3ff;
  background: rgba(12, 25, 43, 0.78);
  border: 1px solid rgba(131, 227, 163, 0.28);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
  font-size: 12px;
  letter-spacing: 0;
}

.music-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.music-toggle.is-on {
  color: #071421;
  background: linear-gradient(180deg, #8ff2ad, #46c67d);
}

.primary-button:active,
.control-button:active,
.music-toggle:active {
  transform: translateY(1px);
}

.mobile-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-button {
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  color: #eef7ff;
  background: rgba(16, 31, 52, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

@media (hover: hover) {
  .primary-button:hover,
  .music-toggle:hover,
  .control-button:hover {
    filter: brightness(1.08);
  }
}

@media (max-width: 780px) {
  .game-shell {
    min-height: 100dvh;
    padding: 10px 12px 10px;
    grid-template-rows: auto auto auto;
    gap: 10px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .brand-block {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  h1 {
    max-width: 280px;
    font-size: 24px;
  }

  .status-panel {
    width: 100%;
    max-width: none;
    justify-items: stretch;
  }

  .agency-mark {
    width: 42px;
    height: 42px;
    font-size: 12px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .stat-card:nth-child(3) {
    grid-column: 1 / -1;
  }

  .music-toggle {
    min-height: 34px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    justify-content: stretch;
    width: 100%;
  }

  .quick-actions .music-toggle {
    min-width: 0;
  }

  .stat-card {
    padding: 8px 9px;
  }

  .stat-card span {
    font-size: 11px;
  }

  .stat-card strong {
    font-size: 16px;
  }

  #rateValue {
    font-size: 15px;
  }

  .stage-wrap {
    height: clamp(318px, 46dvh, 380px);
    min-height: 0;
  }

  .hud-note {
    right: 12px;
    top: 10px;
    font-size: 11px;
  }

  .modal {
    padding: 17px 14px;
  }

  .modal p:not(.kicker) {
    font-size: 14px;
  }

  .key-guide span {
    padding: 7px 9px;
    font-size: 12px;
  }

  .mobile-controls {
    display: grid;
    align-items: start;
  }

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

@media (max-width: 420px) {
  h1 {
    font-size: 21px;
  }

  .stats {
    gap: 6px;
  }

  .stat-card {
    padding: 8px 7px;
  }

  .stat-card strong {
    font-size: 14px;
  }

  #rateValue {
    font-size: 13px;
  }

  .game-shell {
    gap: 8px;
  }

  .stage-wrap {
    height: clamp(300px, 45dvh, 350px);
  }

}
