:root {
  --ink: #342f27;
  --ink-soft: #675d4f;
  --muted: #988a76;
  --cream: #fff9ee;
  --forest: #3d5a47;
  --forest-deep: #263d31;
  --blue: #397b78;
  --blue-soft: #dcefeb;
  --red: #bf5547;
  --red-soft: #f6e1d9;
  --gold: #cf9a5b;
  --coral: #e49a86;
  --line: rgba(75, 61, 43, 0.12);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --serif: "Optima", "Candara", "Avenir Next", "Palatino Linotype", Georgia, serif;
  --display: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "SimSun", serif;
  --ease: cubic-bezier(0.22, 0.78, 0.22, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #f1e2cc;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- backdrop ---------- */
.game-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 52% 42% at 74% 12%, rgba(255, 247, 220, .9), transparent 68%),
    radial-gradient(ellipse 80% 54% at 50% 105%, rgba(183, 162, 126, .36), transparent 72%),
    linear-gradient(180deg, #f8eddd 0%, #f2e3cd 48%, #e5d1b4 100%);
}
.sun {
  position: absolute; top: 3%; right: 13%; width: min(34vw, 520px); height: min(34vw, 520px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,252,235,.9) 0 12%, rgba(255,243,209,.55) 36%, rgba(255,238,198,0) 70%);
  filter: blur(2px);
}
.halo { position: absolute; border-radius: 50%; filter: blur(10px); pointer-events: none; }
.halo-a { left: -10%; bottom: -20%; width: 60vw; height: 54vw; background: radial-gradient(circle, rgba(203,190,160,.25), rgba(203,190,160,0) 68%); }
.halo-b { right: -4%; bottom: 4%; width: 40vw; height: 40vw; background: radial-gradient(circle, rgba(224,160,93,.1), rgba(224,160,93,0) 68%); }
.grain {
  position: absolute; inset: 0; opacity: .065; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
.game-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: 22px 34px 0; pointer-events: none;
}
.game-header > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 11px; justify-self: start; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.7);
  background: var(--forest-deep); color: #f6ead7;
  font-family: var(--display); font-size: 18px;
  box-shadow: 0 6px 18px rgba(51,60,43,.18);
}
.brand-copy { display: flex; flex-direction: column; gap: 4px; }
.brand-copy strong {
  font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: .08em; line-height: 1;
  color: var(--forest-deep);
}
.brand-copy small {
  font-family: var(--serif); font-size: 7px; font-weight: 600; letter-spacing: .13em;
  color: rgba(64,77,59,.52);
}
.round-heading { text-align: center; padding-top: 1px; }
.round-heading p {
  margin: 0 0 5px; font-family: var(--serif); font-size: 7px; font-weight: 600;
  letter-spacing: .2em; color: rgba(72,82,61,.56);
}
.round-heading h1 {
  margin: 0; font-family: var(--display); font-size: 30px; line-height: 1;
  font-weight: 600; letter-spacing: .12em; color: var(--forest-deep);
}
.header-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }
.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.72);
  background: rgba(255,250,241,.5);
  box-shadow: 0 8px 20px rgba(74,62,42,.06);
  backdrop-filter: blur(14px);
  font-size: 10px; letter-spacing: .05em; color: var(--ink-soft);
  transition: background .25s, color .25s, border-color .25s;
}
.ghost-btn:hover { background: rgba(255,252,246,.9); color: var(--forest-deep); border-color: rgba(207,154,91,.3); }
.ghost-btn[aria-pressed="false"] { color: var(--muted); opacity: .72; }

