:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #f6f7fb;
  background: #090c14;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #090c14;
  background-size: 42px 42px;
}

button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .17;
  pointer-events: none;
}
.ambient-one { top: -240px; left: -180px; background: #725cff; }
.ambient-two { right: -260px; bottom: -250px; background: #18c89b; }

.shell {
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.075);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 760;
  cursor: pointer;
}
.brand b { color: #7c6cf3; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #8877ff, #5947e1);
  box-shadow: 0 10px 28px rgba(105,85,235,.32);
}

.connection { display: flex; align-items: center; gap: 8px; color: #919bae; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #e8b044; box-shadow: 0 0 10px currentColor; }
.connection.connected .status-dot { background: #42d3a7; }
.connection.disconnected .status-dot { background: #f16f85; }

.home-view {
  align-self: center;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(48px, 8vw, 110px);
  align-items: center;
  padding: 68px 0;
}
.eyebrow, .card-kicker { color: #8e80ff; font-size: 12px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 17px 0 24px; font-size: clamp(52px, 7.4vw, 84px); line-height: 1.02; letter-spacing: -.06em; }
h1 span { color: transparent; background: linear-gradient(100deg,#a092ff,#51e3bd); background-clip: text; -webkit-background-clip: text; }
.intro { max-width: 570px; margin: 0; color: #9ba5b8; font-size: 18px; line-height: 1.8; }

.join-card, .lobby-panel, .game-panel, .result-panel, .summary-panel {
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 24px;
  background: rgba(17,22,35,.86);
  box-shadow: 0 28px 80px rgba(0,0,0,.32);
  backdrop-filter: blur(18px);
}
.join-card { padding: 31px; }
.join-card label, .setting-item > label { display: block; margin: 24px 0 9px; color: #c8ceda; font-size: 13px; font-weight: 700; }
.input-wrap { display: flex; border: 1px solid #30384a; border-radius: 13px; background: #0b0f19; transition: border-color .2s, box-shadow .2s; }
.input-wrap:focus-within { border-color: #7564ef; box-shadow: 0 0 0 3px rgba(117,100,239,.14); }
.input-wrap input { width: 100%; min-width: 0; height: 54px; padding: 0 16px; border: 0; outline: 0; background: transparent; color: #fff; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.icon-button { width: 50px; border: 0; background: transparent; color: #8e98aa; cursor: pointer; font-size: 20px; }

.primary { min-height: 52px; border: 0; border-radius: 13px; background: linear-gradient(135deg,#7968f2,#604de4); font-weight: 800; cursor: pointer; box-shadow: 0 12px 30px rgba(91,72,219,.25); }
.primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.primary:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.wide { width: 100%; }
.join-card .primary { margin-top: 15px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; }
.form-hint { margin: 14px 0 0; text-align: center; color: #6f798b; font-size: 12px; }
.form-error { min-height: 18px; margin: 7px 0 -8px; color: #ff8799; font-size: 12px; text-align: center; }
.feature-row { grid-column: 1 / -1; display: flex; justify-content: center; gap: 34px; color: #687387; font-size: 13px; }

.room-view { padding: 34px 0 58px; }
.room-toolbar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 28px; }
.muted-label { display: block; margin-bottom: 5px; color: #6f798c; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.room-code { display: flex; gap: 10px; align-items: baseline; padding: 0; border: 0; background: none; cursor: pointer; }
.room-code strong { font-size: 26px; letter-spacing: .07em; }
.room-code span { color: #796bf0; font-size: 12px; }
.quiet-button, .danger-button { padding: 9px 14px; border: 1px solid #2b3343; border-radius: 10px; background: #121824; color: #a8b1c1; cursor: pointer; }
.danger-button { color: #ff8da0; border-color: rgba(245,94,118,.3); background: rgba(245,94,118,.07); }

.scoreboard { display: grid; grid-template-columns: 1fr 90px 1fr; align-items: center; margin-bottom: 24px; }
.player-card { min-height: 104px; display: flex; align-items: center; gap: 15px; padding: 18px 22px; border: 1px solid rgba(255,255,255,.075); background: rgba(17,23,36,.7); }
.self-card { border-radius: 18px 0 0 18px; }
.opponent-card { justify-content: flex-end; border-radius: 0 18px 18px 0; text-align: right; }
.player-avatar { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 15px; background: rgba(117,99,238,.18); color: #ad9fff; font-weight: 850; }
.opponent-avatar { background: rgba(42,199,158,.14); color: #5adeba; }
.player-label { display: block; font-weight: 800; }
.player-card small { display: block; margin-top: 4px; color: #717c90; }
.score { margin-left: auto; font-size: 42px; line-height: 1; }
.opponent-card .score { margin: 0 auto 0 0; }
.versus { height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-block: 1px solid rgba(255,255,255,.075); background: rgba(12,16,26,.8); }
.versus span { font-weight: 900; color: #657085; }
.versus small { margin-top: 7px; color: #919bad; white-space: nowrap; font-size: 10px; }

.notice { margin: 0 0 18px; padding: 12px 16px; border: 1px solid rgba(242,178,64,.25); border-radius: 12px; color: #e9bd6a; background: rgba(242,178,64,.07); font-size: 13px; }
.lobby-panel { width: min(900px,100%); }
.game-panel, .result-panel, .summary-panel { width: min(760px,100%); }
.lobby-panel, .game-panel, .result-panel, .summary-panel { margin: 0 auto; padding: 30px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; }
.panel-heading h2 { margin: 7px 0 0; font-size: 28px; }
.host-badge { padding: 6px 10px; border: 1px solid rgba(117,100,239,.35); border-radius: 999px; color: #a89cff; background: rgba(117,100,239,.1); font-size: 11px; }
.seat-stage { margin: 26px 0; padding: 18px; border: 1px solid rgba(255,255,255,.07); border-radius: 18px; background: rgba(8,12,20,.52); }
.battle-seats { display: grid; grid-template-columns: 1fr 54px 1fr; align-items: center; }
.seat-versus { color: #606b7e; text-align: center; font-size: 12px; font-weight: 900; }
.seat { min-width: 0; display: flex; align-items: center; gap: 11px; border: 1px dashed #344055; border-radius: 14px; background: rgba(18,25,39,.7); color: #9aa5b6; cursor: pointer; text-align: left; transition: .16s; }
.seat:hover { border-color: #7363e7; transform: translateY(-1px); }
.seat.occupied { border-style: solid; border-color: #303a4d; color: #eef0f5; }
.seat.is-self { border-color: #7d6cf2; background: rgba(113,94,231,.14); box-shadow: inset 0 0 0 1px rgba(125,108,242,.35); }
.player-seat { min-height: 72px; padding: 12px 15px; }
.spectator-heading { display: flex; justify-content: space-between; align-items: baseline; margin: 19px 1px 10px; color: #aab2c1; font-size: 12px; font-weight: 750; }
.spectator-heading small { color: #606b7e; font-size: 10px; font-weight: 500; }
.spectator-seats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.spectator-seat { min-height: 58px; padding: 9px 11px; }
.seat-avatar, .seat-plus { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: #20293a; color: #978aff; font-size: 11px; font-weight: 850; }
.seat-plus { background: transparent; border: 1px dashed #3a465a; color: #68758a; font-size: 17px; }
.seat strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.seat small { margin-left: auto; color: #667287; white-space: nowrap; font-size: 9px; }
.settings-title { margin: 4px 0 -12px; color: #6d788b; font-size: 11px; font-weight: 750; letter-spacing: .12em; }
.ready-panel, .summary-ready { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 20px; padding: 13px 15px; border: 1px solid rgba(255,255,255,.075); border-radius: 14px; background: rgba(10,14,23,.58); }
.ready-statuses { display: flex; flex-wrap: wrap; gap: 8px; }
.ready-statuses span { padding: 5px 8px; border-radius: 8px; background: #1a2231; color: #7e899c; font-size: 10px; }
.ready-statuses span.ready { background: rgba(54,202,158,.11); color: #62dbb8; }
.ready-button { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid #6959df; border-radius: 10px; background: rgba(105,89,223,.14); color: #ab9fff; cursor: pointer; font-size: 12px; font-weight: 800; }
.ready-button.is-ready { border-color: rgba(66,211,167,.45); background: rgba(66,211,167,.1); color: #69ddba; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.setting-item { padding: 0 18px 18px; border: 1px solid rgba(255,255,255,.07); border-radius: 16px; background: rgba(8,12,20,.5); }
.number-control { display: flex; align-items: center; border: 1px solid #2c3546; border-radius: 11px; overflow: hidden; background: #0a0e17; }
.number-control input { width: 100%; min-width: 0; height: 45px; padding: 0 12px; border: 0; outline: 0; background: transparent; color: white; font-weight: 800; }
.number-control span { padding-right: 13px; color: #707b8d; font-size: 12px; }
.toggle { display: flex !important; align-items: center; gap: 8px; margin: 13px 0 0 !important; color: #8d97a8 !important; cursor: pointer; font-weight: 500 !important; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 30px; height: 17px; padding: 2px; border-radius: 999px; background: #30384a; transition: .2s; }
.toggle span::after { content: ""; display: block; width: 13px; height: 13px; border-radius: 50%; background: white; transition: .2s; }
.toggle input:checked + span { background: #6f5ee9; }
.toggle input:checked + span::after { transform: translateX(13px); }
.setting-item small { display: block; margin-top: 14px; color: #697487; font-size: 11px; }
.start-button { margin-top: 18px; }
.guest-wait { min-height: 220px; display: grid; place-items: center; align-content: center; color: #919bad; }
.waiting-ring { width: 34px; height: 34px; border: 3px solid #293143; border-top-color: #7867ee; border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.game-panel { text-align: center; }
.timer-wrap { display: flex; justify-content: center; align-items: baseline; gap: 7px; color: #7c879b; }
.timer-wrap strong { min-width: 118px; color: #fff; font-size: 58px; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.timer-wrap strong.urgent { color: #ff7d91; }
.choice-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; margin-top: 28px; }
.choice-button { position: relative; min-height: 178px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border: 1px solid #2a3242; border-radius: 18px; background: #101622; cursor: pointer; transition: transform .15s,border-color .15s,background .15s; }
.choice-button:hover { transform: translateY(-3px); border-color: #6557cf; }
.choice-button.selected { border-color: #8b7aff; background: rgba(111,92,233,.16); box-shadow: inset 0 0 0 1px #8b7aff; }
.choice-button kbd { position: absolute; top: 11px; right: 12px; min-width: 24px; padding: 3px; border: 1px solid #353e50; border-radius: 6px; color: #788397; background: #171e2c; font-size: 11px; }
.choice-emoji { font-size: 53px; }
.choice-button strong { font-size: 15px; }
.keyboard-hint { margin: 18px 0; color: #657084; font-size: 12px; }
.watch-message { margin: 28px 0 20px; padding: 24px 18px; border: 1px dashed #313b4d; border-radius: 16px; color: #8d98aa; background: rgba(9,13,22,.46); }
.watch-message > p { margin: 0 0 18px; color: #687489; font-size: 11px; letter-spacing: .08em; }
.watch-choices { display: grid; grid-template-columns: 1fr 40px 1fr; align-items: center; }
.watch-choices div { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.watch-choices span { min-height: 58px; font-size: 48px; line-height: 1.2; }
.watch-choices small { max-width: 100%; overflow: hidden; color: #aab3c2; text-overflow: ellipsis; white-space: nowrap; }
.watch-choices > strong { color: #596477; font-size: 11px; }

.result-panel { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.result-hands { display: flex; align-items: center; gap: 30px; }
.result-hands div { display: flex; flex-direction: column; gap: 8px; }
.result-hands span { font-size: 66px; }
.result-hands small, .result-hands > strong { color: #6e798c; }
.result-panel h2 { margin: 22px 0 6px; font-size: 34px; }
.result-panel p { margin: 0; color: #939daf; }
.next-round { margin-top: 24px; color: #7467dc; font-size: 12px; }
.result-panel .danger-button { margin-top: 18px; }
.summary-panel { text-align: center; }
.summary-heading h2 { margin: 8px 0 5px; font-size: 32px; }
.summary-heading p { margin: 0; color: #a99dff; font-size: 17px; font-weight: 800; }
.summary-totals { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin: 24px 0; }
.summary-totals div { padding: 16px 8px; border: 1px solid rgba(255,255,255,.07); border-radius: 13px; background: rgba(9,13,22,.5); }
.summary-totals strong { display: block; font-size: 27px; }
.summary-totals span { display: block; margin-top: 4px; overflow: hidden; color: #737e91; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.history-table { overflow: hidden; border: 1px solid rgba(255,255,255,.075); border-radius: 14px; text-align: left; }
.history-head, .history-row { display: grid; grid-template-columns: 58px 1fr 1fr 1fr; align-items: center; }
.history-head { min-height: 38px; background: #0d121d; color: #687387; font-size: 10px; font-weight: 750; }
.history-row { min-height: 47px; border-top: 1px solid rgba(255,255,255,.055); color: #c3cad5; font-size: 12px; }
.history-head span, .history-row span { min-width: 0; padding: 7px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.history-head span:nth-child(2), .history-row span:nth-child(2) { text-align: left; }
.history-head span:last-child, .history-row span:last-child { text-align: right; }
.empty-history { padding: 28px; color: #6d788b; text-align: center; font-size: 12px; }
.summary-ready { margin: 20px 0 12px; }
.summary-panel > .quiet-button { width: 100%; }

footer { align-self: end; padding: 22px 0 28px; color: #596477; text-align: center; font-size: 12px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; max-width: calc(100% - 32px); padding: 11px 16px; border: 1px solid #333d50; border-radius: 11px; background: #151c29; color: #dfe3eb; box-shadow: 0 12px 40px rgba(0,0,0,.4); opacity: 0; transform: translate(-50%,12px); pointer-events: none; transition: .2s; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.success { border-color: rgba(66,211,167,.35); color: #8ce5c9; }
.toast.error { border-color: rgba(241,111,133,.4); color: #ff9bac; }
.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,5,10,.72); backdrop-filter: blur(8px); }
.modal-card { width: min(430px,100%); padding: 28px; border: 1px solid #30394b; border-radius: 20px; background: #121824; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.modal-card h2 { margin: 9px 0; font-size: 23px; }
.modal-card p { margin: 0; color: #8e99ab; line-height: 1.65; font-size: 13px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 24px; }
.modal-actions .primary { min-height: 43px; }

@media (max-width: 760px) {
  .shell { width: min(100% - 26px,1120px); }
  .topbar { min-height: 66px; }
  .home-view { grid-template-columns: 1fr; gap: 38px; padding: 46px 0; }
  h1 { margin-top: 12px; font-size: clamp(48px,15vw,68px); }
  .intro { font-size: 16px; }
  .feature-row { gap: 12px; justify-content: space-between; font-size: 11px; }
  .scoreboard { grid-template-columns: 1fr 52px 1fr; }
  .player-card { min-height: 91px; gap: 9px; padding: 13px 11px; }
  .player-avatar { width: 36px; height: 36px; border-radius: 11px; font-size: 12px; }
  .player-label { font-size: 12px; }
  .player-card small { font-size: 10px; }
  .score { font-size: 30px; }
  .versus { height: 91px; }
  .versus small { display: none; }
  .lobby-panel, .game-panel, .result-panel, .summary-panel { padding: 21px 15px; }
  .seat-stage { padding: 12px; }
  .battle-seats { grid-template-columns: 1fr 34px 1fr; }
  .player-seat { min-height: 68px; padding: 9px; }
  .spectator-heading small { display: none; }
  .spectator-seats { grid-template-columns: repeat(2,1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .choice-grid { gap: 7px; }
  .choice-button { min-height: 142px; border-radius: 15px; }
  .choice-emoji { font-size: 43px; }
  .timer-wrap strong { min-width: 94px; font-size: 48px; }
  .ready-panel, .summary-ready { align-items: stretch; flex-direction: column; }
  .ready-button { width: 100%; }
  .history-head, .history-row { grid-template-columns: 42px 1fr .8fr 1fr; }
  .history-head span, .history-row span { padding-inline: 5px; font-size: 10px; }
}

@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
  .feature-row span:nth-child(2) { display: none; }
  .room-view { padding-top: 24px; }
  .room-code strong { font-size: 21px; }
  .player-card { flex-wrap: wrap; }
  .player-card .score { width: 100%; margin: 2px 0 0; text-align: center; }
  .opponent-card .score { order: 3; }
  .choice-button { min-height: 126px; }
  .choice-button kbd { display: none; }
  .seat small { display: none; }
  .seat-avatar, .seat-plus { width: 30px; height: 30px; }
  .spectator-seat { min-height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
