/* =========================================================
   MODALS, TOASTS & RESPONSIVE
   ========================================================= */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 8, 6, 0.72);
  backdrop-filter: blur(8px);
  animation: overlay-in 180ms ease both;
}

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

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(86vh, 900px);
  border: 1px solid rgba(225, 199, 143, 0.18);
  border-radius: 15px;
  background:
    radial-gradient(circle at 85% -10%, rgba(214, 177, 106, 0.1), transparent 38%),
    linear-gradient(160deg, #14241d, #0b1611 62%);
  box-shadow:
    0 35px 100px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: modal-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  overflow: hidden;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal.wide {
  width: min(760px, 100%);
}

.modal.rules-modal {
  width: min(820px, 100%);
  max-height: min(88vh, 920px);
}

.modal.card-modal {
  width: min(680px, 100%);
}

.modal.gameover-modal {
  width: min(700px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 20px;
  padding: 23px 25px 17px;
  border-bottom: 1px solid rgba(225, 199, 143, 0.09);
}

.modal-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 8px;
  letter-spacing: 0.28em;
}

.modal-head h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.modal-head p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.modal-close {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-top: -2px;
  border: 1px solid rgba(225, 199, 143, 0.12);
  border-radius: 50%;
  color: var(--muted);
  font-size: 16px;
  transition: 150ms ease;
}

.modal-close:hover {
  color: var(--ink);
  border-color: rgba(225, 199, 143, 0.3);
  transform: rotate(90deg);
}

.modal-body {
  flex: 1;
  padding: 22px 25px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(214, 177, 106, 0.2) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(214, 177, 106, 0.18);
  border-radius: 4px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 9px;
  padding: 15px 25px;
  border-top: 1px solid rgba(225, 199, 143, 0.09);
  background: rgba(5, 11, 8, 0.28);
}

.modal-foot .spacer {
  flex: 1;
}

.modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid rgba(225, 199, 143, 0.16);
  border-radius: 7px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  letter-spacing: 0.03em;
  transition: 150ms ease;
}

.modal-btn:hover {
  border-color: rgba(225, 199, 143, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

.modal-btn.gold {
  border-color: rgba(255, 242, 200, 0.3);
  color: #1b160b;
  background: linear-gradient(135deg, #e6c67e, #c99e50);
  font-weight: 700;
}

.modal-btn.gold:hover {
  filter: brightness(1.07);
}

.modal-btn.danger {
  color: var(--danger);
  border-color: rgba(221, 122, 110, 0.28);
}

.modal-btn:disabled {
  opacity: 0.36;
}

/* ---------- rules prose ---------- */

.prose {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.85;
}

.prose h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 26px 0 9px;
  color: var(--gold-bright);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.prose h3:first-child {
  margin-top: 0;
}

.prose h3::before {
  content: "◆";
  color: rgba(214, 177, 106, 0.5);
  font-size: 7px;
}

.prose p {
  margin: 7px 0;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose ul,
.prose ol {
  margin: 8px 0;
  padding-left: 19px;
}

.prose li {
  margin: 4px 0;
}

.prose li::marker {
  color: var(--gold);
}

.prose .rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.prose .rule-box {
  padding: 11px 13px;
  border: 1px solid rgba(225, 199, 143, 0.09);
  border-radius: 7px;
  background: rgba(4, 10, 8, 0.3);
}

.prose .rule-box b {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.prose .rule-box p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.prose table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 10px;
}

.prose th,
.prose td {
  padding: 7px 9px;
  border: 1px solid rgba(225, 199, 143, 0.09);
  text-align: center;
}

.prose th {
  color: var(--gold);
  background: rgba(214, 177, 106, 0.06);
  font-weight: 500;
}

.prose td {
  color: var(--muted);
}

.prose .rules-note {
  margin-top: 15px;
  padding: 12px 14px;
  border-left: 2px solid rgba(214, 177, 106, 0.35);
  background: rgba(214, 177, 106, 0.04);
  color: var(--muted);
  font-size: 10px;
}

.prose a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- card detail ---------- */

.card-detail {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 26px;
  align-items: start;
}

.detail-card-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 265px;
  border: 1px solid rgba(225, 199, 143, 0.08);
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 44%, rgba(214, 177, 106, 0.08), transparent 55%),
    rgba(4, 10, 8, 0.28);
  perspective: 800px;
}

.detail-card-stage .dev-card {
  width: 166px;
  min-height: 228px;
  pointer-events: none;
  transform: rotate(-3deg);
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.45);
}

.detail-card-stage .card-inner {
  min-height: 228px;
}

.detail-card-stage .card-gem {
  width: 58px;
  height: 65px;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.detail-title .bonus-orb {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.4), transparent 28%),
    radial-gradient(circle at 50% 55%, var(--gem), var(--gem-deep) 80%);
  box-shadow: 0 4px 13px var(--gem-glow);
}

