* { box-sizing: border-box; }

:root {
  --bg: #fff8f4;
  --paper: #fffdf9;
  --ink: #543e3f;
  --muted: #8f7477;
  --line: #e8c6c8;
  --pink: #ff8aa1;
  --pink-dark: #e6607c;
  --gold: #ffe25b;
  --shadow: 0 18px 45px rgba(94, 58, 61, 0.12);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, #ffe5e9 0, transparent 30%),
    radial-gradient(circle at 92% 92%, #fff1bd 0, transparent 28%),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  width: min(1500px, 96vw);
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--pink-dark);
  font-weight: 800;
  letter-spacing: .06em;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 4px;
  font-size: clamp(30px, 4vw, 50px);
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
}

.top-actions, .modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 11px 17px;
  font-weight: 800;
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .48; transform: none; }

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  box-shadow: 0 10px 22px rgba(230, 96, 124, .23);
}

.ghost-btn {
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
}

.danger-btn {
  color: #a73348;
  background: #ffe7ea;
  border: 1px solid #f0bcc4;
}

.text-btn {
  padding: 2px 5px;
  color: var(--muted);
  background: transparent;
}

.full-btn { width: 100%; }
.hidden-action { display: none; }
.hidden-action.visible { display: inline-flex; align-items: center; justify-content: center; }

.status-panel {
  display: grid;
  grid-template-columns: minmax(245px, 1fr) minmax(185px, .65fr) minmax(245px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.player-card, .turn-card, .board-card, .control-card {
  background: rgba(255, 253, 249, .95);
  border: 1px solid rgba(232, 198, 200, .92);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  opacity: .68;
}

.player-card.active {
  opacity: 1;
  outline: 3px solid rgba(255, 138, 161, .2);
}

.player-dot {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.65);
}

.player-main { flex: 1; min-width: 0; }
.player-card small, .turn-card span, .current-cell > span { display: block; color: var(--muted); }
.player-card strong { display: block; margin-top: 2px; font-size: 18px; }

.position-label {
  white-space: nowrap;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1e3df;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width .3s ease;
}

.turn-card {
  display: grid;
  place-content: center;
  min-height: 78px;
  padding: 10px;
  text-align: center;
}

.turn-card strong { margin: 3px 0; font-size: 21px; }
.turn-card small { color: #9b7a55; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.board-card { padding: 14px; overflow: hidden; }

.board-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: #f5e3df;
  line-height: 0;
}

.board-shell img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.token {
  position: absolute;
  z-index: 5;
  width: clamp(22px, 2.55vw, 36px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 3px solid white;
  border-radius: 50% 50% 46% 46%;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 5px 12px rgba(61, 35, 38, .38);
  transition: left .24s ease, top .24s ease, transform .24s ease;
}

.token::after {
  content: "";
  position: absolute;
  bottom: -19%;
  width: 42%;
  height: 25%;
  border: 2px solid white;
  border-top: 0;
  border-radius: 50%;
  background: inherit;
}

.token span { position: relative; z-index: 2; font-size: 12px; }

.board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.board-footer p { margin: 0; }
.board-footer a { flex: none; color: #bd5168; font-weight: 800; }

.control-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.dice-zone {
  padding-bottom: 15px;
  border-bottom: 1px dashed var(--line);
  text-align: center;
}

.dice-zone p { margin-bottom: 5px; color: var(--muted); }
.dice {
  margin: 6px auto 12px;
  font-size: 82px;
  line-height: 1;
  filter: drop-shadow(0 7px 5px rgba(70,45,46,.16));
}
.dice.rolling { animation: shake .13s linear infinite alternate; }

@keyframes shake {
  from { transform: rotate(-8deg) translateY(-2px); }
  to { transform: rotate(8deg) translateY(2px); }
}

#rollBtn { width: 100%; min-height: 50px; }

.current-cell {
  padding: 14px;
  border: 1px solid #f2d5cb;
  border-radius: 15px;
  background: #fff5f0;
}

.current-cell strong { display: block; margin: 5px 0; font-size: 18px; }
.current-cell p { margin-bottom: 8px; color: var(--muted); line-height: 1.55; }

.requirement-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.requirement-tags span {
  padding: 4px 8px;
  border-radius: 999px;
  color: #83621d;
  background: #fff1af;
  font-size: 12px;
  font-weight: 800;
}

.centered-tags { justify-content: center; }

.log-zone { min-height: 190px; }
.section-title { display: flex; align-items: center; justify-content: space-between; }

#gameLog {
  max-height: 245px;
  margin: 10px 0 0;
  padding-left: 23px;
  overflow: auto;
}
#gameLog li { padding: 4px 0; color: var(--muted); line-height: 1.45; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
  background: rgba(63, 43, 45, .5);
  backdrop-filter: blur(6px);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 25px 80px rgba(42, 25, 27, .25);
}

.wide-modal { width: min(680px, 94vw); }
.modal-card h2 { margin-bottom: 8px; }
.modal-card h3 { margin: 18px 0 10px; font-size: 17px; }
.modal-subtitle { color: var(--muted); line-height: 1.55; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 145px;
  gap: 14px;
  margin: 18px 0;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.form-grid .full-row { grid-column: 1 / -1; }

input, select, textarea {
  min-height: 43px;
  padding: 8px 11px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: white;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,138,161,.14);
}

input[type="color"] { width: 100%; padding: 4px; }
textarea.save-code { width: 100%; min-height: 100px; resize: vertical; font-family: Consolas, monospace; font-size: 12px; }

.modal-actions { margin-top: 15px; }
.bottom-actions { padding-top: 5px; border-top: 1px solid #f1e4e1; }

.event-card { text-align: center; }
.event-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #a63c50;
  background: #ffe4e8;
  font-weight: 900;
}
.event-index { margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.event-text { margin: 14px 0 18px; font-size: 20px; line-height: 1.65; white-space: pre-line; }
.consent-note { margin: 15px 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.starter-note { color: var(--muted); font-size: 16px; }
.starter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}
.starter-btn {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink);
  border: 2px solid var(--line);
  background: white;
  box-shadow: 0 10px 25px rgba(80,50,53,.08);
}
.starter-btn:hover { border-color: var(--pink); }
.starter-color {
  width: 25px;
  height: 25px;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(50,35,36,.24);
}

.skipped-list {
  display: grid;
  gap: 9px;
  max-height: 360px;
  overflow-y: auto;
}
.skipped-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #f0d6d8;
  border-radius: 12px;
  background: #fff7f5;
}
.skipped-item div { flex: 1; }
.skipped-item small { display: block; color: var(--muted); }
.skipped-item button { padding: 7px 10px; }

