:root {
  --bg-1: #f7f9fa;
  --bg-2: #e6eaee;
  --paper: #ffffff;
  --ink: #16202e;
  --ink-soft: rgba(22, 32, 46, 0.62);
  --ink-faint: rgba(22, 32, 46, 0.5);
  --line: rgba(22, 32, 46, 0.14);
  --line-strong: #5b6573;
  --p1: #1f5e45;
  --p1-light: #2f7a5c;
  --p2: #1f3f6e;
  --p2-light: #325a92;
  --turn: var(--p1);
  --green: #2f7a4a;
  --crimson: #b03a2e;
  --track: #dde2e7;
  --cell: 70px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(ellipse at top, var(--bg-1) 0%, var(--bg-2) 70%, #d5dbe1 100%),
    repeating-linear-gradient(45deg, rgba(22,32,46,0.03) 0 1px, transparent 1px 9px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.tooltip {
  position: fixed;
  z-index: 1500;
  background: #ffffff;
  color: #16202e;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
  max-width: 280px;
  width: 280px;
  box-shadow: 0 12px 28px rgba(22,32,46,0.25);
  border: 1.5px solid rgba(22,32,46,0.4);
}
.tooltip .tt-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.tooltip .tt-name { font-size: 18px; font-weight: 700; }
.tooltip .tt-score { font-size: 15px; font-weight: 700; }
.tooltip .tt-tag {
  font-family: 'Cormorant Garamond', serif; font-style: italic;
  font-size: 14px; color: rgba(22,32,46,0.6); margin-bottom: 8px;
}
.tooltip .tt-body { display: flex; flex-direction: column; gap: 8px; }
.tooltip .tt-row { display: flex; gap: 10px; align-items: flex-start; }
.tooltip .tt-icon {
  flex-shrink: 0; width: 26px; height: 26px;
  border: 1px solid;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.tooltip .tt-text { flex: 1; min-width: 0; }
.tooltip .tt-label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.tooltip .tt-desc {
  font-size: 14px; line-height: 1.35; color: rgba(22,32,46,0.75); margin-top: 2px;
}

/* ---------- MENU ---------- */
/* Fixed-width digits only where numbers change in place (tabular-nums also widens hyphens). */
.pushbar-num, .pushbar-mobile-num, .bag-count, .gameover-scores .num, .shop-shells .num,
.set-price, .fx-popup, .tile-chip, .topbar-title .round { font-variant-numeric: tabular-nums; }

/* Screens fill the space above the footer. */
body { display: flex; flex-direction: column; }
.screen {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---------- FOOTER, LEGAL, CONSENT ---------- */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 6px 18px; padding: 14px 16px 18px;
  font-size: 13px; color: var(--ink-faint);
}
.site-footer a { color: var(--ink-soft); font-weight: 600; text-decoration: none; }
.site-footer a:hover { color: var(--p2); text-decoration: underline; }
.footer-link {
  background: none; border: none; padding: 2px 0;
  font-size: 13px; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 3px;
}
.footer-link:hover { color: var(--p2); }
.shop.legal { max-width: 640px; }
.legal-body { font-size: 15px; line-height: 1.55; color: var(--ink); }
.legal-body h3 { font-size: 15px; margin: 18px 0 4px; }
.legal-body p { margin: 0 0 8px; }
.legal-body a { color: var(--p2); }
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 16px; align-items: center;
  padding: 16px 18px; border-radius: 12px;
  background: var(--paper); border: 1.5px solid var(--line);
  box-shadow: 0 16px 40px rgba(22,32,46,0.25);
  font-size: 14px; line-height: 1.45; color: var(--ink);
}
.consent-text { flex: 1; }
.consent-text strong { display: block; margin-bottom: 2px; }
.consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.consent-actions button { padding: 11px 16px; }
@media (max-width: 600px) {
  .consent { flex-direction: column; align-items: stretch; }
  .consent-actions button { flex: 1; }
}
.menu-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 40px 44px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(22,32,46, 0.12);
  background-image: repeating-linear-gradient(45deg, rgba(22,32,46,0.04) 0 1.5px, transparent 1.5px 7px);
}
.menu-eyebrow {
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint);
}
.menu-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 66px; font-weight: 600; line-height: 1; margin-top: 6px; letter-spacing: 0.02em;
}

