:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei UI", system-ui, sans-serif;
  color: #f8f5ef;
  background: #101522;
  --muted: #aeb8cd;
  --line: #313b52;
  --gold: #ffd15c;
  --red: #b92342;
  --yellow: #ffd15c;
  --green: #087954;
  --blue: #265ac8;
  --card-size: clamp(66px, 8vw, 103px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
p { margin: 0; }
.masthead {
  min-height: 70px; border-bottom: 1px solid #262e40; padding: 10px clamp(12px, 5vw, 64px);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand strong { color: var(--gold); font-size: 26px; font-weight: 950; font-style: italic; letter-spacing: -.08em; }
.brand span { font-size: 13px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.connection { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 3px; }
.connection::before { content: '●'; margin-right: 5px; color: #f7ab72; }
.connection.online::before { color: #6fe0b2; }
main { max-width: 1250px; margin: auto; padding: clamp(12px, 3vw, 34px); }
.home {
  min-height: min(600px, calc(100dvh - 145px)); display: grid; grid-template-columns: 1.1fr 1fr;
  border-radius: 26px; border: 1px solid var(--line); overflow: hidden; background: #1a2133;
}
.home-art {
  position: relative; min-height: 330px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% 48%, #3c4061, #242742 48%, #171f34 80%);
}
.art-orbit {
  width: 71%; max-width: 370px; aspect-ratio: 1; border-radius: 50%; border: 1px solid #777d9c50;
  box-shadow: 0 0 0 30px #b2a0ec09, 0 0 0 61px #b2a0ec08, 0 0 0 92px #b2a0ec07;
}
.home-art .art-card {
  position: absolute; width: clamp(92px, 15vw, 170px); border-width: 6px;
  font-size: clamp(40px, 8vw, 86px); box-shadow: 0 16px 30px #0c0f2398;
}
.art-left { transform: translate(-57%, 6%) rotate(-23deg); }
.art-right { transform: translate(56%, 8%) rotate(22deg); }
.art-center { transform: translateY(-6%) rotate(-7deg); }
.spark { position: absolute; color: #ffe6a2; font-size: clamp(18px, 4vw, 36px); }
.spark-one { top: 18%; right: 21%; }
.spark-two { bottom: 17%; left: 17%; }
.home-content { align-self: center; padding: clamp(24px, 5vw, 72px); }
h1 { font-size: clamp(32px, 5vw, 61px); letter-spacing: -.05em; line-height: 1.15; margin: 0 0 12px; }
h1 span { color: var(--gold); font-weight: 950; font-style: italic; }
.home p, .waiting > p { color: var(--muted); line-height: 1.6; }
#entry { display: grid; gap: 10px; margin-top: 26px; }
label { color: var(--muted); font-size: 13px; }
input {
  width: 100%; min-width: 0; min-height: 46px; padding: 10px 13px; border-radius: 10px;
  border: 1px solid #47536e; background: #111827; color: inherit;
}
input::placeholder { color: #a7b1c7; }
#room-code { text-transform: uppercase; }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.primary, .secondary, .quiet, .color-choice {
  border: 1px solid transparent; border-radius: 10px; min-height: 44px; padding: 8px 14px;
  font-weight: 750; color: inherit;
}
.primary { background: var(--gold); color: #211806; }
.secondary { background: #252f46; border-color: #46536e; }
.quiet { background: transparent; color: var(--muted); }
.primary:disabled, .secondary:disabled, .quiet:disabled, .color-choice:disabled { opacity: .6; }
#share { font-size: 12px; letter-spacing: .04em; }
.waiting { background: #1a2133; border: 1px solid var(--line); border-radius: 23px; padding: clamp(20px, 5vw, 50px); }
.waiting h1 { font-size: clamp(29px, 5vw, 46px); }
.lobby-seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 24px 0; }
.seat { display: flex; align-items: center; gap: 9px; min-width: 0; background: #192439; border: 1px solid #3d4a62; border-radius: 13px; padding: 9px; }
.seat-active { border-color: var(--gold); box-shadow: 0 0 16px #ffd15c27; }
.avatar { display: grid; place-items: center; flex: 0 0 34px; aspect-ratio: 1; border-radius: 9px; color: #111827; font-weight: 850; }
.avatar-0 { background: #ffd15c; } .avatar-1 { background: #e6a2ef; }
.avatar-2 { background: #8cdbeb; } .avatar-3 { background: #9ce0aa; }
.seat-detail { display: grid; gap: 3px; min-width: 0; flex: 1; }
.seat-name, .seat-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-name { font-size: 14px; } .seat-status { font-size: 11px; color: var(--muted); }
.seat-count { font-variant-numeric: tabular-nums; font-weight: 800; background: #303d54; border-radius: 6px; padding: 3px 6px; }
.game { display: grid; gap: 12px; }
.table {
  position: relative; border: 1px solid #315749; border-radius: 26px; min-height: 390px;
  padding: 28px; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, #235746, #153c35 65%, #142d2f);
}
.table::before {
  content: ''; position: absolute; inset: 22px; border: 1px solid #98bca12f; border-radius: 42%; pointer-events: none;
}
.opponents { display: contents; }
.opponents .seat { position: absolute; width: clamp(118px, 18%, 180px); }
.opponents .seat:nth-child(1) { left: 4%; top: 50%; transform: translateY(-50%); }
.opponents .seat:nth-child(2) { left: 50%; top: 20px; transform: translateX(-50%); }
.opponents .seat:nth-child(3) { right: 4%; top: 50%; transform: translateY(-50%); }
.table-center { position: relative; display: grid; gap: 12px; justify-items: center; margin-top: 37px; }
.round-state, .piles { display: flex; align-items: center; gap: 13px; }
.round-state { justify-content: center; flex-wrap: wrap; gap: 5px; }
.round-state > span { font-size: 12px; font-weight: 750; border-radius: 20px; background: #112c29; padding: 5px 9px; }
.active-color { display: inline-flex; align-items: center; gap: 4px; }
.active-color::before { content: ''; width: 10px; aspect-ratio: 1; border-radius: 50%; background: var(--face); }
.round-state .penalty { color: #241807; background: var(--gold); }
.pile { display: grid; gap: 7px; justify-items: center; font-size: 12px; color: #e0eee7; }
.event { color: #e0eee7; font-size: 13px; min-height: 1.4em; text-align: center; overflow-wrap: anywhere; max-width: min(94vw, 40ch); }
.red { --face: var(--red); } .yellow { --face: var(--yellow); --ink: #221805; }
.green { --face: var(--green); } .blue { --face: var(--blue); }
.wild { --face: conic-gradient(from 45deg, #a51e42, #a51e42 25%, #194d9e 0 50%, #14644d 0 75%, #664114 0); }
.card {
  position: relative; width: var(--card-size); aspect-ratio: 5 / 7; border-radius: 11%;
  border: 3px solid #fff5e7; display: grid; place-items: center; isolation: isolate;
  background: var(--face, #151c30); color: var(--ink, #fffaf1); font-weight: 950;
  font-size: clamp(25px, 4.5vw, 55px); box-shadow: 0 5px 9px #0a13295c;
  padding: 0; flex: none;
}
.card::before {
  content: ''; position: absolute; inset: 10% 17%; transform: rotate(26deg); border-radius: 50%;
  background: #fff8e52a; z-index: -1;
}
.card.back { color: var(--gold); font-style: italic; font-size: clamp(17px, 3vw, 29px); letter-spacing: -.1em; }
.card.back::before { background: #b92342; }
.card-mark { transform: rotate(-9deg); line-height: 1; }
.corner, .card-name, .jump-label { position: absolute; font-size: clamp(9px, 1.25vw, 12px); line-height: 1.1; }
.corner-top { top: 5%; left: 6%; } .corner-bottom { bottom: 5%; right: 6%; transform: rotate(180deg); }
.card-name { bottom: 14%; white-space: nowrap; }
.player-area { padding: 11px 14px 6px; background: #1a2133; border: 1px solid var(--line); border-radius: 18px; }
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 51px; }
.player-bar h2 { margin: 0 0 3px; font-size: 17px; }
.player-bar h2 small, #turn-note { color: var(--muted); font-size: 12px; }
.play-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 5px; }
.color-choice { background: var(--face); color: var(--ink, white); }
.hand { display: flex; overflow-x: auto; gap: 9px; padding: 11px 4px 14px; scrollbar-color: #515c78 transparent; }
.hand .card:disabled { opacity: .57; }
.hand .card:not(:disabled) { box-shadow: 0 0 0 2px var(--gold); }
.jump-label { top: -6px; right: -6px; background: var(--gold); color: #211806; padding: 3px 5px; border-radius: 5px; }
#notice {
  position: fixed; z-index: 2; bottom: calc(15px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); padding: 11px 14px; border: 1px solid #4a5673;
  border-radius: 10px; background: #242e44; color: white; box-shadow: 0 5px 25px #0b1024a6;
}
@media (max-width: 730px) {
  .masthead { min-height: 55px; }
  .home { grid-template-columns: 1fr; }
  .home-art { min-height: clamp(185px, 44vw, 315px); }
  .home-content { padding: 21px; }
  .lobby-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { min-height: 0; padding: 9px 8px 13px; gap: 12px; }
  .table::before { inset: 54px 10px 8px; }
  .opponents { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .opponents .seat:nth-child(n) { position: static; transform: none; width: auto; padding: 5px; gap: 4px; border-radius: 8px; }
  .opponents .avatar { display: none; }
  .opponents .seat-name, .opponents .seat-count { font-size: 11px; }
  .opponents .seat-status { font-size: 10px; }
  .table-center { margin: 0; gap: 8px; }
  .player-area { padding-inline: 8px; }
  .play-actions button { padding-inline: 8px; font-size: 12px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  :root { --card-size: 62px; }
  .masthead { min-height: 47px; padding-block: 2px; }
  main { padding-block: 6px; }
  .home { grid-template-columns: 1fr 1fr; }
  .home-art { min-height: 220px; }
  .table { min-height: 188px; }
  .table-center { margin-top: 15px; gap: 4px; }
  .opponents .seat:nth-child(2) { top: 5px; }
}
@media (max-width: 360px) {
  .brand span, .connection { display: none; }
  .player-bar { align-items: start; flex-direction: column; }
  .play-actions { justify-content: start; }
}
