@font-face {
  font-family: "Signal Sans";
  src: url("signal-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: block;
}

:root {
  --ink: #03080e;
  --paper: #edf8ff;
  --muted: #91a8bb;
  --signal: #63e6e2;
  --violet: #d792ff;
  --line: rgba(133, 199, 233, 0.24);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Signal Sans", Arial, sans-serif;
}

button,
a { font: inherit; }

button {
  min-width: 44px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 16px;
  background: rgba(9, 22, 36, 0.92);
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  cursor: pointer;
}

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

.game-page {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.game-shell {
  position: fixed;
  top: var(--visual-top, 0px);
  left: var(--visual-left, 0px);
  display: grid;
  width: var(--visual-width, 100vw);
  height: var(--visual-height, 100svh);
  place-items: center;
  padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 12%, rgba(35, 94, 122, 0.34), transparent 32rem),
    radial-gradient(circle at 8% 88%, rgba(64, 45, 115, 0.26), transparent 30rem),
    var(--ink);
}

.game-stage {
  position: relative;
  width: var(--stage-width, min(100vw, 177.778svh));
  height: var(--stage-height, min(100svh, 56.25vw));
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  touch-action: none;
}

canvas:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: -3px;
}

.game-mark {
  position: absolute;
  top: max(7px, env(safe-area-inset-top));
  left: 50%;
  z-index: 3;
  margin: 0;
  color: rgba(237, 248, 255, 0.72);
  font-size: clamp(0.58rem, 2.1vmin, 0.78rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.13em;
  transform: translateX(-50%);
  pointer-events: none;
}

.touch-zones {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.touch-zones span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
}

.touch-left { left: 0; }
.touch-right { right: 0; }
.solo-mode .touch-right { display: none; }

.match-actions {
  position: absolute;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  gap: 12px;
  transform: translateX(-50%);
}

.match-actions button {
  min-height: 38px;
  padding: 0 12px;
  border-color: rgba(133, 199, 233, 0.22);
  background: transparent;
  color: rgba(145, 168, 187, 0.72);
  font-size: clamp(0.58rem, 1.8vmin, 0.7rem);
  text-shadow: 0 1px 2px #000;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.match-actions button:focus-visible,
.match-actions button:active {
  border-color: rgba(99, 230, 226, 0.72);
  background: rgba(9, 22, 36, 0.46);
  color: var(--paper);
}

@media (hover: hover) {
  .match-actions button:hover {
    border-color: rgba(99, 230, 226, 0.6);
    background: rgba(9, 22, 36, 0.4);
    color: var(--paper);
  }
}

.match-active .game-mark { opacity: 0; }

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(3, 8, 14, 0.86);
  text-align: center;
}

.mini-title {
  margin: 0 0 3px;
  color: var(--signal);
  font-size: clamp(0.6rem, 2.2vmin, 0.78rem);
  letter-spacing: 0.14em;
}

.game-overlay h2 {
  margin: 0 0 12px;
  color: var(--paper);
  font-size: clamp(1.05rem, 4.4vmin, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.mode-switch,
.overlay-actions {
  display: flex;
  gap: 6px;
}

.mode-switch button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--muted);
}

.mode-switch button.is-active,
.primary-button {
  border-color: var(--signal);
  background: var(--signal);
  color: #031116;
}

.instruction {
  margin: 11px 0 10px;
  color: var(--muted);
  font-size: clamp(0.56rem, 1.9vmin, 0.7rem);
  letter-spacing: 0.08em;
}

.primary-button { min-width: 112px; }

.info-links {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.info-links a {
  color: var(--muted);
  font-size: clamp(0.55rem, 1.8vmin, 0.68rem);
  text-underline-offset: 3px;
}

.final-score {
  margin: -4px 0 12px;
  color: var(--signal);
  font-size: clamp(0.9rem, 3vmin, 1.2rem);
  letter-spacing: 0.1em;
}

.rotate-prompt { display: none; }

.rotate-device {
  width: 64px;
  height: 36px;
  border: 2px solid var(--paper);
  border-radius: 6px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 12px;
  background: var(--paper);
  color: #000;
  transform: translateY(-150%);
}

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

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

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  margin: 0;
  padding: 30px;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
}

.policy-page {
  width: min(720px, calc(100% - 34px));
  margin: 0 auto;
  padding: 46px 0 64px;
}

.policy-page .eyebrow {
  margin: 0 0 5px;
  color: var(--signal);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}

.policy-page h1 {
  margin: 0 0 32px;
  font-size: clamp(2rem, 8vw, 4rem);
  letter-spacing: 0.04em;
}

.policy-page h2 {
  margin: 32px 0 10px;
  font-size: 1.2rem;
}

.policy-page p,
.policy-page li {
  color: #c9d8e3;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

.policy-page a { color: var(--signal); }

@media (orientation: portrait) and (pointer: coarse) {
  .game-shell { visibility: hidden; }

  .rotate-prompt {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: max(28px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
    background: var(--ink);
    text-align: center;
  }

  .rotate-prompt strong {
    color: var(--signal);
    font-size: 1rem;
    letter-spacing: 0.1em;
  }

  .rotate-prompt span {
    color: var(--muted);
    font-size: 0.75rem;
  }
}

@media (max-height: 360px) and (orientation: landscape) {
  .game-overlay { padding: 6px; }
  .game-overlay h2 { margin-bottom: 7px; }
  .instruction { margin: 7px 0; }
  .info-links { margin-top: 7px; }
  .mode-switch button,
  .game-overlay button { min-height: 34px; }
}

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