@font-face {
  font-family: "Archivo Black";
  src: url("./assets/archivo-black.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./assets/space-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #10120f;
  --panel: #151814;
  --border: #2b3027;
  --ink: #f4f5ec;
  --muted: #a6ad9e;
  --soft: #868f7e;
  --accent: #d6fa42;
  --display: "Archivo Black", "Arial Black", system-ui, sans-serif;
  --numbers: "Space Grotesk", ui-monospace, monospace;
  --body: "Space Grotesk", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  background: var(--background);
  color: var(--ink);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { cursor: default; }
p, h1, h2, dl, dd { margin: 0; }

.shell { width: min(1160px, calc(100% - 104px)); margin: 0 auto; padding-bottom: 38px; }

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font: 700 17px/1 var(--numbers); letter-spacing: .045em; }
.brand img { display: block; border: 1px solid #343a2b; border-radius: 9px; }
.brand-divider { color: var(--accent); padding: 0 3px; }

.settings { display: flex; gap: 8px; }

.utility {
  display: grid;
  min-width: 44px;
  height: 42px;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #171a16;
  color: var(--muted);
  transition: background-color .15s, color .15s, border-color .15s;
}

.utility:hover { background: #22271d; color: var(--ink); border-color: #454e3d; }
.utility.language { font: 700 14px var(--numbers); }
.sound-off, [aria-pressed="false"] .sound-on { display: none; }
[aria-pressed="false"] .sound-off { display: initial; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, .805fr) minmax(0, 1.45fr);
  gap: clamp(30px, 5.4vw, 84px);
  align-items: center;
  padding-top: clamp(32px, 5.6vh, 70px);
}

.intro { min-width: 0; padding: 0 0 2px; }
.kicker { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: .82rem; font-weight: 700; letter-spacing: .095em; text-transform: uppercase; }
.kicker > :first-child { width: 19px; height: 2px; background: var(--accent); }

h1 {
  display: flex;
  flex-direction: column;
  margin: 26px 0 25px -6px;
  font: 400 clamp(3.5rem, 7.66vw, 7.05rem)/.77 var(--display);
  letter-spacing: -.096em;
}

h1 > :nth-child(2) { color: var(--accent); }
.title-period { padding-left: .017em; }
.tagline { font-size: clamp(1.33rem, 2vw, 1.85rem); font-weight: 700; letter-spacing: -.045em; }
.instructions { margin-top: 11px; max-width: 345px; color: var(--muted); font-size: .98rem; line-height: 1.8; }

.modes { margin-top: 32px; }
.modes h2 { margin-bottom: 10px; color: var(--soft); font-size: .79rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.mode-options { display: grid; gap: 8px; }
.mode {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 63px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  background: #161914;
  transition: background-color .14s, border-color .14s;
}

.mode:hover:not(:disabled) { background: #20251c; border-color: #57644a; }
.mode[aria-pressed="true"] { background: #202719; border-color: #586837; }
.mode-icon { color: var(--muted); }
.mode[aria-pressed="true"] .mode-icon { color: var(--accent); }
.mode-copy { display: grid; gap: 2px; min-width: 0; }
.mode strong { font-size: .96rem; line-height: 1.2; }
.mode small { color: var(--muted); font-size: .79rem; line-height: 1.35; }

.radio-mark { width: 13px; height: 13px; border: solid 1px #67735e; border-radius: 50%; }
.mode[aria-pressed="true"] .radio-mark { border-color: var(--accent); background: radial-gradient(circle closest-side, var(--accent) 57%, transparent 65%); }

.game-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #343a2e;
  border-radius: 22px;
  box-shadow: 0 24px 80px #0003;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 18px 6px 17px;
  border-bottom: 1px solid var(--border);
}

.hud div { display: grid; gap: 3px; justify-items: center; }
.hud div + div { border-left: 1px solid var(--border); }
.hud dt { color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.hud dd { font: 700 clamp(1.52rem, 3vw, 2rem)/1.12 var(--numbers); font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.hud div:first-child dd, #combo[data-combo="true"] { color: var(--accent); }

.arena {
  --arena-height: clamp(314px, 44.5vh, 475px);
  position: relative;
  height: var(--arena-height);
  background:
    radial-gradient(ellipse at 50% 48%, #1e241a66, transparent 69%),
    radial-gradient(circle, #363c31 0.75px, transparent 1px) center / 20px 20px,
    #11140f;
  cursor: pointer;
  touch-action: manipulation;
  isolation: isolate;
  user-select: none;
}

.arena canvas { display: block; width: 100%; height: 100%; }
.arena[data-phase="over"] canvas { opacity: .35; }
.arena[data-phase="over"] { background-color: #10120f; }

.feedback, .result {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  text-align: center;
  pointer-events: none;
}

.feedback { font: 700 clamp(1.55rem, 4vw, 2.5rem)/1 var(--numbers); letter-spacing: -.065em; }
.feedback[data-kind="perfect"] { color: var(--accent); }
.feedback small { font-size: .95rem; line-height: 1.2; letter-spacing: .03em; }

.result-label { color: var(--accent); font-weight: 700; font-size: .86rem; letter-spacing: .11em; text-transform: uppercase; }
.result-score { color: var(--ink); font: 700 clamp(3.5rem, 7vw, 5.4rem)/1 var(--numbers); letter-spacing: -.09em; }
.result-detail { color: var(--muted); font-size: .87rem; }
.quit {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid #3b4335;
  background: #161a14;
  color: var(--muted);
  font-size: .78rem;
}
.quit:hover { border-color: #65715b; color: var(--ink); }

.controls {
  display: grid;
  gap: 11px;
  justify-items: center;
  min-height: 117px;
  padding: 16px 19px 14px;
  border-top: 1px solid var(--border);
}

.actions { display: flex; width: 100%; min-height: 52px; gap: 8px; }
.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 800;
  transition: background-color .12s, border-color .12s, transform .12s;
}

.primary {
  flex: 1;
  padding: 10px 12px;
  background: var(--accent);
  color: #17200a;
  box-shadow: inset 0 -3px 0 #2537082a;
}
.primary:hover { background: #e2ff71; }
.primary:active, .secondary:active { transform: translateY(1px); }
.action-symbol path { display: none; }
.primary[data-phase="ready"] .start-symbol { display: initial; fill: currentColor; stroke-width: 1.3; }
.primary[data-phase="playing"] .snap-symbol, .primary[data-phase="over"] .retry-symbol { display: initial; }
.secondary { padding: 9px 14px; background: #22271e; border-color: #424b38; color: var(--ink); font-size: .87rem; }
.secondary:hover { background: #30392a; border-color: #626f55; }
.input-hint { min-height: 20px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }

.share-dialog {
  width: min(430px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(16px, 4vw, 24px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #454e3a;
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px #0009;
}

.share-dialog::backdrop { background: #080a07bd; }
.share-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.share-heading h2 { margin: 0; font-size: 1.25rem; line-height: 1.25; text-wrap: balance; }
.share-heading .utility { width: 40px; height: 40px; }
.share-preview {
  display: block;
  width: min(100%, 252px, 43dvh);
  height: auto;
  margin: 12px auto 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.share-platforms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.share-platforms :is(a, button) { min-height: 46px; padding-inline: 7px; font-size: .86rem; text-decoration: none; }
.share-platforms svg { flex: none; }
.share-platforms button:disabled { opacity: .55; cursor: default; }
.share-hint { min-height: 2.5em; margin: 9px 0 3px; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.share-tools { display: flex; flex-wrap: wrap; gap: 0 13px; border-top: 1px solid var(--border); }
.share-tools :is(a, button) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: .78rem;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.share-dialog a:focus-visible, .share-manual:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.share-manual {
  display: block;
  width: 100%;
  min-height: 105px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--ink);
  font: inherit;
  font-size: .78rem;
}

kbd { padding: 1px 5px; color: #c5cbbd; background: #22271e; border: 1px solid #3b4532; border-radius: 4px; font: 700 .69rem/1.3 var(--numbers); letter-spacing: .04em; }

.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

@media (max-width: 980px) {
  .shell { width: calc(100% - 64px); }
  .layout { gap: 32px; }
  h1 { font-size: clamp(3.45rem, 8.3vw, 6.7rem); }
}

@media (max-width: 720px) {
  .shell { width: min(500px, calc(100% - 32px)); padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .topbar { height: 64px; }
  .brand { display: flex; gap: 7px; font-size: .84rem; }
  .brand img { width: 28px; height: 28px; border-radius: 7px; }
  .settings { gap: 6px; }
  .layout { gap: 17px; padding-top: 21px; grid-template-columns: minmax(0, 1fr); }
  .intro { display: contents; }
  .intro-copy { grid-row: 1; }
  .kicker, .tagline { display: none; }
  h1 { flex-direction: row; gap: .16em; margin: 0 0 8px -2px; font-size: clamp(2.1rem, 10.4vw, 3.9rem); line-height: .92; }
  .instructions { max-width: 455px; margin-top: 0; font-size: .89rem; line-height: 1.6; }
  .modes { grid-row: 3; margin-top: 0; }
  .mode-options { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mode { gap: 7px; min-height: 66px; padding: 8px; }
  .mode-icon { width: 17px; height: 17px; }
  .mode strong { font-size: .83rem; }
  .mode small { font-size: .73rem; }
  .radio-mark { width: 11px; height: 11px; }
  .game-card { grid-row: 2; border-radius: 17px; }
  .hud { padding: 11px 4px; }
  .arena { height: clamp(223px, 73vw, 361px); }
  .controls { gap: 7px; min-height: 89px; padding: 10px 11px 8px; }
  .actions { min-height: 47px; }
  .primary { font-size: .93rem; }
  .secondary { padding-inline: 9px; font-size: .78rem; }
}

@media (pointer: coarse) {
  .input-hint kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
