@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #9298b7;
  --surface: rgba(14, 18, 38, 0.84);
  --surface-solid: #10152b;
  --line: rgba(157, 166, 218, 0.16);
  --yellow: #ffd84d;
  --cyan: #48e4f2;
  --blue: #6b63ff;
  --pink: #ff4f8b;
  --radius: 24px;
  font-family: "Outfit", "Noto Sans SC", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #070912;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(78, 69, 221, 0.28), transparent 45%),
    linear-gradient(145deg, #090b16 0%, #060810 55%, #0a0d1c 100%);
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(72, 228, 242, 0.65);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.orb {
  position: fixed;
  z-index: -2;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.13;
  pointer-events: none;
}

.orb-one {
  top: -160px;
  left: -180px;
  background: var(--blue);
}

.orb-two {
  right: -200px;
  bottom: -180px;
  background: var(--pink);
}

.landing-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.landing-card {
  width: min(100%, 520px);
  position: relative;
  padding: clamp(28px, 6vw, 52px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.06), transparent 38%),
    var(--surface);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px);
}

.landing-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(rgba(122, 130, 196, 0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(122, 130, 196, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  margin-bottom: 18px;
}

.brand-mouth {
  width: 54px;
  height: 54px;
  display: block;
  border-radius: 50%;
  background: conic-gradient(from 42deg, transparent 0 22%, var(--yellow) 22% 100%);
  filter: drop-shadow(0 0 18px rgba(255, 216, 77, 0.28));
  animation: chomp 0.6s ease-in-out infinite alternate;
}

.brand-mark i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #faf0a1;
  box-shadow: 0 0 12px rgba(255, 216, 77, 0.6);
}

.brand-mark i:nth-of-type(2) { opacity: 0.7; }
.brand-mark i:nth-of-type(3) { opacity: 0.4; }

@keyframes chomp {
  from { clip-path: polygon(0 0, 100% 0, 58% 50%, 100% 100%, 0 100%); }
  to { clip-path: polygon(0 0, 100% 0, 98% 50%, 100% 100%, 0 100%); }
}

.eyebrow,
.control-label {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  font-size: clamp(2.9rem, 10vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.08em;
}

h1 span {
  color: var(--yellow);
  text-shadow: 0 0 28px rgba(255, 216, 77, 0.24);
}

.intro {
  max-width: 410px;
  margin: 18px 0 28px;
  color: #a9aec8;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.94rem;
  line-height: 1.75;
}

.field-label {
  display: block;
  margin: 0 0 8px 2px;
  color: #c3c7da;
  font-size: 0.78rem;
  font-weight: 600;
}

.text-input,
.room-input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(4, 7, 18, 0.54);
  transition: border-color 160ms ease, background 160ms ease;
}

.text-input {
  padding: 0 16px;
  margin-bottom: 12px;
}

.text-input:focus,
.room-input:focus {
  border-color: rgba(72, 228, 242, 0.65);
  background: rgba(7, 11, 27, 0.88);
}

.primary-button,
.secondary-button,
.icon-button,
.room-badge,
.direction {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 15px;
  color: #141100;
  background: var(--yellow);
  box-shadow: 0 10px 30px rgba(255, 216, 77, 0.13);
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(255, 216, 77, 0.22);
}

.primary-button:active,
.secondary-button:active,
.direction:active {
  transform: translateY(1px) scale(0.98);
}

.primary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 21px 0 14px;
  color: #737995;
  font-size: 0.72rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

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

.room-input {
  padding: 0 14px;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.secondary-button {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.secondary-button:hover {
  border-color: rgba(72, 228, 242, 0.45);
  background: rgba(72, 228, 242, 0.09);
}

.form-message {
  min-height: 18px;
  margin: 9px 0 0;
  color: #ff879f;
  font-size: 0.76rem;
  text-align: center;
}

.feature-strip {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 4vw, 25px);
  margin-top: 20px;
  color: #777e9b;
  font-size: 0.71rem;
}

.feature-strip b {
  color: var(--cyan);
}

.game-shell {
  width: min(100%, 1160px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(14px, 3vw, 32px) max(24px, env(safe-area-inset-bottom));
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.mini-brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.04em;
}

.mini-pac {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(from 42deg, transparent 0 23%, var(--yellow) 23% 100%);
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
}

.connection i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f6aa52;
  box-shadow: 0 0 10px currentColor;
}

.connection.online i { background: #59e899; }
.connection.offline i { background: #ff6382; }

.room-badge,
.icon-button {
  height: 39px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.room-badge {
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.72rem;
}

.room-badge strong {
  margin: 0 5px;
  color: var(--yellow);
  letter-spacing: 0.12em;
}

.room-badge svg,
.icon-button svg {
  width: 15px;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.icon-button {
  width: 39px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.player-card,
.clock-card {
  min-height: 70px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(14, 18, 38, 0.72);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}

.player-card {
  position: relative;
  gap: 11px;
  padding: 10px 14px;
  overflow: hidden;
}

.player-card::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: currentColor;
  opacity: 0.8;
}

.player-yellow { color: var(--yellow); }
.player-cyan { color: var(--cyan); }
.player-card.me { box-shadow: inset 0 0 20px color-mix(in srgb, currentColor 10%, transparent); }
.player-card.disconnected { opacity: 0.46; }

.player-token {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  border-radius: 12px;
  background: color-mix(in srgb, currentColor 9%, transparent);
  font-size: 0.7rem;
  font-weight: 800;
}

.player-card > div:nth-child(2) {
  min-width: 0;
  display: grid;
}

.player-card span:not(.lives) {
  overflow: hidden;
  color: #b2b7ce;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card strong {
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.1;
}

.lives {
  margin-left: auto;
  color: currentColor;
  font-size: 0.58rem;
  letter-spacing: 2px;
  white-space: nowrap;
}

.clock-card {
  display: grid;
  place-content: center;
  text-align: center;
}

.clock-card span {
  color: var(--muted);
  font-size: 0.61rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.clock-card strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.28rem;
}

.arena-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
  gap: 16px;
  align-items: start;
}

.board-wrap {
  width: 100%;
  position: relative;
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid rgba(106, 99, 255, 0.32);
  border-radius: 24px;
  background: rgba(3, 5, 14, 0.8);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4), inset 0 0 45px rgba(58, 50, 166, 0.09);
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
  touch-action: none;
}

.game-overlay {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(3, 5, 14, 0.63);
  backdrop-filter: blur(7px);
  transition: opacity 180ms ease;
}

.game-overlay.clear {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(86%, 380px);
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 22px;
  background: rgba(13, 17, 36, 0.94);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.overlay-card > span {
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.overlay-card > strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
}

.overlay-card > p {
  margin: 10px auto 20px;
  color: var(--muted);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 0.78rem;
  line-height: 1.65;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.compact {
  width: auto;
  min-width: 118px;
  min-height: 43px;
  height: 43px;
  padding: 0 17px;
}

.control-panel {
  display: grid;
  gap: 17px;
  justify-items: center;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(14, 18, 38, 0.58);
}

.control-label {
  text-align: center;
  color: #8b92ad;
}

.dpad {
  width: 180px;
  height: 180px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 5px;
}

.direction,
.dpad-center {
  display: grid;
  place-items: center;
  background: #171d39;
}

.direction {
  border: 1px solid rgba(166, 174, 224, 0.13);
  color: #dfe2f4;
  font-size: 1.2rem;
  transition: color 100ms ease, background 100ms ease, transform 100ms ease;
}

.direction:active,
.direction.active {
  color: #111300;
  background: var(--yellow);
}

.direction.up { grid-area: 1 / 2; border-radius: 14px 14px 6px 6px; }
.direction.left { grid-area: 2 / 1; border-radius: 14px 6px 6px 14px; }
.direction.right { grid-area: 2 / 3; border-radius: 6px 14px 14px 6px; }
.direction.down { grid-area: 3 / 2; border-radius: 6px 6px 14px 14px; }
.dpad-center { grid-area: 2 / 2; border-radius: 9px; }

.dpad-center i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #343b5d;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1);
}

.tips-card {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(2, 5, 14, 0.32);
}

.tips-card p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
  color: #aeb3ca;
  font-size: 0.68rem;
}

.tips-card strong {
  margin-left: auto;
  color: #f6f7ff;
}

.tips-card small {
  display: block;
  margin-top: 11px;
  color: #666d88;
  font-size: 0.61rem;
  text-align: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pellet-dot { background: #f8e7a3; box-shadow: 0 0 7px #f8e7a3; }
.power-dot { width: 12px; height: 12px; background: var(--yellow); box-shadow: 0 0 9px var(--yellow); }
.ghost-mini { color: #698bff; font-size: 1rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #eef0ff;
  background: rgba(15, 19, 40, 0.94);
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.42);
  font-size: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  .game-shell { padding-inline: 10px; }
  .mini-brand strong { display: none; }
  .connection { display: none; }
  .game-header { margin-bottom: 10px; }
  .hud { grid-template-columns: 1fr 82px 1fr; gap: 6px; }
  .player-card { min-height: 59px; padding: 7px 8px; gap: 7px; }
  .player-token { width: 30px; height: 30px; border-radius: 9px; font-size: 0.58rem; }
  .player-card strong { font-size: 1rem; }
  .player-card span:not(.lives) { font-size: 0.63rem; }
  .lives { position: absolute; right: 7px; bottom: 5px; font-size: 0.46rem; }
  .clock-card { min-height: 59px; }
  .clock-card strong { font-size: 1rem; }
  .arena-layout { grid-template-columns: 1fr; gap: 10px; }
  .board-wrap { padding: 6px; border-radius: 18px; }
  .game-overlay { inset: 6px; }
  .control-panel { display: flex; justify-content: space-around; align-items: center; padding: 10px; }
  .dpad { width: min(38vw, 148px); height: min(38vw, 148px); }
  .tips-card { width: min(45%, 190px); }
  .direction { font-size: 1rem; }
}

@media (max-width: 420px) {
  .landing-card { border-radius: 25px; }
  .feature-strip { gap: 10px; font-size: 0.64rem; }
  .room-badge { padding: 0 8px; }
  .icon-button { width: 36px; }
  .control-panel { padding: 8px; }
  .tips-card { padding: 8px; }
  .tips-card p { margin: 4px 0; font-size: 0.59rem; }
  .tips-card small { margin-top: 7px; font-size: 0.55rem; }
}

@media (max-height: 720px) and (orientation: landscape) {
  .game-shell { width: min(100%, 980px); padding-block: 8px; }
  .game-header { margin-bottom: 6px; }
  .hud { margin-bottom: 6px; }
  .player-card, .clock-card { min-height: 50px; }
  .arena-layout { grid-template-columns: minmax(0, calc(100dvh - 140px)) 190px; justify-content: center; }
  .control-panel { padding: 10px; }
  .dpad { width: 145px; height: 145px; }
}

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