/*
 * Design system for the mobile edition: tokens, base and shared components.
 *
 * Direction: restrained "Korean premium" game UI. Near-black charcoal surfaces, hairline borders,
 * small radii with chamfered corners, champagne gold as the premium accent, crimson only for the
 * primary action. English eyebrow labels and numbers use a condensed display face (Barlow Semi
 * Condensed, bundled); body text uses the system UI font (all six languages). Touch targets stay
 * 44 px or larger, numbers are tabular, colours keep their meaning (stars, gold, HP, shield, armor,
 * seven skill categories, eight item rarity tiers).
 */

@font-face {
  font-family: 'US3 Display';
  src: url('../fonts/bsc-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'US3 Display';
  src: url('../fonts/bsc-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'US3 Display';
  src: url('../fonts/bsc-700.woff2') format('woff2');
  font-weight: 700 900;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* surfaces */
  --bg-0: #07080b;
  --bg-1: #0d0f13;
  --bg-2: #13151a;
  --bg-3: #1a1d23;
  --bg-4: #23262e;
  --glass: rgba(11, 12, 16, 0.84);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --line-3: rgba(255, 255, 255, 0.22);

  /* text (warm ivory on cool charcoal) */
  --tx-1: #f1ede6;
  --tx-2: #a6a8af;
  --tx-3: #6a6d77;
  --tx-inv: #0b0c0f;

  /* accents: crimson = primary action, champagne = premium / highlight */
  --brand: #d92f3c;
  --brand-2: #ee4f5a;
  --brand-ink: #fff;
  --brand-soft: rgba(217, 47, 60, 0.12);
  --acc: #cfae76;
  --acc-2: #ead1a2;
  --acc-ink: #1c1509;
  --acc-soft: rgba(207, 174, 118, 0.1);
  --acc-line: rgba(207, 174, 118, 0.36);

  /* semantic */
  --star: #f0cc7a;
  --gold: #dfa54c;
  --hp: #e5484d;
  --hp-2: #f0805a;
  --shield: #58b3e6;
  --shield-2: #8f96ee;
  --armor: #b7bdc9;
  --ok: #3fcb98;
  --warn: #e6b54e;
  --bad: #ef5d62;
  --info: #6ca7ee;

  /* skill categories */
  --c-defense: #4cc897;
  --c-attack: #ee6170;
  --c-magic: #58b4ea;
  --c-utility: #a18cf0;
  --c-special: #e7bd57;
  --c-holy: #efdc9c;
  --c-evil: #d478e6;

  /* item rarities (legacy names, see screens.css .rt0-.rt7 for the tiers) */
  --r-0: #9aa1ae;
  --r-1: #4fd08c;
  --r-2: #3fc8de;
  --r-3: #a083f0;
  --r-4: #e3b94e;
  --r-5: #ef5f73;
  --r-6: #f3a6f0;

  --radius-s: 3px;
  --radius-m: 4px;
  --radius-l: 6px;
  --radius-xl: 10px;
  --cut: 9px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, 0.6);
  --hi: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
    "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  --font-d: "US3 Display", var(--font);

  /* safe-area insets in the app's own orientation (set by view.js) */
  --sat: 0px;
  --sar: 0px;
  --sab: 0px;
  --sal: 0px;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--tx-1);
  font: 500 15px/1.4 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 1px solid var(--acc);
  outline-offset: 2px;
}

.num {
  font-family: var(--font-d);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

[hidden] {
  display: none !important;
}

/* English eyebrow label (decorative, never translated): "STORE", "HERO", ... */
.eb {
  display: block;
  font: 600 10.5px/1.2 var(--font-d);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--acc);
  white-space: nowrap;
}

/* Diamond bullet used as a separator / marker. */
.dia {
  display: inline-block;
  width: 5px;
  height: 5px;
  flex: none;
  transform: rotate(45deg);
  background: currentColor;
}

/* ---------------------------------------------------------------- icons */

.ic {
  width: 20px;
  height: 20px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.ic.s { width: 16px; height: 16px; }
.ic.l { width: 24px; height: 24px; }
.ic.xl { width: 32px; height: 32px; }

.star-c { color: var(--star); }
.gold-c { color: var(--gold); }
.hp-c { color: var(--hp); }
.sh-c { color: var(--shield); }
.ar-c { color: var(--armor); }

/* ---------------------------------------------------------------- chamfered corners
 * Cards cut their top-right corner, buttons cut top-left + bottom-right. The diagonal hairline
 * that the clip removes from the border is redrawn by a corner gradient (--bd = border colour). */

.card {
  --corner: linear-gradient(to bottom left, transparent calc(50% - 0.5px), var(--bd) calc(50% - 0.5px), var(--bd) calc(50% + 0.7px), transparent calc(50% + 0.7px)) top right / var(--cut) var(--cut) no-repeat;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}

.btn {
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--bd) calc(50% - 0.5px), var(--bd) calc(50% + 0.7px), transparent calc(50% + 0.7px)) top left / var(--cut) var(--cut) no-repeat,
    linear-gradient(to bottom right, transparent calc(50% - 0.7px), var(--bd) calc(50% - 0.7px), var(--bd) calc(50% + 0.5px), transparent calc(50% + 0.5px)) bottom right / var(--cut) var(--cut) no-repeat;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  --bd: var(--line-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 0;
  border: 1px solid var(--bd);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 60%), var(--bg-3);
  color: var(--tx-1);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s, opacity 0.15s, filter 0.15s;
}

.btn:active,
.btn.pressed {
  transform: scale(0.97);
  filter: brightness(1.15);
}

