:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(180deg, #67c8f4 0 22%, #173d5b 22% 31%, #2f7da0 31% 42%, #52d64b 42% 100%);
  color: #f7f4e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
}

body {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #3f7b24;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.75) 0 5%, transparent 6%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.62) 0 4%, transparent 5%),
    linear-gradient(180deg, #67c8f4 0 22%, #173d5b 22% 31%, #2f7da0 31% 42%, #52d64b 42% 100%);
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100vw, 390px, calc(100dvh * 390 / 844));
  height: min(100dvh, 844px, calc(100vw * 844 / 390));
  aspect-ratio: 390 / 844;
  overflow: hidden;
  background: #1b3c25;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  touch-action: none;
  user-select: none;
}

@media (min-aspect-ratio: 390 / 844) {
  .game-shell {
    width: min(100vw, 390px, calc(100dvh * 390 / 844));
    height: min(100dvh, 844px, calc(100vw * 844 / 390));
  }
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: none;
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.game-shell.is-playing .hud {
  display: grid;
}

.hud-card {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(20, 26, 18, 0.58);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 5px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.hud-label {
  font-size: 10px;
  line-height: 1;
  color: rgba(247, 244, 232, 0.68);
}

.hud-card strong {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.shot-track {
  min-height: 38px;
  border-radius: 8px;
  background: rgba(20, 26, 18, 0.46);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
}

.shot-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.shot-dot.save {
  border-color: #d8ff70;
  background: #6fd44b;
}

.shot-dot.miss {
  border-color: #ffd19a;
  background: #f06b38;
}

.center-panel {
  position: absolute;
  z-index: 4;
  left: 18px;
  right: 18px;
  bottom: max(28px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0;
  border-radius: 8px;
  color: #fff8df;
  text-align: center;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  box-shadow: none;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.48);
}

.center-panel.hidden {
  display: none;
}

.center-panel[data-mode="intro"] .kicker,
.center-panel[data-mode="intro"] h1,
.center-panel[data-mode="intro"] .subcopy {
  display: none;
}

.motion-prompt,
.bridge-overlay {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 8, 5, 0.52);
  backdrop-filter: blur(10px);
}

.motion-prompt.hidden,
.bridge-overlay.hidden {
  display: none;
}

.motion-dialog,
.bridge-card {
  width: min(100%, 318px);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-radius: 8px;
  color: #fff8df;
  text-align: center;
  background: rgba(19, 22, 17, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}

.motion-dialog h2,
.bridge-event-name {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.motion-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bridge-event-data {
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 248, 223, 0.88);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}

.kicker {
  margin: 0;
  color: #ffe08a;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.center-panel h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 32px);
  line-height: 1.02;
  letter-spacing: 0;
}

.subcopy {
  margin: 0;
  max-width: 28ch;
  color: rgba(255, 248, 223, 0.82);
  font-size: 14px;
  line-height: 1.42;
}

.primary-button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  min-width: 148px;
  min-height: 48px;
  padding: 0 22px;
  background: linear-gradient(180deg, #ff3155, #df0d34);
  color: #fff8f2;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(72, 0, 12, 0.34);
}

.primary-button:active {
  transform: translateY(1px);
}

.secondary-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  min-height: 48px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff8df;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:active {
  transform: translateY(1px);
}

.toast {
  position: absolute;
  z-index: 5;
  left: 22px;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff8df;
  font-weight: 850;
  font-size: 18px;
  line-height: 1.2;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.45);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (pointer: coarse) {
  .hud-card,
  .shot-track,
  .center-panel,
  .motion-prompt {
    backdrop-filter: none;
  }
}
