/* Deck'em Down — base styles & design tokens. ART DIRECTION: docs/ART_DIRECTION.md (binding for all UI work). */
@font-face { font-family: 'Cinzel'; src: url('../assets/fonts/Cinzel.ttf') format('truetype'); font-weight: 400 900; font-display: block; }
@font-face { font-family: 'Cinzel Decorative'; src: url('../assets/fonts/CinzelDecorative-Bold.ttf') format('truetype'); font-weight: 700; font-display: block; }
@font-face { font-family: 'Cinzel Decorative'; src: url('../assets/fonts/CinzelDecorative-Black.ttf') format('truetype'); font-weight: 900; font-display: block; }
@font-face { font-family: 'Alegreya Sans'; src: url('../assets/fonts/AlegreyaSans-Regular.ttf') format('truetype'); font-weight: 400; font-display: block; }
@font-face { font-family: 'Alegreya Sans'; src: url('../assets/fonts/AlegreyaSans-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: 'Alegreya Sans'; src: url('../assets/fonts/AlegreyaSans-Bold.ttf') format('truetype'); font-weight: 700; font-display: block; }
@font-face { font-family: 'Alegreya Sans'; src: url('../assets/fonts/AlegreyaSans-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: block; }
@font-face { font-family: 'Oswald'; src: url('../assets/fonts/Oswald.ttf') format('truetype'); font-weight: 200 700; font-display: block; }
@font-face { font-family: 'Cormorant'; src: url('../assets/fonts/CormorantGaramond-Italic.ttf') format('truetype'); font-weight: 300 700; font-style: italic; font-display: block; }

:root {
  /* surfaces */
  --ink: #09060d;
  --bg-0: #0d0812;
  --bg-1: #160c1d;
  --bg-2: #211129;
  --bg-3: #2e1838;
  --panel: rgba(22, 11, 29, 0.92);
  --panel-2: rgba(40, 18, 46, 0.9);
  --line: rgba(232, 193, 112, 0.28);
  --line-strong: rgba(232, 193, 112, 0.6);
  /* accents */
  --rose: #ff4f8b;      /* Pleasure / Arousal */
  --rose-deep: #b3164f;
  --magenta: #ff2d95;
  --wine: #5a0f2e;
  --crimson: #c8233f;
  --gold: #e8c170;
  --gold-hi: #fff1c4;
  --gold-deep: #9c7330;
  --violet: #8a4dff;
  --teal: #29d3b0;
  --composure: #66c2ff; /* Block */
  --passion: #ff7a3d;   /* Energy */
  --buff: #7dffb0;
  --debuff: #ff6b6b;
  /* text */
  --text: #f5e9f1;
  --text-dim: #bfa9bc;
  --text-faint: #7f6a80;
  /* type */
  /* The display fonts are Latin-only: the system fallbacks after them carry Cyrillic, Greek, CJK, Thai, Arabic. */
  --f-intl: 'Segoe UI', 'Microsoft YaHei', 'Microsoft JhengHei', 'Yu Gothic UI', 'Malgun Gothic', 'Leelawadee UI', Tahoma;
  --f-display: 'Cinzel Decorative', 'Cinzel', Georgia, var(--f-intl), serif;
  --f-head: 'Cinzel', Georgia, var(--f-intl), serif;
  --f-body: 'Alegreya Sans', var(--f-intl), sans-serif;
  --f-num: 'Oswald', 'Arial Narrow', var(--f-intl), sans-serif;
  --f-flavor: 'Cormorant', Georgia, var(--f-intl), serif;
  /* motion */
  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --glow-rose: 0 0 18px rgba(255, 79, 139, .55);
  --glow-gold: 0 0 18px rgba(232, 193, 112, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; user-select: none; -webkit-user-select: none; }
body { font-family: var(--f-body); color: var(--text); -webkit-font-smoothing: antialiased; cursor: default; }
/* Arabic (the only RTL locale): the 1920x1080 layout stays as designed; each text block takes its direction from its
   own first letter, so punctuation and [bracketed] choices land on the right side of Arabic sentences. */
html.lang-rtl #stage :is(div, p, span, h1, h2, h3, h4, button, li, small, label, option) { unicode-bidi: plaintext; }
img { -webkit-user-drag: none; }
button { font-family: inherit; }

#viewport { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(ellipse at center, #1a0d20 0%, #000 75%); }
#stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; overflow: hidden; background: var(--bg-0); font-size: 22px; }
#screen-layer, #hud-layer, #modal-layer, #tip-layer { position: absolute; inset: 0; pointer-events: none; }
#screen-layer > .screen { position: absolute; inset: 0; pointer-events: auto; }
#hud-layer { z-index: 50; }
#modal-layer { z-index: 100; }
#tip-layer { z-index: 200; }
#curtain { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .26s ease; z-index: 300; }
#curtain.on { opacity: 1; pointer-events: auto; }
.fatal { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); padding: 30px; background: #300; border: 2px solid #f55; font-size: 22px; }

/* ---------- buttons ---------- */
.btn { position: relative; font-family: var(--f-head); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 22px; color: var(--gold-hi); padding: 14px 34px; border-radius: 6px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #3a1b3f 0%, #22102a 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.5); cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, filter .2s, background .2s; pointer-events: auto; }
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.18); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 0 22px rgba(255,79,139,.35), 0 8px 22px rgba(0,0,0,.55); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); }
.btn-primary { background: linear-gradient(180deg, #c42a5e 0%, #7a1038 100%); border-color: #ff8ab3; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.btn-gold { background: linear-gradient(180deg, #e8c170 0%, #9c7330 100%); border-color: var(--gold-hi); color: #2a1408; text-shadow: none; }
.btn-ghost { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.18); color: var(--text-dim); }
.btn-small { font-size: 16px; padding: 8px 18px; }
.btn-row { display: flex; gap: 18px; justify-content: center; margin-top: 26px; }
.chip { font-family: var(--f-head); font-size: 15px; letter-spacing: .06em; color: var(--text-dim); background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.14); border-radius: 30px; padding: 6px 16px; cursor: pointer; pointer-events: auto; }
.chip.on, .chip:hover { color: var(--gold-hi); border-color: var(--gold); background: rgba(232,193,112,.12); }
.chips { display: flex; gap: 8px; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.03); }
.ornate { position: relative; }
.ornate::before, .ornate::after { content: ''; position: absolute; width: 38px; height: 38px; border: 2px solid var(--gold); pointer-events: none; opacity: .7; }
.ornate::before { left: -6px; top: -6px; border-right: none; border-bottom: none; }
.ornate::after { right: -6px; bottom: -6px; border-left: none; border-top: none; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 700; letter-spacing: .06em; margin: 0; }
.flavor { font-family: var(--f-flavor); font-style: italic; color: var(--text-dim); }
.kw { color: var(--gold); font-weight: 700; }
.num { font-family: var(--f-num); font-weight: 600; }
.num-up { color: var(--buff); }
.num-down { color: var(--debuff); }
.num-upg { color: #9dff7a; }
.ico-energy { display: inline-block; width: .95em; height: .95em; vertical-align: -0.12em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe0a8, var(--passion) 45%, #a52a0a 100%); box-shadow: 0 0 6px rgba(255,122,61,.8); }
.ico-star { color: var(--gold); text-shadow: 0 0 6px rgba(232,193,112,.8); }
.empty-note { grid-column: 1 / -1; text-align: center; color: var(--text-faint); font-size: 26px; padding: 80px; font-family: var(--f-flavor); font-style: italic; }

/* ---------- modals ---------- */
.modal-back { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 2, 8, .78); backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s ease; pointer-events: auto; }
.modal-back.nodim { background: transparent; backdrop-filter: none; }
.modal-back.in { opacity: 1; }
.modal-back.out { opacity: 0; pointer-events: none; } /* a fading modal must not re-trigger tooltips (one stayed stuck) */
.modal { transform: translateY(14px) scale(.98); transition: transform .25s var(--ease-out); }
.modal-back.in .modal { transform: none; }
.confirm { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; padding: 40px 56px; min-width: 620px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.confirm h2 { font-size: 34px; color: var(--gold-hi); }
.confirm p { color: var(--text-dim); font-size: 22px; line-height: 1.4; }
.modal-potion .potion-menu { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 200px; box-shadow: 0 12px 30px rgba(0,0,0,.6); }
.pm-title { font-family: var(--f-head); color: var(--gold-hi); font-size: 18px; text-align: center; }

/* ---------- picker / deck view ---------- */
.picker { width: 1680px; height: 960px; display: flex; flex-direction: column; background: linear-gradient(180deg, rgba(30,14,38,.97), rgba(14,7,19,.97)); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 30px 90px rgba(0,0,0,.8); }
.picker-head { padding: 26px 40px 14px; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); }
.picker-head h2 { font-size: 34px; color: var(--gold-hi); flex: 1; }
.picker-head p { color: var(--text-dim); margin: 0; }
.picker-info { color: var(--text-dim); font-family: var(--f-num); font-size: 20px; }
.picker-scroll { flex: 1; overflow-y: auto; padding: 24px 40px; }
.picker-scroll::-webkit-scrollbar { width: 12px; }
.picker-scroll::-webkit-scrollbar-thumb { background: rgba(232,193,112,.35); border-radius: 6px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, 220px); gap: 26px 30px; justify-content: center; }
.picker-card { position: relative; cursor: pointer; transition: transform .18s var(--ease); border-radius: 14px; }
.picker-card:hover { transform: translateY(-6px) scale(1.04); }
.picker-card.static { cursor: default; }
.picker-card.sel { transform: translateY(-6px) scale(1.04); }
.picker-card.sel::after { content: ''; position: absolute; inset: -8px; border-radius: 18px; border: 3px solid var(--rose); box-shadow: var(--glow-rose); pointer-events: none; }
.picker-foot { padding: 18px 40px 26px; display: flex; justify-content: flex-end; gap: 18px; border-top: 1px solid var(--line); }

/* ---------- tooltip ---------- */
#tooltip { position: absolute; max-width: 380px; display: none; flex-direction: column; gap: 6px; pointer-events: none; }
#tooltip.on { display: flex; }
.tip-entry { background: linear-gradient(180deg, rgba(36,16,42,.98), rgba(18,8,23,.98)); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 14px; box-shadow: 0 10px 28px rgba(0,0,0,.65); font-size: 19px; line-height: 1.3; }
.tip-title { font-family: var(--f-head); font-weight: 700; color: var(--gold-hi); font-size: 18px; margin-bottom: 3px; letter-spacing: .03em; }
.tip-text { color: var(--text); }
.tip-tier { font-family: var(--f-body); font-size: 14px; color: var(--text-faint); margin-left: 6px; font-weight: 400; }

/* ---------- toast & banner ---------- */
.toast { position: absolute; left: 50%; top: 150px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line-strong); padding: 12px 28px; border-radius: 30px; font-family: var(--f-head); font-size: 20px; color: var(--gold-hi); box-shadow: 0 10px 30px rgba(0,0,0,.6); animation: toastIn .3s var(--ease-out); transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translate(-50%, -12px); }
.toast.gold { color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }
.banner { position: absolute; left: 0; right: 0; top: 400px; display: flex; justify-content: center; pointer-events: none; animation: bannerIn .45s var(--ease-out); transition: opacity .45s, transform .45s; }
.banner.out { opacity: 0; transform: scaleY(.6); }
.banner-inner { font-family: var(--f-display); font-weight: 900; font-size: 64px; letter-spacing: .08em; color: var(--gold-hi); padding: 18px 120px; background: linear-gradient(90deg, transparent, rgba(30,8,30,.85) 20%, rgba(30,8,30,.85) 80%, transparent); text-shadow: 0 0 20px rgba(255,79,139,.6), 0 3px 0 #3a0a1e; border-top: 1px solid rgba(232,193,112,.4); border-bottom: 1px solid rgba(232,193,112,.4); }
.banner.enemy .banner-inner { color: #ffb3c9; font-size: 48px; }
.banner.turn .banner-inner { font-size: 52px; }
.banner.victory .banner-inner { color: #ffd6e6; text-shadow: 0 0 30px rgba(255,45,149,.9), 0 3px 0 #4a0a26; font-size: 76px; }
.banner.defeat .banner-inner { color: #ff9aa8; }
.banner.boss .banner-inner { color: #ffcf6e; font-size: 60px; }
.banner.elite .banner-inner { color: #ffb0d0; font-size: 52px; }
@keyframes bannerIn { from { opacity: 0; transform: scaleY(.3); } }

/* ---------- top bar ---------- */
.topbar { position: absolute; left: 0; right: 0; top: 0; height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: linear-gradient(180deg, rgba(14,6,18,.97), rgba(24,10,30,.92)); border-bottom: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.55); z-index: 40; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold-deep), var(--gold), var(--gold-deep), transparent); opacity: .5; }
.tb-left, .tb-right, .tb-center { display: flex; align-items: center; gap: 18px; }
.tb-center { flex-direction: column; gap: 0; align-items: center; position: absolute; left: 50%; transform: translateX(-50%); }
.tb-act { font-family: var(--f-head); font-size: 18px; color: var(--gold); letter-spacing: .08em; }
.tb-floor { font-size: 16px; color: var(--text-dim); }
.tb-floor b { font-family: var(--f-num); color: var(--text); }
.tb-portrait { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); box-shadow: var(--glow-gold); }
.tb-portrait img { width: 100%; height: 100%; object-fit: cover; }
.tb-portrait-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-family: var(--f-head); font-weight: 900; font-size: 26px; color: #fff; }
.tb-name { font-family: var(--f-head); font-weight: 700; font-size: 20px; color: var(--text); line-height: 1; }
.tb-title { font-size: 14px; color: var(--text-dim); }
.tb-stat { display: flex; align-items: center; gap: 6px; font-family: var(--f-num); font-size: 26px; padding: 4px 12px; border-radius: 6px; background: rgba(0,0,0,.25); }
.tb-stat .ico { width: 30px; height: 30px; display: flex; }
.tb-stat .ico svg { width: 100%; height: 100%; }
.tb-stat small { font-size: 18px; color: var(--text-dim); }
.tb-hp { color: #ff8fb4; }
.tb-hp.danger { animation: dangerPulse 1.2s infinite; }
@keyframes dangerPulse { 50% { background: rgba(255,45,149,.3); } }
.tb-gold { color: var(--gold); }
.tb-gold.bump { animation: bump .4s var(--ease-out); }
@keyframes bump { 40% { transform: scale(1.25); } }
.tb-potions { display: flex; gap: 6px; margin-left: 8px; }
.potion-slot { width: 46px; height: 46px; border-radius: 50%; border: 1px dashed rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; cursor: default; }
.potion-slot.full { border: 1px solid rgba(232,193,112,.4); background: rgba(0,0,0,.3); cursor: pointer; }
.potion-slot.full:hover { box-shadow: var(--glow-gold); }
.potion-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; }
.potion-icon img, .potion-icon svg { width: 100%; height: 100%; object-fit: contain; }
.potion-ph { width: 22px; height: 30px; border-radius: 6px 6px 10px 10px; box-shadow: inset 0 -8px 0 rgba(0,0,0,.25); }
.tb-btn { display: flex; align-items: center; gap: 8px; font-family: var(--f-head); font-size: 17px; color: var(--text-dim); background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12); padding: 8px 14px; border-radius: 6px; cursor: pointer; pointer-events: auto; }
.tb-btn svg { width: 26px; height: 26px; }
.tb-btn b { font-family: var(--f-num); color: var(--gold-hi); }
.tb-btn:hover, .tb-btn.active { color: var(--gold-hi); border-color: var(--gold); background: rgba(232,193,112,.1); }
.sin-badge { display: flex; align-items: center; gap: 6px; font-family: var(--f-head); color: #ff6b8b; font-size: 17px; }
.sin-badge svg { width: 22px; height: 22px; }
.relic-bar { position: absolute; left: 18px; top: 76px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 1300px; z-index: 39; }
.relic-icon { position: relative; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: default; transition: transform .15s; }
.relic-icon:hover { transform: scale(1.12); }
.relic-icon img, .relic-icon svg { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.7)); }
.relic-icon.used { filter: grayscale(1) brightness(.6); }
.relic-icon.flash { animation: relicFlash .7s var(--ease-out); }
@keyframes relicFlash { 0% { transform: scale(1); filter: brightness(1); } 35% { transform: scale(1.45); filter: brightness(2) drop-shadow(0 0 10px #ffd27a); } 100% { transform: scale(1); } }
.relic-ph { width: 42px; height: 42px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1c4, #b8893a 60%, #4a300c); display: flex; align-items: center; justify-content: center; font-family: var(--f-head); font-weight: 900; color: #2a1408; }
.relic-counter { position: absolute; right: -2px; bottom: -2px; min-width: 22px; height: 22px; border-radius: 11px; background: #12060f; border: 1px solid var(--gold); font-family: var(--f-num); font-size: 15px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.art-missing { background: repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 10px, transparent 10px 20px); }

/* picker: make the selection unmistakable */
.picker-hint { color: var(--gold); font-size: 17px; margin: 0; font-family: var(--f-head); letter-spacing: .04em; }
.picker-card.sel { transform: translateY(-10px) scale(1.07); }
.picker-card.sel::after { inset: -10px; border-width: 4px; box-shadow: 0 0 30px rgba(255,79,139,.9); }
.picker-card.sel::before { content: '✔'; position: absolute; right: -6px; top: -12px; z-index: 6; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--rose); color: #fff; font-size: 22px; font-weight: 900; box-shadow: 0 4px 12px rgba(0,0,0,.5); }

/* upgrade preview in pickers: pure CSS hover, no DOM swapping */
.picker-card.has-up .pk-up { position: absolute; left: 0; top: 0; visibility: hidden; pointer-events: none; }
.picker-card.has-up:hover .pk-up { visibility: visible; }
.picker-card.has-up:hover .pk-base { visibility: hidden; }
