:root {
  --bg: #0f1618;
  --surface: #151f21;
  --surface-2: #1a2729;
  --surface-3: #203033;
  --line: #2b3d40;
  --text: #d9e5e3;
  --muted: #93a8a5;
  --faint: #667a78;
  --accent: #69aaa5;
  --accent-strong: #82c4bd;
  --accent-dark: #315e5b;
  --ready: #34756f;
  --warning: #a77b5d;
  --danger: #9c655f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--accent-strong);
  color: #0e1718;
  font-weight: 800;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% -5%, rgba(105, 170, 165, 0.12), transparent 30%),
    var(--bg);
}

.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  width: min(1240px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-button,
.text-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.tool-button {
  min-height: 40px;
  padding: 8px 13px;
  font-size: 0.82rem;
}

.tool-button:hover,
.text-button:hover,
.secondary-button:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

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

.fullscreen-exit {
  position: fixed;
  z-index: 100;
  top: 16px;
  right: 16px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: rgba(15, 22, 24, 0.94);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.view {
  min-height: calc(100dvh - 76px);
}

.home-hero {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(64px, 10vw, 126px) 0 clamp(48px, 7vw, 86px);
  text-align: center;
}

.eyebrow,
.section-kicker,
.arena-eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.19em;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 7.7rem);
  line-height: 0.95;
  letter-spacing: -0.065em;
}

.home-hero > p:last-child {
  max-width: 660px;
  margin: 28px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.13rem);
}

.ad-layout {
  display: grid;
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  grid-template-columns: 150px minmax(0, 1120px) 150px;
  justify-content: center;
  gap: 22px;
}

.home-content {
  min-width: 0;
}

.ad-slot {
  display: grid;
  place-items: center;
  border: 1px dashed #33484b;
  border-radius: 12px;
  background: rgba(21, 31, 33, 0.46);
  color: var(--faint);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  user-select: none;
}

.ad-banner {
  min-height: 92px;
  margin-bottom: 28px;
}

.ad-side {
  position: sticky;
  top: 22px;
  height: 560px;
}

.ad-result {
  width: min(760px, 100%);
  min-height: 100px;
  margin: 24px auto 0;
}

.mode-section,
.records-section,
.guide-section,
.explanation-section,
.faq-section {
  padding: clamp(48px, 7vw, 86px) 0;
}

.section-title {
  margin-bottom: 30px;
}

