:root {
  color-scheme: dark;

  --bg: #101c19;
  --panel: #1b2925;
  --line: #34463d;
  --text: #f3f0e6;
  --muted: #a8b6ac;
  --gold: #e5bf79;
  --green: #94c8a3;

  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(ellipse at 15% 65%, #23493955, transparent 52%);
}

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

button,
input {
  font: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}

.lobby-shell {
  max-width: 1240px;
  margin: auto;
  padding: 0 56px;
}

.topbar {
  height: 112px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ffffff0d;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 15px;
  letter-spacing: 3px;
  font-weight: 650;
}

.brand-symbol {
  font-size: 41px;
  letter-spacing: -6px;
  line-height: 1;
  font-family: Georgia, serif;
}

.brand-symbol span {
  color: var(--gold);
}

.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 2.3px;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 400;
}

.quiet-link {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0 12px 12px;
}

.quiet-link span {
  color: var(--gold);
  margin-left: 10px;
}

.quiet-link:hover {
  color: var(--text);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 470px;
  gap: 54px;
  align-items: center;
  padding: 64px 0 60px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--gold);
}

.welcome > .eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 24px;
}

.tiny-line {
  width: 26px;
  height: 1px;
  background: var(--gold);
}

h1 {
  font-size: clamp(44px, 5vw, 66px);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 0;
}

.gold {
  color: var(--gold);
}

.intro {
  margin: 23px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: 1px;
}

.table-scene {
  height: 230px;
  position: relative;
  margin: 8px -15px 0 -25px;
  overflow: hidden;
  isolation: isolate;
}

.table-glow {
  position: absolute;
  width: 330px;
  height: 150px;
  left: 15%;
  top: 25%;
  background: #408e6433;
  filter: blur(45px);
  border-radius: 50%;
}

