:root {
  --ink: #f4ead6;
  --muted: #b9c2d3;
  --gold: #e7b843;
  --gold-2: #f6d37a;
  --red: #e25b4f;
  --green: #3fb57a;
  --glass: rgba(12, 24, 42, 0.78);
  --glass-2: rgba(22, 40, 66, 0.86);
  --line: rgba(231, 184, 67, 0.28);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1424;
  color: var(--ink);
  font: 16px/1.5 var(--font);
  overscroll-behavior: none;
}
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
body.no-3d #stage {
  display: none;
}
body.no-3d {
  background: radial-gradient(circle at 50% 40%, #1b3a5c, #0a1424 70%);
}
#labels,
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#app > *,
#app .center-card,
#app .lobby-wrap {
  pointer-events: auto;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 44px;
  transition:
    transform 0.12s,
    background 0.2s,
    opacity 0.2s;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #2a1c06;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(231, 184, 67, 0.3);
}
.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.warn {
  background: rgba(226, 91, 79, 0.16);
  border: 1px solid rgba(226, 91, 79, 0.5);
  color: #ffc9c2;
}
.link {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 6px 8px;
  min-height: 32px;
}
.mini {
  padding: 4px 12px;
  min-height: 34px;
  font-size: 14px;
}
.big {
  width: 100%;
  min-height: 52px;
  font-size: 18px;
}
.icon {
  background: rgba(255, 255, 255, 0.06);
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 19px;
}
.hint {
  color: var(--muted);
  font-size: 14px;
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
input,
select {
  font: inherit;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 46px;
  width: 100%;
}
input:focus,
select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 0.08em;
  color: var(--gold-2);
  text-shadow: 0 2px 18px rgba(231, 184, 67, 0.35);
}
h2 {
  margin: 0 0 12px;
  font-size: 21px;
}

/* ---------------------------------------------------------------- landing and lobby */
.center-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px));
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.center-card.wide {
  width: min(560px, calc(100vw - 24px));
}
.center-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.center-card label {
  font-size: 14px;
  color: var(--muted);
}
.logo {
  font-size: 44px;
  line-height: 1;
}
.tag-line {
  margin: 0;
  color: var(--muted);
}
.lobby-wrap {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  pointer-events: none;
}
.lobby-wrap .center-card {
  top: auto;
  bottom: 16px;
  transform: translateX(-50%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
@media (min-width: 900px) {
  .lobby-wrap .center-card {
    left: auto;
    right: 24px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
}
.seats {
  list-style: none;
  margin: 4px 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  text-align: left;
}
.seats li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  min-height: 44px;
  font-size: 15px;
}
.seats .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}
.seats b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seats em {
  font-style: normal;
  font-size: 12px;
  color: var(--gold-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 4px;
}
.seats em.off {
  color: var(--muted);
}
.seats .mini {
  margin-left: auto;
  min-height: 30px;
}
.row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.row > button {
  flex: 1;
}
.row.small > button {
  flex: none;
}
.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  font-size: 15px;
}
.opts label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.opts select {
  width: auto;
  flex: 1;
}
.opts .check input {
  width: 22px;
  height: 22px;
  min-height: 0;
  flex: none;
}
.role-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.role-chip {
  flex: 1 0 120px;
  text-align: left;
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--c);
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 6px;
  align-items: center;
}
.role-chip span {
  font-size: 22px;
  grid-row: span 2;
}
.role-chip small {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

/* ---------------------------------------------------------------- seat labels and bubbles */
.seat-label {
  position: absolute;
  left: 0;
  top: 0;
  text-align: center;
  white-space: nowrap;
  transition: opacity 0.3s;
  will-change: transform;
}
.seat-label .tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(8, 16, 30, 0.82);
  border: 2px solid var(--c);
  font-size: 13.5px;
}
.seat-label .tag i {
  font-style: normal;
  font-size: 12px;
}
.seat-label .tag i.off {
  opacity: 0.7;
}
.seat-label .cash {
  font-weight: 800;
  color: var(--gold-2);
  font-size: 15px;
  text-shadow: 0 1px 4px #000;
}
.seat-label .st {
  font-size: 12px;
  color: var(--muted);
  text-shadow: 0 1px 3px #000;
}
.seat-label .known {
  font-size: 12px;
  color: #d9c6ff;
  background: rgba(60, 30, 110, 0.75);
  border-radius: 6px;
  padding: 0 6px;
}
.seat-label.me {
  display: flex;
  align-items: center;
  gap: 6px;
}
.seat-label.me .st,
.seat-label.me .cash {
  font-size: 14px;
}
.seat-label.me .tag {
  background: rgba(70, 50, 10, 0.88);
}
.seat-label.dim {
  opacity: 0.55;
}
.seat-label.ready .st {
  color: #9be3b9;
}
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 200px;
  white-space: normal;
  padding: 6px 12px;
  border-radius: 14px;
  background: #fdf6e6;
  color: #2a1c06;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: pop 0.25s ease-out;
  transition: opacity 0.4s;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  margin-left: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: #fdf6e6;
}
.bubble.big {
  font-size: 28px;
  background: none;
  box-shadow: none;
  padding: 0;
}
.bubble.big::after {
  display: none;
}
.bubble.out {
  opacity: 0;
}
@keyframes pop {
  from {
    transform: translate(-50%, -80%) scale(0.6);
    opacity: 0;
  }
}
.float-money {
  position: absolute;
  transform: translate(-50%, -100%);
  font-weight: 900;
  font-size: 22px;
  text-shadow: 0 2px 8px #000;
  animation: rise 2.2s ease-out forwards;
}
.float-money.up {
  color: #ffe082;
}
.float-money.down {
  color: #ff9a8f;
}
@keyframes rise {
  0% {
    opacity: 0;
    margin-top: 10px;
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    margin-top: -60px;
  }
}

