/* FlashLock — dark Deadlock-flavored theme */
@font-face {
  font-family: "Radiance";
  src: url("assets/radiance-regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Radiance";
  src: url("assets/radiance-semibold.otf") format("opentype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Radiance";
  src: url("assets/radiance-bold.otf") format("opentype");
  font-weight: 700 800;
  font-display: swap;
}

:root {
  --bg: #0b0e13;
  --bg-2: #11151d;
  --panel: #161b26;
  --panel-2: #1c2230;
  --border: #252d3d;
  --text: #e8ecf2;
  --muted: #8b96a8;
  --dim: #5b6577;
  --weapon: #f59e3c;
  --spirit: #a78bfa;
  --vitality: #34d399;
  --hit: #4ade80;
  --hit-bg: rgba(74, 222, 128, 0.12);
  --practice: #34d399;
  --standard: #fbbf24;
  --ranked: #f87171;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

button, select, input, textarea { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- shared ---------- */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; }
.btn.primary { background: linear-gradient(180deg, #2a3350, #1d2436); border-color: #3a4a6e; }
.btn.danger { color: #fca5a5; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid #4a5468;
  background: #3b4457; /* unselected: neutral gray */
  color: #c3cbd9;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  cursor: default;
}
.chip.tap { cursor: pointer; }
.chip.tap:active { transform: scale(0.96); }
.chip.on { background: var(--accent, var(--hit)); border-color: var(--accent, var(--hit)); color: #0b0e13; }
.chip.on::after { content: "✓"; margin-left: 2px; }

/* ---------- loading / error ---------- */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.logo { font-size: 52px; line-height: 1; filter: drop-shadow(0 0 18px rgba(167, 139, 250, 0.35)); }
.logo img { width: 58px; height: auto; display: block; margin: 0 auto; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--spirit); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-steps { font-size: 13px; color: var(--dim); min-height: 18px; }
.error-box { color: #fca5a5; font-size: 14px; max-width: 340px; }

/* ---------- setup screen ---------- */
.setup { overflow-y: auto; padding: 20px 18px calc(16px + env(safe-area-inset-bottom)); font-family: "Radiance", var(--font); }
.brand { text-align: center; margin-bottom: 18px; }
.brand h1 { margin: 6px 0 2px; font-size: 34px; letter-spacing: 2px; font-family: "Radiance", var(--font); font-weight: 800; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.banner {
  margin: 10px 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fcd34d;
}
.filter-group { margin: 18px 0; }
.filter-group h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); margin: 0 0 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row .chip.on[data-t="1"] { background: #d4d4d8; border-color: #d4d4d8; }
.chip-row .chip.on[data-t="2"] { background: #4ade80; border-color: #4ade80; }
.chip-row .chip.on[data-t="3"] { background: #60a5fa; border-color: #60a5fa; }
.chip-row .chip.on[data-t="4"] { background: #fbbf24; border-color: #fbbf24; }
.chip.on[data-ty="weapon"] { background: var(--weapon); border-color: var(--weapon); }
.chip.on[data-ty="spirit"] { background: var(--spirit); border-color: var(--spirit); }
.chip.on[data-ty="vitality"] { background: var(--vitality); border-color: var(--vitality); }
select.deck {
  appearance: none;
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}
.diff-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 10px;
  cursor: pointer;
}
.diff-card:active { transform: scale(0.99); }
.diff-card.on { border-color: var(--dc); box-shadow: 0 0 0 1px var(--dc); background: var(--panel-2); }
.diff-card .emoji { font-size: 22px; margin-top: 1px; }
.diff-card .name { font-weight: 700; font-size: 16px; }
.diff-card .tag { color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.4; }
.start-area { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.match-count { text-align: center; font-size: 13.5px; color: var(--muted); }
.match-count b { color: var(--text); }
.version { text-align: center; font-size: 11.5px; color: var(--dim); margin-top: 18px; }

/* ---------- session screen ---------- */
.session { padding: 12px 14px 0; gap: 10px; }
.session-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.session-head .quit { background: none; border: none; color: var(--muted); font-size: 18px; padding: 6px; cursor: pointer; }
.progress { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.progress .txt { font-size: 13px; color: var(--muted); }
.progress .txt b { color: var(--text); }
.progress .bar { height: 4px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--spirit); border-radius: 2px; transition: width 0.25s; }
.diff-tag { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.diff-tag.practice_range { color: var(--practice); border-color: var(--practice); }
.diff-tag.standard_match { color: var(--standard); border-color: var(--standard); }
.diff-tag.ranked { color: var(--ranked); border-color: var(--ranked); }

/* the card */
.card-zone { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 6px 0; perspective: 1400px; }
.card3d {
  position: relative;
  width: 100%;
  height: min(62dvh, 480px);
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.card3d.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  overflow-x: hidden;
}
.face.front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px;
  cursor: pointer;
}
.face.back { transform: rotateY(180deg); padding: 18px 18px 24px; }
.item-art {
  width: min(58%, 190px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, #232b3d, #12161f 75%);
  border: 1px solid var(--border);
}
.imgph {
  width: min(58%, 190px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, #232b3d, #12161f 75%);
  border: 1px solid var(--border);
  font-size: 44px;
  font-weight: 800;
  color: var(--muted);
}
.front-badges { display: flex; gap: 8px; align-items: center; }
.tier-pill { font-size: 12.5px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.type-pill { font-size: 12.5px; font-weight: 800; padding: 4px 10px; border-radius: 999px; color: #0b0e13; }
.type-pill.weapon { background: var(--weapon); }
.type-pill.spirit { background: var(--spirit); }
.type-pill.vitality { background: var(--vitality); }
.hint-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.hint-chips .chip { font-size: 12px; color: var(--muted); border-style: dashed; }
.tap-hint { font-size: 12px; color: var(--dim); }

/* card back */
.name-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 17px;
  font-weight: 800;
}
.name-chip .name-icon { width: 20px; height: 20px; }
.name-chip.tap { cursor: pointer; }
.name-chip.hit, .chip.hit, .section-head.hit { background: var(--hit-bg); border-color: var(--hit); color: var(--hit); box-shadow: 0 0 0 1px var(--hit); }
.name-chip.hit::after, .chip.hit::after, .section-head.hit::after { content: "✓"; margin-left: 2px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cost { font-size: 13px; color: var(--muted); white-space: nowrap; }
.cost::before { content: "◆ "; color: #9aa7bd; }
.section { margin-bottom: 16px; }
.section-head {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 8px;
}
.section-head.tap { cursor: pointer; }
.section-desc { font-size: 14px; line-height: 1.55; color: var(--text); margin: 0 0 10px; }
.section-desc span { color: var(--sc, var(--spirit)); font-weight: 700; }
.section-desc .diminish { color: var(--dim); }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center; }
.stat-row .chip { font-weight: 600; font-size: 13.5px; padding: 8px 12px; }
.stat-row .chip.value { color: var(--muted); font-variant-numeric: tabular-nums; }
.stat-row .chip.value.hit { color: var(--hit); }
.stat-row .chip.value.hit::after { content: "✓"; }
.stat-row .chip.type.hit::after { content: "✓"; }
.stat-icon { width: 18px; height: 18px; }

/* footer bar */
.footer-bar {
  display: flex;
  gap: 10px;
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
}
.footer-bar .btn { flex: 1; }
.footer-bar .btn.wide { flex: 1.4; }
.btn.ghost { background: none; }
.micro-version { text-align: center; font-size: 10.5px; color: var(--dim); padding: 2px 0 6px; }

/* ---------- results ---------- */
.results { overflow-y: auto; padding: 20px 18px calc(16px + env(safe-area-inset-bottom)); }
.score-big { text-align: center; padding: 18px 0 6px; }
.score-big .pct { font-size: 64px; font-weight: 900; line-height: 1; }
.score-big .pct small { font-size: 26px; color: var(--muted); }
.score-big .sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.row-list { margin: 18px 0; display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.row-item img, .row-item .imgph-mini {
  width: 40px; height: 40px; border-radius: 8px; object-fit: contain;
  background: var(--panel-2); border: 1px solid var(--border); flex: none;
}
.imgph-mini { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); font-size: 15px; }
.row-item .meta { flex: 1; min-width: 0; }
.row-item .name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .sub { font-size: 11.5px; color: var(--dim); }
.row-item .pct { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.row-item .pct.good { color: var(--hit); }
.row-item .pct.bad { color: var(--ranked); }
.row-item .pct.skip { color: var(--dim); }
.name-tick { font-size: 13px; margin-left: 6px; }
.name-tick.yes { color: var(--hit); }
.name-tick.no { color: var(--ranked); }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