.empty-state {
  padding: 25px 10px;
  color: var(--muted);
  text-align: center;
}

.rules-list { padding-left: 23px; color: var(--muted); line-height: 1.75; }
.consent-box {
  margin: 18px 0 0;
  padding: 13px;
  border-radius: 12px;
  color: #8b5660;
  background: #fff0f2;
  line-height: 1.65;
}

hr { margin: 22px 0; border: 0; border-top: 1px solid #f0dfdc; }

@media (max-width: 1000px) {
  .topbar { flex-direction: column; }
  .game-layout { grid-template-columns: 1fr; }
  .control-card { display: grid; grid-template-columns: minmax(190px,.7fr) 1fr; }
  .log-zone { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .app { width: 100%; padding: 12px; }
  .status-panel { grid-template-columns: 1fr 1fr; }
  .turn-card { grid-column: 1 / -1; grid-row: 1; }
  .player-card { padding: 10px; }
  .position-label { font-size: 12px; }
  .control-card { grid-template-columns: 1fr; }
  .log-zone { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-row { grid-column: auto; }
  .board-card { padding: 7px; }
  .board-footer { align-items: flex-start; flex-direction: column; }
  .starter-actions { grid-template-columns: 1fr; }
  .stacked-mobile { flex-direction: column-reverse; }
  .stacked-mobile button { width: 100%; }
}

@media (orientation: portrait) and (max-width: 700px) {
  .board-shell::before {
    content: "横屏观看棋盘会更清楚";
    position: absolute;
    top: 8px;
    left: 50%;
    z-index: 10;
    transform: translateX(-50%);
    padding: 7px 11px;
    border-radius: 999px;
    color: #82434e;
    background: rgba(255,255,255,.92);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(61,35,38,.15);
  }
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 999px;
  color: #6f4a24;
  font: inherit;
  font-weight: 800;
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
  background: linear-gradient(135deg, rgba(255, 138, 161, .28), rgba(255, 226, 91, .45));
  border: 1px solid rgba(226, 151, 117, .48);
  box-shadow: 0 5px 14px rgba(151, 96, 73, .10);
}

.home-link-icon {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .65);
}

.home-link:visited {
  color: #6f4a24;
}

.home-link:hover {
  transform: translateY(-1px);
  color: #5e3b1d;
  border-color: rgba(218, 127, 142, .62);
  background: linear-gradient(135deg, rgba(255, 138, 161, .38), rgba(255, 226, 91, .58));
  box-shadow: 0 7px 17px rgba(151, 96, 73, .14);
}

.home-link:active {
  transform: translateY(0);
}

.home-link:focus-visible {
  outline: 3px solid rgba(255, 138, 161, .35);
  outline-offset: 2px;
}
