:root {
  --ink: #24301c;
  --cream: #fff8e8;
  --leaf: #2f8a34;
  --sun: #f0a202;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, #fff3b0 0, transparent 26%),
    linear-gradient(#b7e4fb, #d9f6ae 42%, #86c84e);
}

#fit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 900px;
  margin: -450px 0 0 -800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: center center;
}

button, input, select { font: inherit; color: inherit; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 0;
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  color: #ffe14a;
  text-shadow: 0 2px 0 #e07a12, 2px 0 0 #c45112, -2px 0 0 #c45112, 0 -2px 0 #c45112, 0 4px 0 #9a3d0c;
}

.tag { margin: 2px 0 0; font-weight: 700; font-size: 13px; }

h2 { margin: 0 0 12px; }

.screen {
  flex: 1;
  min-height: 0;
  padding: 8px 16px 10px;
}
.screen[hidden] { display: none !important; }

#home, #secret { overflow: auto; }

#table {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 4px;
}

.panel {
  background: var(--cream);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(40, 70, 20, 0.16);
}

.wide { max-width: 560px; text-align: left; }

.parade { margin-bottom: 8px; }
.parade img {
  width: 100%;
  max-height: 22vh;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  display: block;
  box-shadow: 0 8px 18px rgba(40, 70, 20, 0.16);
}

#home { max-width: 580px; margin: 0 auto; }
#home h2 { font-size: 32px; margin-bottom: 14px; }
#home .panel { padding: 28px 32px; }
#home .parade img { max-height: 200px; }
#home .stepper-row,
#home .field,
#home .check { font-size: 22px; margin: 14px 0; }
#home .note { font-size: 18px; margin: 6px 0 14px; }
#home input:not([type="checkbox"]),
#home select { font-size: 20px; padding: 12px 14px; min-width: 200px; }
#home .check { justify-content: flex-start; gap: 12px; }
#home input[type="checkbox"] {
  width: 28px;
  height: 28px;
  min-width: 28px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}
#home .stepper button {
  width: 48px;
  height: 48px;
  font-size: 28px;
  padding: 0;
}
#home #count-label { font-size: 28px; min-width: 32px; text-align: center; }
#home #start-btn { font-size: 24px; padding: 14px 20px; margin-top: 10px; }

.stepper-row, .field, .check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  font-weight: 700;
}

.stepper { display: flex; align-items: center; gap: 10px; }

.row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 8px;
  margin-bottom: 8px;
}

input, select {
  border: 2px solid #e4d3a4;
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
}

.primary, .ghost {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  background: var(--sun);
  color: #4a2a00;
  box-shadow: 0 4px 0 #c47a00;
}

.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #c47a00; }

.ghost {
  background: white;
  border: 2px solid #e4d3a4;
}

#start-btn { width: 100%; margin-top: 8px; }

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  column-gap: 8px;
  flex: 0 0 auto;
}

.side-tools {
  display: flex;
  align-items: flex-start;
  justify-self: end;
  align-self: start;
  gap: 8px;
}

body:has(#home:not([hidden])) #rules-btn,
body:has(#table:not([hidden])) #rules-btn { display: none; }

.side-tools .ghost,
.side-tools .primary {
  padding: 6px 10px;
  font-size: 13px;
}

.button-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  flex: 0 0 auto;
  width: 200px;
}

#rules-table,
#peek,
#cancel,
#skip {
  box-sizing: border-box;
  width: 200px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0 10px;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#peek:disabled,
#cancel:disabled,
#skip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.seats {
  display: flex;
  flex-wrap: wrap;
  justify-self: start;
  align-self: start;
  align-items: center;
  min-height: 142px;
  gap: 8px;
  min-width: 0;
}

.seat {
  background: rgba(255, 248, 232, 0.92);
  border-radius: 12px;
  padding: 4px 8px;
  min-width: 120px;
  border: 3px solid transparent;
}

.seat.active { border-color: var(--sun); }

.seat .who { display: block; font-weight: 800; }
.seat .meta { display: block; font-size: 13px; opacity: 0.8; }
.seat img { width: 48px; height: 40px; }