.detail-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.detail-stats {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.detail-stat {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(225, 199, 143, 0.09);
  border-radius: 7px;
  background: rgba(4, 10, 8, 0.26);
}

.detail-stat span {
  display: block;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.detail-stat b {
  display: block;
  margin-top: 4px;
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 400;
}

.detail-section {
  margin-top: 16px;
}

.detail-section h3 {
  margin-bottom: 8px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.detail-cost-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.detail-cost {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 57px;
  padding: 5px 7px;
  border: 1px solid color-mix(in srgb, var(--gem) 26%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--gem) 8%, transparent);
}

.detail-cost .orb {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.4), transparent 28%), var(--gem);
  box-shadow: 0 2px 6px var(--gem-glow);
}

.detail-cost b {
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 400;
}

.detail-cost small {
  color: var(--faint);
  font-size: 7px;
}

.pay-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(225, 199, 143, 0.08);
  border-radius: 7px;
  background: rgba(4, 10, 8, 0.26);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.pay-summary strong {
  color: var(--gold-bright);
}

.mushroom-discount-note {
  color: #d4b8f2;
}

.pay-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: Georgia, serif;
  font-size: 10px;
}

.pay-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gem);
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.detail-actions .modal-btn {
  flex: 1;
}

/* ---------- discard ---------- */

.discard-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(214, 177, 106, 0.14);
  border-radius: 8px;
  background: rgba(214, 177, 106, 0.045);
  color: var(--muted);
  font-size: 11px;
}

.discard-count b {
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 400;
}

.discard-count em {
  color: var(--faint);
  font-size: 9px;
  font-style: normal;
}

.discard-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.discard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 11px;
  border: 1px solid rgba(225, 199, 143, 0.09);
  border-radius: 8px;
  background: rgba(4, 10, 8, 0.28);
}

.discard-item .token-orb {
  width: 31px;
  height: 31px;
}

.discard-name {
  flex: 1;
  min-width: 0;
}

.discard-name b {
  display: block;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.discard-name small {
  color: var(--faint);
  font-size: 8px;
}

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

.stepper button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(225, 199, 143, 0.13);
  border-radius: 5px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.025);
  font-size: 14px;
  transition: 140ms ease;
}

.stepper button:hover:not(:disabled) {
  border-color: rgba(214, 177, 106, 0.35);
  color: var(--gold);
}

.stepper button:disabled {
  opacity: 0.25;
}

.stepper b {
  min-width: 28px;
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 400;
  text-align: center;
}

.discard-total {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(225, 199, 143, 0.08);
  color: var(--muted);
  font-size: 10px;
}

.discard-total b {
  color: var(--gold-bright);
}

/* ---------- noble choice ---------- */

.noble-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.noble-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid rgba(214, 177, 106, 0.18);
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 0%, rgba(214, 177, 106, 0.12), transparent 58%),
    rgba(4, 10, 8, 0.28);
  transition: 170ms ease;
}

.noble-choice:hover {
  border-color: rgba(214, 177, 106, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.28);
}

.noble-choice .noble-emblem {
  width: 44px;
  height: 45px;
  font-size: 24px;
}