/* ---------- stage ---------- */
.game-stage { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.canvas-host {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: auto; touch-action: none;
}
.canvas-host canvas { display: block; width: 100%; height: 100%; }
.canvas-host.is-pointing { cursor: pointer; }

.turn-pill {
  position: absolute; top: 94px; left: 50%; z-index: 16;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 15px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.78);
  background: rgba(255,249,239,.72);
  box-shadow: 0 12px 30px rgba(68,74,53,.09);
  backdrop-filter: blur(18px);
  font-size: 11px; letter-spacing: .06em; color: var(--forest-deep);
  transition: background .3s, color .3s;
  pointer-events: none;
}
.turn-pill.is-blue { background: rgba(225,243,239,.82); color: #2f625f; }
.turn-pill.is-red { background: rgba(250,232,224,.85); color: #9a4438; }
.turn-pill.is-thinking .turn-dot { animation: thinking-dot .65s ease-in-out infinite; }
.turn-pill.is-thinking { box-shadow: 0 0 0 1px rgba(207,154,91,.18), 0 12px 30px rgba(68,74,53,.12); }
.mode-badge {
  margin-left: 2px; padding-left: 8px;
  border-left: 1px solid rgba(92,105,84,.2);
  font-family: var(--serif); font-size: 7.5px; letter-spacing: .08em;
  color: var(--muted); white-space: nowrap;
}
@keyframes thinking-dot {
  0%, 100% { transform: scale(.72); opacity: .5; }
  50% { transform: scale(1.15); opacity: 1; }
}
.turn-pill.is-pulsing { animation: turn-pulse .52s cubic-bezier(.2,.8,.3,1); }
@keyframes turn-pulse {
  0% { transform: translateX(-50%) scale(1); }
  38% { transform: translateX(-50%) scale(1.075); }
  100% { transform: translateX(-50%) scale(1); }
}
.turn-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 4px rgba(191,85,71,.13);
  transition: background .3s, box-shadow .3s;
}
.turn-pill.is-blue .turn-dot { background: var(--blue); box-shadow: 0 0 0 4px rgba(57,123,120,.13); }

/* ---------- team panels ---------- */
.team-panel {
  position: absolute; top: 142px; z-index: 15; width: 224px;
  padding: 12px 13px 11px; border-radius: 18px;
  border: 1px solid rgba(255,255,255,.7);
  background: rgba(255,249,240,.58);
  box-shadow: 0 14px 36px rgba(78,63,44,.07);
  backdrop-filter: blur(18px) saturate(1.04);
  transition: background .3s, border-color .3s, transform .3s;
  pointer-events: none;
}
.team-panel.team-blue { left: 34px; }
.team-panel.team-red { right: 34px; }
.team-panel.is-active {
  background: rgba(255,252,246,.86);
  border-color: rgba(207,154,91,.35);
  transform: translateY(1px);
}
.team-top { display: flex; align-items: center; gap: 7px; min-height: 22px; }
.team-swatch {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 3px rgba(57,123,120,.12);
}
.team-red .team-swatch { background: var(--red); box-shadow: 0 0 0 3px rgba(191,85,71,.12); }
.team-top b { font-family: var(--display); font-size: 17px; letter-spacing: .06em; font-weight: 600; color: var(--forest-deep); white-space: nowrap; flex: 0 0 auto; }
.team-top em { font-style: normal; font-size: 8px; letter-spacing: .04em; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.team-tag {
  margin-left: 3px; padding: 2px 6px; border-radius: 999px;
  border: 1px solid rgba(57,123,120,.16); background: rgba(57,123,120,.07);
  font-family: var(--serif); font-size: 6.5px; letter-spacing: .04em;
  color: #397b78; white-space: nowrap;
}
.team-red .team-tag {
  border-color: rgba(191,85,71,.16); background: rgba(191,85,71,.07); color: #a54e40;
}
.team-state {
  margin-left: auto; padding: 3px 7px; border-radius: 999px;
  font-family: var(--serif); font-size: 7px; letter-spacing: .12em; color: var(--muted);
  border: 1px solid var(--line);
}
.team-panel.is-active .team-state { color: var(--forest-deep); border-color: rgba(207,154,91,.3); background: rgba(255,255,255,.55); }
.team-panel.is-victorious {
  border-color: rgba(205,160,92,.48);
  box-shadow: 0 0 0 1px rgba(236,204,151,.22), 0 16px 42px rgba(175,125,55,.16);
}
.team-panel.is-defeated { filter: grayscale(.62); opacity: .6; }

.loss-panel {
  position: absolute; top: 252px; z-index: 14;
  width: 190px; padding: 10px 12px;
  border-radius: 17px; border: 1px solid rgba(255,255,255,.68);
  background: rgba(255,249,239,.62);
  box-shadow: 0 14px 34px rgba(74,62,42,.06);
  backdrop-filter: blur(16px);
  pointer-events: none;
}
.loss-blue { left: 34px; border-left: 2px solid rgba(57,123,120,.45); }
.loss-red { right: 34px; border-right: 2px solid rgba(191,85,71,.45); }
.loss-head { display: flex; align-items: center; gap: 7px; }
.loss-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.loss-red .loss-dot { background: var(--red); }
.loss-head b { font-family: var(--display); font-size: 11px; letter-spacing: .08em; color: var(--forest-deep); font-weight: 600; }
.loss-count {
  margin-left: auto; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--line); font-family: var(--serif);
  font-size: 7px; color: var(--muted);
}
.loss-list { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; min-height: 32px; margin-top: 8px; }
.loss-list img {
  width: 32px; height: 32px; border-radius: 8px; object-fit: cover;
  border: 1px solid rgba(255,255,255,.7); background: rgba(236,225,205,.55);
  filter: grayscale(.65) opacity(.68);
}
.loss-empty { font-family: var(--serif); font-size: 8px; letter-spacing: .06em; color: rgba(103,96,79,.48); padding: 5px 0; }
.captured { display: flex; align-items: center; gap: 4px; min-height: 28px; margin-top: 8px; flex-wrap: wrap; }
.captured img.is-new { animation: captured-pop .38s cubic-bezier(.2,.8,.3,1); }
@keyframes captured-pop {
  0% { transform: scale(.35) rotate(-12deg); opacity: 0; }
  65% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.captured img {
  width: 25px; height: 25px; object-fit: cover; object-position: 50% 36%;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.9);
  background: rgba(255,255,255,.5); box-shadow: 0 3px 8px rgba(60,54,40,.12);
}
.captured-empty { font-size: 8.5px; letter-spacing: .06em; color: rgba(111,99,82,.55); }

/* ---------- selected / hint / legend ---------- */
.selected-card {
  position: absolute; left: 34px; bottom: 30px; z-index: 18;
  width: 286px; min-height: 76px; padding: 10px 12px;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.78);
  background: rgba(255,250,241,.76);
  box-shadow: 0 18px 44px rgba(76,62,42,.11);
  backdrop-filter: blur(22px) saturate(1.06);
  pointer-events: auto;
}
.selected-empty { display: flex; align-items: center; gap: 10px; height: 55px; }
.empty-knot {
  width: 27px; height: 27px; flex: 0 0 27px; border-radius: 50%;
  border: 1px dashed rgba(104,96,76,.35);
  background: radial-gradient(circle, rgba(207,154,91,.15), transparent 65%);
}
.selected-empty p { margin: 0; font-size: 10px; line-height: 1.6; color: var(--ink-soft); }
.selected-empty small { font-size: 8.5px; letter-spacing: .02em; color: var(--muted); }
.selected-content { display: flex; align-items: center; gap: 10px; }
.selected-content img {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 14px;
  object-fit: cover; object-position: 50% 34%;
  background: #f8edde; border: 1px solid rgba(255,255,255,.9);
}
.selected-copy { min-width: 0; flex: 1; }
.selected-meta { display: block; font-family: var(--serif); font-size: 7px; letter-spacing: .1em; color: var(--accent, #a86b32); }
.selected-copy strong { display: block; margin-top: 3px; font-family: var(--display); font-size: 21px; font-weight: 600; line-height: 1.1; color: var(--forest-deep); }
.selected-copy p { margin: 3px 0 0; font-size: 8.5px; line-height: 1.4; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selected-count {
  align-self: flex-start; flex: 0 0 auto; padding: 3px 7px;
  border-radius: 999px; background: rgba(255,255,255,.62);
  font-family: var(--serif); font-size: 7.5px; letter-spacing: .08em; color: var(--muted);
}
.hint {
  position: absolute; left: 50%; bottom: 40px; z-index: 14;
  transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(255,249,238,.68);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: 0 10px 25px rgba(68,78,55,.07);
  backdrop-filter: blur(16px);
  font-size: 9.5px; letter-spacing: .05em; color: rgba(58,73,56,.72);
  white-space: nowrap; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.hint.warn { color: #9d4c3e; background: rgba(252,235,227,.85); }
.board-legend {
  position: absolute; right: 34px; bottom: 33px; z-index: 14;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 13px; border-radius: 999px;
  background: rgba(255,249,238,.6);
  border: 1px solid rgba(255,255,255,.6);
  font-size: 8px; letter-spacing: .05em; color: rgba(85,78,62,.62);
  pointer-events: none;
}
.board-legend span { display: inline-flex; align-items: center; gap: 5px; }
.board-legend i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.legend-water { background: #82b9c6; }
.legend-trap { background: #e49a86; }
.legend-den { background: #2c4538; }
.credit {
  position: absolute; right: 34px; bottom: 11px; z-index: 10;
  font-family: var(--serif); font-size: 6.5px; letter-spacing: .16em;
  color: rgba(90,81,64,.38); pointer-events: none;
}

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
  background: rgba(44,50,37,.28);
  backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden;
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal:not(.is-open) { pointer-events: none; }
.modal-card {
  position: relative; width: min(760px, 92vw); max-height: min(86vh, 780px);
  overflow-y: auto; padding: 34px 36px 28px;
  border-radius: 28px; border: 1px solid rgba(255,255,255,.9);
  background: linear-gradient(145deg, rgba(255,252,246,.98), rgba(249,239,224,.97));
  box-shadow: 0 40px 90px rgba(50,53,37,.26);
  transform: translateY(0) scale(1);
}
.modal.is-open .modal-card {
  transform: translateY(0) scale(1);
}

/* ---------- mode picker ---------- */
.mode-card { width: min(660px, 92vw); }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.mode-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  min-height: 112px; padding: 14px 16px; border-radius: 18px;
  border: 1px solid var(--line); background: rgba(255,255,255,.34);
  color: var(--forest-deep); text-align: left; cursor: pointer;
  font-family: inherit; transition: border-color .2s, background .2s, box-shadow .2s, transform .2s;
}
.mode-option:hover { transform: translateY(-1px); border-color: rgba(57,123,120,.3); }
.mode-option.is-selected {
  border-color: rgba(57,123,120,.48);
  background: rgba(230,243,235,.72);
  box-shadow: 0 0 0 1px rgba(57,123,120,.08), 0 12px 26px rgba(57,123,120,.08);
}
.mode-icon {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: var(--forest-deep); color: #f6ead7;
  font-family: var(--display); font-size: 14px;
}
.mode-option strong { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.mode-option small { font-family: var(--body); font-size: 9px; line-height: 1.5; color: var(--muted); }
.ai-settings {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 16px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: 16px;
  background: rgba(255,255,255,.3);
}
.setting-row { display: flex; align-items: center; gap: 12px; }
.setting-label {
  width: 38px; flex: none; font-family: var(--serif); font-size: 8px;
  letter-spacing: .14em; color: var(--muted);
}
.segmented {
  display: inline-flex; gap: 3px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.42);
}
.segment-btn {
  border: 0; border-radius: 999px; padding: 5px 10px;
  background: none; color: var(--muted); cursor: pointer;
  font-family: var(--serif); font-size: 8px; letter-spacing: .04em;
}
.segment-btn.is-selected { background: var(--forest-deep); color: #f6ead7; }
.setting-note { margin: 0; font-family: var(--body); font-size: 8px; line-height: 1.5; color: var(--muted); }
.mode-card .primary-btn { width: 100%; margin-top: 18px; }
@keyframes card-settle {
  0% { opacity: .55; transform: translateY(14px) scale(.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute; top: 16px; right: 18px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255,255,255,.5);
  font-size: 19px; line-height: 1; color: var(--muted);
}
.modal-eyebrow { margin: 0 0 8px; font-family: var(--serif); font-size: 7.5px; letter-spacing: .2em; color: var(--gold); }
.modal-card h2 { margin: 0; font-family: var(--display); font-size: 34px; line-height: 1.15; font-weight: 600; color: var(--forest-deep); }
.modal-lead { margin: 10px 0 0; font-size: 10.5px; line-height: 1.8; color: var(--ink-soft); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.rules-grid article { padding: 13px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.42); }
.rules-grid h3 { margin: 0 0 6px; font-family: var(--display); font-size: 14px; letter-spacing: .05em; font-weight: 600; color: var(--forest-deep); }
.rules-grid p { margin: 0; font-size: 9.5px; line-height: 1.7; color: #69705f; }
.rank-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px;
  margin-top: 14px; padding: 10px 12px; border-radius: 12px;
  background: rgba(244,231,211,.55); border: 1px solid rgba(255,255,255,.65);
  font-size: 8.5px; letter-spacing: .03em; color: #766a56;
}
.rank-title { font-family: var(--serif); font-size: 7px; letter-spacing: .12em; color: var(--muted); margin-right: 3px; }
.modal-note { margin: 10px 2px 0; font-size: 8.5px; letter-spacing: .04em; color: var(--muted); }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--forest-deep); color: #f7ecdb;
  font-size: 11px; letter-spacing: .07em;
  box-shadow: 0 10px 24px rgba(43,56,41,.17);
  transition: transform .2s, background .2s;
}
.primary-btn:hover { background: #314b3b; transform: translateY(-1px); }
#rulesStart { margin-top: 18px; }
.win-card { text-align: center; width: min(440px, 90vw); padding: 34px 34px 28px; }
.win-mark {
  width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 14px;
  border-radius: 50%; background: radial-gradient(circle at 34% 27%, #fff, transparent 45%), #f3e3cb;
  font-family: var(--display); font-size: 30px; color: var(--red);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 12px 30px rgba(74,63,44,.13);
}
.win-card h2 { font-size: 38px; }
.win-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }
.win-actions .ghost-btn { height: 40px; padding: 0 17px; background: rgba(255,255,255,.55); }
.win-loser {
  display: inline-block; margin: 13px 0 0; padding: 4px 10px;
  border: 1px solid rgba(96,86,69,.14); border-radius: 999px;
  font-family: var(--serif); font-size: 8px; letter-spacing: .12em;
  color: rgba(102,91,75,.58);
}

/* ---------- screen flash / effects ---------- */
.flash {
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 52%, var(--flash-color, rgba(255,217,138,.8)), transparent 62%);
  mix-blend-mode: screen;
}
.flash.is-on { animation: screen-flash .48s ease-out forwards; }
@keyframes screen-flash {
  0% { opacity: .55; }
  55% { opacity: .18; }
  100% { opacity: 0; }
}

.capture-toast {
  position: fixed; left: 50%; top: 152px; z-index: 65;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 15px; border-radius: 999px;
  background: rgba(38,58,46,.94); color: #fff8ec;
  border: 1px solid rgba(238,207,157,.36);
  box-shadow: 0 12px 30px rgba(54,43,28,.2);
  font-family: var(--display); font-size: 16px; letter-spacing: .1em;
  pointer-events: none; opacity: 0;
  transform: translate(-50%, 8px);
}
.capture-toast::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--toast-color, #d6ad6c);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12);
}
.capture-toast.is-on { animation: capture-toast 1.1s ease-out forwards; }
@keyframes capture-toast {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.92); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  68% { opacity: 1; transform: translate(-50%, -2px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(1); }
}

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: #f4e6d2;
  transition: opacity .6s var(--ease), visibility .6s;
}
body.is-ready .loader { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 50%; background: var(--forest-deep); color: #f6ead7;
  font-family: var(--display); font-size: 25px;
  box-shadow: 0 10px 30px rgba(56,65,47,.17);
  animation: bob 2s ease-in-out infinite alternate;
}
.loader p { margin: 0; font-family: var(--display); font-size: 12px; letter-spacing: .1em; color: var(--forest-deep); }
.loader > span { width: 150px; height: 2px; overflow: hidden; border-radius: 99px; background: rgba(60,82,63,.12); }
.loader > span i { display: block; width: 38%; height: 100%; border-radius: inherit; background: var(--gold); animation: load 1.4s var(--ease) infinite; }
@keyframes bob { to { transform: translateY(-6px); } }
@keyframes load { 0% { transform: translateX(-110%); } 100% { transform: translateX(350%); } }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .game-header { padding: 18px 24px 0; }
  .team-panel { width: 198px; top: 132px; }
  .team-panel.team-blue { left: 24px; }
  .team-panel.team-red { right: 24px; }
  .loss-panel { top: 238px; width: 170px; padding: 8px 10px; }
  .loss-blue { left: 24px; }
  .loss-red { right: 24px; }
  .loss-list img { width: 28px; height: 28px; }
  .loss-head b { font-size: 10px; }
  .team-top em { display: none; }
  .selected-card { left: 24px; bottom: 22px; width: 266px; }
  .board-legend { right: 24px; bottom: 26px; }
  .hint { bottom: 32px; font-size: 9px; }
  .credit { right: 24px; }
}
@media (max-width: 980px) {
  .round-heading h1 { font-size: 24px; }
  .round-heading p { font-size: 6px; }
  .header-actions .ghost-btn:first-child { display: none; }
  .game-header { grid-template-columns: auto 1fr auto; gap: 10px; }
  .brand-copy small { display: none; }
  .team-panel { width: 172px; top: 122px; padding: 9px 10px; }
  .team-top em { display: none; }
  .team-top b { font-size: 15px; }
  .team-panel.team-blue { left: 14px; }
  .team-panel.team-red { right: 14px; }
  .team-tag { display: none; }
  .loss-panel { display: none; }
  .captured img { width: 21px; height: 21px; }
  .selected-card { left: 14px; bottom: 14px; width: 244px; }
  .selected-content img { width: 44px; height: 44px; flex-basis: 44px; }
  .selected-copy strong { font-size: 18px; }
  .board-legend { display: none; }
  .hint { bottom: 20px; left: auto; right: 16px; transform: none; max-width: 48vw; white-space: normal; line-height: 1.5; text-align: right; }
  .credit { display: none; }
  .turn-pill { top: 82px; }
  .rules-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .game-header { padding: 12px 14px 0; }
  .brand-mark { width: 32px; height: 32px; font-size: 15px; }
  .brand-copy strong { font-size: 16px; }
  .round-heading { display: none; }
  .header-actions { gap: 5px; }
  .ghost-btn { height: 30px; padding: 0 10px; font-size: 9px; }
  .turn-pill { top: 62px; height: 31px; font-size: 10px; }
  .team-panel { top: 104px; width: 145px; border-radius: 14px; }
  .team-top { gap: 5px; }
  .team-state { display: none; }
  .captured { min-height: 20px; }
  .captured img { width: 18px; height: 18px; }
  .selected-card { width: 220px; padding: 8px 9px; min-height: 62px; }
  .selected-empty { height: 45px; }
  .selected-empty p { font-size: 9px; }
  .selected-content img { width: 38px; height: 38px; flex-basis: 38px; border-radius: 10px; }
  .selected-copy strong { font-size: 16px; }
  .selected-copy p { display: none; }
  .selected-count { display: none; }
  .hint { display: none; }
  .mode-badge { display: none; }
  .mode-options { grid-template-columns: 1fr; }
  .mode-option { min-height: 84px; }
  .setting-row { flex-wrap: wrap; }
  .setting-label { width: 100%; }
  .modal-card { padding: 26px 20px 22px; border-radius: 22px; }
  .modal-card h2 { font-size: 27px; }
}
@media (max-height: 760px) and (min-width: 981px) {
  .team-panel { top: 116px; }
  .turn-pill { top: 78px; }
  .selected-card { bottom: 16px; }
  .hint { bottom: 21px; }
  .board-legend { bottom: 19px; }
  .credit { bottom: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
