:root {
  color-scheme: light;
  --paper: #f5ecdb;
  --paper-deep: #e2d0a8;
  --ink: #1d2a44;
  --navy: #193254;
  --red: #bc3f2a;
  --red-deep: #8d2419;
  --gold: #f1b84a;
  --green: #367a52;
  --white: #fffdf8;
  --shadow: rgba(16, 27, 47, 0.18);
  --shadow-strong: rgba(16, 27, 47, 0.32);
  --button-shadow: 0 10px 18px rgba(25, 50, 84, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Aptos", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(241, 184, 74, 0.22), transparent 28%),
    linear-gradient(180deg, #f8f1df 0%, #edd8b2 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 36vw;
  height: 36vw;
  max-width: 240px;
  max-height: 240px;
  border-radius: 28%;
  background: rgba(188, 63, 42, 0.08);
  filter: blur(2px);
  pointer-events: none;
}

body::before {
  top: -3rem;
  left: -2rem;
  transform: rotate(18deg);
}

body::after {
  right: -4rem;
  bottom: 10rem;
  background: rgba(25, 50, 84, 0.08);
  transform: rotate(-16deg);
}

.app-shell {
  width: min(100%, 29rem);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 0.95rem max(1rem, env(safe-area-inset-bottom));
}

.masthead {
  padding: 0.4rem 0.25rem 0.85rem;
}

.eyebrow,
.overlay-eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--red);
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.7rem);
  line-height: 1;
}

.tagline {
  margin: 0.45rem 0 0;
  font-size: 0.98rem;
  line-height: 1.35;
  max-width: 26rem;
}

.game-frame {
  position: relative;
  padding: 0.95rem;
  border: 3px solid rgba(25, 50, 84, 0.12);
  border-radius: 1.6rem;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(244, 233, 209, 0.96)),
    var(--white);
  box-shadow:
    0 24px 40px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.hud-card {
  padding: 0.72rem 0.8rem 0.82rem;
  border-radius: 1.1rem;
  background: linear-gradient(180deg, rgba(25, 50, 84, 0.07), rgba(25, 50, 84, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hud-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.28rem;
}

.hud-card-wide {
  grid-column: 1 / -1;
}

.hud-label {
  display: block;
  font-size: 0.77rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(29, 42, 68, 0.75);
}

.meter-track {
  margin-top: 0.42rem;
  height: 0.72rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(25, 50, 84, 0.14);
}

.meter-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #56b379);
  transition: width 140ms linear, background 180ms linear;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  margin: 0.9rem 0 0.7rem;
}

.tool-button,
.primary-button,
.secondary-button,
.lane-button {
  appearance: none;
  border: 0;
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

.tool-button,
.secondary-button {
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(25, 50, 84, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.difficulty-pill {
  justify-self: center;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(241, 184, 74, 0.32);
  text-align: center;
}

.playfield {
  position: relative;
  aspect-ratio: 9 / 15.4;
  border-radius: 1.45rem;
  overflow: hidden;
  background: linear-gradient(180deg, #cfd6d8 0%, #c7d2cd 18%, #ecd8a9 100%);
  box-shadow:
    inset 0 0 0 4px rgba(25, 50, 84, 0.08),
    0 16px 28px rgba(25, 50, 84, 0.14);
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(16, 26, 43, 0.44);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(100%, 19rem);
  padding: 1.25rem 1.1rem 1.15rem;
  border-radius: 1.3rem;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(246, 237, 218, 0.98));
  box-shadow: 0 20px 34px var(--shadow-strong);
  text-align: left;
}

.overlay-card h2 {
  font-size: 1.72rem;
  line-height: 1.05;
}

.overlay-body {
  margin: 0.6rem 0 0.85rem;
  line-height: 1.38;
}

.overlay-list {
  margin: 0 0 1rem;
  padding-left: 1.05rem;
  line-height: 1.4;
}

.overlay-list li + li {
  margin-top: 0.35rem;
}

.brief-red {
  color: #bc3f2a;
  font-weight: 800;
}

.brief-orange {
  color: #d2761d;
  font-weight: 800;
}

.overlay-actions {
  display: flex;
  gap: 0.65rem;
}

.overlay-actions > * {
  flex: 1;
}

.primary-button {
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  font-weight: 800;
  color: var(--white);
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  box-shadow: var(--button-shadow);
}

.secondary-button.hidden {
  display: none;
}

.announcer {
  min-height: 1.5rem;
  margin: 0.8rem 0 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--navy);
}

.lane-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.62rem;
}

.lane-button {
  position: relative;
  padding: 0.9rem 0.25rem 0.82rem;
  border-radius: 1.15rem;
  color: var(--white);
  box-shadow: var(--button-shadow);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lane-a {
  background: linear-gradient(180deg, #315c90, #193254);
}

.lane-b {
  background: linear-gradient(180deg, #d35737, #9a2d1f);
}

.lane-c {
  background: linear-gradient(180deg, #4b8c60, #2f6947);
}

.lane-button:active,
.tool-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.lane-button-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
}

.lane-button-subtitle {
  display: block;
  margin-top: 0.16rem;
  font-size: 0.66rem;
  opacity: 0.9;
}

.footer-note {
  margin: 0.85rem 0 0;
  padding: 0 0.2rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(29, 42, 68, 0.75);
}

@media (max-width: 400px) {
  .app-shell {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .game-frame {
    padding: 0.8rem;
    border-radius: 1.3rem;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .difficulty-pill {
    grid-column: 1 / -1;
    order: -1;
  }

  .lane-button {
    padding-top: 0.78rem;
    padding-bottom: 0.72rem;
  }
}