.btn.primary {
  --bd: transparent;
  border-color: transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 52%),
    linear-gradient(90deg, #c4202f, var(--brand) 45%, #e3434d);
  color: var(--brand-ink);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.btn.gold {
  --bd: transparent;
  border-color: transparent;
  background: linear-gradient(180deg, var(--acc-2), var(--acc));
  color: var(--acc-ink);
  font-weight: 700;
}

.btn.ghost {
  --bd: transparent;
  background: transparent;
  border-color: transparent;
  color: var(--tx-2);
}

.btn.danger {
  color: var(--bad);
}

.btn.block {
  width: 100%;
}

.btn[disabled],
.btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn.primary.disabled,
.btn.primary[disabled],
.btn.gold.disabled {
  --bd: var(--line-2);
  opacity: 1;
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--tx-3);
  text-shadow: none;
}

.ibtn {
  position: relative;
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-2);
  background: rgba(13, 15, 19, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--tx-1);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s;
}

.ibtn .ic {
  width: 21px;
  height: 21px;
}

.ibtn:active,
.ibtn.pressed {
  transform: scale(0.92);
  background: var(--bg-4);
  border-color: var(--acc-line);
}

.ibtn.sm {
  width: 40px;
  height: 40px;
}

.ibtn.sm .ic {
  width: 19px;
  height: 19px;
}

.ibtn.hot {
  background: var(--brand);
  border-color: var(--brand-2);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(217, 47, 60, 0.2);
  animation: breathe 1.4s ease-in-out infinite;
}

.ibtn.off {
  opacity: 0.38;
}

@keyframes breathe {
  50% { box-shadow: 0 0 0 9px rgba(217, 47, 60, 0.04); }
}

/* ---------------------------------------------------------------- chips, tabs, segmented */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px 0 10px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-2);
  background: rgba(7, 8, 11, 0.55);
  color: var(--tx-1);
  font-weight: 650;
  font-size: 14px;
  white-space: nowrap;
}

.chip .num {
  font-size: 16px;
  font-weight: 600;
}

.chip .ic {
  width: 16px;
  height: 16px;
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

/* Underline tabs: text + icon, the active one gets its colour and a 2 px bar. */
.tab {
  --tab: var(--acc);
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--tx-3);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.tab::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: var(--tab);
  transform: scaleX(0);
  transition: transform 0.2s var(--ease);
}

.tab .ic {
  width: 16px;
  height: 16px;
  color: var(--tab);
  opacity: 0.6;
}

.tab .n {
  font-family: var(--font-d);
  font-variant-numeric: tabular-nums;
  color: var(--tx-3);
  font-weight: 600;
  font-size: 14px;
}

.tab.on {
  color: var(--tx-1);
  background: linear-gradient(to top, color-mix(in srgb, var(--tab) 12%, transparent), transparent 80%);
}

.tab.on::after {
  transform: scaleX(1);
}

.tab.on .ic {
  opacity: 1;
}

.tab.on .n {
  color: var(--tab);
}

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-m);
  background: rgba(7, 8, 11, 0.6);
  border: 1px solid var(--line-2);
}

.seg.v {
  flex-direction: column;
}

.seg button {
  min-width: 44px;
  min-height: 38px;
  padding: 0 8px;
  border: none;
  border-radius: var(--radius-s);
  background: none;
  color: var(--tx-3);
  font-family: var(--font-d);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}

.seg button.on {
  background: var(--tx-1);
  color: var(--tx-inv);
}

/* ---------------------------------------------------------------- cards, bars, stats */

.card {
  --bd: var(--line);
  border-radius: 0;
  background: var(--corner), linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0) 45%), var(--bg-2);
  border: 1px solid var(--bd);
}

.bar {
  position: relative;
  height: 6px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--v, 0) * 100%);
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, var(--c1, var(--brand)), var(--c2, var(--brand-2)));
  transition: width 0.25s var(--ease);
}

/* Ten-segment ticks over the big stat bars. */
.bar.seg10::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(7, 8, 11, 0.7) calc(10% - 1px) 10%);
  pointer-events: none;
}

.bar.hp { --c1: #c8323b; --c2: var(--hp-2); }
.bar.sh { --c1: var(--shield); --c2: var(--shield-2); }

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--tx-2);
}

.kv b {
  color: var(--tx-1);
  font-weight: 600;
  font-family: var(--font-d);
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-4);
  color: var(--tx-2);
  white-space: nowrap;
}

.caption {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tx-3);
}

/* ---------------------------------------------------------------- toggles / choices (settings) */

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.toggle .txt {
  font-weight: 600;
}

.toggle .txt small {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tx-3);
}

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  position: relative;
  transition: background 0.18s, border-color 0.18s;
}

.toggle input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tx-3);
  transition: transform 0.18s var(--ease), background 0.18s;
}

.toggle input:checked {
  background: var(--acc-soft);
  border-color: var(--acc);
}

.toggle input:checked::after {
  transform: translateX(20px);
  background: var(--acc-2);
}

.choice {
  display: flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-m);
  background: rgba(7, 8, 11, 0.6);
  border: 1px solid var(--line-2);
}

.choice button {
  flex: 1;
  min-height: 42px;
  border: none;
  border-radius: var(--radius-s);
  background: none;
  color: var(--tx-3);
  font-size: 14px;
  font-weight: 650;
}

.choice button.on {
  background: var(--bg-4);
  color: var(--tx-1);
  box-shadow: inset 0 -2px 0 var(--acc);
}

select.field {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--tx-1);
  font: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