.table-surface {
  position: absolute;
  width: 420px;
  height: 200px;
  top: 28px;
  left: -5px;
  transform: rotate(-19deg) skewX(15deg);
  border: 9px solid #354b3c;
  border-radius: 28px;
  background:
    repeating-linear-gradient(0deg, #2c5c4607, #2c5c4607 2px, #00000008 3px),
    linear-gradient(140deg, #245e43, #183e30);
  box-shadow:
    0 10px 0 #1d2b23,
    0 22px 35px #0006,
    inset 0 0 0 3px #0c2d23,
    inset 0 0 35px #0005;
}

.table-mark {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c9b98a;
  top: -6px;
}

.mark-one {
  left: 20%;
}

.mark-two {
  left: 50%;
}

.mark-three {
  left: 80%;
}

.ball {
  position: absolute;
  border-radius: 50%;
  box-shadow: 9px 16px 12px #0006;
  display: grid;
  place-items: center;
}

.ball::after {
  content: "";
  position: absolute;
  inset: 6% 10% 55% 16%;
  background: radial-gradient(ellipse at 30% 40%, #ffffffa8, transparent 70%);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.ball span {
  background: #f5f0df;
  border-radius: 50%;
  width: 37%;
  height: 37%;
  color: #272925;
  display: grid;
  place-items: center;
  font:
    bold 20px Georgia,
    serif;
  box-shadow: inset -2px -2px 5px #0002;
  transform: rotate(-22deg);
}

.ball-eight {
  width: 99px;
  height: 99px;
  left: 48%;
  top: 55px;
  background: radial-gradient(
    circle at 35% 22%,
    #535a52,
    #141a15 58%,
    #070e0a 90%
  );
}

.ball-nine {
  width: 78px;
  height: 78px;
  left: 32%;
  top: 102px;
  background:
    radial-gradient(circle at 30% 25%, #ffffff48, transparent 70%),
    linear-gradient(160deg, #eae7d9 0% 24%, #d3a333 26% 75%, #eae7d9 77%);
}

.ball-white {
  width: 46px;
  height: 46px;
  left: 17%;
  top: 80px;
  background: radial-gradient(circle at 28% 22%, #fffdf4, #ded8c4 65%, #999f88);
}

.cue-stick {
  position: absolute;
  height: 5px;
  width: 215px;
  top: 130px;
  left: -92px;
  transform: rotate(-29deg);
  border-radius: 3px;
  background: linear-gradient(90deg, #55422c, #c8a975 90%, #a2c4bb 95%);
  box-shadow: 3px 8px 7px #0005;
}

.scene-label {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 8px;
  letter-spacing: 2px;
  color: #8aa695;
}

.features {
  display: flex;
  gap: 25px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.features span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.features i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #759780;
}

.room-card {
  padding: 31px;
  border: 1px solid #3d4d3e;
  border-radius: 22px;
  background: linear-gradient(135deg, #24322b, #192722);
  box-shadow:
    0 24px 65px #0002,
    inset 0 1px 0 #ffffff06;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-index {
  font-size: 10px;
  color: #788d7e;
  letter-spacing: 2px;
}

h2 {
  font-size: 23px;
  font-weight: 550;
  letter-spacing: 0.3px;
  margin: 14px 0 24px;
}

.tabs {
  display: flex;
  padding: 5px;
  gap: 5px;
  border-radius: 10px;
  background: #101d17;
  margin-bottom: 24px;
}

.tabs button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  background: #34483a;
  box-shadow: 0 2px 7px #0002;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 10px;
}

.field-label span {
  color: #94a393;
  font-size: 10px;
}

input[type="text"] {
  width: 100%;
  height: 48px;
  border: 1px solid #405041;
  border-radius: 9px;
  background: #17251e;
  padding: 0 15px;
  color: var(--text);
  font-size: 14px;
}

input::placeholder {
  color: #849688;
}

input[type="text"]:focus {
  border-color: var(--gold);
}

fieldset {
  padding: 0;
  border: 0;
  margin: 23px 0 0;
}

legend {
  padding: 0;
  font-size: 12px;
  margin-bottom: 12px;
}

.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.transport-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.transport-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid #405041;
  border-radius: 10px;
  cursor: pointer;
}

.transport-option:has(input:checked) {
  border-color: var(--gold);
  background: #a8904c13;
}

.transport-option input {
  margin: 0;
  accent-color: var(--gold);
}

.transport-option strong,
.transport-option small {
  display: block;
}

.transport-option strong {
  font-size: 13px;
  font-weight: 500;
}

.transport-option small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.rule-option {
  display: flex;
  position: relative;
  align-items: center;
  gap: 10px;
  min-height: 81px;
  padding: 12px 9px;
  border: 1px solid #405041;
  border-radius: 10px;
  cursor: pointer;
  background: #17271f55;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.rule-option:hover {
  background: #344b3655;
}

.rule-option:has(input:checked) {
  border-color: var(--gold);
  background: #a8904c13;
}

.rule-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rule-option:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.rule-option strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.rule-option small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-top: 7px;
  white-space: nowrap;
}

.rule-ball {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font:
    bold 12px Georgia,
    serif;
  box-shadow:
    inset -3px -4px 6px #0005,
    0 3px 5px #0002;
}

.yellow {
  background: linear-gradient(
    0deg,
    #e7d9ae 0% 22%,
    #dbb758 24% 78%,
    #f3e9c9 80%
  );
  color: #3c301c;
}

.black {
  background: radial-gradient(circle at 30% 20%, #6c7169, #171b17 65%);
  color: #fff;
}

.red {
  background: radial-gradient(circle at 30% 20%, #e89788, #9f433b 65%);
}

.ivory {
  background: radial-gradient(circle at 30% 20%, #fff9e6, #ccc4a5 70%);
}

.check {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 10px;
  height: 10px;
  border: 1px solid #59705c;
  border-radius: 50%;
}

.rule-option:has(input:checked) .check {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px #2a3527;
}

.primary {
  display: block;
  width: 100%;
  min-height: 49px;
  border: 1px solid #ead29b;
  border-radius: 9px;
  background: linear-gradient(110deg, #efd59d, #d9b36d);
  color: #283124;
  font-size: 14px;
  font-weight: 650;
  margin-top: 25px;
  transition:
    filter 0.15s,
    transform 0.15s;
}

.primary:hover {
  filter: brightness(1.07);
}

.primary:active {
  transform: translateY(1px);
}

.card-note {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  margin: 14px 0 0;
}

.connection-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 23px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
}

.connection-icon {
  color: var(--green);
  font-size: 20px;
}

.connection-note p {
  margin: 0;
  font-size: 10px;
  line-height: 1.8;
  color: var(--muted);
}

#feedback {
  font-size: 12px;
  line-height: 1.8;
  color: var(--green);
  overflow-wrap: anywhere;
  margin: 0;
}

#feedback:not(:empty) {
  margin-top: 16px;
}

#feedback.error {
  color: #f3b9a7;
}

#code-field {
  margin-top: 23px;
}

#room-code {
  letter-spacing: 3px;
  font-family: "Segoe UI", monospace;
}

.helper {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  margin: 12px 0 0;
}

.rule-tag {
  font-size: 11px;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
}

#room-panel h2 {
  margin: 12px 0;
  text-align: center;
}

#room-detail {
  min-height: 44px;
  text-align: center;
}

.waiting-orbit {
  width: 78px;
  height: 78px;
  margin: 23px auto 15px;
  position: relative;
  display: grid;
  place-items: center;
}

.orbit-ball {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 22%, #fff9e6, #bcbda0);
  box-shadow: 0 9px 17px #0004;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border: 1px solid #64765a;
  border-radius: 50%;
}

.orbit-ring::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  top: 2px;
  left: 16px;
}

