:root {
  color-scheme: dark;
  --bg: #050b12;
  --bg-deep: #02070c;
  --surface: rgba(8, 18, 29, 0.82);
  --surface-strong: #0a1622;
  --line: rgba(137, 186, 222, 0.2);
  --line-strong: rgba(137, 186, 222, 0.34);
  --text: #f2f7fb;
  --muted: #8fa2b2;
  --muted-strong: #b7c4ce;
  --blue: #45b8ff;
  --blue-soft: #8dd8ff;
  --red: #ff5d73;
  --red-soft: #ff9baa;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(55, 114, 154, 0.12), transparent 40%),
    linear-gradient(180deg, #06101a 0%, var(--bg) 42%, var(--bg-deep) 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  pointer-events: none;
  opacity: 0.45;
  background-image:
    radial-gradient(circle at 13% 17%, rgba(255, 255, 255, 0.72) 0 1px, transparent 1.4px),
    radial-gradient(circle at 72% 31%, rgba(255, 255, 255, 0.45) 0 1px, transparent 1.4px),
    radial-gradient(circle at 42% 76%, rgba(255, 255, 255, 0.35) 0 1px, transparent 1.4px),
    radial-gradient(circle at 91% 68%, rgba(255, 255, 255, 0.46) 0 1px, transparent 1.4px);
  background-size: 211px 211px, 293px 293px, 347px 347px, 421px 421px;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--blue-soft);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -2;
  width: min(34vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.12;
}

.ambient-blue {
  top: 9vh;
  left: -20vw;
  background: var(--blue);
}

.ambient-red {
  right: -22vw;
  bottom: 3vh;
  background: var(--red);
}

.button {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

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

.button-primary {
  color: #03101a;
  background: linear-gradient(180deg, #78d1ff 0%, var(--blue) 100%);
  box-shadow: 0 8px 26px rgba(69, 184, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.button-primary:hover {
  box-shadow: 0 10px 34px rgba(69, 184, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.button-secondary,
.button-quiet {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(13, 28, 42, 0.84);
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: rgba(141, 216, 255, 0.62);
  background: rgba(18, 39, 57, 0.92);
}

.lobby-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 28px;
}

.lobby-shell {
  width: min(1120px, 100%);
}

.wordmark {
  display: flex;
  justify-content: center;
  gap: 0.15em;
  font-size: clamp(2rem, 5vw, 4.5rem);
  font-weight: 540;
  line-height: 1;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-shadow: 0 0 22px rgba(111, 199, 255, 0.22);
}

.wordmark-line {
  color: #ffd9df;
  text-shadow: 0 0 23px rgba(255, 93, 115, 0.34);
}


.lobby-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
  gap: 48px;
  margin-top: 56px;
  align-items: center;
}

.hero-copy h1 {
  max-width: 670px;
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 5.2rem);
  font-weight: 520;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero-copy > p {
  max-width: 620px;
  margin: 28px 0 0;
  color: var(--muted-strong);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.75;
}

.primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.join-form {
  max-width: 520px;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.join-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.join-row input {
  min-width: 0;
  height: 46px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: rgba(3, 10, 17, 0.7);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.join-row input::placeholder {
  color: #556878;
}


.hero-diagram {
  position: relative;
  min-height: 340px;
  border: 1px solid rgba(126, 182, 220, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(86, 133, 166, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 133, 166, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 54%, rgba(50, 91, 122, 0.12), transparent 56%),
    rgba(2, 9, 15, 0.72);
  background-size: 42px 42px, 42px 42px, auto, auto;
  box-shadow: var(--shadow), inset 0 0 80px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.hero-diagram::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.72);
}

.hero-diagram svg {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 94%;
  transform: translate(-50%, -50%);
  overflow: visible;
}

.diagram-rail {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}

.diagram-blue {
  stroke: var(--blue);
  filter: url(#blueGlow);
}

.diagram-red {
  stroke: var(--red);
  filter: url(#redGlow);
}

.diagram-spark {
  fill: white;
  filter: drop-shadow(0 0 10px white);
}

.diagram-spark-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 1;
}

.diagram-core {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 35px;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateY(-50%);
}

.diagram-core::before {
  position: absolute;
  inset: -19px;
  content: "";
  border: 1px dashed currentColor;
  border-radius: 50%;
  opacity: 0.62;
}

.diagram-core-blue {
  left: 22px;
  color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 12px white, 0 0 34px var(--blue), 0 0 80px rgba(69, 184, 255, 0.44);
}

.diagram-core-red {
  right: 22px;
  color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 0 12px white, 0 0 34px var(--red), 0 0 80px rgba(255, 93, 115, 0.44);
}




.lobby-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.lobby-rules article {
  min-height: 140px;
  padding: 28px 30px 30px;
  background: rgba(5, 13, 21, 0.94);
}




.lobby-rules h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.lobby-rules p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.game-view {
  min-height: 100vh;
}

.game-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(132, 181, 216, 0.15);
  background: rgba(3, 9, 15, 0.88);
  backdrop-filter: blur(18px);
}

.compact-wordmark {
  justify-self: start;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.compact-wordmark span:last-child {
  color: var(--red-soft);
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.room-meta strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
}


.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-button,
.icon-button {
  border: 0;
  color: #a8bac8;
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 9px 2px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.text-button:hover,
.icon-button:hover {
  color: white;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.icon-button:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.icon-button svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-off-icon {
  display: none;
}

#mute-button.is-muted .sound-on-icon {
  display: none;
}

#mute-button.is-muted .sound-off-icon {
  display: block;
}





.game-shell {
  width: min(1240px, 100%, calc((100dvh - 220px) * 16 / 9));
  margin: 0 auto;
  padding: 26px 26px 42px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(160px, auto) minmax(190px, 1fr);
  gap: clamp(20px, 7vw, 120px);
  align-items: end;
  margin: 0 4px 20px;
}

.player-hud {
  min-width: 0;
}




.ink-track {
  height: 8px;
  border: 1px solid rgba(132, 181, 216, 0.34);
  border-radius: 999px;
  background: rgba(3, 8, 14, 0.78);
  overflow: hidden;
}

.ink-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 80ms linear;
}

.player-hud-blue .ink-fill {
  background: linear-gradient(90deg, var(--blue), var(--blue-soft));
  box-shadow: 0 0 14px rgba(69, 184, 255, 0.55);
}

.player-hud-red .ink-fill {
  margin-left: auto;
  background: linear-gradient(90deg, var(--red-soft), var(--red));
  box-shadow: 0 0 14px rgba(255, 93, 115, 0.55);
}

.scoreboard {
  min-width: 150px;
  text-align: center;
}

.scores {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 17px;
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1;
}

.scores span:first-child {
  color: var(--blue);
  text-shadow: 0 0 20px rgba(69, 184, 255, 0.4);
}

.scores span:last-child {
  color: var(--red);
  text-shadow: 0 0 20px rgba(255, 93, 115, 0.4);
}

.scores em {
  color: #738794;
  font-size: 1rem;
  font-style: normal;
  font-weight: 400;
}

.scoreboard > span {
  display: block;
  margin-top: 9px;
  color: #8093a2;
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.28em;
}

.arena-frame {
  user-select: none;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(129, 181, 219, 0.24);
  border-radius: var(--radius);
  background: #02080e;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.015);
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
  user-select: none;
}

.arena-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.63);
}

.center-overlay {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  width: min(470px, calc(100% - 42px));
  padding: 27px 30px 29px;
  border: 1px solid rgba(139, 189, 224, 0.27);
  border-radius: 7px;
  background: rgba(4, 12, 20, 0.86);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.5);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.center-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 8px));
}

.center-overlay.is-goal {
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 14px 24px;
}


.overlay-title {
  margin-top: 0;
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 580;
  letter-spacing: -0.025em;
}

.overlay-detail {
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.center-overlay .button {
  margin-top: 20px;
}

.event-banner {
  position: absolute;
  z-index: 7;
  top: 18%;
  left: 50%;
  color: white;
  font-size: clamp(0.85rem, 2vw, 1.35rem);
  font-weight: 750;
  letter-spacing: 0.22em;
  text-shadow: 0 0 22px currentColor;
  opacity: 0;
  transform: translate(-50%, 7px);
  pointer-events: none;
}

.event-banner.is-visible {
  animation: event-in 880ms ease both;
}

.event-banner.is-blue {
  color: var(--blue-soft);
}

.event-banner.is-red {
  color: var(--red-soft);
}

@keyframes event-in {
  0% { opacity: 0; transform: translate(-50%, 9px) scale(0.98); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

.identity-badge,
.spectator-badge {
  position: absolute;
  z-index: 5;
  bottom: 14px;
  left: 14px;
  padding: 8px 10px;
  border: 1px solid rgba(141, 216, 255, 0.26);
  border-radius: 5px;
  color: var(--blue-soft);
  background: rgba(3, 10, 17, 0.72);
  font-size: 0.59rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.identity-badge.is-red {
  left: auto;
  right: 14px;
  border-color: rgba(255, 155, 170, 0.28);
  color: var(--red-soft);
}

.spectator-badge {
  left: 50%;
  color: #d7e1e8;
  transform: translateX(-50%);
}

.portrait-notice {
  display: none;
  position: absolute;
  z-index: 12;
  inset: 0;
  place-items: center;
  padding: 24px;
  color: var(--muted-strong);
  background: rgba(3, 9, 15, 0.94);
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}






kbd {
  display: inline-block;
  min-width: 25px;
  margin-right: 5px;
  padding: 3px 5px;
  border: 1px solid rgba(135, 183, 216, 0.22);
  border-radius: 4px;
  color: #a7bac8;
  background: rgba(13, 27, 40, 0.8);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  line-height: 1;
  text-align: center;
}











.rules-dialog {
  width: min(610px, calc(100% - 34px));
  padding: 0;
  border: 1px solid rgba(139, 189, 224, 0.28);
  border-radius: var(--radius);
  color: var(--text);
  background: #07121c;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72);
}

.rules-dialog::backdrop {
  background: rgba(0, 4, 8, 0.76);
  backdrop-filter: blur(7px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--line);
}


.dialog-header h2 {
  margin: 8px 0 0;
  font-size: 1.55rem;
  font-weight: 560;
  letter-spacing: -0.025em;
}

.dialog-body {
  padding: 10px 26px 22px;
}

.dialog-body p {
  margin: 17px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

.dialog-body strong {
  color: #dfe9ef;
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: rgba(7, 18, 28, 0.96);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.5);
  font-size: 0.76rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .lobby-hero {
    grid-template-columns: 1fr;
    gap: 52px;
  }

  .hero-copy {
    max-width: 740px;
    margin-inline: auto;
    text-align: center;
  }

  .hero-copy > p,
  .join-form {
    margin-inline: auto;
  }

  .primary-actions {
    justify-content: center;
  }

  .hero-diagram {
    min-height: 260px;
  }



}

@media (max-width: 720px) {
  .lobby-view {
    padding: 36px 18px;
  }

  .wordmark {
    font-size: clamp(1.55rem, 8vw, 2.7rem);
    letter-spacing: 0.18em;
    text-indent: 0.18em;
  }


  .hero-copy h1 {
    font-size: clamp(2.35rem, 12vw, 4rem);
  }

  .hero-copy > p {
    font-size: 0.96rem;
    line-height: 1.66;
  }

  .primary-actions {
    display: grid;
  }

  .primary-actions .button {
    width: 100%;
  }

  .hero-diagram {
    min-height: 210px;
  }

  .diagram-core {
    width: 25px;
  }

  .diagram-core::before {
    inset: -13px;
  }


  .lobby-rules {
    grid-template-columns: 1fr;
    margin-top: 52px;
  }

  .lobby-rules article {
    min-height: 0;
  }

  .game-header {
    min-height: 54px;
    padding: 0 13px;
  }

  .compact-wordmark {
    font-size: 0.72rem;
  }

  .header-actions {
    gap: 5px;
  }


  .game-shell {
    padding: 16px 10px 28px;
    width: 100%;
  }

  .hud {
    grid-template-columns: 1fr auto 1fr;
    gap: 13px;
    margin-bottom: 13px;
  }



  .ink-track {
    height: 6px;
  }

  .scoreboard {
    min-width: 92px;
  }

  .scores {
    gap: 9px;
    font-size: 1.42rem;
  }

  .scoreboard > span {
    font-size: 0.48rem;
    letter-spacing: 0.15em;
  }

  .arena-frame {
    border-radius: 5px;
  }

  .center-overlay {
    padding: 20px 17px;
  }

  .overlay-detail {
    font-size: 0.76rem;
  }

  .identity-badge,
  .spectator-badge {
    bottom: 7px;
    left: 7px;
    padding: 5px 7px;
    font-size: 0.46rem;
  }

  .identity-badge.is-red {
    right: 7px;
  }





}

@media (max-width: 720px) and (orientation: portrait) {
  .game-view .arena-frame {
    min-height: 300px;
    aspect-ratio: 16 / 10;
  }

  .portrait-notice {
    display: grid;
  }
}

@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;
  }
}

button:disabled { opacity: 0.55; cursor: default; transform: none; }
.text-button { min-height: 44px; padding-inline: 6px; }
.icon-button { width: 44px; height: 44px; padding: 12px; }
.overlay-detail:empty { display: none; }
.toast { max-width: calc(100vw - 44px); }
@media (max-width: 980px) {
  .game-shell { width: 100%; }
  .lobby-hero { gap: 32px; }
}
@media (max-width: 720px) {
  .compact-wordmark { letter-spacing: 0.06em; font-size: 0.65rem; }
  .header-actions { gap: 0; }
  .room-meta { gap: 0; }
  .room-meta strong { font-size: 0.7rem; letter-spacing: 0.08em; }
  .text-button { font-size: 0.6rem; }
  .wordmark { letter-spacing: 0.08em; }
  .lobby-hero { margin-top: 36px; }
}
@media (max-width: 360px) {
  .game-header { grid-template-columns: 1fr auto; }
  .compact-wordmark { display: none; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .game-header { min-height: 44px; }
  .game-shell { width: min(100%, calc((100dvh - 136px) * 16 / 9 + 20px)); padding: 8px 10px; }
  .hud { grid-template-columns: 1fr auto 1fr; gap: 20px; margin-bottom: 8px; }
  .scores { font-size: 1.3rem; }
  .scoreboard > span { margin-top: 4px; }
  .center-overlay { padding: 12px; }
  .center-overlay .button { margin-top: 10px; }
}

.practice-guide { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding-block: 8px; }
.practice-guide p { margin: 0; color: var(--muted-strong); font-size: 0.85rem; line-height: 1.5; }
.practice-guide .button { flex-shrink: 0; }
@media (max-width: 720px) { .practice-guide { flex-wrap: wrap; } }
@media (max-height: 540px) and (orientation: landscape) {
  .game-shell:has(.practice-guide:not([hidden])) { width: min(100%, calc((100dvh - 160px) * 16 / 9 + 20px)); }
  .practice-guide { gap: 12px; padding-block: 4px; }
  .practice-guide p { font-size: 0.7rem; }
  .practice-guide .button { min-height: 44px; padding: 8px 12px; }
}