.noble-choice-name {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.noble-choice-req {
  display: flex;
  gap: 5px;
}

.noble-choice-points {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.08em;
}

/* ---------- game over ---------- */

.gameover-hero {
  position: relative;
  padding: 12px 0 20px;
  text-align: center;
}

.gameover-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  border: 1px solid rgba(214, 177, 106, 0.3);
  border-radius: 50%;
  color: var(--gold-bright);
  background: radial-gradient(circle, rgba(214, 177, 106, 0.16), transparent 68%);
  box-shadow: 0 0 38px rgba(214, 177, 106, 0.12);
  font-size: 26px;
}

.gameover-hero h2 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.gameover-hero p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.gameover-hero p b {
  color: var(--gold-bright);
  font-weight: 500;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 8px 13px;
  border: 1px solid rgba(225, 199, 143, 0.08);
  border-radius: 8px;
  background: rgba(4, 10, 8, 0.24);
}

.rank-row.winner {
  border-color: rgba(214, 177, 106, 0.3);
  background: linear-gradient(90deg, rgba(214, 177, 106, 0.09), rgba(4, 10, 8, 0.2));
}

.rank-num {
  width: 20px;
  color: var(--faint);
  font-family: Georgia, serif;
  font-size: 13px;
  text-align: center;
}

.rank-row.winner .rank-num {
  color: var(--gold);
}