/* Tokami brand */
.tokami-lockup {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 4px 0 18px;
}
.tokami-mark {
  filter: drop-shadow(0 4px 8px rgba(22,32,46,0.18));
}
.tokami-wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 90px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  line-height: 0.9;
  color: var(--ink);
  margin-top: 6px;
}
.tokami-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 4px;
}
.topbar-title h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px; font-weight: 600; margin: 0;
  letter-spacing: 0.06em; text-transform: lowercase;
}
.topbar-title { gap: 10px; }
.tokami-mark-sm { flex-shrink: 0; }
.menu-main-card { text-align: center; }
.menu-main-card .menu-tagline {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 19px;
  line-height: 1.4; color: var(--ink-soft);
  margin-top: 4px; max-width: 380px;
}
.menu-tagline {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px; font-style: italic; color: var(--ink-soft); margin-top: 14px;
}
.menu-actions { display: flex; gap: 10px; flex-direction: column; margin-top: 28px; }
.menu-actions .btn-primary { display: flex; flex-direction: column; align-items: center; gap: 4px; line-height: 1.1; padding: 14px 22px; }
.menu-actions .btn-primary .mode-name { font-size: 16px; }
.menu-actions .btn-primary .mode-sub {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 14px;
  letter-spacing: 0.04em; text-transform: none; opacity: 0.85;
  font-weight: 400;
}
.btn-primary {
  font-size: 15px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 14px 22px; background: var(--p1); color: white; border: none; border-radius: 8px;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 6px 14px rgba(31,94,69,0.35);
}
.btn-primary:active { transform: translateY(1px); box-shadow: 0 3px 8px rgba(31,94,69,0.35); }
.btn-secondary {
  font-size: 14px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 12px 18px; background: transparent; color: var(--ink-soft);
  border: 1.5px solid var(--line); border-radius: 8px;
}
.menu-rules {
  margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line);
  font-family: 'Cormorant Garamond', serif; font-size: 17px; line-height: 1.5; color: var(--ink-soft);
  text-align: left;
}
.menu-rules ul { padding-left: 20px; margin: 8px 0 0; }
.link-btn {
  display: inline-block; margin-top: 18px; padding: 4px 2px;
  background: none; border: none;
  font-size: 15px; font-weight: 600; color: var(--p2);
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--p1); }
.shop.rules-modal { max-width: 560px; }
.rules-modal .menu-rules { margin-top: 0; padding-top: 0; border-top: none; font-size: 19px; color: var(--ink); }
.menu-rules li { margin-bottom: 4px; }

/* ---------- GAME ---------- */
.game {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: rgba(255,255,255, 0.55);
  border-radius: 12px;
  border: 1px solid rgba(22,32,46,0.2);
}
.topbar-title { display: flex; align-items: baseline; gap: 14px; }
.topbar-title h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px; font-weight: 600; margin: 0; letter-spacing: 0.04em;
}
.topbar-title .round {
  font-size: 13px; color: var(--ink-faint); letter-spacing: 0.16em; text-transform: uppercase;
}
.topbar-turn { display: flex; align-items: center; gap: 10px; }
.topbar-turn .label {
  font-size: 13px; color: var(--ink-faint); letter-spacing: 0.16em; text-transform: uppercase;
}
.turn-pill {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 6px; border: 1px solid;
}

.main-row {
  display: flex; gap: 18px; justify-content: center; align-items: flex-start;
}

/* pushbar (desktop vertical) */
.pushbar {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 8px 0;
}
.pushbar-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
}
.pushbar-num {
  font-size: 26px; font-weight: 700; line-height: 1;
}
.pushbar-track {
  position: relative;
  width: 32px;
  flex: 1;
  background: var(--track);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(22,32,46,0.25), 0 1px 0 rgba(255,255,255,0.5);
  border: 1.5px solid var(--line-strong);
  min-height: 360px;
}
.pushbar-fill-top {
  position: absolute; top: 0; left: 0; right: 0;
  background: linear-gradient(180deg, var(--p2) 0%, var(--p2-light) 100%);
  transition: height 0.4s ease;
}
.pushbar-fill-bot {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, var(--p1) 0%, var(--p1-light) 100%);
  transition: height 0.4s ease;
}
.pushbar-divider {
  position: absolute; top: 50%; left: -3px; right: -3px; height: 1px;
  background: rgba(22,32,46,0.3);
}

