:root {
  --ink: #2a1f14;
  --muted: #7a654f;
  --panel: rgba(255, 252, 245, 0.95);
  --sand: #e8c98a;
  --track: #d4a574;
  --accent: #e8590c;
  --font-d: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  --font-b: "Noto Sans SC", system-ui, sans-serif;
  --c-blue: #1c7ed6;
  --c-green: #2f9e44;
  --c-orange: #e8590c;
  --c-yellow: #f59f00;
  --c-white: #f8f9fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-b);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
  background: #3d2a1a;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(255, 200, 100, 0.35), transparent 55%),
    radial-gradient(ellipse 50% 40% at 80% 100%, rgba(232, 89, 12, 0.2), transparent 50%),
    linear-gradient(180deg, #5c3d24 0%, #3d2a1a 45%, #2a1c12 100%);
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.2rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: #fff5e6;
}
.back { color: #ffd8a8; text-decoration: none; font-weight: 700; }
.brand { display: flex; gap: 0.7rem; align-items: center; flex: 1; }
.mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ffa94d, #e8590c);
  color: #2a1f14;
  font-family: var(--font-d);
  font-size: 1.35rem;
}
.brand h1 { margin: 0; font-family: var(--font-d); font-size: 1.5rem; }
.brand p { margin: 0; font-size: 0.85rem; opacity: 0.75; }

main { max-width: 1180px; margin: 0 auto; padding: 0.5rem 1.2rem 3rem; }

.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 1.3rem;
  max-width: 460px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
}
.panel h2 { margin: 0 0 1rem; font-family: var(--font-d); font-size: 1.75rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.9rem; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 0.5rem; }
.row input {
  flex: 1;
  border: 1px solid #e0c9a8;
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}
.name-list { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; gap: 0.35rem; }
.name-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.7rem;
  background: #f5e6d0;
  border-radius: 10px;
  font-weight: 700;
}
.name-list button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.7rem 0 0; }

.btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 14px;
  padding: 0.7rem 1.15rem;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(145deg, #ffa94d, #e8590c);
  color: #fff;
}
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid #e0c9a8;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff5e6;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn.wide { width: 100%; }