.section-title h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.mode-grid,
.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mode-card {
  position: relative;
  overflow: hidden;
  padding: clamp(26px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
}

.mode-card h3 {
  max-width: 420px;
  margin: 14px 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.mode-card > p {
  max-width: 490px;
  margin: 0;
  color: var(--muted);
}

.mode-card ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 32px;
  padding: 0;
  list-style: none;
}

.mode-card li {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #a9bbb8;
  font-size: 0.76rem;
}

.mode-number {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.mode-visual {
  position: relative;
  display: grid;
  height: 168px;
  margin-bottom: 26px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(130, 196, 189, 0.14);
  border-radius: 14px;
  background: #121b1d;
}

.color-visual span {
  position: absolute;
  inset: 0;
}

.color-visual span:first-child {
  clip-path: polygon(0 0, 52% 0, 43% 100%, 0 100%);
  background: #253638;
}

.color-visual span:last-child {
  clip-path: polygon(53% 0, 100% 0, 100% 100%, 44% 100%);
  background: var(--ready);
}

.target-visual::before,
.target-visual::after {
  position: absolute;
  border: 1px solid #2c4143;
  border-radius: 50%;
  content: "";
}

.target-visual::before {
  width: 128px;
  height: 128px;
}

.target-visual::after {
  width: 78px;
  height: 78px;
}

.target-visual span {
  z-index: 1;
  width: 54px;
  height: 54px;
  border: 10px solid var(--accent-dark);
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 10px rgba(105, 170, 165, 0.12);
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #0b1516;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  min-width: 120px;
}

.records-section,
.guide-section,
.explanation-section,
.faq-section {
  border-top: 1px solid var(--line);
}

.records-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.text-button {
  min-height: 40px;
  padding: 8px 13px;
  color: var(--muted);
}

.record-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.record-card h3 {
  margin: 0 0 18px;
  font-size: 1.05rem;
}

.record-card dl {
  margin: 0;
}

.record-card dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.record-card dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.record-card dd {
  margin: 0;
  text-align: right;
  font-weight: 850;
}

.storage-note {
  margin: 16px 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.guide-grid article {
  min-height: 230px;
  padding: 28px;
  background: var(--surface);
}

.guide-grid article > span {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
}

.guide-grid h3 {
  margin: 40px 0 10px;
  font-size: 1.05rem;
}

.guide-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.explanation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.explanation-grid article {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.explanation-grid h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.explanation-grid p,
.faq-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.faq-list summary {
  padding: 20px 22px;
  cursor: pointer;
  font-weight: 800;
}

.faq-list details[open] summary {
  padding-bottom: 12px;
}

.faq-list p {
  max-width: 800px;
  padding: 0 22px 22px;
}

.site-footer {
  display: grid;
  width: min(1120px, calc(100% - 40px));
  margin: 60px auto 0;
  padding: 42px 0;
  grid-template-columns: 1fr auto;
  gap: 28px;
  border-top: 1px solid var(--line);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px 24px;
}

.site-footer nav a,
.site-footer p {
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 8px 0 0;
}

.site-footer > p {
  grid-column: 1 / -1;
}

.game-view {
  padding: 22px 20px 48px;
}

.game-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.game-heading {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
}

.game-heading h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.6vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.game-heading > p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  text-align: right;
  font-size: 0.86rem;
}

.color-arena,
.target-arena {
  position: relative;
  min-height: clamp(470px, calc(100dvh - 215px), 760px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.color-arena {
  display: grid;
  place-items: center;
  background: #283537;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: background-color 120ms linear;
}

.color-arena.is-ready {
  background: var(--ready);
}

.color-arena.is-false-start {
  background: #5d403b;
}

.color-arena.is-result {
  background: #1d2b2d;
  cursor: default;
}

.arena-content {
  width: min(640px, calc(100% - 36px));
  padding: 36px;
  text-align: center;
}

.signal-icon {
  display: block;
  margin-bottom: 16px;
  color: #91a4a1;
  font-size: 1.5rem;
}

.is-ready .signal-icon {
  color: #d6e7e3;
}

.color-arena h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.color-arena p:not(.arena-eyebrow) {
  margin: 16px 0 0;
  color: #b7c7c4;
}

.result-value {
  display: block;
  margin-top: 18px;
  color: var(--accent-strong);
  font-size: clamp(3.2rem, 10vw, 7.5rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.target-arena {
  background:
    linear-gradient(rgba(105, 170, 165, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(105, 170, 165, 0.025) 1px, transparent 1px),
    #121b1d;
  background-size: 40px 40px;
  touch-action: manipulation;
  user-select: none;
}

.target-start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.target-start-panel p {
  margin: 24px 0 4px;
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  font-weight: 750;
}

.target-start-panel small {
  color: var(--muted);
}

.start-point {
  position: relative;
  display: grid;
  width: 126px;
  height: 126px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: #1b2a2c;
  color: var(--accent-strong);
  cursor: crosshair;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.start-point::before,
.start-point::after {
  position: absolute;
  border: 1px solid rgba(105, 170, 165, 0.35);
  border-radius: 50%;
  content: "";
}

.start-point::before {
  inset: -16px;
}

.start-point::after {
  inset: 18px;
}

.start-point:hover,
.start-point.is-preparing {
  background: var(--accent-dark);
  transform: scale(1.04);
}

.start-point.is-preparing::before {
  animation: ready-ring 700ms ease-out infinite;
}

.target-arena-notice {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 50%;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 22, 24, 0.84);
  color: var(--muted);
  font-size: 0.78rem;
  transform: translateX(-50%);
  pointer-events: none;
}

.target-button {
  --target-size: 62px;
  --slide-x: 0px;
  --slide-y: 0px;
  position: absolute;
  z-index: 4;
  display: grid;
  width: var(--target-size);
  height: var(--target-size);
  padding: 0;
  place-items: center;
  border: 8px solid var(--accent-dark);
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow:
    0 0 0 7px rgba(105, 170, 165, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.72);
  animation: target-in 150ms cubic-bezier(0.2, 0.85, 0.3, 1.15) forwards;
}

.target-button span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #183130;
}

.target-button.is-hit {
  pointer-events: none;
  animation: target-out 170ms ease-in forwards;
}

.target-result-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow-y: auto;
  padding: clamp(28px, 5vw, 58px);
  background: rgba(18, 27, 29, 0.97);
  text-align: center;
}

.target-result-panel h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.target-result-panel > p:not(.arena-eyebrow) {
  margin: 12px auto 0;
  color: var(--muted);
}

.target-metrics {
  display: grid;
  width: min(900px, 100%);
  margin: 30px auto;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.target-metrics > div {
  padding: 20px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.target-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.target-metrics strong {
  display: block;
  margin-top: 5px;
  color: var(--accent-strong);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.round-results {
  display: grid;
  width: min(900px, 100%);
  margin: 0 auto;
  gap: 7px;
}

.round-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 70px;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
}

.round-row > span:first-child {
  color: var(--muted);
  text-align: right;
}

.round-bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #263537;
}

.round-bar {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-strong));
}

.round-time {
  text-align: right;
  font-weight: 800;
}

.app-shell:fullscreen,
.app-shell:-webkit-full-screen {
  overflow: auto;
  background: var(--bg);
}

.app-shell:fullscreen .ad-slot,
.app-shell:-webkit-full-screen .ad-slot {
  display: none !important;
}

body.is-playing .site-footer {
  display: none;
}

@keyframes target-in {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes target-out {
  to {
    opacity: 0;
    transform: translate(var(--slide-x), var(--slide-y)) scale(0.78);
  }
}

@keyframes ready-ring {
  from {
    opacity: 0.7;
    transform: scale(0.85);
  }
  to {
    opacity: 0;
    transform: scale(1.16);
  }
}

@media (max-width: 1320px) {
  .ad-layout {
    width: min(1120px, calc(100% - 32px));
    grid-template-columns: minmax(0, 1fr);
  }

  .ad-side {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    width: min(100% - 24px, 1240px);
    min-height: 68px;
    align-items: flex-start;
    padding: 13px 0;
  }

  .brand {
    min-height: 40px;
  }

  .brand-mark {
    display: none;
  }

  .toolbar {
    gap: 6px;
  }

  .tool-button {
    min-height: 38px;
    padding-inline: 10px;
    font-size: 0.74rem;
  }

  .home-hero {
    width: min(100% - 28px, 1040px);
  }

  .home-hero h1 {
    font-size: clamp(3.3rem, 17vw, 5.7rem);
  }

  .ad-layout {
    width: min(100% - 24px, 1120px);
  }

  .mode-grid,
  .record-grid,
  .guide-grid,
  .explanation-grid {
    grid-template-columns: 1fr;
  }

  .guide-grid {
    gap: 1px;
  }

  .guide-grid article {
    min-height: auto;
  }

  .guide-grid h3 {
    margin-top: 26px;
  }

  .records-heading,
  .game-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .records-heading {
    display: flex;
  }

  .game-heading {
    display: flex;
    padding: 18px 0;
    gap: 8px;
  }

  .game-heading > p {
    text-align: left;
  }

  .game-view {
    padding: 0 12px 24px;
  }

  .color-arena,
  .target-arena {
    min-height: calc(100dvh - 204px);
    border-radius: 15px;
  }

  .arena-content {
    padding: 24px 12px;
  }

  .target-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-footer {
    width: min(100% - 28px, 1120px);
    grid-template-columns: 1fr;
  }

  .site-footer nav {
    justify-content: flex-start;
  }
}

@media (pointer: coarse) {
  .target-button {
    --target-size: 76px;
    border-width: 10px;
  }

  .primary-button,
  .secondary-button,
  .tool-button,
  .text-button {
    min-height: 46px;
  }
}

@media (max-width: 430px) {
  .brand {
    max-width: 92px;
    overflow: hidden;
    font-size: 0.71rem;
  }

  .toolbar {
    max-width: 230px;
  }

  .tool-button {
    padding-inline: 8px;
  }

  .mode-card {
    padding: 24px;
  }

  .mode-visual {
    height: 140px;
  }

  .target-result-panel {
    padding: 24px 16px;
  }

  .round-row {
    grid-template-columns: 34px minmax(0, 1fr) 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