.back {
  display: inline-block;
  width: 28px;
  height: 36px;
  border-radius: 6px;
  background: url("../assets/card-back.webp") center/cover no-repeat;
  border: 2px solid #c4a46a;
}

.piles { display: flex; gap: 6px; align-items: flex-start; }

.pile { text-align: center; font-size: 13px; font-weight: 700; }
.pile span { display: block; margin-top: 4px; }

.card-back, .discard-card {
  width: 104px;
  height: 142px;
  border-radius: 12px;
  border: 3px solid #c4a46a;
  background: url("../assets/card-back.webp") center/cover no-repeat;
  color: white;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-weight: 800;
  padding-bottom: 8px;
}

.discard-card {
  background: #fffef8;
  color: var(--ink);
  border-color: var(--leaf);
  font-size: 28px;
}

.hint, .banner {
  text-align: center;
  font-weight: 700;
  margin: 0 auto;
  max-width: 920px;
  flex: 0 0 auto;
}

.hint { font-size: 13px; line-height: 1.25; }

.banner {
  position: absolute;
  z-index: 400;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(760px, 92%);
  margin: 0;
  pointer-events: none;
  background: rgba(255, 248, 232, 0.96);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.3;
  box-shadow: 0 8px 20px rgba(40, 70, 20, 0.22);
}
.banner:empty { display: none; }

.board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.board-stage {
  position: relative;
  width: min(100cqw, calc(100cqh * 1040 / 480 * 1.08));
  height: 100cqh;
  max-height: 100cqh;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 18px;
  box-shadow: 0 8px 18px rgba(40, 70, 20, 0.16);
}

#pieces { position: absolute; inset: 0; }

.turtle {
  position: absolute;
  width: 7.6%;
  aspect-ratio: 78 / 64;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: none;
  transform: translate(-50%, -78%);
  transition: left 0.45s ease, top 0.45s ease;
}

.turtle img, .card img, .seat img, .rank img, #secret img { object-fit: contain; display: block; }
.turtle img { width: 100%; height: 100%; filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.seat img { width: 48px; height: 40px; }
.turtle.pickable { pointer-events: auto; cursor: pointer; }
.turtle.pickable img { filter: drop-shadow(0 0 6px #ffe14a); }

.hand {
  display: flex;
  justify-content: center;
  justify-self: center;
  align-self: start;
  align-items: flex-start;
  gap: 8px;
  overflow-x: auto;
  width: max-content;
  max-width: 100%;
  padding: 0;
}

.card {
  width: 104px;
  height: 142px;
  flex: 0 0 auto;
  border-radius: 18px;
  border: 4px solid var(--leaf);
  background: linear-gradient(#fffef8, #eef6df);
  box-shadow: 0 6px 0 #1d6b24;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 10px;
  cursor: pointer;
}

.card img { width: 76px; height: 62px; }
.card .move { font-size: 20px; font-weight: 900; line-height: 1; }
.card .cap { font-size: 13px; font-weight: 800; }
.card.rainbow { border-color: #7a45c4; box-shadow: 0 6px 0 #5a2e96; }
.card.bad { opacity: 0.42; cursor: not-allowed; }
.card.selected { transform: translateY(-6px); outline: 3px solid #ffbf00; }

.curtain {
  position: fixed;
  inset: 0;
  background: rgba(36, 48, 28, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 18px;
}

.curtain[hidden] { display: none; }
.curtain .panel { text-align: center; max-width: 460px; }
.curtain .panel p { font-size: 20px; font-weight: 800; }

#secret { display: flex; justify-content: center; }
#secret[hidden] { display: none; }
#secret .panel { max-width: 460px; text-align: center; }
#secret img { width: 180px; height: 160px; margin: 0 auto; }

dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: var(--cream);
  max-width: 560px;
}

dialog form { padding: 22px; }
dialog::backdrop { background: rgba(36, 48, 28, 0.45); }
dialog li { margin: 6px 0; }

.rank { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: 700; }
.rank img { width: 56px; height: 46px; }
.note { font-size: 14px; }