.rank-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 33px;
  border-radius: 6px;
  color: #0c1611;
  background: linear-gradient(145deg, var(--avatar-a, #d8b878), var(--avatar-b, #91702f));
  font-family: var(--serif);
  font-size: 11px;
}

.rank-name {
  flex: 1;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.rank-name small {
  margin-left: 6px;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 8px;
}

.rank-stats {
  color: var(--faint);
  font-size: 8px;
  text-align: right;
}

.rank-points {
  width: 60px;
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 21px;
  text-align: right;
}

.rank-points small {
  margin-left: 2px;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 7px;
}

.tie-note {
  margin-top: 14px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
}

/* ---------- toasts ---------- */

.toast-root {
  position: fixed;
  z-index: 300;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid rgba(225, 199, 143, 0.16);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(13, 25, 20, 0.96);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  font-size: 11px;
  line-height: 1.5;
  animation: toast-in 220ms ease both;
}

.toast::before {
  content: "◆";
  color: var(--gold);
  font-size: 7px;
}

.toast.error {
  border-color: rgba(221, 122, 110, 0.28);
}

.toast.error::before {
  content: "!";
  color: var(--danger);
  font-family: Georgia, serif;
  font-size: 11px;
}

.toast.success::before {
  content: "✓";
  color: var(--success);
  font-size: 11px;
}

.toast.leaving {
  animation: toast-out 200ms ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1240px) {
  .game-shell {
    grid-template-columns: 248px minmax(0, 1fr) 308px;
    gap: 9px;
    padding: 9px;
  }

  .market-row {
    grid-template-columns: 28px repeat(4, minmax(0, 1fr)) 72px;
    gap: 5px;
    min-height: 139px;
  }

  .card-inner {
    min-height: 139px;
    padding: 6px 6px 5px;
  }

  .card-art {
    min-height: 41px;
  }

  .card-gem {
    width: 31px;
    height: 36px;
  }

  .card-level {
    font-size: 29px;
  }

  .card-points {
    min-width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .card-bonus {
    width: 23px;
    height: 23px;
  }

  .cost-chip {
    min-width: 25px;
    height: 23px;
    padding: 0 5px;
    font-size: 11.5px;
  }

  .card-cost {
    gap: 4px;
    min-height: 27px;
  }

  .my-area {
    grid-template-columns: minmax(0, 1fr) 194px;
    min-height: 96px;
  }

  .noble-tile {
    min-height: 62px;
    justify-content: center;
    padding-top: 14px;
  }

  .noble-emblem {
    display: none;
  }

  .bonus-dot {
    width: 23px;
    height: 23px;
  }
}

@media (max-width: 1080px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(370px, 430px);
    gap: 38px;
  }

  .gem-cloud {
    opacity: 0.55;
    transform: scale(0.85);
    transform-origin: right bottom;
  }

  .game-shell {
    grid-template-columns: 232px minmax(0, 1fr) 292px;
  }

  .bank-board {
    gap: 5px;
    padding: 2px 7px 7px;
  }

  .bank-token {
    gap: 6px;
    padding: 6px 7px;
    min-height: 48px;
  }

  .token-orb {
    width: 31px;
    height: 31px;
  }

  .token-meta b {
    font-size: 10px;
  }

  .token-meta small {
    font-size: 9px;
  }

  .card-inner {
    padding: 5px 4px;
  }

  .card-cost {
    gap: 2px;
  }

  .cost-chip {
    min-width: 18px;
    height: 21px;
    padding: 0 3px;
    gap: 2px;
    font-size: 10.5px;
  }

  .right-rail {
    gap: 8px;
  }

  .player-meta {
    gap: 4px;
    font-size: 7.5px;
  }
}

@media (max-width: 960px) {
  .home-view {
    padding: 0 24px;
  }

  .hero {
    grid-template-columns: 1fr;
    max-width: 600px;
    gap: 46px;
    padding-top: 40px;
  }

  .hero-copy {
    padding-bottom: 0;
  }

  .gem-cloud {
    display: none;
  }

  .hero h1 {
    font-size: clamp(60px, 13vw, 92px);
  }

  .entry-panel {
    width: 100%;
  }

  .home-lower {
    grid-template-columns: 1fr;
  }

  .lower-card {
    padding: 17px 22px;
  }

  .home-footer {
    flex-direction: column;
    gap: 8px;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .lobby-side {
    order: -1;
  }

  .game-view {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .game-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    padding: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .board-main {
    order: 1;
    min-height: auto;
  }

  .left-rail {
    order: 2;
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
    overflow: visible;
  }

  .right-rail {
    order: 3;
    overflow: visible;
  }

  .market-board {
    overflow-x: auto;
    overflow-y: visible;
  }

  .cost-chip {
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    font-size: 11px;
  }

  .card-cost {
    gap: 3px;
  }

  .market-row {
    grid-template-columns: 30px repeat(4, minmax(122px, 1fr)) 76px;
    min-width: 690px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nobles-board {
    grid-template-columns: 1fr 1fr;
  }

  .noble-emblem {
    display: flex;
  }

  .noble-tile {
    min-height: 66px;
    padding-top: 8px;
  }

  .my-area {
    grid-template-columns: minmax(0, 1fr) 200px;
  }

  .log-list {
    max-height: 200px;
  }

  .players-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .game-topbar {
    position: sticky;
    top: 0;
    height: 54px;
  }
}

@media (max-width: 680px) {
  .home-nav {
    min-height: 70px;
  }

  .nav-actions .live-pill {
    display: none;
  }

  .brand-words strong {
    font-size: 16px;
  }

  .brand-words small {
    font-size: 7px;
  }

  .hero {
    padding-top: 30px;
    gap: 34px;
  }

  .hero h1 {
    margin-top: 14px;
    font-size: clamp(52px, 15vw, 72px);
  }

  .lead {
    font-size: 14px;
    line-height: 1.85;
  }

  .feature-row {
    gap: 24px;
    margin-top: 26px;
  }

  .feature b {
    font-size: 23px;
  }

  .hero-note {
    display: none;
  }

  .entry-content {
    padding: 23px 20px 20px;
  }

  .entry-tab {
    height: 52px;
    font-size: 12px;
  }

  .form-heading h2 {
    font-size: 20px;
  }

  .difficulty-card {
    padding: 8px 4px;
  }

  .difficulty-card b {
    font-size: 12px;
  }

  .difficulty-card small {
    font-size: 8px;
  }

  .home-lower {
    margin-top: 10px;
  }

  .lobby-view .home-nav,
  .lobby-content {
    width: calc(100% - 28px);
  }

  .lobby-content {
    padding-top: 30px;
  }

  .lobby-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
  }

  .lobby-heading h1 {
    font-size: 33px;
    line-height: 1.25;
  }

  .room-code-wrap {
    display: flex;
    margin: 7px 0 0;
  }

  .room-code {
    font-size: 24px;
  }

  .seat-panel,
  .lobby-side {
    padding: 17px;
  }

  .seat-grid {
    grid-template-columns: 1fr;
  }

  .seat-card {
    min-height: 80px;
  }

  .game-topbar {
    grid-template-columns: 1fr auto;
    gap: 6px;
    padding: 0 10px;
  }

  .game-meta {
    display: none;
  }

  .game-actions {
    gap: 5px;
  }

  .game-actions .ghost-btn {
    min-height: 30px;
    padding: 0 8px;
    font-size: 10px;
  }

  .game-shell {
    padding: 6px;
  }

  .left-rail {
    display: flex;
    flex-direction: column;
  }

  .my-area {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .my-bonuses {
    min-height: 79px;
  }

  .bonus-summary {
    max-width: 300px;
    margin: 0 auto;
  }

  .players-list {
    grid-template-columns: 1fr;
  }

  .market-row {
    grid-template-columns: 26px repeat(4, 122px) 70px;
    min-width: 0;
  }

  .card-inner {
    min-height: 136px;
  }

  .reserved-slots {
    gap: 4px;
  }

  .reserved-mini {
    padding: 4px;
  }

  .res-meta b {
    font-size: 7px;
  }

  .turn-banner {
    align-items: flex-start;
    padding: 9px 11px;
  }

  .turn-sub {
    display: none;
  }

  .modal-root {
    align-items: flex-end;
    padding: 10px;
  }

  .modal {
    max-height: 92dvh;
    border-radius: 14px;
  }

  .modal-head {
    padding: 19px 18px 14px;
  }

  .modal-body {
    padding: 17px 18px;
  }

  .modal-foot {
    padding: 13px 18px;
  }

  .card-detail {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .detail-card-stage {
    min-height: 210px;
  }

  .detail-card-stage .dev-card {
    width: 132px;
    min-height: 190px;
  }

  .detail-card-stage .card-inner {
    min-height: 190px;
  }

  .detail-card-stage .card-gem {
    width: 43px;
    height: 49px;
  }

  .prose .rules-grid {
    grid-template-columns: 1fr;
  }

  .gameover-hero h2 {
    font-size: 25px;
  }

  .rank-stats {
    display: none;
  }

  .toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 390px) {
  .home-view {
    padding: 0 16px;
  }

  .brand-gem {
    width: 32px;
  }

  .hero h1 {
    font-size: 48px;
  }

  .entry-content {
    padding: 20px 15px 18px;
  }

  .difficulty-grid {
    grid-template-columns: 1fr;
  }

  .difficulty-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 7px 10px;
    text-align: left;
  }

  .segmented label span {
    font-size: 11px;
  }

  .my-area {
    display: flex;
    flex-direction: column;
  }

  .bonus-summary {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
/* ---------- gem colour tokens ---------- */
.color-white { --gem: var(--gem-white); --gem-deep: var(--gem-white-deep); --gem-glow: var(--gem-white-glow); }
.color-blue { --gem: var(--gem-blue); --gem-deep: var(--gem-blue-deep); --gem-glow: var(--gem-blue-glow); }
.color-green { --gem: var(--gem-green); --gem-deep: var(--gem-green-deep); --gem-glow: var(--gem-green-glow); }
.color-red { --gem: var(--gem-red); --gem-deep: var(--gem-red-deep); --gem-glow: var(--gem-red-glow); }
.color-black { --gem: var(--gem-black); --gem-deep: var(--gem-black-deep); --gem-glow: var(--gem-black-glow); }
.color-gold { --gem: var(--gem-gold); --gem-deep: var(--gem-gold-deep); --gem-glow: var(--gem-gold-glow); }

/* ---------- small board states ---------- */
.market-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border: 1px dashed rgba(225, 199, 143, 0.07);
  border-radius: 9px;
  background: rgba(4, 10, 8, 0.14);
  color: rgba(225, 199, 143, 0.13);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.noble-tile.eligible {
  border-color: rgba(214, 177, 106, 0.62);
  box-shadow: 0 0 20px rgba(214, 177, 106, 0.16), inset 0 0 15px rgba(214, 177, 106, 0.06);
}

.noble-tile.eligible::after {
  content: "可拜访";
  position: absolute;
  bottom: 2px;
  left: 50%;
  color: var(--gold);
  font-size: 5px;
  letter-spacing: 0.1em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.noble-empty {
  grid-column: 1 / -1;
  padding: 15px 8px;
  color: var(--faint);
  font-size: 9px;
  text-align: center;
}

.spinner.tiny {
  width: 10px;
  height: 10px;
  border-width: 1px;
}

body.is-busy .primary-btn,
body.is-busy .card-action {
  pointer-events: none;
}

.primary-btn.is-loading {
  pointer-events: none;
  filter: brightness(0.86);
}

.primary-btn.is-loading .spinner {
  border-color: rgba(27, 22, 11, 0.2);
  border-top-color: #1b160b;
}

.room-code-inline {
  color: var(--gold-bright);
  font-family: Georgia, serif;
  letter-spacing: 0.16em;
}

.log-empty {
  padding: 18px 8px;
  color: var(--faint);
  font-size: 9px;
  text-align: center;
}


/* Mobile action-first order: turn → bank → market → hand → nobles → players */
@media (max-width: 680px) {
  .board-main {
    display: contents;
  }

  .turn-banner {
    order: 1;
    position: sticky;
    top: 54px;
    z-index: 14;
    background:
      linear-gradient(90deg, rgba(214, 177, 106, 0.07), transparent 62%),
      #0f1c16;
  }

  .left-rail {
    display: contents;
  }

  .bank-panel {
    order: 2;
    margin-top: 6px;
  }

  .market-board {
    order: 3;
    flex: 0 0 auto;
    width: 100%;
    margin-top: 8px;
  }

  .my-area {
    order: 4;
    width: 100%;
  }

  .nobles-panel {
    order: 5;
    margin-top: 8px;
  }

  .right-rail {
    order: 6;
  }

  .mobile-round {
    display: inline;
  }

  .market-board::before {
    content: "← 左右滑动查看每级卡牌 →";
    display: block;
    padding: 4px 0 2px 28px;
    color: var(--faint);
    font-size: 7px;
    letter-spacing: 0.08em;
  }
}

/* ---------- public room browser ---------- */

.room-browser {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(225, 199, 143, 0.1);
}

.room-browser-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.room-browser-head h3 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 230px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid rgba(225, 199, 143, 0.09);
  border-radius: 7px;
  background: rgba(4, 10, 8, 0.25);
}

.room-item-code {
  flex: 0 0 auto;
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.1em;
}

.room-item-main {
  flex: 1;
  min-width: 0;
}

.room-item-host {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--faint);
  font-size: 8px;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 5px;
  border: 1px solid rgba(124, 196, 165, 0.22);
  border-radius: 3px;
  color: var(--success);
  background: rgba(124, 196, 165, 0.06);
  font-size: 7px;
  letter-spacing: 0.05em;
}

.room-badge.locked {
  color: #e1c6ff;
  border-color: rgba(170, 133, 214, 0.3);
  background: rgba(139, 102, 184, 0.1);
}

.room-join-btn {
  flex: 0 0 auto;
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid rgba(214, 177, 106, 0.26);
  border-radius: 4px;
  color: var(--gold);
  background: rgba(214, 177, 106, 0.07);
  font-size: 8px;
  letter-spacing: 0.04em;
  transition: 150ms ease;
}

.room-join-btn:hover:not(:disabled) {
  background: rgba(214, 177, 106, 0.16);
}

.room-join-btn:disabled {
  opacity: 0.35;
}

.room-empty {
  padding: 18px 8px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 420px) {
  .room-list {
    max-height: 205px;
  }

  .room-item {
    padding: 6px 7px;
  }

  .room-item-code {
    font-size: 11px;
  }
}