/* mobile horizontal pushbar */
.pushbar-mobile {
  display: none;
  align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--paper); border-radius: 12px; border: 1.5px solid var(--line);
}
.pushbar-mobile-num { font-size: 22px; font-weight: 700; line-height: 1;
}
.pushbar-mobile-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
}
.pushbar-mobile-track {
  position: relative; flex: 1; height: 16px; background: var(--track);
  border-radius: 8px; overflow: hidden; border: 1.5px solid var(--line-strong);
}
.pushbar-mobile-fill-l {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--p1) 0%, var(--p1-light) 100%);
  transition: width 0.4s ease;
}
.pushbar-mobile-fill-r {
  position: absolute; right: 0; top: 0; bottom: 0;
  background: linear-gradient(270deg, var(--p2) 0%, var(--p2-light) 100%);
  transition: width 0.4s ease;
}

/* board */
.board-wrap { position: relative; }
.board {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(31,63,110,0.06) 0%, rgba(31,63,110,0.1) 8%, rgba(255,255,255,0.4) 50%, rgba(31,94,69,0.1) 92%, rgba(31,94,69,0.06) 100%),
    repeating-linear-gradient(0deg, rgba(22,32,46,0.04) 0 1px, transparent 1px 14px),
    repeating-linear-gradient(90deg, rgba(22,32,46,0.04) 0 1px, transparent 1px 14px);
  border-radius: 16px;
  border: 1.5px solid rgba(22,32,46,0.3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4), 0 12px 30px rgba(22,32,46,0.1);
  display: grid;
  gap: 6px;
}

.cell {
  width: var(--cell); height: var(--cell);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.3s ease, transform 0.15s ease;
  position: relative;
}
.cell.cell-owned-1 { background: rgba(31,94,69,0.7); }
.cell.cell-owned-2 { background: rgba(31,63,110,0.7); }
.cell:not(.cell-owned-1):not(.cell-owned-2) {
  border: 1.5px dashed rgba(22,32,46,0.18);
}
.cell.shore-1 {
  border-color: rgba(31,94,69,0.35);
  background: rgba(31,94,69,0.04);
}
.cell.shore-2 {
  border-color: rgba(31,63,110,0.35);
  background: rgba(31,63,110,0.04);
}
.cell.valid-target {
  background: color-mix(in srgb, var(--turn) 14%, transparent);
  border: 1.5px solid var(--turn);
  cursor: pointer;
  animation: pulse 1.4s ease-in-out infinite;
}
.cell-owned-1.valid-target, .cell-owned-2.valid-target { /* not reached, valid target only on empty */ }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--turn) 40%, transparent); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