.layout { display: grid; gap: 1rem; }
@media (min-width: 980px) {
  .layout { grid-template-columns: 1fr 280px; align-items: start; }
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.status > span {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff5e6;
  font-weight: 650;
}
.status strong { color: #fff; }

.track-wrap {
  position: relative;
  margin-top: 0.85rem;
  border-radius: 18px;
  background: linear-gradient(160deg, #c9955a, #a8743f 55%, #8f5f32);
  border: 2px solid rgba(255, 230, 180, 0.35);
  padding: 0.75rem 0.55rem 1.1rem;
  overflow: hidden;
  min-height: 11.5rem;
}
.track {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.35rem;
}
.space {
  position: relative;
  min-height: 4.6rem;
  border-radius: 10px;
  background: rgba(255, 248, 230, 0.22);
  border: 1px dashed rgba(255, 255, 255, 0.28);
  padding: 0.2rem;
}
.space .idx {
  position: absolute;
  top: 0.2rem;
  left: 0.35rem;
  font-size: 0.68rem;
  font-weight: 900;
  color: rgba(255, 245, 220, 0.75);
}
.space.finish {
  background: rgba(255, 212, 59, 0.35);
  border-style: solid;
  border-color: #ffd43b;
}
.space.has-desert {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}
.desert-chip {
  position: absolute;
  bottom: 0.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 900;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 2;
}
.desert-chip.oasis { background: #69db7c; color: #0b3d1a; }
.desert-chip.mirage { background: #ff8787; color: #5c1010; }

.camel-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* 骆驼 token */
.camel-tok {
  position: absolute;
  width: 2.35rem;
  height: 1.55rem;
  transform: translate(-50%, -50%);
  transition: left 0.28s ease, top 0.28s ease;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
  z-index: 6;
}
.camel-tok.is-moving {
  z-index: 20;
  transition: left 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.camel-tok .body {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 40% 45% 35% 40% / 55% 50% 45% 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  position: relative;
}
.camel-tok .body::before {
  content: "";
  position: absolute;
  right: -0.15rem;
  top: -0.35rem;
  width: 0.85rem;
  height: 0.7rem;
  border-radius: 50% 45% 40% 50%;
  background: inherit;
  border: 2px solid rgba(0, 0, 0, 0.18);
  border-left: 0;
}
.camel-tok .body::after {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: -0.55rem;
  width: 0.35rem;
  height: 0.55rem;
  border-radius: 4px 4px 0 0;
  background: inherit;
  border: 1.5px solid rgba(0, 0, 0, 0.15);
}
.camel-tok .hump {
  position: absolute;
  left: 35%;
  top: -28%;
  width: 38%;
  height: 55%;
  border-radius: 50% 50% 40% 40%;
  background: inherit;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-bottom: 0;
}
.camel-tok.blue .body { background: linear-gradient(145deg, #74c0fc, var(--c-blue)); }
.camel-tok.green .body { background: linear-gradient(145deg, #8ce99a, var(--c-green)); }
.camel-tok.orange .body { background: linear-gradient(145deg, #ffc078, var(--c-orange)); }
.camel-tok.yellow .body { background: linear-gradient(145deg, #ffe066, var(--c-yellow)); }
.camel-tok.white .body {
  background: linear-gradient(145deg, #fff, #dee2e6);
  border-color: #adb5bd;
}

.board-row {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.65rem;
}
@media (min-width: 700px) {
  .board-row { grid-template-columns: 160px 1fr; }
}

.pyramid-box, .bets-box, .final-bets > div {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff5e6;
}
.box-t {
  margin: 0 0 0.45rem;
  font-family: var(--font-d);
  font-size: 1.05rem;
  color: #ffd8a8;
}

.pyramid {
  position: relative;
  width: 5.5rem;
  height: 4.2rem;
  margin: 0.3rem auto;
  display: grid;
  place-items: end center;
}
.pyr-body {
  font-size: 3.6rem;
  line-height: 0.85;
  color: #ff922b;
  text-shadow: 0 4px 0 #c2410c;
  transition: transform 0.15s;
}
.pyramid.is-shake .pyr-body {
  animation: pyr-shake 0.45s ease;
}
@keyframes pyr-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-6px) rotate(-4deg); }
  40% { transform: translateX(7px) rotate(5deg); }
  60% { transform: translateX(-5px) rotate(-3deg); }
  80% { transform: translateX(4px) rotate(2deg); }
}
.dice-out {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  min-height: 2.2rem;
}
.die-chip {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.95rem;
  color: #1a1a1a;
  border: 2px solid rgba(255, 255, 255, 0.5);
  animation: die-pop 0.35s cubic-bezier(0.2, 1.4, 0.3, 1);
}
@keyframes die-pop {
  from { transform: scale(0.4) translateY(-20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.die-chip.blue { background: var(--c-blue); color: #fff; }
.die-chip.green { background: var(--c-green); color: #fff; }
.die-chip.orange { background: var(--c-orange); color: #fff; }
.die-chip.yellow { background: var(--c-yellow); }
.die-chip.white { background: #f1f3f5; }

.leg-bets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.leg-stack {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  min-width: 3.4rem;
}
.leg-stack .cname {
  font-size: 0.72rem;
  font-weight: 800;
}
.leg-tile {
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  color: #fff;
  min-width: 2.8rem;
}
.leg-tile:disabled { opacity: 0.4; cursor: not-allowed; }
.leg-tile.blue { background: var(--c-blue); }
.leg-tile.green { background: var(--c-green); }
.leg-tile.orange { background: var(--c-orange); }
.leg-tile.yellow { background: var(--c-yellow); color: #1a1a1a; }
.leg-tile.white { background: #f1f3f5; color: #1a1a1a; border: 1px solid #ced4da; }

.final-bets {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.55rem;
}
@media (min-width: 700px) {
  .final-bets { grid-template-columns: 1fr 1fr; }
}
.final-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 2rem;
}
.final-chip {
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.msg {
  text-align: center;
  font-family: var(--font-d);
  font-size: 1.35rem;
  color: #ffc078;
  margin: 0.8rem 0 0.1rem;
  min-height: 1.45em;
}
.submsg {
  text-align: center;
  color: rgba(255, 245, 230, 0.75);
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 1.2em;
  margin: 0 0 0.5rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  min-height: 3rem;
}

.side {
  background: var(--panel);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  position: sticky;
  top: 0.55rem;
}
.side h2 { margin: 0; font-family: var(--font-d); font-size: 1.3rem; }
.log-h { margin-top: 0.8rem !important; }

.scores { list-style: none; margin: 0.55rem 0; padding: 0; display: grid; gap: 0.4rem; }
.scores li {
  padding: 0.5rem 0.6rem;
  background: #f5e6d0;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem;
}
.scores li.is-turn { box-shadow: inset 0 0 0 2px rgba(232, 89, 12, 0.4); }
.scores .nm { font-weight: 800; }
.scores .pts { font-weight: 900; color: var(--accent); font-size: 1.15rem; }
.scores .sub { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); }

.log {
  list-style: none;
  margin: 0.35rem 0;
  padding: 0;
  max-height: 9rem;
  overflow: auto;
}
.log li {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.2rem 0;
  border-bottom: 1px solid #ead9c0;
}

.rules { border-top: 1px solid #ead9c0; padding-top: 0.55rem; margin-top: 0.45rem; }
.rules .t { margin: 0 0 0.3rem; font-weight: 700; }
.rules ul {
  margin: 0;
  padding-left: 1.05rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.fx-banner {
  position: fixed;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(92vw, 400px);
  padding: 0.95rem 1.2rem;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(60, 35, 18, 0.96), rgba(30, 18, 10, 0.96));
  border: 1px solid rgba(255, 169, 77, 0.65);
  color: #fff;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}
.fx-banner.is-on { animation: fx-in 0.28s ease forwards; }
.fx-banner.is-out { animation: fx-out 0.22s ease forwards; }
.fx-banner[hidden] { display: none !important; }
.fx-kicker { margin: 0; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.1em; color: #ffd8a8; }
.fx-title { margin: 0.2rem 0 0; font-family: var(--font-d); font-size: 1.3rem; }
.fx-detail { margin: 0.3rem 0 0; font-size: 0.92rem; color: rgba(255, 245, 230, 0.9); }
@keyframes fx-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes fx-out {
  to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

.pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  width: 100%;
}
.space-btn {
  border: 0;
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}
.space-btn:disabled { opacity: 0.35; cursor: not-allowed; }

[hidden] { display: none !important; }