/* ---------------------------------------------------------------- the show caption */
#caption {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--dock, 90px) + 10px);
  transform: translate(-50%, 12px);
  width: min(520px, calc(100vw - 32px));
  text-align: center;
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(8, 16, 30, 0.84);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s,
    transform 0.3s;
  z-index: 5;
}
#caption.on {
  opacity: 1;
  transform: translate(-50%, 0);
}
#caption b {
  display: block;
  font-size: 21px;
  color: var(--gold-2);
}
#caption span {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-top: 2px;
}
#caption.collide b,
#caption.named b,
#caption.alone b {
  color: #ff8b80;
}
#caption.survive b {
  color: #9be3b9;
}
#caption.final b {
  font-size: 24px;
}
body.lobby #caption {
  display: none;
}

/* ---------------------------------------------------------------- top bar */
#top {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top) + 10px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
}
#top .round {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}
#top .round b {
  white-space: nowrap;
}
#top .round span {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#top .round em {
  color: var(--gold-2);
  font-style: normal;
}
#top .goal {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
#top nav {
  display: flex;
  gap: 6px;
}
.held {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 74px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  z-index: 6;
}
.held span {
  color: var(--muted);
  font-size: 14px;
}
.net {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 70px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(226, 91, 79, 0.9);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 6;
}

/* ---------------------------------------------------------------- dock */
#dock {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 16px));
  max-height: 52vh;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#dock .head,