/* tile (SVG pebble) */
.tile {
  position: relative;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.tile-svg {
  position: absolute; inset: 0;
  filter: drop-shadow(0 3px 6px rgba(22,32,46,0.22));
  transition: transform 0.2s ease, filter 0.2s ease;
}
.tile-svg-glow {
  filter: drop-shadow(0 0 8px var(--deck-accent, #1f5e45)) drop-shadow(0 6px 12px rgba(22,32,46,0.3));
  transform: scale(1.04);
}
.tile-glow { transform: scale(1.04); }
.tile-ghost { opacity: 0.5; }
.tile-mod-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  line-height: 0;
}
.tile-arrow svg { display: block; }
.tile-chip {
  z-index: 4;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.tile-skill {
  z-index: 3;
}
.tile-glow {
  box-shadow:
    0 0 0 4px var(--player-wash2, rgba(31,94,69,0.3)),
    0 6px 12px rgba(22,32,46,0.22);
  transform: scale(1.04);
}
.tile-ghost { opacity: 0.45; }

.tile-glyph {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.tile-score {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  letter-spacing: -0.04em;
  z-index: 2;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  pointer-events: none;
}
.tile-score {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  letter-spacing: -0.04em;
  z-index: 2;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255,255,255, 0.4);
}
.tile-chip.pos { color: var(--green); background: rgba(47,122,74,0.18); box-shadow: 0 0 0 1px rgba(47,122,74,0.25); }
.tile-chip.neg { color: var(--crimson); background: rgba(176,58,46,0.18); box-shadow: 0 0 0 1px rgba(176,58,46,0.25); }

/* hands */
.hand {
  display: flex; flex-direction: row; align-items: stretch;
  padding: 12px 16px; gap: 14px;
  background: rgba(255,255,255,0.6);
  border-radius: 12px; border: 1.5px solid rgba(22,32,46,0.25);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hand-main { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hand-active {
  border-color: var(--p1);
}
.hand-active.hand-2 { border-color: var(--p2); }
.hand-header { display: flex; align-items: baseline; gap: 12px; }
.hand-header .label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
}
.hand-1 .hand-header .label { color: var(--p1); }
.hand-2 .hand-header .label { color: var(--p2); }
.hand-header .count {
  font-size: 12px; color: var(--ink-faint); letter-spacing: 0.08em; text-transform: uppercase;
}
.hand-header .now-tag {
  font-size: 11px; font-weight: 700; color: white;
  padding: 3px 8px; border-radius: 4px; letter-spacing: 0.1em; text-transform: uppercase;
}
.hand-1 .now-tag { background: var(--p1); }
.hand-2 .now-tag { background: var(--p2); }
.hand-tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.hand-slot {
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.hand-active .hand-slot:active { transform: translateY(-2px); }
.hand-slot.empty {
  border: 1.5px dashed rgba(22,32,46,0.25); border-radius: 4px;
  cursor: default;
}
.hand-slot-selected { transform: translateY(-4px); }

/* discard zone: left of board */
.discard-zone {
  width: 72px;
  align-self: stretch;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: 2px dashed rgba(176,58,46,0.45);
  border-radius: 14px;
  background: rgba(176,58,46,0.04);
  color: var(--crimson);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  text-align: center;
}
.discard-zone .discard-icon { color: rgba(176,58,46,0.55); transition: color 0.2s; }
.discard-zone .discard-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  writing-mode: vertical-rl; transform: rotate(180deg);
  color: rgba(176,58,46,0.55);
  transition: color 0.2s;
}
.discard-zone .discard-sub {
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px; font-style: italic; color: rgba(176,58,46,0.4);
  display: none;
}
.discard-zone.armed {
  background: rgba(176,58,46,0.08);
  border-color: rgba(176,58,46,0.7);
}
.discard-zone.armed .discard-icon, .discard-zone.armed .discard-label {
  color: var(--crimson);
}
.discard-zone.hover-target {
  background: rgba(176,58,46,0.18);
  border-color: var(--crimson);
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(176,58,46,0.15);
}

/* tile bag: sits beside each hand */
.bag {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 8px;
  background: var(--paper);
  border-radius: 12px;
  border: 1.5px solid var(--line);
  box-shadow: 0 4px 12px rgba(22,32,46,0.10);
  transition: transform 0.2s, opacity 0.3s;
  flex-shrink: 0;
  align-self: center;
}
.bag-side { min-width: 110px; }
.bag.bag-empty { opacity: 0.5; }
.bag-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.bag-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint);
}
.bag-count {
  font-size: 22px; font-weight: 700; color: var(--p1);
  margin-top: 2px;
  line-height: 1;
}
.bag-discard {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 2px;
  line-height: 1;
  min-height: 12px;
}

/* mirror mode: flip P2 hand 180° for face-to-face play */
body.mirror-p2 #hand-2 { transform: rotate(180deg); }

/* settings toggle on main menu */
.setting-toggle {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(22,32,46,0.04);
  cursor: pointer;
  text-align: left;
}
.setting-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.setting-toggle .track {
  position: relative; width: 36px; height: 20px;
  background: var(--track); border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.setting-toggle .thumb {
  position: absolute; top: 1px; left: 1px;
  width: 14px; height: 14px;
  background: var(--paper);
  border-radius: 50%;
  border: 1px solid var(--line);
  transition: left 0.2s;
}
.setting-toggle input:checked ~ .track { background: var(--p1); border-color: var(--p1); }
.setting-toggle input:checked ~ .track .thumb { left: 18px; }
.setting-label { display: flex; flex-direction: column; line-height: 1.2; }
.setting-name { font-size: 15px; font-weight: 600; color: var(--ink); }
.setting-sub { font-family: 'Cormorant Garamond', serif; font-style: italic; font-size: 14px; color: var(--ink-soft); }

/* deal animation: tile enters from bag location */
@keyframes deal-in {
  0%   { opacity: 0; transform: translate(var(--from-x, 200px), var(--from-y, 200px)) rotate(-12deg) scale(0.8); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}
.hand-slot.tile-deal { animation: deal-in 0.55s cubic-bezier(0.2, 0.8, 0.3, 1.05) backwards; }

/* drag visuals */
body.dragging { cursor: grabbing; touch-action: none; -webkit-user-select: none; user-select: none; }
body.dragging * { touch-action: none; }
.hand-slot { touch-action: none; cursor: grab; }
.hand-active .hand-slot:not(.empty):active { cursor: grabbing; }
.hand-slot-dragged { opacity: 0.25; pointer-events: none; }
.hand-slot.ai-thinking {
  transform: translateY(-4px);
  box-shadow: 0 0 0 3px rgba(31,63,110,0.35), 0 8px 16px rgba(31,63,110,0.25);
  border-radius: 7px;
  animation: ai-pulse 0.5s ease-in-out;
}
@keyframes ai-pulse {
  0%, 100% { transform: translateY(-4px) scale(1); }
  50%      { transform: translateY(-6px) scale(1.06); }
}
.tile.drag-floating {
  filter: drop-shadow(0 12px 20px rgba(22,32,46,0.35));
  transition: none;
}

.cell.hover-target {
  background: color-mix(in srgb, var(--turn) 28%, transparent);
  border: 1.5px solid var(--turn);
  transform: scale(1.05);
}

/* hand hint */
.hand .hint {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 14px; color: var(--ink-faint);
  margin-left: auto;
}
.hand .hint.hint-cutoff {
  font-family: 'Inter', sans-serif; font-style: normal; font-weight: 600;
  color: var(--turn);
  display: block;
}

/* effects overlay */
.effects {
  position: absolute; inset: 0; pointer-events: none; z-index: 30;
}
.fx-trail {
  position: absolute;
  height: 4px; border-radius: 2px;
  transform-origin: 0 50%;
  animation: trail-in 0.6s ease-out backwards;
}
.fx-popup {
  position: absolute;
  font-size: 24px; font-weight: 800; letter-spacing: -0.03em;
  background: white; border: 2px solid; border-radius: 8px;
  padding: 3px 10px;
  transform: translate(-50%, -130%);
  box-shadow: 0 6px 14px rgba(22,32,46,0.18);
  animation: popup-in 0.7s ease-out backwards;
}
@keyframes trail-in {
  from { opacity: 0; transform: rotate(var(--r, 0deg)) scaleX(0.2); }
  to   { opacity: 1; }
}
@keyframes popup-in {
  0%   { opacity: 0; transform: translate(-50%, -90%); }
  60%  { opacity: 1; transform: translate(-50%, -140%); }
  100% { opacity: 1; transform: translate(-50%, -130%); }
}

/* game over */
.gameover-card {
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 36px; max-width: 480px; text-align: center;
  box-shadow: 0 16px 40px rgba(22,32,46, 0.12);
}
.gameover-eyebrow {
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint);
}
.gameover-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 54px; font-weight: 700; margin: 8px 0 18px; letter-spacing: 0.02em;
}
.gameover-scores {
  display: flex; justify-content: center; gap: 32px; padding: 16px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.gameover-scores .col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gameover-scores .col .label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 600;
}
.gameover-scores .col .num {
  font-size: 40px; font-weight: 700; line-height: 1;
}
.col-1 .label, .col-1 .num { color: var(--p1); }
.col-2 .label, .col-2 .num { color: var(--p2); }
.gameover-card { box-shadow: 0 24px 60px rgba(22,32,46,0.3); }
.gameover-shells { margin-top: 14px; font-size: 15px; font-weight: 700; color: var(--p1); }
.gameover-actions {
  display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap;
  margin-top: 20px;
}
.gameover-actions .btn-secondary { padding: 13px 18px; }

/* square icon button (eye, settings) */
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
}
.icon-btn:hover { border-color: var(--line-strong); }
.floating-eye {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 120; width: 52px; height: 52px; border-radius: 50%;
  box-shadow: 0 8px 20px rgba(22,32,46,0.25);
}

/* settings menu in the top bar */
.settings { position: relative; }
.settings .icon-btn { width: 38px; height: 38px; }
.settings-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 180px; padding: 6px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(22,32,46,0.18);
}
.settings-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: none; border-radius: 6px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.settings-item:hover { background: rgba(22,32,46,0.06); }
.settings-item.confirm, .settings-item.confirm:hover { background: var(--crimson); color: #ffffff; }

/* deck pick screen */
.menu-deck-card {
  position: relative;
  max-width: 1080px;
  width: 100%;
  text-align: left;
}
.deck-pick-actions {
  display: flex; gap: 10px; margin: 14px 0 6px;
}
.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 10px;
  max-height: 70vh;
  overflow-y: auto;
  /* room for the hover lift and selected ring inside the scroll area */
  padding: 6px 6px 8px 4px;
}

