:root {
  --bg: #101714;
  --bg-deep: #070b09;
  --card: #17241f;
  --card-active: #1d3329;
  --ink: #f4f1ea;
  --muted: #93a099;
  --faint: rgba(244, 241, 234, 0.48);
  --line: rgba(244, 241, 234, 0.1);
  --gold: #ffd15c;
  --gold-ink: #241c08;
  --danger: #ff8d6b;
  --draw: #c5e4ff;
  --energy: #ffe08a;
  --supporter: #ffc7a8;
  --retreat: #b7f0cf;
  --radius: 22px;
  color-scheme: dark;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "SF Pro Text", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
input { user-select: text; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  width: min(100%, 480px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(120% 50% at 50% -10%, rgba(255, 209, 92, 0.08), transparent 46%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.setup {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
}

.setup-top {
  flex: 0 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.back-btn:active { background: rgba(255, 255, 255, 0.08); }
.back-btn.is-empty { visibility: hidden; }
.back-btn.is-empty:last-child { margin: 0 -8px 0 0; }

.steps {
  display: flex;
  gap: 6px;
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(244, 241, 234, 0.18);
  transition: width 0.25s ease, background 0.25s ease;
}

.step-dot.is-done { background: rgba(255, 209, 92, 0.5); }
.step-dot.is-on { width: 22px; background: var(--gold); }

.step {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.step.is-entering { animation: step-in 0.28s ease; }

@keyframes step-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

.step-head { padding: 14px 0 0; }

.step-no {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.step-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px 0;
}

.step-foot { flex: 0 0 auto; }

.phone {
  width: 150px;
  height: min(260px, 36dvh);
  padding: 8px;
  border-radius: 28px;
  background: #0c1210;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(244, 241, 234, 0.14);
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
}

.phone-half {
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 850;
}

.phone-half.is-top {
  background: #24362c;
  color: var(--ink);
}

.phone-half.is-top span { transform: rotate(180deg); }

.phone-half.is-bottom {
  background: var(--gold);
  color: var(--gold-ink);
}

.phone.is-solo { grid-template-rows: 1fr; }

.phone.is-solo .phone-half {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.phone.is-solo small {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.7;
}

.mode-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.swap-btn {
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 750;
}

.swap-btn:active { background: rgba(255, 255, 255, 0.1); }

.durations {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.duration {
  height: 92px;
  border-radius: 20px;
  border: 2px solid transparent;
  background: #1a2822;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.duration.selected {
  border-color: var(--gold);
  background: #24362c;
}

.duration-num {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.duration-num.is-text { font-size: 20px; }

.duration-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.duration.selected .duration-unit { color: var(--gold); }

.custom-field {
  width: 100%;
  height: 60px;
  border-radius: 16px;
  border: 1px solid rgba(255, 209, 92, 0.5);
  background: #0f1714;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 8px;
}

.custom-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
}

.custom-field input::-webkit-outer-spin-button,
.custom-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-field span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.coin-stage {
  position: relative;
  width: 100%;
  height: min(230px, 30dvh);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  perspective: 900px;
}

.coin {
  position: relative;
  z-index: 1;
  width: 128px;
  height: 128px;
  margin-bottom: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.coin-jump,
.coin-inner {
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.coin-inner.show-tails { transform: rotateX(180deg); }

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 900;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.coin-front {
  background: radial-gradient(circle at 35% 30%, #fff1b8 0%, #ffd15c 45%, #d99a1e 100%);
  color: #5a3a00;
  box-shadow: inset 0 0 0 7px rgba(140, 90, 0, 0.35), inset 0 0 0 9px rgba(255, 241, 184, 0.6);
}

.coin-back {
  transform: rotateX(180deg);
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d7dde2 45%, #8f9aa3 100%);
  color: #2b343b;
  box-shadow: inset 0 0 0 7px rgba(40, 52, 60, 0.3), inset 0 0 0 9px rgba(255, 255, 255, 0.6);
}

.coin-shadow {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 104px;
  height: 14px;
  margin-left: -52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  filter: blur(4px);
}

.coin-jump.jumping { animation: coin-jump 1.3s forwards; }
.coin-shadow.jumping { animation: coin-shadow 1.3s forwards; }
.coin-inner.spin-heads { animation: spin-heads 1.3s cubic-bezier(0.2, 0.6, 0.3, 1) forwards; }
.coin-inner.spin-tails { animation: spin-tails 1.3s cubic-bezier(0.2, 0.6, 0.3, 1) forwards; }

@keyframes coin-jump {
  0% { transform: translateY(0); animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
  45% { transform: translateY(var(--coin-jump, -150px)) scale(1.08); animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  82% { transform: translateY(0) scale(1); }
  90% { transform: translateY(-12px); }
  100% { transform: translateY(0); }
}

@keyframes coin-shadow {
  0%, 100% { transform: scale(1); opacity: 1; }
  45% { transform: scale(0.45); opacity: 0.35; }
  82% { transform: scale(1); opacity: 1; }
}

@keyframes spin-heads {
  from { transform: rotateX(0); }
  to { transform: rotateX(1800deg); }
}

@keyframes spin-tails {
  from { transform: rotateX(0); }
  to { transform: rotateX(1980deg); }
}

.coin-label {
  margin: -6px 0 0;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.coin-label strong {
  font-size: 24px;
  font-weight: 850;
}

.coin-label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.coin-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 11, 9, 0.84);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: overlay-in 0.2s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.coin-overlay-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.coin-overlay.is-rotated .coin-overlay-body { transform: rotate(180deg); }

.coin-overlay-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--faint);
  font-weight: 650;
}

.rules-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
  background: rgba(7, 11, 9, 0.8);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.rules-overlay.is-rotated .rules-panel { transform: rotate(180deg); }

.rules-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: #142019;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.rules-head {
  flex: 0 0 auto;
  height: 56px;
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.rules-head .back-btn { margin-left: -6px; }

.rules-head h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 850;
}

.close-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.rules-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 18px;
  user-select: text;
}

.cond-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cond-row {
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 16px;
  background: #1a2822;
  padding: 10px 14px 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  box-shadow: inset 3px 0 0 var(--cc);
}

.cond-row:active { background: #22352c; }

.cond-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cond-name {
  font-size: 17px;
  font-weight: 850;
  color: var(--cc);
}

.cond-sum {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.4;
}

.cond-arrow {
  font-size: 24px;
  color: var(--faint);
  line-height: 1;
}

.cond-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.cond-mark span {
  position: relative;
  width: 20px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid var(--cc);
  background: rgba(255, 255, 255, 0.04);
}

.cond-mark span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 8px;
  height: 3px;
  margin-left: -4px;
  border-radius: 2px;
  background: var(--cc);
}

.cond-mark.is-turn-left span { transform: rotate(-90deg); }
.cond-mark.is-turn-right span { transform: rotate(90deg); }
.cond-mark.is-turn-down span { transform: rotate(180deg); }

.cond-mark.is-marker span {
  border-color: rgba(244, 241, 234, 0.35);
}

.cond-mark.is-marker span::after {
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
}

.rule-notes {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.rule-notes p { margin: 0; }
.rule-notes p + p { margin-top: 6px; }

.cond-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: #1a2822;
  box-shadow: inset 3px 0 0 var(--cc);
}

.cond-hero .cond-mark { width: 52px; height: 52px; }
.cond-hero .cond-mark span { width: 26px; height: 36px; }

.cond-hero-name {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--cc);
}

.cond-hero-mark {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
}

.rule-block { margin-top: 16px; }

.rule-block h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.rule-block p,
.rule-block li {
  font-size: 15px;
  line-height: 1.55;
}

.rule-block p { margin: 0; }

.rule-block ul {
  margin: 0;
  padding-left: 18px;
}

.rule-block li + li { margin-top: 4px; }

.role-pick {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.role-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 750;
}

.seg {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: #1a2822;
}

.seg-btn {
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.seg-btn.selected {
  background: var(--gold);
  color: var(--gold-ink);
}

.role-opp {
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
}

.start {
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 16px;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 18px;
  font-weight: 800;
}

.start:disabled {
  opacity: 0.38;
}

.start:not(:disabled):active { transform: scale(0.99); }

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding:
    calc(8px + env(safe-area-inset-top))
    calc(8px + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    calc(8px + env(safe-area-inset-left));
}

.half {
  min-height: 0;
  display: flex;
}

.board.is-solo { grid-template-rows: 1fr; }

.is-solo .card { gap: 10px; padding: 14px 14px 14px; }
.is-solo .who { font-size: 22px; }
.is-solo .timer { font-size: clamp(34px, 6dvh, 56px); }
.is-solo .tile-name { font-size: clamp(20px, 3.4dvh, 32px); }
.is-solo .tile-status { font-size: clamp(12px, 2dvh, 16px); }
.is-solo .tile[data-state="used"] .tile-name { font-size: clamp(15px, 2.2dvh, 20px); }
.is-solo .tile[data-state="used"] .tile-status { font-size: clamp(16px, 2.6dvh, 24px); }
.is-solo .end-slot { flex-basis: 76px; }
.is-solo .end-title { font-size: 20px; }

.half.is-opp-turn { --turn: #8fc8ff; }

.is-opp-turn.is-active .card {
  background: linear-gradient(180deg, #23384a 0%, #19262f 100%);
  box-shadow: inset 0 0 0 2px rgba(143, 200, 255, 0.9);
}

.is-opp-turn .who,
.is-opp-turn.is-active .timer { color: var(--turn); }

.is-opp-turn .pill.is-live,
.is-opp-turn .end-btn.ready {
  background: var(--turn);
  color: #0c1c2a;
}

.is-opp-turn .rulehint:not(.is-warn) { color: var(--turn); }

.is-solo .half.flash .card { animation: turn-in 0.45s ease; }

@keyframes turn-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.otherline {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.otherline span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.otherline time { color: var(--ink); }

.end-slot.has-undo {
  display: flex;
  gap: 8px;
}

.end-slot.has-undo .undo-btn { flex: 0 0 88px; width: auto; }
.end-slot.has-undo .end-btn { flex: 1; width: auto; }

.card {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.is-rotated .card {
  transform: rotate(180deg);
}

.is-active .card {
  background: linear-gradient(180deg, #2a4034 0%, #1c2e26 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 209, 92, 0.92);
}

body.is-paused .is-active .card {
  box-shadow: inset 0 0 0 2px rgba(255, 141, 107, 0.85);
}

.half.flash .card {
  animation: arrive 0.9s ease;
}

@keyframes arrive {
  0% { box-shadow: inset 0 0 0 3px #fff, 0 0 0 0 rgba(255, 209, 92, 0.5); }
  100% { box-shadow: inset 0 0 0 2px rgba(255, 209, 92, 0.92), 0 0 0 18px rgba(255, 209, 92, 0); }
}

.head { display: flex; flex-direction: column; gap: 2px; }

.head-top, .head-mid {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.spacer { flex: 1; }

.round {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.round-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.round-time {
  font-size: 13px;
  font-weight: 800;
}

.round.is-low { background: rgba(255, 209, 92, 0.16); }
.round.is-low .round-time,
.round.is-low .round-label { color: var(--gold); }

.round.is-up { background: rgba(255, 141, 107, 0.18); }
.round.is-up .round-time,
.round.is-up .round-label { color: var(--danger); }

.pill, .badge, .mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.pill.is-live {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: transparent;
}

.pill.is-paused {
  background: rgba(255, 141, 107, 0.18);
  color: var(--danger);
  border-color: transparent;
}

.badge.first {
  background: var(--gold);
  color: var(--gold-ink);
}

.badge.second {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.mini-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 0 10px;
}

.mini-btn.is-hot {
  background: var(--gold);
  color: var(--gold-ink);
}

.idblock { min-width: 0; flex: 1; }

.who {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turnline {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clockblock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 0 auto;
}

.clock-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 700;
}

.timer {
  font-family: "SF Pro Display", "Avenir Next", "DIN Alternate", "PingFang SC", sans-serif;
  font-size: clamp(28px, 4.8dvh, 46px);
  font-weight: 760;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
  color: var(--muted);
}

.is-active .timer { color: var(--gold); }
body.is-paused .timer { color: var(--danger); }

.clock-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8ee0b0;
  box-shadow: 0 0 0 0 rgba(142, 224, 176, 0.7);
  animation: ping 1.6s infinite;
}

body.is-paused .live-dot {
  background: var(--danger);
  animation: none;
}

@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(142, 224, 176, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(142, 224, 176, 0); }
  100% { box-shadow: 0 0 0 0 rgba(142, 224, 176, 0); }
}

.rulehint {
  flex: 0 0 auto;
  height: 16px;
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--gold);
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rulehint.is-warn { color: var(--danger); }

.actions {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}

.tile {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 16px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #101816;
  color: var(--faint);
  box-shadow: inset 0 3px 0 var(--c, var(--gold));
}

.tile-name {
  font-size: clamp(16px, 2.5dvh, 26px);
  font-weight: 850;
  line-height: 1.1;
}

.tile-status {
  font-size: clamp(11px, 1.6dvh, 14px);
  font-weight: 750;
}

.tile[data-state="open"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 46%),
    var(--c);
  color: var(--gold-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.tile[data-state="open"] .tile-status { color: rgba(36, 28, 8, 0.62); }

.tile[data-state="used"] .tile-name {
  font-size: clamp(13px, 1.8dvh, 16px);
  color: rgba(244, 241, 234, 0.42);
}

.tile[data-state="used"] .tile-status {
  font-size: clamp(14px, 2.1dvh, 20px);
  color: var(--ink);
}

.tile[data-state="frozen"],
.tile[data-state="idle"],
.tile[data-state="locked"] {
  background: #101816;
}

.tile[data-state="locked"] .tile-status { color: var(--gold); }

.tile[data-state="open"]:active,
.tile[data-state="used"]:active { transform: scale(0.98); }

.tile.attn[data-state="open"] { animation: nudge 0.9s ease-in-out infinite; }

@keyframes nudge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.end-slot {
  flex: 0 0 62px;
  min-height: 0;
}

.end-btn, .undo-btn, .wait-note {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.end-btn {
  border: 0;
  background: #f4f1ea;
  color: #14201a;
}

.end-btn.ready {
  background: var(--gold);
  color: var(--gold-ink);
}

.end-btn.warn {
  background: var(--danger);
  color: #2a100c;
}

.end-btn:active, .undo-btn:active { transform: scale(0.99); }

.end-title, .wait-note strong, .undo-btn strong {
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.end-sub, .wait-note span, .undo-btn span {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.72;
}

.wait-note {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border: 1px solid var(--line);
}

.undo-btn {
  border: 1px solid rgba(255, 209, 92, 0.7);
  background: rgba(255, 209, 92, 0.08);
  color: var(--gold);
}

.sheet, .confirm {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: rgba(8, 12, 10, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sheet-card, .confirm-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-card button, .confirm-card button {
  height: 52px;
  border-radius: 14px;
  border: 0;
  background: #f4f1ea;
  color: #14201a;
  font-size: 16px;
  font-weight: 800;
}

.sheet-card button.danger, .confirm-card button.danger {
  background: var(--danger);
  color: #2a100c;
}

.sheet-card button.ghost, .confirm-card button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.confirm-card p {
  margin: 0 0 4px;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
}

.toast {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 78px;
  z-index: 3;
  pointer-events: none;
  text-align: center;
  background: rgba(8, 12, 10, 0.92);
  color: var(--ink);
  border: 1px solid rgba(255, 209, 92, 0.45);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

@media (max-height: 700px) {
  .card { padding: 8px 10px; gap: 6px; }
  .end-slot { flex-basis: 54px; }
  .end-title { font-size: 16px; }
  h1 { font-size: 26px; }
  .duration { height: 76px; }
  .coin { width: 108px; height: 108px; --coin-jump: -110px; }
  .step-body { gap: 12px; padding: 10px 0; }
  .sheet { padding: 10px 16px; }
  .sheet-card { gap: 6px; }
  .sheet-card button { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
