:root {
  --bg:        #0c1310;
  --panel:     #15201b;
  --panel-2:   #1d2a23;
  --line:      #2c3a31;
  --gold:      #d9b75f;
  --gold-soft: #b89a52;
  --text:      #e8efe9;
  --muted:     #9fb1a4;
  --green:     #3fae6b;
  --green-bg:  rgba(63,174,107,.14);
  --red:       #e0604f;
  --red-bg:    rgba(224,96,79,.14);
  --blue:      #5aa9e6;
  --violet:    #b07fe0;
  --shadow:    0 10px 30px rgba(0,0,0,.5);

  /* Fluid scale — everything sizes smoothly with the viewport */
  --card-w: clamp(54px, 7vw, 80px);
  --card-h: calc(var(--card-w) * 1.4);
  --hand-w: clamp(74px, 11.5vw, 112px);
  --hand-h: calc(var(--hand-w) * 1.4);
  --gap:    clamp(8px, 1.5vw, 14px);
  --pad:    clamp(12px, 2.2vw, 18px);
  --radius: 14px;
  --fs:     clamp(13.5px, 0.6vw + 12px, 15px);

  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  --backdrop: url("assets/backdrop.jpg");
  background:
    radial-gradient(ellipse 80% 95% at 50% 36%, rgba(8,12,10,.92) 0%, rgba(8,12,10,.6) 58%, rgba(8,12,10,.4) 100%),
    var(--backdrop) center top / cover no-repeat fixed,
    var(--bg);
  color: var(--text);
  font-size: var(--fs);
  display: flex; flex-direction: column; min-height: 100vh;
  overflow-x: hidden;
}
body.theme-medium  { --backdrop: url("assets/backdrop-medium.jpg"); }
body.theme-hard    { --backdrop: url("assets/backdrop-hard.jpg"); }
body.theme-extreme { --backdrop: url("assets/backdrop-extreme.jpg"); }
a { color: var(--gold); }

/* Animated ember layer (Higgsfield video) — over backdrop, under content */
.bg-embers { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; opacity: .22; mix-blend-mode: screen; pointer-events: none; }

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: clamp(8px,1.8vw,13px) clamp(12px,3vw,24px);
  border-bottom: 1px solid var(--line);
  background: rgba(8,12,10,.74); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: clamp(8px,2vw,13px); min-width: 0; }
.brand-mark { font-size: clamp(22px,5vw,28px); color: var(--gold); text-shadow: 0 0 18px rgba(217,183,95,.5); line-height: 1; }
.brand h1 { margin: 0; font-size: clamp(15px,4.4vw,21px); letter-spacing: .11em; text-transform: uppercase; white-space: nowrap; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-right { display: flex; gap: 7px; align-items: center; flex-shrink: 0; }
.stat-pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: clamp(3px,1vw,5px) clamp(8px,2vw,12px); color: var(--text); font-size: clamp(10.5px,2.4vw,13px); white-space: nowrap; }
.stat-pill b { color: var(--gold); }

#app { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: var(--pad) clamp(12px,3vw,16px) clamp(36px,6vw,46px); position: relative; z-index: 1; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 14px; border-top: 1px solid var(--line); position: relative; z-index: 1; }

/* ---------------- Menu ---------------- */
.hero { text-align: center; padding: clamp(8px,2vw,16px) 6px 4px; }
.hero h2 { font-size: clamp(23px,6vw,30px); margin: 6px 0 10px; }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 8px; line-height: 1.55; }
.diff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%,230px), 1fr)); gap: var(--gap); margin: clamp(18px,4vw,26px) 0 10px; }
.diff-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px,3vw,20px); cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; text-align: left; }
.diff-card:hover { transform: translateY(-4px); border-color: var(--gold-soft); box-shadow: var(--shadow); }
.diff-card .emblem { position: absolute; top: 14px; right: 14px; width: clamp(46px,12vw,58px); height: clamp(46px,12vw,58px); object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.55)); pointer-events: none; }
.diff-card h3 { margin: 8px 0 6px; font-size: clamp(17px,4.5vw,19px); padding-right: 56px; }
.diff-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.diff-card .count { margin-top: 12px; font-size: 12.5px; color: var(--gold-soft); }
.cta-row { display: flex; justify-content: center; gap: 12px; margin-top: clamp(18px,4vw,22px); flex-wrap: wrap; }

