/* ===============================================================
   Kaboom Critters — styles
   Theme colours are CSS variables set from js/data.js THEMES.
   =============================================================== */
:root {
  --table: #16613f; --table2: #06301e; --felt: #1d7a50; --panel: #fff; --panel-ink: #1f2933; --accent: #ff6b35; --muted: #66756d;
  --back1: #2b2d6e; --back2: #4b3fa8; --card-scale: 1;
  --cw: calc(108px * var(--card-scale)); --ch: calc(150px * var(--card-scale));
  --font-head: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body); color: var(--panel-ink); overflow: hidden;
  background: radial-gradient(ellipse at 30% 15%, var(--table), var(--table2) 85%) fixed, var(--table2);
}
#bg-deco {
  position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.08) 1.5px, transparent 1.6px), radial-gradient(rgba(255,255,255,.05) 1px, transparent 1.2px);
  background-size: 28px 28px, 17px 17px; animation: drift 80s linear infinite;
}
body.no-anim-bg #bg-deco, body.no-anim-bg .title-floaters { animation: none; display: none; }
@keyframes drift { to { background-position: 280px 560px, -170px 340px; } }

.screen { position: fixed; inset: 0; display: none; overflow: auto; }
.screen.active { display: flex; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd { font: 700 11px var(--font-body); background: rgba(0,0,0,.18); border-radius: 5px; padding: 1px 6px; margin-left: 6px; }
code { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; }

/* ---------- buttons & inputs ---------- */
.btn {
  font: 800 15px var(--font-body); border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer;
  background: #fff; color: #1f2933; box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 6px 16px rgba(0,0,0,.12);
  transition: transform .12s, filter .12s, box-shadow .12s; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #ffad33, var(--accent)); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.btn.danger { background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff; }
.btn.good { background: linear-gradient(180deg, #4ade80, #16a34a); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; border: 1.5px solid currentColor; opacity: .85; }
.btn.big { font-size: 18px; padding: 14px 26px; border-radius: 16px; }
.btn.sm { font-size: 12px; padding: 5px 9px; border-radius: 8px; box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.ghost.sm { box-shadow: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: grayscale(.6); }
input[type=text], input[type=number], select, textarea {
  font: 600 14px var(--font-body); padding: 7px 10px; border-radius: 9px; border: 1.5px solid rgba(0,0,0,.18);
  background: #fff; color: #1f2933; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input.short { width: 72px; text-align: center; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1.5px solid rgba(0,0,0,.2); border-radius: 8px; background: #fff; cursor: pointer; }
input[type=range] { accent-color: var(--accent); width: 160px; }
.switch { position: relative; display: inline-block; width: 48px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c3c9cf; border-radius: 27px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(21px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip { border: 0; padding: 6px 14px; border-radius: 20px; background: rgba(0,0,0,.07); color: inherit; font: 800 14px var(--font-body); cursor: pointer; }
.chip.on { background: var(--accent); color: #fff; }

/* ---------- title ---------- */
#screen-title { align-items: center; justify-content: center; color: #fff; text-align: center; padding: 20px; }
.title-wrap { position: relative; z-index: 1; }
.title-logo { font-size: clamp(80px, 14vw, 130px); line-height: 1; animation: jitter 2.6s ease-in-out infinite; filter: drop-shadow(0 14px 24px rgba(0,0,0,.45)); display: inline-block; }
#title-name {
  font: 700 clamp(40px, 8vw, 86px)/1 var(--font-head); margin: .15em 0 .1em; letter-spacing: .5px;
  background: linear-gradient(90deg, #ffe066, #ffad33 40%, #ff4d4d); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.25));
}
.title-sub { font-size: clamp(16px, 2.4vw, 22px); font-weight: 700; opacity: .9; margin: 0 0 30px; }
.title-btns { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 640px; margin: 0 auto; }
.title-btns .btn.ghost { color: #fff; }
.title-foot { margin-top: 34px; font-size: 13px; opacity: .65; }
.title-floaters { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.title-floaters span { position: absolute; bottom: -80px; opacity: .35; animation: rise linear infinite; }
@keyframes rise { 0% { transform: translateY(0) rotate(-10deg); } 50% { transform: translateY(-60vh) rotate(10deg); } 100% { transform: translateY(-120vh) rotate(-10deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }
@keyframes jitter { 0%, 70%, 100% { transform: rotate(-6deg); } 74% { transform: rotate(8deg) scale(1.05); } 78% { transform: rotate(-8deg); } 82% { transform: rotate(6deg) scale(1.05); } 86% { transform: rotate(-6deg); } }

/* ---------- setup ---------- */
#screen-setup { flex-direction: column; color: #fff; }
.setup-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px 10px; flex-wrap: wrap; }
.setup-head h2 { flex: 1; margin: 0; font: 600 26px var(--font-head); }
.setup-head .btn.ghost { color: #fff; }
.tabs { display: flex; gap: 6px; padding: 0 20px; flex-wrap: wrap; }
.tabs button {
  border: 0; background: rgba(255,255,255,.14); color: #fff; font: 800 15px var(--font-body); padding: 10px 16px;
  border-radius: 12px 12px 0 0; cursor: pointer; transition: background .15s;
}
.tabs button:hover { background: rgba(255,255,255,.24); }
.tabs button.active { background: var(--panel); color: var(--panel-ink); }
.tab-body { flex: 1 0 auto; margin: 0 20px 20px; background: var(--panel); color: var(--panel-ink); border-radius: 0 18px 18px 18px; padding: 22px 26px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.form { column-width: 420px; column-gap: 48px; }
.fsec { font: 600 19px var(--font-head); margin: 18px 0 4px; break-after: avoid; color: var(--accent); }
.fsec:first-child { margin-top: 0; }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid rgba(127,127,127,.18); break-inside: avoid; }
.frow > label { font-weight: 700; }
.frow > label small { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
.fin { display: flex; align-items: center; gap: 8px; flex: none; }
.fin output { min-width: 54px; text-align: right; font-weight: 800; font-size: 13px; }
.fin input[type=number] { width: 110px; }
.fin select { max-width: 230px; }

.pcount { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 16px; flex-wrap: wrap; }
.prow { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(127,127,127,.09); border-left: 6px solid var(--pc); margin-bottom: 8px; flex-wrap: wrap; }
.seat-no { font: 700 18px var(--font-head); width: 22px; text-align: center; opacity: .6; }
.tokbtn { font-size: 30px; width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--pc); background: #fff; cursor: pointer; transition: transform .15s; }
.tokbtn:hover { transform: scale(1.1) rotate(-8deg); }
.prow input[type=text] { flex: 1; min-width: 130px; }
.ptools { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.tok-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; margin-bottom: 12px; }
.tok-grid button { font-size: 30px; padding: 6px; border-radius: 12px; border: 2px solid transparent; background: rgba(127,127,127,.12); cursor: pointer; }
.tok-grid button:hover { border-color: var(--accent); transform: scale(1.08); }

/* card editor */
.ced-top { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.ced-sum { font-weight: 800; background: rgba(127,127,127,.1); border-radius: 12px; padding: 8px 14px; }
.ced-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.ced { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 12px; border-radius: 14px; background: rgba(127,127,127,.07); border-left: 6px solid var(--cc); }
.ced .mini { --cw: 92px; --ch: 128px; }
.ced-f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ced-row { display: flex; gap: 6px; align-items: center; }
.ced-row input[type=text] { flex: 1; }
.ced textarea { width: 100%; resize: vertical; min-height: 44px; font-size: 12.5px; }
.ced select { width: 100%; font-size: 12.5px; }
.ced-count { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; }
.ced-count input { width: 70px; }
.ced.off { opacity: .5; }
.ff { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 800; color: var(--muted); }
.data-tab section { margin-bottom: 22px; }
.data-tab h3 { font: 600 19px var(--font-head); margin: 0 0 6px; color: var(--accent); }
.data-tab .btn { margin: 4px 4px 4px 0; }
.json-box { display: block; width: 100%; min-height: 90px; margin: 10px 0 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* ---------- playing cards ---------- */
.card {
  position: relative; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .11); flex: none;
  background: #fffdf7; color: #222; border: calc(var(--cw) * .045) solid var(--cc, #444);
  box-shadow: 0 4px 10px rgba(0,0,0,.3); display: flex; flex-direction: column; align-items: center; overflow: hidden;
  font-size: calc(var(--cw) / 9); user-select: none;
  background-image: radial-gradient(circle at 100% 0, color-mix(in srgb, var(--cc, #444) 28%, transparent), transparent 60%);
}
.card .c-band { width: 100%; background: var(--cc); color: #fff; font: 600 .95em/1.15 var(--font-head); text-align: center; padding: .3em .2em; text-shadow: 0 1px 1px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-emoji { font-size: 3.3em; line-height: 1.15; margin-top: .15em; filter: drop-shadow(0 .1em .1em rgba(0,0,0,.25)); }
.card .c-desc { font-size: .72em; line-height: 1.2; text-align: center; padding: 0 .45em; font-weight: 700; color: #444; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
body.no-card-text .card .c-desc { display: none; }
body.no-card-text .card .c-emoji { font-size: 4.2em; margin-top: .3em; }
.card .c-corner { position: absolute; bottom: .25em; right: .4em; font-size: .9em; opacity: .55; }
.card.bomb { background: radial-gradient(circle at 50% 45%, #ffcf4d, #ff6b1a 40%, #3a0a0a 85%); color: #fff; }
.card.bomb .c-desc { color: #fff; text-shadow: 0 1px 2px #000; }
.card.back {
  border-color: #fff; background: repeating-linear-gradient(45deg, var(--back1) 0 .8em, var(--back2) .8em 1.6em);
  align-items: center; justify-content: center;
}
.card.back::after { content: attr(data-icon); font-size: 2.6em; filter: drop-shadow(0 .1em .2em rgba(0,0,0,.4)); }
.card.small { --cw: 46px; --ch: 64px; border-width: 2px; }
.card.tiny { --cw: 22px; --ch: 31px; border-width: 1.5px; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.card.tiny::after { font-size: 1.2em; }

/* ---------- game layout ---------- */
#screen-game { gap: 14px; padding: 10px; }
#table {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; border-radius: 26px; padding: 12px;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--felt) 90%, #fff), var(--felt) 60%, color-mix(in srgb, var(--felt) 70%, #000));
  box-shadow: inset 0 0 0 8px rgba(0,0,0,.18), inset 0 0 60px rgba(0,0,0,.35), 0 20px 50px rgba(0,0,0,.4);
}
body.shake #table { animation: shake .5s cubic-bezier(.36,.07,.19,.97) both; }
body.shake-mild #table { animation: shake-mild .4s both; }
@keyframes shake { 10%, 90% { transform: translate(-3px, 2px); } 20%, 80% { transform: translate(6px, -4px) rotate(.4deg); } 30%, 50%, 70% { transform: translate(-10px, 6px) rotate(-.6deg); } 40%, 60% { transform: translate(10px, -6px) rotate(.6deg); } }
@keyframes shake-mild { 25% { transform: translate(-3px, 1px); } 75% { transform: translate(3px, -1px); } }

#seats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.seat {
  position: relative; display: flex; align-items: center; gap: 9px; background: var(--panel); color: var(--panel-ink);
  border-radius: 16px; padding: 8px 12px 8px 8px; border-bottom: 5px solid var(--pc); min-width: 160px; transition: transform .25s, box-shadow .25s, opacity .3s;
}
.seat.active { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--pc), 0 10px 24px rgba(0,0,0,.35); }
.seat.out { opacity: .45; filter: grayscale(1); }
.seat.target { animation: target 1s ease-in-out infinite; cursor: pointer; }
@keyframes target { 50% { box-shadow: 0 0 0 5px var(--accent), 0 10px 24px rgba(0,0,0,.35); } }
.s-ava { font-size: 30px; width: 50px; height: 50px; border-radius: 50%; background: #fff; border: 3px solid var(--pc); display: flex; align-items: center; justify-content: center; flex: none; position: relative; }
.seat.active .s-ava { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--pc); } 50% { box-shadow: 0 0 0 7px transparent; } }
.s-info { min-width: 0; }
.s-name { font-weight: 900; font-size: 15px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 10.5px; background: rgba(127,127,127,.18); padding: 1px 7px; border-radius: 20px; font-weight: 800; }
.tag.warn { background: #fed7aa; color: #7c2d12; }
.tag.score { background: #fde68a; color: #713f12; }
.s-cards { display: flex; align-items: center; margin-top: 4px; min-height: 31px; }
.s-cards .card.tiny + .card.tiny { margin-left: -14px; }
.s-cards b { margin-left: 8px; font: 600 16px var(--font-head); }
.s-open { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; max-width: 220px; }
.s-open span { font-size: 15px; }
.s-turns { position: absolute; top: -9px; right: -6px; background: #ef4444; color: #fff; font: 700 13px var(--font-head); border-radius: 12px; padding: 1px 8px; box-shadow: 0 2px 6px rgba(0,0,0,.35); animation: pop .3s; }
.s-bubble { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 8px); background: #fff; color: #222; font-weight: 800; font-size: 13px; padding: 5px 11px; border-radius: 14px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.35); z-index: 8; animation: pop .25s; pointer-events: none; }
.s-bubble::before { content: ''; position: absolute; top: -6px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom-color: #fff; }

#center { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 60px); min-height: calc(var(--ch) + 60px); position: relative; }
.pile-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pile { position: relative; width: var(--cw); height: var(--ch); }
.pile.deck { cursor: pointer; }
.pile.deck .card { position: absolute; left: 0; top: 0; }
.pile.deck.can-draw { animation: glowcard 1.6s ease-in-out infinite; border-radius: calc(var(--cw) * .11); }
@keyframes glowcard { 50% { box-shadow: 0 0 0 6px rgba(255,200,60,.65), 0 0 30px rgba(255,200,60,.6); } }
.pile.deck:hover .card:last-child { transform: translateY(-4px); }
.pile .count { position: absolute; bottom: -10px; right: -10px; background: #111; color: #fff; font: 700 15px var(--font-head); min-width: 32px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: 0 8px; z-index: 3; border: 2px solid #fff; }
.pile.discard .card { position: absolute; left: 0; top: 0; }
.pile.discard:empty { border: 3px dashed rgba(255,255,255,.35); border-radius: calc(var(--cw) * .11); }
.pile-label { color: #fff; font-weight: 800; font-size: 13px; opacity: .8; }
.known { position: absolute; right: calc(100% + 8px); top: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; z-index: 4; }
.known .k { background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.known .k.bad { background: #b91c1c; }
.danger { width: calc(var(--cw) + 30px); text-align: center; color: #fff; font-weight: 800; font-size: 12px; }
.danger .bar { height: 9px; border-radius: 6px; background: rgba(0,0,0,.35); overflow: hidden; margin-top: 3px; }
.danger .bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #4ade80, #facc15 45%, #ef4444); background-size: calc(var(--cw) + 30px) 100%; transition: width .5s; }
#status { text-align: center; color: #fff; max-width: 280px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.st-who { font: 600 22px var(--font-head); text-shadow: 0 2px 4px rgba(0,0,0,.35); }
.st-sub { font-weight: 700; font-size: 14px; opacity: .9; }
.st-dir { font-size: 26px; opacity: .8; transition: transform .4s; }
.st-dir.rev { transform: scaleX(-1); }
.st-played { min-height: 10px; }

#hand-area { background: rgba(0,0,0,.22); border-radius: 18px; padding: 8px 12px 12px; }
#hand-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: #fff; margin-bottom: 6px; min-height: 40px; }
.hb-who { font: 600 17px var(--font-head); flex: 1; min-width: 160px; }
.hb-hint { font-size: 13px; font-weight: 700; opacity: .9; }
.hb-timer { font: 700 16px var(--font-head); background: rgba(0,0,0,.35); padding: 3px 10px; border-radius: 10px; }
.hb-timer.low { background: #dc2626; animation: pulse-bg .5s infinite alternate; }
@keyframes pulse-bg { to { filter: brightness(1.4); } }
#hand { display: flex; justify-content: center; align-items: flex-end; min-height: calc(var(--ch) + 22px); padding-top: 18px; overflow-x: auto; overflow-y: visible; }
#hand .card { cursor: pointer; transition: transform .18s, box-shadow .18s, margin .18s; margin: 0 calc(var(--ov, 0px) * -1); }
body:not(.fan) #hand { flex-wrap: wrap; gap: 6px; }
body:not(.fan) #hand .card { margin: 0; }
#hand .card:hover { transform: translateY(-14px); z-index: 5; }
#hand .card.sel { transform: translateY(-22px); box-shadow: 0 0 0 4px #ffd23f, 0 12px 24px rgba(0,0,0,.45); z-index: 6; }
#hand.locked .card { cursor: default; }
#hand.locked .card:hover { transform: none; }
#hand.hidden-hand .card { pointer-events: none; }
#hand .card.new { animation: dealin .5s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes dealin { from { transform: translateY(-60px) scale(.6) rotate(-10deg); opacity: 0; } }
.hand-empty { color: #fff; opacity: .7; font-weight: 700; padding: 30px; }
.curtain { color: #fff; text-align: center; padding: 20px; }

#sidebar { width: 330px; flex: 0 0 330px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,.3); color: #fff; border-radius: 14px; padding: 6px 10px; gap: 6px; }
.tb-info { display: flex; gap: 12px; font-weight: 800; font-size: 14px; flex-wrap: wrap; }
.tb-btns { display: flex; flex-wrap: nowrap; }
.icon-btn { background: none; border: 0; font-size: 17px; cursor: pointer; padding: 4px; border-radius: 8px; transition: background .15s; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.icon-btn.off { opacity: .35; }
.log-wrap { flex: 1; min-height: 140px; background: rgba(0,0,0,.3); border-radius: 14px; color: #f1f1f1; display: flex; flex-direction: column; overflow: hidden; }
.log-head { font: 600 14px var(--font-head); padding: 8px 12px 4px; opacity: .8; }
#log { overflow: auto; padding: 0 12px 8px; font-size: 13px; line-height: 1.5; }
.log-item { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.07); animation: fadein .3s; }
.log-item:first-child { color: #fff; }
.pn { background: var(--pc); color: #fff; padding: 0 .45em; border-radius: 1em; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.3); font-weight: 800; }
.cn { background: var(--cc); color: #fff; padding: 0 .45em; border-radius: .5em; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.35); font-weight: 800; }

/* flying cards */
#flyers { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.flyer { position: fixed; transition-property: left, top, transform; transition-timing-function: cubic-bezier(.3, .7, .4, 1); }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 45; background: radial-gradient(circle, #fff7c2, #ff9d2e 50%, #b4130088); opacity: 0; }
#flash.on { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- modals ---------- */
#modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.modal-back { position: fixed; inset: 0; background: rgba(5,10,20,.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: auto; animation: fadein .2s; }
.modal-back.closing { animation: fadeout .16s forwards; }
.modal {
  background: var(--panel); color: var(--panel-ink); border-radius: 20px; max-width: min(500px, 100%); width: 100%;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.5); animation: pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.modal.wide { max-width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px 0; gap: 10px; }
.modal-head h2 { flex: 1; margin: 0; font: 600 22px var(--font-head); }
.modal-body { padding: 14px 20px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 18px; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }
.x:hover { opacity: 1; }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes pop { from { transform: scale(.85) translateY(20px); opacity: 0; } }
.warn-note { background: #fff3cd; color: #7a4f00; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 13px; }

.card-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 10px; perspective: 900px; }
.card-row .card { animation: flipin .6s cubic-bezier(.2, 1.3, .4, 1) both; }
.card-row .card:nth-child(2) { animation-delay: .08s; } .card-row .card:nth-child(3) { animation-delay: .16s; }
.card-row .card:nth-child(4) { animation-delay: .24s; } .card-row .card:nth-child(5) { animation-delay: .32s; }
.card-row.pick .card { cursor: pointer; transition: transform .15s; }
.card-row.pick .card:hover { transform: translateY(-6px); }
.card-row.pick .card.sel { box-shadow: 0 0 0 4px #ffd23f, 0 10px 20px rgba(0,0,0,.35); transform: translateY(-6px); }
@keyframes flipin { from { transform: rotateY(100deg) scale(.6); opacity: 0; } }
.pos-tag { text-align: center; font-weight: 800; font-size: 12px; color: var(--muted); margin-top: 4px; }
.reorder { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.reorder > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.reorder .arrows { display: flex; gap: 4px; }
.center-text { text-align: center; }
.big-emoji { font-size: 64px; text-align: center; line-height: 1.1; }

/* boom */
.boom-modal { max-width: 440px; text-align: center; overflow: visible; }
.boom-modal .modal-body { overflow: visible; }
.boom-modal .card { margin: 0 auto; --cw: 150px; --ch: 208px; animation: boomcard .8s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes boomcard { 0% { transform: scale(.2) rotate(-30deg); } 60% { transform: scale(1.15) rotate(6deg); } 100% { transform: none; } }
.boom-title { font: 700 40px var(--font-head); color: #ef4444; margin: 10px 0 0; letter-spacing: 2px; animation: jitter 1s infinite; }
.boom-modal .modal-foot { justify-content: center; }
.slot-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.slot-range { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 800; }
.slot-range input[type=range] { width: 220px; }

/* hold-it prompt */
.holdit-modal { max-width: 460px; }
.hi-action { display: flex; gap: 14px; align-items: center; }
.hi-bar { height: 8px; border-radius: 4px; background: rgba(127,127,127,.2); overflow: hidden; margin-top: 12px; }
.hi-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; animation: shrink linear forwards; }
@keyframes shrink { to { transform: scaleX(0); } }
.target-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.target-grid button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--pc); background: rgba(127,127,127,.06); cursor: pointer; font: 800 14px var(--font-body); color: inherit; min-width: 100px; }
.target-grid button span { font-size: 34px; }
.target-grid button:hover { background: color-mix(in srgb, var(--pc) 18%, transparent); transform: translateY(-2px); }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.name-grid button { display: flex; gap: 6px; align-items: center; padding: 8px; border-radius: 10px; border: 2px solid var(--cc); background: rgba(127,127,127,.05); cursor: pointer; font: 800 13px var(--font-body); color: inherit; text-align: left; }
.name-grid button:hover { background: color-mix(in srgb, var(--cc) 18%, transparent); }

/* guide, victory & help */
.guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.guide > div { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(127,127,127,.07); border-left: 5px solid var(--cc); }
.guide b { display: block; }
.guide small { color: var(--muted); font-weight: 700; display: block; line-height: 1.3; }
.guide .g-emoji { font-size: 30px; }
.victory { text-align: center; }
.victory h2 { font: 700 34px var(--font-head); margin: 0 0 12px; }
.win-crown { font-size: 70px; animation: bob 2s ease-in-out infinite; }
.win-tok { font-size: 54px; margin-top: -10px; }
.rank { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.rank td { padding: 7px 6px; border-bottom: 1px solid rgba(127,127,127,.2); font-weight: 800; text-align: left; }
.rank tr.out { opacity: .6; }
.howto ol { padding-left: 20px; line-height: 1.7; }
.ig-form { column-width: 340px; }

/* toasts & fx */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; align-items: center; width: max-content; max-width: 92vw; }
.toast { background: rgba(17,22,34,.94); color: #fff; padding: 9px 18px; border-radius: 30px; font-weight: 800; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); border-left: 5px solid var(--tc, var(--accent)); animation: tin .35s cubic-bezier(.2, 1.4, .4, 1); transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes tin { from { opacity: 0; transform: translateY(-16px) scale(.9); } }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  body { overflow: auto; }
  #screen-game { flex-direction: column; padding: 8px; gap: 10px; }
  #table { flex: none; padding: 10px; }
  #sidebar { width: 100%; flex: none; }
  .log-wrap { min-height: 220px; }
  .tab-body { margin: 0 8px 12px; padding: 16px; }
  .tabs, .setup-head { padding-left: 8px; padding-right: 8px; }
  .frow { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  :root { --cw: calc(82px * var(--card-scale)); --ch: calc(114px * var(--card-scale)); }
  .seat { min-width: 0; padding: 6px 8px 6px 6px; gap: 6px; }
  .s-ava { width: 38px; height: 38px; font-size: 22px; }
  .s-name { font-size: 13px; }
  #center { gap: 12px; }
  #status { max-width: 130px; }
  .st-who { font-size: 17px; }
  .known { right: auto; left: 0; top: calc(100% + 34px); flex-direction: row; flex-wrap: wrap; width: 200px; }
  .btn.big { font-size: 16px; padding: 12px 18px; }
  input[type=range] { width: 120px; }
  .ced-list { grid-template-columns: 1fr; }
}
/* phones: the hand in rows (no fan), bigger card names; the full text shows in the large card view */
@media (max-width: 560px) {
  #seats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .seat { width: auto; }
  .seat .s-cards .card.tiny + .card.tiny { margin-left: -16px; }
  #hand { container-type: inline-size; flex-wrap: wrap; gap: 6px; justify-content: center; overflow: visible; padding-top: 12px; min-height: 0; }
  #hand .card { --cw: min(calc(82px * var(--card-scale)), calc((100cqw - 18px) / 4)); height: auto; aspect-ratio: 82 / 114; margin: 0 !important; font-size: calc(var(--cw) / 7); }
  #hand .card .c-band { white-space: normal; font-size: 1.02em; line-height: 1.08; min-height: 2.35em; display: flex; align-items: center; justify-content: center; padding: .2em .15em; }
  #hand .card .c-emoji { font-size: 3em; margin-top: .2em; }
  #hand .card .c-desc { display: none; }
  #hand .card:hover { transform: none; }
  #hand .card.sel { transform: translateY(-8px); }
  #hand-area { padding: 8px 8px 12px; }
  .modal .card-row { gap: 8px; }
  .modal:not(.boom-modal) .card:not(.back) { --cw: 92px; --ch: 128px; font-size: calc(var(--cw) / 7.4); }
  .modal:not(.boom-modal) .card:not(.back) .c-desc { font-size: .7em; }
}
#card-peek { position: fixed; z-index: 90; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)); cursor: pointer; }
#card-peek .card.peek { animation: pop .18s; }
#card-peek[hidden] { display: none; }
#card-peek .card.peek { --cw: min(190px, 52vw); --ch: calc(var(--cw) * 1.39); height: var(--ch); font-size: calc(var(--cw) / 9); }
#card-peek .card.peek .c-band { white-space: normal; }
#card-peek .card.peek .c-desc { display: block; -webkit-line-clamp: unset; font-size: .82em; line-height: 1.25; padding: .2em .6em; }
#card-peek .card.peek .c-emoji { font-size: 3.6em; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.ced input.short { width: 46px; padding-left: 4px; padding-right: 4px; }