#dock .line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#dock .line.watch {
  justify-content: center;
  min-height: 44px;
}
#dock .head b {
  font-size: 17px;
}
.clock {
  margin-left: auto;
  position: relative;
  width: 110px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex: none;
}
#clock-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #3d8fe0, #5ab7d8);
  transition: width 0.25s linear;
}
#clock {
  position: relative;
  display: block;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  line-height: 26px;
}
#clock.hurry {
  color: #ffd1cc;
  animation: pulse 0.6s infinite alternate;
}
.clock:has(#clock.hurry) #clock-bar {
  background: linear-gradient(90deg, #c23b3b, #e25b4f);
}
@keyframes pulse {
  to {
    opacity: 0.55;
  }
}
.my-role {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 28%, transparent);
  border: 1px solid var(--c);
}
.my-role span {
  font-size: 24px;
}
.my-role small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}
.my-role b {
  font-size: 16px;
  line-height: 1.2;
}
.pick-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}
.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, #102238), #0f1f33);
  border: 2px solid var(--c);
  border-radius: 14px;
  position: relative;
}
.role-card span {
  font-size: 30px;
  line-height: 1.1;
}
.role-card b {
  font-size: 17px;
}
.role-card small {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
}
.role-card em {
  position: absolute;
  top: -9px;
  right: -6px;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  background: var(--gold);
  color: #2a1c06;
  border-radius: 999px;
  padding: 1px 7px;
}
.role-card.off {
  filter: grayscale(0.8);
}
.table-info {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.mini-role {
  font-size: 13px;
  color: var(--ink);
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 32%, transparent);
  border: 1px solid var(--c);
}
.mini-role.back {
  --c: #6c7a92;
}
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.offers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.offers li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
}
.offers li span {
  flex: 1;
}
.offers li.mine {
  background: rgba(231, 184, 67, 0.16);
  border: 1px solid var(--line);
}
.offers b {
  color: var(--gold-2);
}
.chat .emojis {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
}
.emoji {
  background: rgba(255, 255, 255, 0.06);
  font-size: 20px;
  padding: 0;
  width: 40px;
  min-height: 40px;
  flex: none;
}
.chat .emojis .mini {
  margin-left: auto;
  flex: none;
}
.phrases {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.phrase {
  background: rgba(255, 255, 255, 0.07);
  font-size: 14px;
  padding: 4px 12px;
  min-height: 36px;
}
#chat-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
#chat-form button {
  flex: none;
}

/* ---------------------------------------------------------------- sheets */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.sheet {
  position: fixed;
  z-index: 21;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 16px));
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px 18px;
  background: var(--glass-2);
  animation: up 0.22s ease-out;
}
@keyframes up {
  from {
    transform: translate(-50%, 30px);
    opacity: 0;
  }
}
.x {
  position: absolute;
  right: 8px;
  top: 8px;
  background: none;
  font-size: 26px;
  min-height: 40px;
  width: 44px;
  padding: 0;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.seg button,
.who button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.seg button.on,
.who button.on {
  background: rgba(231, 184, 67, 0.22);
  border-color: var(--gold);
  color: var(--gold-2);
  font-weight: 700;
}
.who {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.who button {
  display: flex;
  flex-direction: column;
  border-left: 4px solid var(--c, transparent);
}
.who small {
  color: var(--muted);
  font-size: 12px;
}
.amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.amount b {
  font-size: 30px;
  color: var(--gold-2);
  min-width: 130px;
  text-align: center;
}
.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 26px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
}
.quick {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 8px 0;
}
.rules {
  padding-left: 20px;
  margin: 0 0 12px;
}
.rules li {
  margin-bottom: 6px;
}
.role-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.log {
  padding-left: 22px;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.log li {
  margin-bottom: 4px;
}
.rank {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rank li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--c);
}
.rank li span {
  width: 22px;
  color: var(--muted);
}
.rank li em {
  margin-left: auto;
  font-style: normal;
  font-weight: 800;
  color: var(--gold-2);
}
.rank li.win {
  background: rgba(231, 184, 67, 0.18);
}
.rank li.win b::after {
  content: " 👑";
}
details {
  margin-bottom: 12px;
  font-size: 14px;
}
summary {
  cursor: pointer;
  color: var(--muted);
}
.hist {
  padding-left: 18px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 40%;
  transform: translate(-50%, 10px);
  background: rgba(8, 16, 30, 0.92);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 12px;
  opacity: 0;
  transition: 0.25s;
  pointer-events: none;
  z-index: 40;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 600px) {
  #top {
    left: 8px;
    right: 8px;
    padding: 6px 6px 6px 12px;
    gap: 6px;
  }
  #top .goal {
    display: none;
  }
  #top nav {
    margin-left: auto;
    gap: 4px;
  }
  .icon {
    width: 38px;
    height: 38px;
    min-height: 38px;
    font-size: 17px;
  }
  #dock {
    padding: 10px;
    border-radius: 16px;
  }
  .pick-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .actions {
    grid-template-columns: 1fr 1fr;
  }
  .actions .primary {
    grid-column: span 2;
  }
  .clock {
    width: 84px;
  }
  .seat-label .tag {
    font-size: 12px;
    padding: 1px 7px;
  }
  .seat-label .cash {
    font-size: 13px;
  }
  #caption b {
    font-size: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