.invitation {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 10px;
  border: 1px dashed #5a6c52;
  border-radius: 12px;
  margin-top: 21px;
  background: #12201877;
}

.invitation > span {
  font-size: 11px;
  color: var(--muted);
}

.invitation strong {
  font-size: 29px;
  letter-spacing: 6px;
  color: var(--gold);
  margin: 11px 0 7px;
  font-variant-numeric: tabular-nums;
}

.invitation button {
  background: none;
  color: var(--muted);
  border: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  min-height: 38px;
  font-size: 11px;
}

.players {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.players > div {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.players strong {
  display: block;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}

.players small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: #40563d;
  color: var(--gold);
  border-radius: 50%;
  font-size: 11px;
}

.avatar.friend {
  background: #2c3b30;
  color: var(--muted);
}

.versus {
  color: #778874;
  font-size: 10px;
  letter-spacing: 1px;
}

.secondary {
  display: block;
  width: 100%;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  min-height: 44px;
  margin-top: 7px;
}

.footer {
  padding: 24px 0 29px;
  border-top: 1px solid #ffffff0d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #91a394;
  font-size: 10px;
}

.footer nav {
  display: flex;
  gap: 17px;
}

.footer a:hover {
  color: var(--text);
}

.noscript {
  color: var(--gold);
  padding: 20px;
}

#game-stage {
  display: none;
}

.playing .lobby-shell {
  display: none;
}

.playing #game-stage {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 6px 18px;
  background: #16271f;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.game-bar > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-bar button {
  margin-left: auto;
  border: 1px solid #5a6c52;
  color: var(--text);
  background: transparent;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 12px;
}

.direct-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  white-space: nowrap;
  font-size: 10px;
}

.direct-badge i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

#game-frame {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 0;
  background: #101c19;
}

@media (width <= 1000px) {
  .lobby-shell {
    padding: 0 30px;
  }

  .main-grid {
    grid-template-columns: 1fr 430px;
    gap: 25px;
  }

  .room-card {
    padding: 26px;
  }

  .table-scene {
    margin-left: -30px;
  }

  .features {
    gap: 14px;
    font-size: 10px;
  }
}

@media (width <= 780px) {
  .lobby-shell {
    max-width: 560px;
    padding: 0 22px;
  }

  .topbar {
    height: 83px;
  }

  .main-grid {
    grid-template-columns: 1fr;
    padding: 35px 0;
    gap: 30px;
  }

  .welcome {
    position: relative;
  }

  .welcome > .eyebrow {
    margin-bottom: 16px;
    font-size: 8px;
  }

  h1 {
    font-size: 44px;
  }

  .intro {
    font-size: 12px;
    margin-top: 14px;
  }

  .table-scene {
    position: absolute;
    width: 210px;
    right: -18px;
    top: 36px;
    height: 190px;
    margin: 0;
    transform: scale(0.75);
    transform-origin: right center;
    pointer-events: none;
    opacity: 0.9;
  }

  .table-surface {
    left: -125px;
  }

  .ball-eight {
    left: 38%;
  }

  .ball-nine {
    left: 11%;
  }

  .ball-white {
    left: -8%;
  }

  .scene-label {
    display: none;
  }

  .features {
    margin-top: 23px;
    font-size: 11px;
    gap: 23px;
  }

  .room-card {
    border-radius: 17px;
    padding: 25px;
  }

  .footer {
    align-items: flex-start;
    gap: 14px;
    line-height: 1.8;
  }

  .footer nav {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 12px;
    max-width: 210px;
  }
}

@media (width <= 390px) {
  .lobby-shell {
    padding: 0 15px;
  }

  .room-card {
    padding: 20px;
  }

  h2 {
    font-size: 20px;
  }

  .rule-option {
    gap: 7px;
    padding: 12px 7px;
  }

  .rule-option small {
    font-size: 8px;
  }

  .rule-ball {
    flex-basis: 24px;
    height: 24px;
  }

  .direct-badge {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