/* ---------------- Buttons ---------------- */
.btn { font: inherit; font-size: clamp(14px,3vw,15px); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 11px 18px; border-radius: 10px; cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.btn:hover { transform: translateY(-2px); border-color: var(--gold-soft); }
.btn-primary { background: linear-gradient(180deg, #e6c674, #c9a34e); color: #20170a; border-color: #c9a34e; font-weight: 700; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }

/* ---------------- Difficulty badges ---------------- */
.d-badge { font-size: clamp(10.5px,2.4vw,11.5px); text-transform: uppercase; letter-spacing: .09em; padding: 4px 10px; border-radius: 999px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.d-easy   { color: #8be0a6; background: rgba(63,174,107,.16); border-color: rgba(63,174,107,.4); }
.d-medium { color: #f0cf86; background: rgba(217,183,95,.14); border-color: rgba(217,183,95,.4); }
.d-hard   { color: #f0a293; background: rgba(224,96,79,.14); border-color: rgba(224,96,79,.4); }
.d-extreme { color: #d3b0f2; background: rgba(176,127,224,.16); border-color: rgba(176,127,224,.45); }

/* ---------------- Scenario head ---------------- */
.scenario-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scenario-head .meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.scenario-head .counter { color: var(--muted); font-size: clamp(11px,2.6vw,13px); }
.emblem-sm { width: clamp(26px,7vw,32px); height: clamp(26px,7vw,32px); object-fit: contain; filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); flex-shrink: 0; }
.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 10px 0 14px; border: 1px solid var(--line); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); transition: width .3s; }

/* ---------------- Prompt banner ---------------- */
.prompt-banner { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; padding: clamp(10px,2.2vw,13px) clamp(12px,2.6vw,16px); margin-bottom: var(--gap); }
.pb-title { font-size: clamp(16px,4.4vw,18px); font-weight: 700; color: var(--gold); }
.pb-prompt { margin-top: 4px; font-size: clamp(14px,3.3vw,15px); line-height: 1.5; }
.pb-story { margin-top: 6px; font-size: clamp(11.5px,2.8vw,12.5px); color: var(--muted); }

/* Extreme: live step instruction + sequence HUD */
.step-live { margin-top: 10px; padding: 9px 12px; border-radius: 9px; background: rgba(176,127,224,.1); border: 1px solid rgba(176,127,224,.32); display: flex; align-items: center; gap: 10px; font-size: clamp(13px,3.2vw,14.5px); }
.step-live.flash-bad { animation: stepBad .5s ease; }
.step-chip { flex-shrink: 0; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #20170a; background: linear-gradient(180deg,#e0c0f5,#c79ae8); border-radius: 999px; padding: 3px 9px; }
.step-text { line-height: 1.4; }
@keyframes stepBad { 0%,100% { background: rgba(176,127,224,.1); transform: translateX(0); } 25% { background: rgba(224,96,79,.22); transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.step-bar .reveal-moves { background: none; border: none; color: var(--gold-soft); cursor: pointer; font: inherit; font-size: inherit; text-decoration: underline; padding: 0; }
.step-bar .step-moves { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.stars { color: var(--gold); letter-spacing: 2px; }

/* ---------------- Table ---------------- */
.table {
  border: 1px solid var(--line);
  border-radius: clamp(12px,2vw,18px);
  padding: clamp(10px,1.8vw,14px) clamp(10px,1.8vw,14px) clamp(8px,1.4vw,10px);
  background:
    var(--felt-tint, linear-gradient(rgba(10,17,13,.48), rgba(8,13,10,.66))),
    url("assets/felt.jpg") center / cover no-repeat;
  box-shadow: inset 0 0 70px rgba(0,0,0,.5), var(--shadow);
}
.opp-row { display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: center; align-items: flex-start; }

/* seats */
.seat { position: relative; flex: 1 1 clamp(98px, 22%, 190px); max-width: 320px; min-width: 0; background: rgba(12,19,15,.5); border: 1px solid var(--line); border-radius: 11px; padding: clamp(7px,1.4vw,10px); transition: filter .3s, opacity .3s; }
.seat.you { flex: 0 0 auto; min-width: clamp(150px,42%,250px); max-width: 360px; margin: var(--gap) auto 2px; }
.avatar { display: flex; flex-direction: column; gap: 4px; }
.seat-name { font-size: clamp(12px,2.8vw,13px); font-weight: 700; }
.seat-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.life { font-size: clamp(14px,3.4vw,15px); font-weight: 800; color: #ff9aa2; display: inline-flex; align-items: center; gap: 3px; }
.life .heart { font-size: 12px; }
.life-num { transition: color .15s; display: inline-block; min-width: 1.3em; text-align: right; }
.life-num.life-down { color: var(--red); }
.life-num.life-up { color: var(--green); }
.cmd-badge { font-size: 11px; font-weight: 700; color: var(--gold); background: rgba(217,183,95,.12); border: 1px solid rgba(217,183,95,.35); border-radius: 999px; padding: 2px 8px; }
.cmd-badge.lethal { color: #fff; background: var(--red); border-color: var(--red); animation: pulseRed 1s infinite; }
.seat-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }

.zone { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.seat-board { justify-content: center; margin-top: 7px; }
.seat-board:empty { display: none; }
.your-board { justify-content: center; align-items: center; min-height: calc(var(--card-h) * .82); margin: var(--gap) 0; padding: 8px; border-radius: 12px; border: 1px dashed transparent; transition: border-color .2s, background .2s; }
.zone-empty { color: var(--muted); font-size: clamp(11px,2.6vw,13px); font-style: italic; opacity: .7; padding: 12px 0; width: 100%; text-align: center; }

/* permanents */
.perm { position: relative; width: var(--card-w); height: var(--card-h); flex: 0 0 auto; border-radius: 6px; transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .15s; transform-origin: center; }
.perm img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid #000; box-shadow: 0 3px 8px rgba(0,0,0,.5); display: block; background: #0a0d0b; }
.perm.placeholder .ph, .hand-card.placeholder .ph { width: 100%; height: 100%; border-radius: 6px; border: 1px solid #000; display: flex; align-items: flex-end; justify-content: center; font-size: 9px; font-weight: 700; color: #f3e6c4; padding: 7px 5px; text-align: center; background: #0a0d0b url("assets/cardback.jpg") center / cover no-repeat; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.perm.tapped { transform: rotate(90deg); }
.perm.attacking { box-shadow: 0 0 0 2px var(--red), 0 0 14px rgba(224,96,79,.5); animation: bobAttack 1.4s ease-in-out infinite; }
.perm.targeted { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(217,183,95,.55); }
.perm.onstack { box-shadow: 0 0 0 2px var(--blue), 0 0 14px rgba(90,169,230,.5); animation: floatStack 1.6s ease-in-out infinite; }
.perm-note { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 9px; color: var(--gold-soft); pointer-events: none; }
.token-copy { box-shadow: 0 0 0 1px var(--green); }

/* interactivity cues */
.draggable { cursor: grab; touch-action: none; }
.draggable:hover { box-shadow: 0 0 0 2px var(--gold-soft), 0 6px 16px rgba(0,0,0,.6); }
.clickable { cursor: pointer; }
.drop-active { outline: 2px dashed var(--gold-soft); outline-offset: 3px; }
.your-board.drop-active { border-color: var(--gold); background: rgba(217,183,95,.08); }
.seat.drop-active { outline: 2px dashed var(--red); }
.drop-hot { outline-style: solid !important; outline-color: var(--gold) !important; box-shadow: 0 0 18px rgba(217,183,95,.5); }
.seat.drop-hot { outline-color: var(--red) !important; box-shadow: 0 0 18px rgba(224,96,79,.5); }
.drag-clone { border-radius: 8px; box-shadow: 0 16px 36px rgba(0,0,0,.7); opacity: .96; }
.drag-clone .perm-note { display: none; }

/* ---------------- Hand (fanned) ---------------- */
.hand { display: flex; justify-content: center; align-items: flex-end; min-height: calc(var(--hand-h) + 30px); margin-top: var(--gap); padding: 0 clamp(8px,4vw,30px) 4px; }
.hand.empty { min-height: 0; margin: 0; }
.hand-card {
  position: relative; width: var(--hand-w); height: var(--hand-h);
  margin: 0 calc(var(--hand-w) * -0.2); border-radius: 8px;
  transform-origin: bottom center;
  transform: translateY(var(--ty, 0px)) rotate(var(--r, 0deg));
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
  cursor: grab; touch-action: none; user-select: none;
}
.hand-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid #000; box-shadow: 0 6px 14px rgba(0,0,0,.55); display: block; background: #0a0d0b; }
.hand-card:hover { transform: translateY(calc(var(--hand-h) * -0.32)) rotate(0deg) scale(1.12); z-index: 60; box-shadow: 0 18px 34px rgba(0,0,0,.6); }
.hand-card .perm-note { bottom: 5px; background: rgba(0,0,0,.7); padding: 1px 6px; border-radius: 6px; }

/* ---------------- Action bar ---------------- */
.action-bar { margin-top: clamp(12px,3vw,20px); }
.action-bar .hint { color: var(--muted); font-size: clamp(11.5px,2.8vw,12.5px); margin-bottom: 8px; }
.action-bar .hint.flash { animation: hintFlash .6s ease; }
.play-btns { display: flex; flex-direction: column; gap: 9px; }
.play-btn { font: inherit; font-size: clamp(13.5px,3.2vw,14.5px); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: clamp(11px,2.6vw,13px) clamp(13px,3vw,15px); color: var(--text); cursor: pointer; transition: border-color .12s, transform .1s, background .12s; }
.play-btn:hover:not(:disabled) { border-color: var(--gold-soft); transform: translateX(2px); }
.play-btn:disabled { cursor: default; opacity: .85; }
.play-btn.chosen-right { border-color: var(--green); background: var(--green-bg); }
.play-btn.chosen-wrong { border-color: var(--red); background: var(--red-bg); }

/* ---------------- Explanation ---------------- */
.explain { margin-top: var(--gap); border-radius: 12px; padding: clamp(13px,3vw,18px); border: 1px solid var(--line); background: var(--panel); animation: fade .25s ease; }
.explain.good { border-left: 4px solid var(--green); }
.explain.bad  { border-left: 4px solid var(--red); }
.explain .verdict { font-weight: 700; margin: 0 0 8px; font-size: 15px; }
.explain.good .verdict { color: var(--green); }
.explain.bad .verdict { color: var(--red); }
.explain .feedback { margin: 0 0 8px; color: var(--gold-soft); font-size: 14px; }
.explain p { margin: 0; line-height: 1.6; opacity: .95; }
.nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 12px; flex-wrap: wrap; }

/* ---------------- Results ---------------- */
.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px,5vw,32px); text-align: center; box-shadow: var(--shadow); }
.result-card h2 { margin: 0 0 6px; font-size: clamp(22px,5.5vw,26px); }
.score-big { font-size: clamp(44px,12vw,56px); font-weight: 800; color: var(--gold); margin: 10px 0; }
.score-sub { color: var(--muted); margin-bottom: 18px; }
.breakdown { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 26px; }
.bd-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 18px; min-width: 96px; }
.bd-item .v { font-size: 22px; font-weight: 700; }
.bd-item .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

/* ---------------- Defeated seat ---------------- */
.seat.defeated { filter: grayscale(1) brightness(.55); opacity: .7; }
.seat.defeated::after { content: "ELIMINISAN"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(12px,3vw,14px); font-weight: 800; letter-spacing: .1em; color: var(--red); transform: rotate(-12deg); text-shadow: 0 2px 6px #000; border: 2px solid var(--red); border-radius: 11px; background: rgba(224,96,79,.08); }

/* ---------------- Decorative deck pile ---------------- */
.deck-pile {
  position: fixed; left: clamp(14px,2vw,24px); bottom: clamp(20px,4vh,32px);
  width: 78px; height: 109px; border-radius: 7px;
  background: #0a0d0b url("assets/cardback.jpg") center / cover no-repeat;
  box-shadow: 0 0 0 1px #000, 4px 4px 0 -1px #15110a, 8px 8px 0 -2px #15110a, 11px 11px 0 -3px #15110a, 0 12px 22px rgba(0,0,0,.6);
  opacity: 0; transform: translateY(22px) rotate(-3deg); transition: opacity .45s, transform .45s; pointer-events: none; z-index: 18;
}
.deck-pile::after { content: "ŠPIL"; position: absolute; bottom: -19px; left: 0; right: 0; text-align: center; font-size: 10px; letter-spacing: .14em; color: var(--gold-soft); text-shadow: 0 1px 3px #000; }
body.playing .deck-pile { opacity: .95; transform: none; }
@media (max-width: 1080px) { .deck-pile { display: none; } }

/* ---------------- Floating FX ---------------- */
.float-text { position: fixed; z-index: 120; font-weight: 800; font-size: clamp(15px,4vw,17px); letter-spacing: .03em; pointer-events: none; text-shadow: 0 2px 10px rgba(0,0,0,.8); white-space: nowrap; }
.float-text.big { font-size: clamp(22px,6vw,30px); }
.mana-pip { position: fixed; z-index: 115; font-weight: 800; font-size: 16px; color: #f3e6c4; background: #4a3a16; border: 1px solid var(--gold); border-radius: 999px; padding: 2px 8px; pointer-events: none; box-shadow: 0 0 10px rgba(217,183,95,.6); }
.spark { position: fixed; z-index: 118; color: var(--gold); font-size: 22px; pointer-events: none; }

/* ---------------- Card preview (hover) ---------------- */
.card-preview { position: fixed; z-index: 130; width: 250px; pointer-events: none; opacity: 0; transform: scale(.96); transition: opacity .1s, transform .1s; background: var(--panel); border: 1px solid var(--gold-soft); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.card-preview.show { opacity: 1; transform: scale(1); }
.card-preview img { width: 100%; border-radius: 8px; display: block; }
.card-preview .pv-text { padding: 8px 6px 4px; }
.card-preview .pv-name { font-weight: 700; font-size: 13px; }
.card-preview .pv-type { font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }
.card-preview .pv-oracle { font-size: 11.5px; line-height: 1.4; opacity: .9; white-space: pre-wrap; }

/* ---------------- Loading ---------------- */
.loading-overlay { position: fixed; inset: 0; background: linear-gradient(rgba(8,11,9,.88), rgba(8,11,9,.95)), url("assets/backdrop.jpg") center / cover no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 200; transition: opacity .3s; }
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 46px; height: 46px; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
#loading-text { color: var(--muted); font-size: 14px; }

/* ---------------- Theme per difficulty ---------------- */
body.theme-medium { --felt-tint: linear-gradient(rgba(30,21,6,.5), rgba(22,15,5,.66)); }
body.theme-hard   { --felt-tint: linear-gradient(rgba(32,9,8,.52), rgba(22,7,6,.68)); }
body.theme-medium .progress > div { background: linear-gradient(90deg, var(--gold-soft), #f0cf86); }
body.theme-hard   .progress > div { background: linear-gradient(90deg, #7a241b, var(--red)); }
body.theme-hard   .prompt-banner { border-left-color: var(--red); }
body.theme-hard   .pb-title { color: #f0a293; }
body.theme-extreme { --felt-tint: linear-gradient(rgba(26,12,38,.55), rgba(16,8,26,.7)); }
body.theme-extreme .progress > div { background: linear-gradient(90deg, #6a3fa0, var(--violet)); }
body.theme-extreme .prompt-banner { border-left-color: var(--violet); }
body.theme-extreme .pb-title { color: #d3b0f2; }

/* ---------------- Keyframes ---------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulseRed { 0%,100% { box-shadow: 0 0 0 0 rgba(224,96,79,.5); } 50% { box-shadow: 0 0 0 4px rgba(224,96,79,0); } }
@keyframes bobAttack { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes floatStack { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hintFlash { 0%,100% { color: var(--muted); } 30% { color: var(--gold); transform: translateX(3px); } }
.shake { animation: shakeAnim .4s ease; }
@keyframes shakeAnim { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-5px,2px); } 40% { transform: translate(5px,-2px); } 60% { transform: translate(-4px,1px); } 80% { transform: translate(4px,-1px); } }

/* ---------------- Gamification ---------------- */
.rank-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px 4px 9px; cursor: pointer; font: inherit; color: var(--text); transition: border-color .15s, transform .1s; }
.rank-chip:hover { border-color: var(--gold-soft); transform: translateY(-1px); }
.rk-icon { font-size: 14px; line-height: 1; }
.rk-lv { font-size: 12px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.rk-bar { width: clamp(32px,8vw,52px); height: 5px; background: #0c130f; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.rk-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.run-pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: clamp(11px,2.5vw,13px); white-space: nowrap; }
.run-pill b { color: var(--gold); }
.rp-streak { color: var(--red); font-weight: 700; }

.rank-banner { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 560px; margin: 14px auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; color: var(--text); font: inherit; text-align: left; transition: border-color .15s, transform .12s, box-shadow .15s; }
.rank-banner:hover { border-color: var(--gold-soft); transform: translateY(-2px); box-shadow: var(--shadow); }
.rb-icon { font-size: 26px; line-height: 1; }
.rb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rb-name { font-weight: 700; font-size: 14px; }
.rb-bar { height: 7px; background: #0c130f; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.rb-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.rb-stats { font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 520px) { .rb-stats { display: none; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 160; background: rgba(6,9,7,.72); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: clamp(12px,4vw,40px) 12px; overflow-y: auto; opacity: 0; transition: opacity .2s; }
.modal-overlay.show { opacity: 1; }
.modal { position: relative; width: 100%; max-width: 620px; background: linear-gradient(180deg, #16201b, #111a15); border: 1px solid var(--line); border-radius: 16px; padding: clamp(18px,4vw,28px); box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 15px; }
.modal-x:hover { border-color: var(--gold-soft); }
.prof-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.prof-rank-icon { font-size: clamp(40px,10vw,56px); line-height: 1; filter: drop-shadow(0 3px 8px rgba(0,0,0,.5)); }
.prof-rank-info { flex: 1; min-width: 0; }
.prof-lv { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.prof-rank-name { font-size: clamp(20px,5vw,26px); font-weight: 800; color: var(--gold); margin: 2px 0 8px; }
.prof-xpbar { height: 10px; background: #0c130f; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.prof-xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); transition: width .6s; }
.prof-xp { font-size: 12px; color: var(--muted); margin-top: 6px; }
.prof-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 18px; }
.prof-stats .ps { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 6px; text-align: center; }
.ps-v { font-size: clamp(18px,5vw,24px); font-weight: 800; }
.ps-l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 3px; }
.prof-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-soft); margin: 6px 0 10px; }
.prof-diff { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.pd-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pd-name { width: 60px; color: var(--muted); flex-shrink: 0; }
.pd-bar { flex: 1; height: 8px; background: #0c130f; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.pd-bar i { display: block; height: 100%; }
.pd-val { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.prof-ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px,1fr)); gap: 8px; }
.ach { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 12.5px; }
.ach.locked { opacity: .45; filter: grayscale(.6); }
.ach.earned { border-color: var(--gold-soft); }
.ach-ic { font-size: 18px; line-height: 1; }
.ach-nm { font-weight: 600; line-height: 1.15; }
.prof-foot { margin-top: 18px; text-align: center; }
@media (max-width: 480px) { .prof-stats { grid-template-columns: repeat(2,1fr); } }

/* Toasts */
#toasts { position: fixed; top: 64px; right: 14px; z-index: 170; display: flex; flex-direction: column; gap: 10px; max-width: min(92vw,340px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; background: linear-gradient(180deg, #1d2a23, #141d18); border: 1px solid var(--gold-soft); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); transform: translateX(120%); opacity: 0; transition: transform .35s cubic-bezier(.2,.9,.2,1), opacity .35s; }
.toast.show { transform: none; opacity: 1; }
.toast .t-icon { font-size: 24px; line-height: 1; }
.toast .t-title { font-weight: 800; font-size: 14px; }
.toast .t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toast.levelup { border-color: var(--gold); }
.toast.ach { border-color: var(--green); }
.toast.break { border-color: var(--red); }

/* Results extras */
.res-xp { font-size: 15px; font-weight: 700; color: var(--gold); margin-top: 6px; }
.res-bar { max-width: 320px; margin: 10px auto 0; }
.res-ach { margin-top: 16px; }
.res-ach-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.res-ach-list .ach { flex: 0 0 auto; }

/* ---------------- Responsive niceties ---------------- */
@media (max-width: 560px) {
  .tagline { display: none; }
  .scenario-head .counter { display: none; }
}
@media (max-width: 720px) {
  .card-preview { display: none; }       /* touch: no hover preview, drag still works */
}
@media (pointer: coarse) {
  .card-preview { display: none; }
}
