:root {
  --bg: #0e1520;
  --panel: #172232;
  --text: #eef2f6;
  --muted: #93a0b0;
  --line: #2a3a50;
  --yellow: #f0c14a;
  --yellow-ink: #1c1404;
  --red: #e0453a;
  --ok: #8ee0b5;
  --radius: 14px;
  font-family: "SF Pro Text", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at top, #24344c, var(--bg) 55%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.4rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

button, input { font: inherit; color: inherit; touch-action: manipulation; }

.top { text-align: center; margin-bottom: 0.9rem; }
.top h1 { margin: 0; font-size: 1.8rem; letter-spacing: 0.02em; }
.tagline { margin: 0.3rem 0 0; color: var(--muted); }
.top-links { margin: 0.45rem 0 0; }
.help-link { color: var(--yellow); text-decoration: none; }
.help-link:hover { text-decoration: underline; }

.panel {
  width: min(440px, 100%);
  background: rgba(23, 34, 50, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.help-page .panel { width: min(680px, 100%); }
.help-page nav { width: min(680px, 100%); margin: 0 0 0.6rem; }
.help-page nav a { color: var(--yellow); text-decoration: none; }
.doc h1 { font-size: 1.4rem; }
.doc h2 { font-size: 1.1rem; margin-top: 1.3rem; }
.doc p, .doc li { color: #d5dde6; line-height: 1.45; }
.doc code { font-size: 0.92em; }
.doc-table { width: 100%; border-collapse: collapse; margin: 0.6rem 0 1rem; }
.doc-table th, .doc-table td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field span, .label {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
input[type="text"] {
  width: 100%;
  background: #0e1724;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.8rem;
  font-size: 1rem;
}
input:focus { outline: 2px solid rgba(240, 193, 74, 0.55); border-color: transparent; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
button {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
  background: #24344a;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--yellow); color: var(--yellow-ink); font-weight: 650; }
button.ghost { background: transparent; border: 1px solid var(--line); }

.sep { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.muted { color: var(--muted); }
.hint { color: #d5dde6; min-height: 1.3em; }
.flash {
  background: #243044;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin: 0 0 0.8rem;
}

.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.code { margin: 0.1rem 0 0; font-size: 1.6rem; letter-spacing: 0.14em; font-weight: 700; }

.open-rooms, .seats { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.open-rooms li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  background: #101a28;
  border: 1px solid rgba(240, 193, 74, 0.45);
  border-radius: 12px;
}
.offer-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.offer-host { font-weight: 650; }
.offer-meta { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em; }
.room-link, .seat {
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  background: #101a28;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.room-meta, .seat-meta { color: var(--muted); font-size: 0.85rem; }
.seat.you { outline: 1px solid rgba(240, 193, 74, 0.45); }
.seat-main { display: flex; align-items: center; gap: 0.5rem; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.player {
  background: #101a28;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  min-width: 0;
}
.player.on { border-color: rgba(240, 193, 74, 0.8); }
.player-line { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.player-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-meta { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; flex: none; }
.dot.y { background: var(--yellow); box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }
.dot.r { background: var(--red); box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); }

.turn {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 650;
  margin: 0.75rem 0 0.65rem;
  min-height: 1.4em;
}
.turn.win { color: var(--ok); }
.turn.lose { color: #ffb1ab; }
.turn.draw { color: var(--yellow); }

.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  padding: 8px 8px 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.22), transparent 26%),
    linear-gradient(180deg, #2d68cc, #173e86 70%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.3), 0 12px 24px rgba(0,0,0,.35);
}

.col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.col:disabled { cursor: default; }
.col:not(:disabled):hover { filter: brightness(1.05); }

.ghost { height: 18px; display: grid; place-items: center; }
.ghost i {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: block;
  opacity: 0;
}
.ghost i.y { background: var(--yellow); }
.ghost i.r { background: var(--red); }
.col:not(:disabled):hover .ghost i,
.col:not(:disabled):focus-visible .ghost i { opacity: 0.9; }

.hole {
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #0b1422 42%, #050910 74%);
  box-shadow: inset 0 5px 7px rgba(0,0,0,.7), 0 1px 0 rgba(255,255,255,.2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.hole.last { box-shadow: inset 0 0 0 2px rgba(255,255,255,.7), inset 0 5px 7px rgba(0,0,0,.45); }
.hole.win { box-shadow: inset 0 0 0 3px #fff, 0 0 10px rgba(255,255,255,.45); }

.disc { width: 86%; height: 86%; border-radius: 50%; display: block; }
.disc.y {
  background: radial-gradient(circle at 35% 30%, #fff3b0, #f0c14a 42%, #b8860b);
  box-shadow: inset 0 -3px 4px rgba(0,0,0,.25);
}
.disc.r {
  background: radial-gradient(circle at 35% 30%, #ffc2bb, #e0453a 46%, #9d261e);
  box-shadow: inset 0 -3px 4px rgba(0,0,0,.25);
}
.disc.drop { animation: fall var(--dur, 0.35s) cubic-bezier(.2, .75, .2, 1); }

@keyframes fall {
  from { transform: translateY(calc(-1 * var(--fall, 80px))); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .disc.drop { animation: none; }
}