/* deck preview modal */
#preview-name { margin-top: 8px; }
.preview-count { font-size: 14px; color: var(--ink-soft); margin: -4px 0 12px; }
.preview-grid {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  padding: 14px; border-radius: 12px; background: rgba(22,32,46,0.04);
}
.preview-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.deck-card {
  position: relative;
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(22,32,46,0.25);
  background: var(--paper);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  background-image: repeating-linear-gradient(45deg, rgba(22,32,46,0.04) 0 1.5px, transparent 1.5px 7px);
}
.deck-card.dark {
  background: #16202e; color: #eef1f4;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 1.5px, transparent 1.5px 7px);
}
.deck-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(22,32,46,0.16);
}
.deck-card.selected { border-color: var(--p1); box-shadow: 0 0 0 3px rgba(31,94,69,0.25); }
/* Back buttons always sit in the top right corner of their card. */
.menu-card { position: relative; }
.corner-back { position: absolute; top: 24px; right: 24px; }
#menu-mode { padding-top: 84px; }
.deck-card-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.deck-rarity {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; display: inline-block;
}
.deck-name {
  font-size: 22px; font-weight: 700; margin-top: 6px; line-height: 1.05;
}
.deck-swatches { display: flex; gap: 4px; }
.deck-swatches span {
  width: 14px; height: 14px; border-radius: 3px; display: inline-block;
  border: 1px solid rgba(22,32,46,0.2);
}
.deck-tagline {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic; font-size: 15px;
  color: rgba(22,32,46,0.6);
  line-height: 1.35;
}
.deck-card.dark .deck-tagline { color: rgba(255,255,255,0.6); }
.deck-samples {
  display: flex; gap: 8px; padding: 10px 4px; justify-content: center;
  background: rgba(22,32,46,0.05);
  border-radius: 10px;
  overflow: visible;
}
.deck-card.dark .deck-samples { background: rgba(255,255,255,0.04); }
.deck-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(22,32,46,0.55);
}
.deck-card.dark .deck-foot { color: rgba(255,255,255,0.55); }
.deck-pick-cta { font-weight: 700; }

