:root {
  --ink: #12182f;
  --ink-soft: #30374f;
  --paper: #f4efe3;
  --paper-deep: #e8dfcd;
  --coral: #ff7455;
  --gold: #f6c453;
  --mint: #89c9bb;
  --white: #fffdf8;
  --line: rgba(18, 24, 47, 0.16);
  --shadow: 0 28px 70px rgba(18, 24, 47, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(18, 24, 47, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 24, 47, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0.5;
  pointer-events: none;
}

.page-glow--one {
  top: -18rem;
  right: -9rem;
  background: var(--gold);
}

.page-glow--two {
  bottom: -22rem;
  left: -12rem;
  background: var(--mint);
}

.site-header,
.site-footer,
.game-layout {
  width: min(1460px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 90px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
}

.header-note {
  margin: 0;
  color: var(--ink-soft);
  font-family: Georgia, "Songti SC", serif;
  font-size: 14px;
  font-style: italic;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(620px, 1.65fr);
  gap: clamp(36px, 6vw, 96px);
  align-items: center;
  min-height: calc(100vh - 162px);
  padding-block: 52px;
}

.intro-panel {
  max-width: 420px;
}

.eyebrow,
.overlay-kicker {
  margin: 0 0 18px;
  color: var(--coral);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(46px, 5vw, 74px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h1 em {
  position: relative;
  color: var(--coral);
  font-weight: 500;
}

h1 em::after {
  position: absolute;
  right: 0.02em;
  bottom: -0.16em;
  left: 0.05em;
  height: 6px;
  background: var(--gold);
  border-radius: 999px;
  content: "";
  transform: rotate(-1.4deg);
}

.intro-copy {
  max-width: 38em;
  margin: 28px 0 30px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.rule-list {
  display: grid;
  gap: 12px;
}

.rule-item {
  display: flex;
  gap: 13px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.rule-icon {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  font-size: 17px;
}

.rule-icon--star {
  color: var(--ink);
  background: var(--white);
}

.rule-icon--gold {
  color: var(--ink);
  background: var(--gold);
}

.rule-icon--meteor {
  color: var(--paper);
  background: var(--coral);
  font-size: 11px;
}

.rule-item div {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
}

.rule-item strong {
  font-size: 13px;
}

.rule-item span:last-child {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.tiny-note {
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 2;
}

kbd {
  min-width: 22px;
  padding: 3px 6px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
}

.game-card {
  min-width: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(18, 24, 47, 0.22);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.game-toolbar,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding-inline: 24px;
}

.status-pill {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #a7a59f;
  border-radius: 50%;
}

.status-dot.is-live {
  background: #3eb489;
  box-shadow: 0 0 0 5px rgba(62, 180, 137, 0.14);
  animation: pulse 1.8s infinite;
}

.status-dot.is-paused {
  background: var(--gold);
}

.scoreboard {
  display: flex;
  gap: clamp(20px, 4vw, 48px);
  align-items: center;
}

.score-item {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 8px;
  align-items: baseline;
}

.score-item span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.score-item strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

#lives-value {
  color: var(--coral);
  letter-spacing: 0.08em;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  margin-inline: 12px;
  background: var(--ink);
  border-radius: 15px;
  isolation: isolate;
}

#game-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 12 / 7;
  cursor: crosshair;
  touch-action: none;
}

.canvas-wrap.hit::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(255, 116, 85, 0.24);
  pointer-events: none;
  animation: hit-flash 260ms ease-out forwards;
  content: "";
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: var(--white);
  text-align: center;
  background: rgba(12, 18, 42, 0.7);
  backdrop-filter: blur(7px);
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}

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

.overlay-emblem {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 20px;
  place-items: center;
  color: var(--ink);
  background: var(--gold);
  border: 6px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background-clip: padding-box;
  font-size: 25px;
  transform: rotate(9deg);
}

.overlay-kicker {
  margin-bottom: 10px;
  color: var(--gold);
}

.game-overlay h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.game-overlay p:not(.overlay-kicker) {
  max-width: 460px;
  margin: 14px 0 24px;
  color: rgba(255, 253, 248, 0.75);
  font-size: 13px;
  line-height: 1.8;
}

.primary-button {
  display: inline-flex;
  gap: 22px;
  align-items: center;
  justify-content: center;
  min-width: 172px;
  padding: 13px 18px;
  color: var(--ink);
  background: var(--gold);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 9px 25px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.primary-button:hover {
  background: #ffd471;
  transform: translateY(-2px);
}

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

.game-footer {
  min-height: 64px;
}

.game-footer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.game-footer strong {
  margin-left: 5px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.text-button {
  padding: 8px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.text-button:disabled {
  color: #aaa8a1;
  cursor: not-allowed;
}

.mobile-controls {
  display: none;
  gap: 8px;
}

.control-button {
  display: grid;
  width: 42px;
  height: 36px;
  place-items: center;
  color: var(--white);
  background: var(--ink);
  border: 0;
  border-radius: 8px;
  font-size: 17px;
  touch-action: none;
  user-select: none;
}

.control-button:active,
.control-button.is-pressed {
  background: var(--coral);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.site-footer span:last-child {
  font-family: Georgia, "Songti SC", serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

@keyframes hit-flash {
  to {
    opacity: 0;
  }
}

@media (max-width: 1040px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 38px;
    max-width: 820px;
  }

  .intro-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    max-width: none;
  }

  .eyebrow,
  .intro-panel h1,
  .intro-copy {
    grid-column: 1;
  }

  .rule-list {
    grid-row: 1 / span 3;
    grid-column: 2;
    align-self: end;
  }

  .tiny-note {
    display: none;
  }

  .game-layout {
    min-height: auto;
  }
}

@media (max-width: 700px) {
  .site-header,
  .site-footer,
  .game-layout {
    width: min(100% - 24px, 620px);
  }

  .site-header {
    min-height: 68px;
  }

  .header-note {
    display: none;
  }

  .game-layout {
    gap: 28px;
    padding-block: 32px;
  }

  .intro-panel {
    display: block;
  }

  h1 {
    font-size: clamp(42px, 14vw, 62px);
  }

  .intro-copy {
    margin-bottom: 20px;
  }

  .rule-list {
    display: none;
  }

  .game-card {
    border-radius: 17px;
  }

  .game-toolbar {
    min-height: 62px;
    padding-inline: 15px;
  }

  .status-pill {
    display: none;
  }

  .scoreboard {
    width: 100%;
    gap: 8px;
    justify-content: space-between;
  }

  .score-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .score-item strong {
    font-size: 14px;
  }

  .canvas-wrap {
    margin-inline: 7px;
    border-radius: 11px;
  }

  .game-overlay {
    padding: 16px;
  }

  .overlay-emblem {
    width: 45px;
    height: 45px;
    margin-bottom: 11px;
    border-width: 4px;
    font-size: 19px;
  }

  .overlay-kicker {
    display: none;
  }

  .game-overlay h2 {
    font-size: clamp(25px, 8vw, 36px);
  }

  .game-overlay p:not(.overlay-kicker) {
    margin: 8px 0 13px;
    font-size: 11px;
    line-height: 1.5;
  }

  .primary-button {
    min-width: 148px;
    padding: 10px 15px;
    font-size: 12px;
  }

  .game-footer {
    min-height: 60px;
    padding-inline: 13px;
  }

  .mobile-controls {
    display: flex;
  }

  .game-footer p {
    display: none;
  }

  .site-footer {
    min-height: 60px;
  }

  .site-footer span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
