:root {
  --ink: #f9f5e7;
  --muted: #b4c8bf;
  --felt: #0c352b;
  --felt-deep: #071d18;
  --panel: rgba(5, 25, 21, 0.76);
  --gold: #f1c35d;
  --orange: #e68038;
  --red: #d94a45;
  --table-light: rgba(50,128,95,.38);
  --table-mid: rgba(10,55,43,.42);
  --table-dark: rgba(3,24,19,.55);
  --card-back: #c96c2e;
  --card-w: clamp(54px, 17vw, 76px);
  --card-h: calc(var(--card-w) * 1.42);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--felt-deep);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; overscroll-behavior: none; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 25%, rgba(40, 111, 83, .48), transparent 42%),
    linear-gradient(155deg, #123d31 0%, var(--felt-deep) 85%);
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(100%, 620px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.home { display: grid; align-content: center; gap: 24px; }
.brand-lockup { text-align: center; animation: rise .6s ease both; }
.brand-mark { width: 92px; height: 92px; filter: drop-shadow(0 18px 22px rgba(0,0,0,.28)); }
.brand-lockup h1 { font-size: clamp(44px, 14vw, 68px); line-height: .95; margin: 13px 0 9px; letter-spacing: -.06em; }
.brand-lockup p { max-width: 340px; color: var(--muted); margin: 0 auto; line-height: 1.45; }

.glass-card {
  background: linear-gradient(145deg, rgba(255,255,255,.1), rgba(255,255,255,.045));
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 24px;
  box-shadow: 0 22px 65px rgba(0,0,0,.25);
  backdrop-filter: blur(18px);
}

.home-actions { padding: 20px; display: grid; gap: 13px; animation: rise .6s .08s ease both; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.field input {
  width: 100%; border: 1px solid rgba(255,255,255,.13); color: var(--ink); background: rgba(2,18,14,.55);
  border-radius: 14px; padding: 14px 15px; outline: none; font-size: 16px;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(241,195,93,.13); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.name-avatar-row { min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; }
.avatar-select {
  width: 58px; border: 1px solid rgba(255,255,255,.13); color: var(--ink); background: rgba(2,18,14,.75);
  border-radius: 14px; padding: 0 7px; outline: none; font-size: 25px; text-align: center;
}
.room-input { text-transform: uppercase; letter-spacing: .14em; font-weight: 800; }
.or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; color: #7f9d90; font-size: 12px; }
.or::before, .or::after { content: ""; height: 1px; background: rgba(255,255,255,.1); }

.btn {
  border: 0; border-radius: 14px; padding: 13px 17px; min-height: 48px; cursor: pointer; color: #11271f;
  background: linear-gradient(135deg, var(--gold), #e79c3e); font-weight: 850; box-shadow: 0 8px 20px rgba(231,156,62,.2);
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.secondary { color: var(--ink); background: rgba(255,255,255,.1); box-shadow: none; border: 1px solid rgba(255,255,255,.12); }
.btn.danger { color: white; background: linear-gradient(135deg, #e95e4f, #bd3838); }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn.icon { width: 42px; min-height: 42px; padding: 0; display: grid; place-items: center; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.eyebrow { color: var(--gold); font-size: 11px; text-transform: uppercase; font-weight: 900; letter-spacing: .13em; }
.topbar h1 { margin: 2px 0 0; font-size: 26px; letter-spacing: -.04em; }
.connection { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection-dot { width: 9px; height: 9px; background: #57cf8a; border-radius: 50%; box-shadow: 0 0 0 4px rgba(87,207,138,.14); }
.connection.offline .connection-dot { background: #e77f4d; box-shadow: 0 0 0 4px rgba(231,127,77,.14); }

.lobby { display: grid; align-content: start; gap: 16px; }
.invite { padding: 20px; text-align: center; }
.invite p { margin: 0; color: var(--muted); }
.room-code { margin: 8px 0 14px; font-size: clamp(34px, 11vw, 52px); letter-spacing: .15em; font-weight: 950; color: var(--gold); }
.lobby-list { padding: 8px; display: grid; gap: 6px; }
.lobby-player { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; padding: 10px; border-radius: 15px; }
.lobby-player + .lobby-player { border-top: 1px solid rgba(255,255,255,.07); }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #2d7159, #184737); font-weight: 900; }
.player-meta strong { display: block; }
.player-meta span { color: var(--muted); font-size: 12px; }
.host-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; }
.hint { color: var(--muted); text-align: center; font-size: 12px; line-height: 1.4; }
.room-scoreboard { padding: 13px 14px; border-radius: 17px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.08); }
.room-scoreboard.compact { margin: 13px 0 8px; text-align: left; }
.score-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.score-title span { color: var(--gold); font-size: 13px; font-weight: 900; }
.score-title small { color: var(--muted); font-size: 10px; }
.score-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.score-chip { padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.065); font-size: 12px; }
.score-chip strong { color: var(--gold); margin-left: 4px; }
.score-chip.leader { box-shadow: inset 0 0 0 1px rgba(241,195,93,.58); background: rgba(241,195,93,.1); }
.starter-note { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.theme-picker { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.theme-picker > span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.theme-choice { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.055); color: var(--ink); border-radius: 999px; padding: 7px 9px; cursor: pointer; font-size: 11px; }
.theme-choice i { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 50%; vertical-align: -1px; background: var(--theme-swatch); }
.theme-choice.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(241,195,93,.1); }
.theme-choice:disabled { opacity: .7; }

.peek-screen { min-height: calc(100dvh - 40px); display: grid; align-content: center; justify-items: center; gap: 22px; text-align: center; }
.peek-screen h1 { margin: 0 0 7px; font-size: 32px; }
.peek-screen p { margin: 0; color: var(--muted); max-width: 340px; }
.peek-cards { display: flex; gap: 15px; }
.peek-grid-wrap { position: relative; display: grid; justify-items: center; padding-top: 5px; }

.playing-shell { padding-left: 10px; padding-right: 10px; display: flex; flex-direction: column; }
.playing-shell.theme-classic { --table-light: rgba(50,128,95,.42); --table-mid: rgba(10,55,43,.46); --table-dark: rgba(3,24,19,.6); --card-back: #c96c2e; }
.playing-shell.theme-midnight { --table-light: rgba(78,114,172,.5); --table-mid: rgba(27,53,96,.55); --table-dark: rgba(8,20,47,.72); --card-back: #32629a; }
.playing-shell.theme-burgundy { --table-light: rgba(157,73,84,.5); --table-mid: rgba(91,33,47,.58); --table-dark: rgba(42,12,24,.72); --card-back: #8c3853; }
.playing-shell.final-round { --table-light: rgba(142,73,70,.52); --table-mid: rgba(72,31,38,.5); }
.playing-shell.final-round .table::before { border-color: rgba(255,101,82,.62); box-shadow: inset 0 0 60px rgba(99,15,28,.3), 0 0 34px rgba(255,77,65,.17); }
.game-header { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 8px; }
.game-header .room-mini { font-weight: 900; letter-spacing: .12em; }
.game-header .round-info { color: var(--muted); font-size: 12px; }
.game-header-controls { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.game-menu-button { min-height: 35px; padding: 7px 10px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid rgba(255,255,255,.16); border-radius: 11px; color: var(--ink); background: rgba(255,255,255,.08); font-size: 11px; font-weight: 900; cursor: pointer; }
.game-menu-button span { color: var(--gold); font-size: 13px; letter-spacing: -2px; }
.game-menu-button:active { transform: scale(.96); }
.peek-menu-button { position: fixed; z-index: 20; top: max(14px, env(safe-area-inset-top)); right: 14px; }
.round-info strong.low { color: #ffd36c; font-size: 17px; animation: lowDeck 1s ease-in-out infinite; }
.round-info strong.critical { color: #ff665e; font-size: 20px; animation: lastCard .58s ease-in-out infinite alternate; }
.status-pill {
  min-height: 42px; display: grid; place-items: center; text-align: center; margin: 0 4px 10px; padding: 8px 14px;
  border-radius: 15px; color: #183025; background: linear-gradient(135deg, #f7d777, #eaa64a); font-weight: 850; font-size: 14px;
  box-shadow: 0 8px 25px rgba(231,156,62,.18);
}
.status-pill.reaction { background: linear-gradient(135deg, #ff755c, #e3aa4f); color: white; animation: reactionGlow 1s ease infinite alternate; }
.final-round .status-pill { color: white; background: linear-gradient(135deg, #b62f43, #691b39); box-shadow: 0 0 28px rgba(227,59,71,.3); }
.final-round-banner { z-index: 14; display: flex; align-items: center; justify-content: center; gap: 8px; margin: -4px 4px 8px; padding: 8px 12px; border: 1px solid rgba(255,136,110,.58); border-radius: 14px; color: #fff; background: linear-gradient(135deg, rgba(169,35,58,.94), rgba(82,20,53,.96)); box-shadow: 0 10px 28px rgba(113,17,44,.28); animation: finalPulse 1.15s ease-in-out infinite alternate; }
.final-round-banner b { color: #ffd36c; letter-spacing: .08em; }
.final-round-banner span { font-size: 11px; font-weight: 900; letter-spacing: .04em; }
.live-match { z-index: 13; display: grid; justify-items: center; gap: 1px; margin: -3px auto 8px; padding: 7px 13px; max-width: calc(100% - 16px); border-radius: 14px; color: #fff; background: linear-gradient(135deg, rgba(213,91,47,.96), rgba(150,50,78,.96)); box-shadow: 0 8px 25px rgba(218,76,47,.22); text-align: center; animation: liveMatch 1.05s ease-in-out infinite alternate; }
.live-match.claimed { background: linear-gradient(135deg, rgba(79,71,151,.96), rgba(112,47,119,.96)); animation: none; }
.live-match strong { font-size: 12px; letter-spacing: .08em; }
.live-match span { font-size: 10px; color: rgba(255,255,255,.82); }
.deck-warning { z-index: 12; margin: -4px auto 7px; padding: 7px 13px; border-radius: 999px; color: #372500; background: #ffd36c; font-size: 11px; text-align: center; box-shadow: 0 8px 24px rgba(255,190,67,.2); animation: lowDeck 1.1s ease-in-out infinite; }
.deck-warning.last, .deck-warning.empty { color: white; background: linear-gradient(135deg, #ef5e4c, #a92838); animation: lastCard .58s ease-in-out infinite alternate; }

.table {
  position: relative; flex: 1; min-height: calc(100dvh - 125px); display: grid;
  grid-template-rows: 244px auto minmax(215px, 1fr); gap: 4px; isolation: isolate;
}
.table::before {
  content: ""; position: absolute; z-index: -1; left: 3%; right: 3%; top: 48px; bottom: 94px;
  border: 2px solid rgba(241,195,93,.24); border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 46%, var(--table-light), var(--table-mid) 58%, var(--table-dark) 100%);
  box-shadow: inset 0 0 55px rgba(0,0,0,.2), 0 20px 60px rgba(0,0,0,.18);
}
.opponents { position: relative; height: 244px; }
.opponents .player-zone {
  --mini-w: 35px; position: absolute; left: var(--seat-x); top: var(--seat-y); width: clamp(92px, 26vw, 122px);
  transform: translateX(-50%); rotate: var(--seat-tilt); transform-origin: 50% 100%;
}
.opponents.count-1 .player-zone { --mini-w: 60px; width: 176px; }
.opponents.count-2 .player-zone { --mini-w: 50px; width: 158px; }
.opponents.count-3 .player-zone { --mini-w: 39px; width: 130px; }
.opponents.count-4 .player-zone { --mini-w: 34px; width: 114px; padding-left: 3px; padding-right: 3px; }
.opponents.count-5 .player-zone { --mini-w: 31px; width: 106px; padding-left: 1px; padding-right: 1px; }
.player-zone { position: relative; border-radius: 18px; padding: 8px; border: 1px solid transparent; transition: background .25s, border .25s, transform .25s; }
.player-zone.active { background: rgba(241,195,93,.09); border-color: rgba(241,195,93,.45); }
.player-zone.event-pulse { animation: zonePulse .65s ease; }
.opponents .player-zone.movement-active { border-color: rgba(100,220,226,.72); background: rgba(55,167,180,.11); animation: opponentTrack 1.15s ease-in-out 3 alternate; }
.player-label { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 6px; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; }
.player-label > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.player-label .cards-left { color: var(--muted); font-weight: 600; }
.mini-avatar { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: rgba(255,255,255,.1); font-style: normal; }
.emote-bubble { position: absolute; z-index: 19; left: 50%; top: -23px; min-width: 37px; height: 34px; padding: 2px 7px; display: grid; place-items: center; transform: translateX(-50%); border-radius: 18px 18px 18px 4px; background: white; color: #18251f; font-size: 22px; box-shadow: 0 8px 22px rgba(0,0,0,.3); animation: emotePop 2.4s ease both; }
.emote-bubble.self-emote { top: -32px; }
.mini-grid {
  display: grid; grid-template-columns: repeat(var(--grid-columns, 2), var(--mini-w, 32px));
  grid-auto-rows: calc(var(--mini-w, 32px) * 1.42); gap: 3px; justify-content: center;
}

.center-table { display: flex; justify-content: center; align-items: center; gap: 16px; min-height: 118px; }
.pile-wrap { display: grid; justify-items: center; gap: 5px; position: relative; }
.pile-label { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.deck-stack::before, .deck-stack::after { content: ""; position: absolute; inset: 0; border-radius: 8px; background: #ebdebf; border: 1px solid rgba(0,0,0,.2); }
.deck-stack::before { transform: translate(4px, -4px); z-index: -2; }
.deck-stack::after { transform: translate(2px, -2px); z-index: -1; }
.deck-stack { position: relative; }
.deck-button { appearance: none; border: 0; padding: 0; color: inherit; background: transparent; }
.deck-button:disabled { opacity: 1; }
.deck-button.can-draw { cursor: pointer; touch-action: manipulation; animation: deckInvite 1.35s ease-in-out infinite; }
.deck-button.can-draw .card.back { box-shadow: 0 0 0 3px rgba(241,195,93,.48), 0 9px 22px rgba(0,0,0,.35); }
.deck-button.can-draw:active { transform: translateY(-5px) rotate(-2deg) scale(.96); }
.deck-stack.deck-bump { animation: deckBump .55s ease; }
.deck-count { position: absolute; right: -8px; bottom: -8px; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 12px; background: var(--gold); color: #173126; font-size: 11px; font-weight: 900; z-index: 3; }
.discard-slot { width: var(--card-w); height: var(--card-h); border: 2px dashed rgba(255,255,255,.15); border-radius: 10px; }
.discard-slot.drag-target { border-color: #72e7dc; box-shadow: 0 0 0 5px rgba(80,224,210,.35), 0 0 34px rgba(74,225,211,.72); transform: translateY(-5px) scale(1.08); }
.discard-wrap { position: relative; }
.power-decision { position: absolute; z-index: 16; left: 50%; top: -35px; transform: translateX(-50%); min-width: 112px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 9px; border-radius: 999px; color: white; background: rgba(40,53,77,.96); border: 1px solid rgba(255,255,255,.24); box-shadow: 0 9px 25px rgba(0,0,0,.34); pointer-events: none; animation: powerDecision 3.1s ease both; }
.power-decision.used { background: rgba(35,101,78,.97); border-color: rgba(102,232,175,.65); }
.power-decision.skipped { background: rgba(83,70,91,.97); border-color: rgba(206,181,220,.48); }
.power-decision b { color: #8cf1bd; font-size: 15px; }
.power-decision.skipped b { color: #d8c5df; }
.power-decision span { font-size: 8px; font-weight: 950; letter-spacing: .06em; white-space: nowrap; }

.self-zone { align-self: end; display: grid; justify-items: center; gap: 9px; padding: 8px 5px 0; }
.self-zone .player-label { font-size: 14px; }
.self-grid { display: grid; grid-template-columns: repeat(var(--grid-columns, 2), var(--card-w)); grid-auto-rows: var(--card-h); gap: 7px; }
.self-grid .slot.empty { width: var(--card-w); height: var(--card-h); }
.self-actions { min-height: 50px; display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawn-tray { display: flex; align-items: center; gap: 10px; }
.drawn-card { animation: drawIn .55s cubic-bezier(.2,.85,.25,1.15) both; }
.gringo-button { letter-spacing: .06em; }
.turn-ready { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.deck-hint { color: var(--gold); font-size: 12px; font-weight: 850; animation: hintPulse 1.3s ease-in-out infinite; }
.turn-end-actions { display: flex; gap: 8px; }
.turn-end-wrap { display: grid; justify-items: center; gap: 5px; }
.turn-end-wrap small { color: var(--muted); font-size: 10px; }
.turn-end-meter { width: min(220px, 62vw); height: 3px; }
.turn-end-meter span { background: var(--gold); }
.final-match-window { display: grid; justify-items: center; gap: 5px; max-width: 290px; padding: 9px 13px; border-radius: 14px; color: white; text-align: center; background: linear-gradient(135deg, rgba(169,55,48,.92), rgba(101,36,74,.94)); border: 1px solid rgba(255,188,91,.7); animation: finalPulse 1s ease-in-out infinite alternate; }
.final-match-window strong { color: #ffd36c; font-size: 11px; letter-spacing: .12em; }
.final-match-window span { font-size: 10px; line-height: 1.3; }
.power-race-hint { display: grid; gap: 2px; padding: 8px 13px; border-radius: 14px; text-align: center; color: white; background: linear-gradient(135deg, rgba(126,76,211,.9), rgba(222,76,127,.9)); animation: reactionGlow .85s ease-in-out infinite alternate; }
.power-race-hint span { font-size: 11px; }
.power-landing { color: #ffe096; font-weight: 900; animation: hintPulse .55s ease-in-out infinite; }
.emote-bar { display: flex; justify-content: center; gap: 4px; padding: 3px 7px; border-radius: 999px; background: rgba(0,0,0,.18); }
.emote-bar button { width: 31px; height: 31px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; font-size: 18px; transition: transform .14s, background .14s; }
.emote-bar button:active { transform: scale(1.3); background: rgba(255,255,255,.14); }

.slot { position: relative; border: 0; background: transparent; padding: 0; border-radius: 10px; }
.slot.selectable { cursor: pointer; animation: selectGlow 1s ease infinite alternate; }
.slot.selectable:active { transform: scale(.94); }
.slot.reorderable { cursor: grab; touch-action: none; }
.slot.reorderable:active { cursor: grabbing; }
.slot.dragging-source .card, .slot.wrong-source .card { opacity: .24; transform: scale(.92); }
.slot.drag-target { box-shadow: 0 0 0 4px rgba(87,207,138,.75), 0 0 24px rgba(87,207,138,.42); transform: scale(1.04); }
.slot.penalty-arrival .card { animation: penaltySettle 1.85s cubic-bezier(.2,.75,.2,1) both; }
.slot.power-match { cursor: pointer; animation: powerMatch .62s ease-in-out infinite alternate; z-index: 5; }
.slot.rank-match { cursor: pointer; animation: rankMatch .72s ease-in-out infinite alternate; z-index: 5; }
.slot.rank-match, .slot.power-match { touch-action: none; cursor: grab; }
.slot.reserved-power-card { animation: reservedPower .32s ease-in-out 4 alternate; }
.slot.swap-source, .slot.swap-target { z-index: 18; animation: swapCardPulse .52s ease-in-out 5 alternate; }
.slot.swap-target { filter: drop-shadow(0 0 16px rgba(255,85,78,.95)); }
.slot.movement-source, .slot.movement-target { z-index: 17; }
.slot.movement-source { box-shadow: 0 0 0 4px rgba(255,208,92,.9), 0 0 28px rgba(255,190,65,.72); }
.slot.movement-target { box-shadow: 0 0 0 4px rgba(255,92,101,.9), 0 0 30px rgba(255,73,94,.78); }
.slot.movement-source::before, .slot.movement-target::before { position: absolute; z-index: 7; left: 50%; top: -13px; transform: translateX(-50%); padding: 2px 5px; border-radius: 999px; color: #241d0d; background: #ffd267; font-size: 7px; font-weight: 950; letter-spacing: .05em; }
.slot.movement-source::before { content: "FROM"; }
.slot.movement-target::before { content: "TO"; color: white; background: #ec5263; }
.slot.reorder-source, .slot.reorder-target { z-index: 16; }
.slot.reorder-source { box-shadow: 0 0 0 4px rgba(66,211,205,.88), 0 0 25px rgba(46,198,202,.62); }
.slot.reorder-target { box-shadow: 0 0 0 4px rgba(73,145,255,.9), 0 0 27px rgba(67,133,255,.7); }
.slot.reorder-source::before, .slot.reorder-target::before { position: absolute; z-index: 7; left: 50%; top: -13px; transform: translateX(-50%); padding: 2px 5px; border-radius: 999px; color: #062f31; background: #63e1d7; font-size: 7px; font-weight: 950; letter-spacing: .05em; white-space: nowrap; }
.slot.reorder-source::before { content: "ORDER FROM"; }
.slot.reorder-target::before { content: "ORDER TO"; color: white; background: #498dff; }
.slot.self-reorder-source, .slot.self-reorder-target { z-index: 22; }
.slot.self-reorder-source { animation: selfReorderFrom 3.15s ease both; }
.slot.self-reorder-target { animation: selfReorderTo 3.15s ease both; }
.slot.self-reorder-source::before, .slot.self-reorder-target::before { position: absolute; z-index: 12; left: 50%; top: -15px; transform: translateX(-50%); padding: 3px 7px; border-radius: 999px; color: #083629; background: #77efbf; font-size: 8px; font-weight: 1000; letter-spacing: .06em; white-space: nowrap; pointer-events: none; animation: selfReorderTag 3.15s ease both; }
.slot.self-reorder-source::before { content: "START"; }
.slot.self-reorder-target::before { content: "NOW HERE"; color: white; background: #5a78ff; }
.self-reorder-confirmation { position: absolute; z-index: 28; left: 50%; top: -36px; width: max-content; max-width: calc(100vw - 28px); display: grid; justify-items: center; gap: 1px; transform: translateX(-50%); padding: 8px 14px; border-radius: 14px; color: white; background: linear-gradient(135deg, rgba(30,143,110,.98), rgba(60,83,190,.98)); border: 1px solid rgba(136,246,207,.68); box-shadow: 0 12px 32px rgba(0,0,0,.34), 0 0 28px rgba(78,219,180,.25); pointer-events: none; animation: selfReorderNotice 3.25s ease both; }
.self-reorder-confirmation b { color: #a9ffd9; font-size: 10px; letter-spacing: .08em; }
.self-reorder-confirmation span { font-size: 11px; font-weight: 850; }
.slot.draw-replaced { z-index: 18; animation: newCardPosition 3.8s ease both; }
.slot.draw-replaced::before, .slot.draw-replaced::after { position: absolute; z-index: 9; left: 50%; transform: translateX(-50%); padding: 3px 6px; border-radius: 999px; font-size: 7px; font-weight: 1000; letter-spacing: .05em; white-space: nowrap; pointer-events: none; }
.slot.draw-replaced::before { content: "OLD CARD OUT"; top: -14px; color: #3b2200; background: #ffb956; animation: oldCardLabel 3.8s ease both; }
.slot.draw-replaced::after { content: "NEW CARD HERE"; bottom: -14px; color: #002e38; background: #68e3ec; animation: newCardLabel 3.8s ease both; }
.slot.replacement-flight .card { animation: replacementCardSettle 2.7s ease both; }
.slot-number { position: absolute; z-index: 8; top: 3px; right: 3px; min-width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(3,15,12,.78); border: 1px solid rgba(255,255,255,.45); font-size: 9px; font-weight: 950; pointer-events: none; }
.mini-grid .slot-number { top: 1px; right: 1px; min-width: 12px; height: 12px; font-size: 7px; }
.slot.empty { border: 2px dashed rgba(255,255,255,.16); }
.slot.empty.selectable::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.3); font-size: 30px; }

.card {
  width: var(--card-w); height: var(--card-h); border-radius: 10px; position: relative; overflow: hidden; user-select: none;
  box-shadow: 0 7px 13px rgba(0,0,0,.28); transform-style: preserve-3d;
}
.mini-grid .card { width: var(--mini-w, 36px); height: calc(var(--mini-w, 36px) * 1.42); border-radius: 6px; box-shadow: 0 4px 7px rgba(0,0,0,.23); }
.card.face { background: linear-gradient(145deg, #fffdf4, #eadfc7); color: #16251f; border: 1px solid rgba(0,0,0,.17); }
.card.face.red { color: #c63737; }
.card.back {
  border: 3px solid #eee2c4;
  background-color: var(--card-back);
  background-image:
    linear-gradient(30deg, rgba(255,255,255,.12) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.12) 87.5%),
    linear-gradient(150deg, rgba(255,255,255,.12) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.12) 87.5%),
    linear-gradient(30deg, rgba(255,255,255,.12) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.12) 87.5%),
    linear-gradient(150deg, rgba(255,255,255,.12) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.12) 87.5%),
    linear-gradient(60deg, rgba(6,48,38,.38) 25%, transparent 25.5%, transparent 75%, rgba(6,48,38,.38) 75%);
  background-size: 20px 35px;
  background-position: 0 0, 0 0, 10px 17px, 10px 17px, 0 0;
}
.card.back::after { content: "G"; position: absolute; inset: 8%; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; color: rgba(255,255,255,.78); font-size: calc(var(--card-w) * .4); font-weight: 950; }
.corner { position: absolute; top: 6px; left: 7px; display: grid; line-height: .9; justify-items: center; font-size: calc(var(--card-w) * .21); font-weight: 950; }
.corner.bottom { inset: auto 7px 6px auto; transform: rotate(180deg); }
.suit-big { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--card-w) * .54); }
.joker-word { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--card-w) * .15); font-weight: 950; letter-spacing: .08em; transform: rotate(-55deg); color: #d06e2d; }
.card.reveal-pop { animation: flipIn .48s cubic-bezier(.2,.8,.2,1.1) both; }

.power-panel { padding: 11px 13px; display: grid; gap: 8px; text-align: center; min-width: min(92vw, 360px); }
.power-panel strong { color: var(--gold); }
.power-buttons { display: flex; justify-content: center; gap: 8px; }
.reaction-meter { width: min(280px, 78vw); height: 5px; border-radius: 5px; overflow: hidden; background: rgba(255,255,255,.12); }
.reaction-meter span { display: block; height: 100%; background: #ff765d; transform-origin: left; animation: drain var(--reaction-time, 3.5s) linear forwards; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(1,12,9,.76); backdrop-filter: blur(9px); }
.modal { width: min(100%, 440px); max-height: 90dvh; overflow: auto; padding: 22px; text-align: center; animation: modalIn .4s cubic-bezier(.2,.8,.2,1.1); }
.game-menu-backdrop { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); background: rgba(1,10,8,.8); backdrop-filter: blur(12px); }
.game-menu-panel { width: min(100%, 390px); max-height: 92dvh; overflow: auto; padding: 25px 22px 21px; text-align: center; animation: modalIn .35s cubic-bezier(.2,.8,.2,1.1); }
.game-menu-panel.paused-panel { border-color: rgba(241,195,93,.52); box-shadow: 0 22px 75px rgba(0,0,0,.46), 0 0 38px rgba(241,195,93,.1); }
.game-menu-panel h2 { margin: 5px 0 8px; font-size: 30px; letter-spacing: -.045em; }
.game-menu-panel p { max-width: 320px; margin: 0 auto 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.menu-symbol { width: 58px; height: 58px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; color: #173126; background: linear-gradient(135deg, var(--gold), #e79c3e); font-size: 29px; font-weight: 950; box-shadow: 0 12px 28px rgba(231,156,62,.25); }
.game-menu-actions { display: grid; gap: 9px; }
.game-menu-actions .btn { width: 100%; }
.menu-continue { border: 0; padding: 9px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.menu-continue:active { color: var(--ink); }
.modal h1 { margin: 4px 0 6px; font-size: 34px; }
.modal > p { color: var(--muted); margin: 0 0 17px; }
.results { display: grid; gap: 8px; margin: 15px 0; }
.result-row { padding: 11px; border-radius: 15px; background: rgba(255,255,255,.055); }
.result-row.winner { outline: 2px solid var(--gold); background: rgba(241,195,93,.1); }
.result-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.result-grid { display: flex; justify-content: center; gap: 4px; --card-w: 38px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.gringo-spotlight { position: fixed; z-index: 60; inset: 0; display: grid; align-content: center; justify-items: center; gap: 5px; padding: 25px; color: white; text-align: center; background: radial-gradient(circle, rgba(184,35,53,.96), rgba(52,8,34,.94) 62%, rgba(8,3,12,.92)); pointer-events: none; animation: gringoAlert 3.1s ease both; }
.gringo-spotlight span { color: #ffd36c; font-size: clamp(54px, 18vw, 86px); line-height: .9; font-weight: 1000; letter-spacing: -.06em; text-shadow: 0 0 35px rgba(255,190,64,.42); }
.gringo-spotlight strong { font-size: 20px; letter-spacing: .19em; }
.gringo-spotlight small { max-width: 320px; color: rgba(255,255,255,.78); font-size: 12px; line-height: 1.4; }

.flying-card { position: fixed; z-index: 50; pointer-events: none; margin: 0; transform-origin: center; }
.flying-card.opponent-flight { z-index: 55; filter: drop-shadow(0 16px 16px rgba(0,0,0,.5)) drop-shadow(0 0 12px rgba(104,224,231,.25)); }
.flying-card.wrong-reveal { z-index: 70; filter: drop-shadow(0 0 12px rgba(255,68,62,.95)); outline: 3px solid rgba(255,63,55,.8); }
.drag-ghost {
  position: fixed; z-index: 90; pointer-events: none; margin: 0;
  transform: translate(-50%, -62%) rotate(4deg) scale(1.06); opacity: .92;
  filter: drop-shadow(0 15px 16px rgba(0,0,0,.38));
}
.gringo-call-warning { position: fixed; z-index: 95; left: 50%; top: 48%; transform: translate(-50%, -50%); width: min(88vw, 390px); display: grid; justify-items: center; gap: 3px; padding: 22px 26px; border-radius: 25px; color: white; text-align: center; background: radial-gradient(circle at 50% 20%, rgba(215,59,59,.98), rgba(91,20,52,.97)); border: 2px solid rgba(255,211,100,.86); box-shadow: 0 0 0 200vmax rgba(5,8,10,.28), 0 25px 80px rgba(0,0,0,.48), 0 0 42px rgba(244,73,62,.35); pointer-events: none; animation: gringoCalled 2.45s ease both; }
.gringo-call-warning b { color: #ffd36c; font-size: clamp(43px, 15vw, 68px); line-height: .95; letter-spacing: -.04em; }
.gringo-call-warning strong { font-size: 17px; }
.gringo-call-warning span { color: rgba(255,255,255,.78); font-size: 11px; font-weight: 900; letter-spacing: .18em; }
#toast-region { position: fixed; z-index: 100; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(calc(100% - 28px), 420px); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 14px; background: rgba(5,25,21,.94); border: 1px solid rgba(255,255,255,.15); box-shadow: 0 12px 35px rgba(0,0,0,.3); animation: toastIn .3s ease, toastOut .3s 2.7s ease forwards; }
.toast.error { border-color: rgba(239,90,77,.65); }
.toast.power { border-color: rgba(181,112,255,.7); background: rgba(53,24,83,.96); }
.toast.swap-victim { border: 2px solid #ff665e; background: rgba(104,26,42,.97); font-size: 16px; font-weight: 900; }
.toast.final-round-toast { border: 2px solid #ff795f; background: rgba(105,20,48,.97); font-size: 16px; font-weight: 950; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes flipIn { from { opacity: 0; transform: perspective(500px) rotateY(85deg) scale(.9); } }
@keyframes drawIn { from { opacity: 0; transform: translateY(-48px) rotate(-7deg) scale(.82); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.96); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes reactionGlow { to { box-shadow: 0 0 28px rgba(255,117,92,.42); } }
@keyframes selectGlow { from { box-shadow: 0 0 0 2px rgba(241,195,93,.4); } to { box-shadow: 0 0 0 5px rgba(241,195,93,.11); } }
@keyframes zonePulse { 40% { scale: 1.035; background: rgba(241,195,93,.15); } }
@keyframes opponentTrack { to { border-color: rgba(115,235,239,.96); background: rgba(59,183,194,.2); box-shadow: 0 0 25px rgba(62,190,203,.28); } }
@keyframes deckBump { 40% { transform: translateY(-7px) rotate(-2deg); } }
@keyframes deckInvite { 50% { transform: translateY(-5px); filter: brightness(1.08); } }
@keyframes hintPulse { 50% { opacity: .62; } }
@keyframes penaltySettle { 0%, 72% { opacity: 0; transform: translateY(-35px) rotate(7deg) scale(.85); } 100% { opacity: 1; transform: none; } }
@keyframes drain { to { transform: scaleX(0); } }
@keyframes lowDeck { 50% { transform: scale(1.045); filter: brightness(1.12); } }
@keyframes lastCard { to { transform: scale(1.08); filter: brightness(1.22); box-shadow: 0 0 25px rgba(255,77,68,.48); } }
@keyframes emotePop { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.4); } 14%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -28px) scale(.84); } }
@keyframes powerMatch { from { box-shadow: 0 0 0 2px rgba(201,124,255,.75), 0 0 10px rgba(201,124,255,.45); } to { box-shadow: 0 0 0 5px rgba(255,100,185,.34), 0 0 28px rgba(201,124,255,.84); transform: translateY(-3px); } }
@keyframes reservedPower { to { transform: scale(1.09) rotate(2deg); filter: drop-shadow(0 0 16px rgba(206,120,255,.95)); } }
@keyframes swapCardPulse { to { transform: scale(1.1) rotate(-2deg); filter: drop-shadow(0 0 22px rgba(255,212,100,.95)); } }
@keyframes rankMatch { from { box-shadow: 0 0 0 2px rgba(255,161,65,.72), 0 0 10px rgba(255,121,58,.38); } to { box-shadow: 0 0 0 5px rgba(255,100,72,.3), 0 0 27px rgba(255,129,57,.75); transform: translateY(-3px); } }
@keyframes liveMatch { to { transform: scale(1.025); filter: brightness(1.12); } }
@keyframes finalPulse { to { border-color: rgba(255,210,101,.95); box-shadow: 0 0 26px rgba(230,57,67,.38); } }
@keyframes powerDecision { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.85); } 12%, 78% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -7px) scale(.96); } }
@keyframes gringoCalled { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.28); } 12%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.92); } }
@keyframes selfReorderFrom { 0% { box-shadow: 0 0 0 0 rgba(113,239,190,0); transform: scale(.94); } 12%, 70% { box-shadow: 0 0 0 5px rgba(113,239,190,.9), 0 0 34px rgba(77,229,175,.76); transform: translateY(-5px) scale(1.07); } 100% { box-shadow: none; transform: none; } }
@keyframes selfReorderTo { 0% { box-shadow: 0 0 0 0 rgba(90,120,255,0); transform: scale(.94); } 12%, 70% { box-shadow: 0 0 0 5px rgba(90,120,255,.92), 0 0 36px rgba(90,120,255,.78); transform: translateY(-5px) scale(1.07); } 100% { box-shadow: none; transform: none; } }
@keyframes selfReorderTag { 0%, 100% { opacity: 0; transform: translate(-50%, 7px) scale(.85); } 12%, 76% { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes selfReorderNotice { 0% { opacity: 0; transform: translate(-50%, 12px) scale(.86); } 12%, 74% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -9px) scale(.94); } }
@keyframes newCardPosition { 0%, 28% { box-shadow: 0 0 0 4px rgba(255,177,75,.92), 0 0 26px rgba(255,151,54,.65); } 38%, 88% { box-shadow: 0 0 0 5px rgba(97,226,235,.95), 0 0 34px rgba(64,205,221,.78); transform: scale(1.07); } 100% { box-shadow: none; transform: none; } }
@keyframes oldCardLabel { 0%, 29% { opacity: 1; } 38%, 100% { opacity: 0; } }
@keyframes newCardLabel { 0%, 28% { opacity: 0; } 39%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes replacementCardSettle { 0%, 22% { filter: brightness(.7); } 45%, 78% { filter: brightness(1.25) drop-shadow(0 0 15px rgba(97,226,235,.9)); transform: translateY(-3px) scale(1.06); } 100% { filter: none; transform: none; } }
@keyframes gringoAlert { 0% { opacity: 0; transform: scale(1.18); } 10%, 72% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.96); } }

@media (min-width: 500px) {
  :root { --card-w: 72px; }
  .table { grid-template-rows: 266px auto minmax(230px, 1fr); }
  .opponents { height: 266px; }
  .opponents.count-1 .player-zone { --mini-w: 66px; width: 192px; }
  .opponents.count-2 .player-zone { --mini-w: 56px; width: 174px; }
  .opponents.count-3 .player-zone { --mini-w: 45px; width: 146px; }
  .opponents.count-4 .player-zone { --mini-w: 39px; width: 130px; }
  .opponents.count-5 .player-zone { --mini-w: 35px; width: 118px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