/* glyph legend */
.glyph-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.glyph-section {
  background: var(--paper);
  border-radius: 12px;
  border: 1.5px solid var(--line);
  padding: 18px;
}
.glyph-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px; font-weight: 700; margin-bottom: 10px;
}
.glyph-row {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 12px;
}
.glyph-icon-box {
  flex-shrink: 0; width: 44px; height: 44px;
  border: 1.5px solid; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.glyph-text { flex: 1; }
.glyph-label {
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.glyph-desc {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; line-height: 1.4;
  color: rgba(22,32,46,0.75);
  margin-top: 2px;
}

/* shop modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(22,32,46, 0.5);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.shop {
  background: var(--paper);
  border-radius: 16px;
  padding: 24px;
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  background-image: repeating-linear-gradient(45deg, rgba(22,32,46,0.025) 0 1px, transparent 1px 8px);
}
.shop-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px; gap: 16px;
}
.shop-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 38px; font-weight: 600; margin: 4px 0 0;
}
.shop-eyebrow { font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.shop-tagline { font-family: 'Cormorant Garamond', serif; font-style: italic; color: var(--ink-soft); margin-top: 6px; max-width: 520px; }
.shop-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.shop-shells {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--paper); border: 1.5px solid var(--line);
  border-radius: 10px;
}
.shop-shells .num { font-size: 22px; font-weight: 700; color: var(--p1); line-height: 1;
}
.shop-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
.set-card {
  position: relative;
  background: var(--paper);
  border-radius: 14px;
  border: 1.5px solid var(--line);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(22,32,46,0.08);
  background-image: repeating-linear-gradient(45deg, rgba(22,32,46,0.04) 0 1.5px, transparent 1.5px 7px);
}
.set-card.featured { border: 2px solid var(--p1); box-shadow: 0 0 0 4px rgba(31,94,69,0.18), 0 16px 28px rgba(22,32,46,0.12); }
.set-card.dark {
  background: #1b2838; color: #eef1f4;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 1.5px, transparent 1.5px 7px);
}
.set-card.dark .set-tagline { color: rgba(255,255,255,0.6); }
.set-rarity {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px; display: inline-block; align-self: flex-start;
}
/* Standard rarity badges, independent of each deck's palette. */
.rarity { color: #ffffff; background: var(--rarity); }
.rarity-default   { --rarity: #6b7480; }
.rarity-common    { --rarity: #2f7a4a; }
.rarity-rare      { --rarity: #1f5ea8; }
.rarity-legendary { --rarity: #6a3fa0; }
.rarity-mythic    { --rarity: #a8366f; }
.set-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; font-weight: 700; line-height: 1.1; margin-top: 6px;
}
.set-tagline { font-family: 'Cormorant Garamond', serif; font-size: 16px; font-style: italic; color: var(--ink-soft); }
.set-samples {
  display: flex; gap: 10px; padding: 12px 0; justify-content: center;
  background: rgba(22,32,46,0.05); border-radius: 10px;
}
.set-card.dark .set-samples { background: rgba(255,255,255,0.04); }
.set-foot { display: flex; justify-content: space-between; align-items: center; }
.set-price { font-size: 17px; font-weight: 700; }
.set-buy {
  font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 10px 16px; border: none; border-radius: 6px; background: var(--p1); color: white;
}
.set-buy:disabled { cursor: default; }
.set-buy:disabled:not(.owned) { background: var(--line-strong); opacity: 0.7; }
.set-buy.owned { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); }
.shop-close {
  background: transparent; border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  :root { --cell: 44px; }
  .topbar { padding: 10px 12px; }
  .topbar-title h1 { font-size: 22px; }
  .pushbar { display: none; }
  .pushbar-mobile { display: flex; }
  .game { padding: 12px; gap: 8px; padding-bottom: 90px; }
  .main-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
    gap: 8px;
    align-items: stretch;
  }
  .board-wrap { grid-column: 1; grid-row: 1; }
  .discard-zone {
    grid-column: 2; grid-row: 1;
    width: 56px;
    padding: 10px 6px;
  }
  .pushbar { display: none; }
  .hand { padding: 8px 10px; }
  .hand .hint { display: none; }
  .hand-tiles { gap: 6px; }
  .menu-title { font-size: 50px; }
  .menu-card { padding: 28px 24px; }
  .shop-grid { grid-template-columns: 1fr; }
  .bag-side { min-width: 86px; padding: 6px 10px 6px 6px; }
  .bag-side svg { width: 36px; height: 36px; }
  .bag-side .bag-label { font-size: 11px; }
  .bag-side .bag-count { font-size: 18px; }
  .deck-grid { grid-template-columns: 1fr; max-height: 60vh; }
  .glyph-grid { grid-template-columns: 1fr; }
  .menu-deck-card { padding: 16px; }
  .tokami-wordmark { font-size: 66px; }
  .tokami-mark { width: 110px !important; height: 110px !important; }
  .topbar-title h1 { font-size: 20px; }
  .tokami-mark-sm { width: 22px !important; height: 22px !important; }
  .corner-back { position: static; display: block; margin: 0 0 12px auto; }
  #menu-mode { padding-top: 28px; }
  .shop-header { flex-wrap: wrap; }
  .shop-header-right { order: -1; width: 100%; justify-content: flex-end; }
  /* keep the game inside a 390px phone */
  .topbar-turn .label, #mode-label { display: none; }
  .board { padding: 8px; gap: 4px; }
  .discard-zone { width: 48px; }
  .hand { gap: 8px; }
  .bag-side { min-width: 0; padding: 6px 8px; }
  .bag-side svg { display: none; }
}
@media (max-width: 380px) {
  :root { --cell: 38px; }
}
