:root {
  color-scheme: dark;
  font-family: 'Malgun Gothic', 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: #0d1120;
  color: #f4f6ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 8% 14%, rgba(91, 80, 189, .16), transparent 30rem),
    radial-gradient(ellipse at 92% 78%, rgba(28, 153, 153, .10), transparent 28rem),
    #0d1120;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.hero {
  position: relative;
  min-height: 208px;
  padding: 30px 42px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(8, 12, 28, .74) 0%, rgba(8, 12, 28, .48) 48%, rgba(8, 12, 28, .12) 100%),
    url("assets/trailblaze-express-banner.webp") 54% 48% / cover no-repeat;
  box-shadow: 0 22px 54px rgba(0, 0, 0, .24);
}

.hero::after, .hero .orbit, .hero .hero-star { display: none; }

.hero-copy { position: relative; z-index: 2; }
.eyebrow { margin: 0 0 12px; color: rgba(246, 247, 255, .78); font-size: 10px; font-weight: 700; letter-spacing: .17em; }
.eyebrow-star { margin-right: 6px; color: #ffe4a4; font-size: 14px; }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 43px); font-weight: 800; line-height: 1.12; letter-spacing: -.055em; }
.hero h1 span { color: #c9f5ee; }
.hero-description { margin: 12px 0 0; color: rgba(245, 248, 255, .83); font-size: 13px; }
.orbit { position: absolute; z-index: 1; border: 1px solid rgba(255, 255, 255, .16); border-radius: 50%; transform: rotate(-25deg); }
.orbit-one { width: 380px; height: 230px; right: 38px; top: -10px; }
.orbit-two { width: 295px; height: 178px; right: 81px; top: 19px; border-color: rgba(255, 255, 255, .1); }
.hero::after { content: ''; position: absolute; right: 130px; top: 42px; width: 104px; height: 104px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 50%; box-shadow: inset 0 0 30px rgba(255, 255, 255, .08), 0 0 58px rgba(208, 255, 246, .16); }
.hero-star { position: absolute; z-index: 1; color: rgba(255, 255, 255, .8); }
.hero-star-one { top: 32px; right: 73px; font-size: 20px; }
.hero-star-two { top: 145px; right: 281px; font-size: 25px; color: #baf5e9; }
.hero-star-three { top: 53px; right: 326px; font-size: 13px; }

.control-panel {
  display: grid;
  grid-template-columns: 130px 175px minmax(220px, 1fr) 112px;
  gap: 22px;
  align-items: center;
  margin: 17px 0 12px;
  padding: 16px 20px;
  border: 1px solid rgba(171, 189, 232, .08);
  border-radius: 18px;
  background: #191f34;
  box-shadow: 0 13px 30px rgba(0, 0, 0, .14);
}

.control-group label { display: block; margin: 0 0 7px; color: #aeb9d2; font-size: 11px; }
.input-with-unit, .bonus-input-row { display: flex; align-items: center; gap: 8px; }
.input-with-unit input, .bonus-input-row input {
  height: 37px;
  border: 1px solid rgba(193, 207, 243, .12);
  border-radius: 9px;
  outline: none;
  background: #283149;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  transition: border-color .18s, box-shadow .18s;
}
.input-with-unit input { width: 78px; }
.bonus-input-row input { width: 65px; }
.input-with-unit input:focus, .bonus-input-row input:focus { border-color: #93a4ff; box-shadow: 0 0 0 3px rgba(130, 153, 255, .14); }
.input-with-unit span { color: #d6dcef; font-size: 12px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { opacity: .65; }

.button {
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, filter .15s, background .15s, opacity .15s;
}
.button:not(:disabled):hover { filter: brightness(1.12); transform: translateY(-1px); }
.button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.button:disabled { cursor: not-allowed; }
.button-add { width: 72px; height: 37px; background: #4a5b84; color: #fff; font-size: 11px; }
.button-add:disabled { opacity: .42; }
.button-reset { width: 112px; height: 42px; background: #39435e; color: #fff; font-size: 12px; }

.usage-area { min-width: 0; }
.usage-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: #f0f3ff; font-size: 11px; font-weight: 700; white-space: nowrap; }
#usageLabel.limit-reached { color: #ff9ca4; }
#remainingLabel { color: #bec8df; font-weight: 500; }
.progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: #303a53; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a680ff, #4fdacc); transition: width .25s ease; }

.party-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.role-card {
  min-width: 0;
  padding: 18px 19px 15px;
  border: 1px solid rgba(171, 189, 232, .08);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(26, 33, 55, .98), rgba(22, 28, 46, .98));
  box-shadow: 0 15px 34px rgba(0, 0, 0, .13);
  transition: border-color .2s, transform .2s;
}
.role-card:hover { border-color: color-mix(in srgb, var(--accent) 30%, transparent); transform: translateY(-1px); }
.card-heading { display: flex; align-items: center; gap: 11px; min-height: 34px; }
.role-number { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.card-heading h2 { margin: 0; color: #f8f9ff; font-size: 15px; font-weight: 700; letter-spacing: -.025em; }
.card-heading p { margin: 3px 0 0; color: #929eb9; font-size: 10px; }
.candidate-count { margin-left: auto; align-self: flex-start; padding-top: 4px; color: #9da9c5; font-size: 10px; white-space: nowrap; }
.card-divider { height: 1px; margin: 12px 0 14px; background: rgba(185, 199, 232, .1); }
.pick-area { display: grid; grid-template-columns: 66px minmax(0, 1fr) 108px; gap: 12px; align-items: center; min-height: 84px; }
.portrait-shell { position: relative; display: grid; width: 66px; height: 78px; place-items: center; overflow: hidden; border: 1px solid rgba(255, 255, 255, .11); border-radius: 12px; background: linear-gradient(145deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02)); }
.portrait { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.portrait[hidden] { display: none; }
.portrait-placeholder { color: var(--accent); font-size: 22px; opacity: .8; }
.character-info { min-width: 0; }
.character-name { overflow: hidden; margin: 0 0 8px; color: #74809f; font-size: clamp(13px, 1.45vw, 18px); font-weight: 800; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.character-name.is-selected { color: #fff; }
.rarity-label { margin: 0; color: #a1adc8; font-size: 10px; }
.rarity-label.is-selected { color: #ffce68; letter-spacing: .035em; }
.button-draw { min-height: 38px; padding: 0 9px; background: var(--accent); color: #141827; font-size: 10px; white-space: nowrap; }
.button-draw:disabled { background: #3a425a; color: #8a95af; }

.cone-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) 88px; gap: 10px; align-items: center; margin-top: 12px; padding-top: 11px; border-top: 1px solid rgba(185, 199, 232, .08); }
.cone-heading { color: #9aa6c1; font-size: 10px; }
.cone-value { overflow: hidden; color: var(--accent); font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.button-cone { min-height: 31px; padding: 0 8px; background: #303c5b; color: #fff; font-size: 9px; white-space: nowrap; }
.button-cone:disabled { background: #3a425a; color: #8792ac; }

.page-footer { display: flex; align-items: center; gap: 15px; min-height: 38px; padding: 12px 4px 0; color: #7f8ba7; font-size: 9px; }
.page-footer p { flex: 1; margin: 0; }
.page-footer a { color: #929fbd; text-decoration: none; white-space: nowrap; }
.page-footer a:hover { color: #cbd5ef; text-decoration: underline; }
.made-by { color: #929fbd; white-space: nowrap; }
.version-note { margin-left: auto; color: #7f8ba7; white-space: nowrap; }

@media (max-width: 820px) {
  .page-shell { width: min(680px, calc(100% - 30px)); padding-top: 15px; }
  .hero { min-height: 184px; padding: 27px 25px; border-radius: 20px; }
  .orbit-one { right: -134px; }
  .orbit-two { right: -86px; }
  .hero::after { right: 14px; width: 84px; height: 84px; }
  .hero-star-one { right: 24px; }
  .hero-star-two { right: 156px; }
  .hero-star-three { right: 215px; }
  .control-panel { grid-template-columns: 105px 148px minmax(100px, 1fr) 78px; gap: 12px; padding: 14px; }
  .button-reset { width: 78px; }
  .usage-copy { display: block; font-size: 10px; }
  #remainingLabel { display: block; margin-top: 3px; }
  .party-grid { gap: 11px; }
  .role-card { padding: 15px 13px 13px; }
  .card-heading { gap: 8px; }
  .role-number { flex-basis: 30px; width: 30px; height: 30px; }
  .card-heading h2 { font-size: 13px; }
  .pick-area { grid-template-columns: 55px minmax(0, 1fr); gap: 9px; }
  .portrait-shell { width: 55px; height: 68px; }
  .character-name { font-size: 14px; }
  .button-draw { grid-column: 2; justify-self: start; min-height: 30px; margin-top: -3px; padding: 0 10px; }
  .cone-row { grid-template-columns: 74px minmax(0, 1fr) 80px; gap: 6px; }
}

@media (max-width: 560px) {
  .page-shell { width: calc(100% - 22px); padding-top: 11px; }
  .hero { min-height: 176px; padding: 24px 20px; }
  .eyebrow { font-size: 8px; }
  .hero h1 { font-size: 32px; }
  .hero-description { max-width: 245px; font-size: 11px; }
  .control-panel { grid-template-columns: 1fr 1fr; gap: 12px 10px; padding: 13px; }
  .base-limit, .bonus-limit { grid-row: 1; }
  .usage-area { grid-column: 1 / 3; grid-row: 2; }
  .usage-copy { display: flex; font-size: 10px; }
  #remainingLabel { display: inline; margin: 0; }
  .button-reset { grid-column: 1 / 3; grid-row: 3; width: 100%; height: 36px; }
  .party-grid { grid-template-columns: 1fr; gap: 10px; }
  .role-card { padding: 15px 16px 13px; }
  .pick-area { grid-template-columns: 62px minmax(0, 1fr) 108px; gap: 10px; }
  .portrait-shell { width: 62px; height: 75px; }
  .character-name { font-size: 16px; }
  .button-draw { grid-column: auto; justify-self: stretch; min-height: 36px; margin: 0; padding: 0 6px; }
  .cone-row { grid-template-columns: 84px minmax(0, 1fr) 88px; gap: 10px; }
  .page-footer { flex-wrap: wrap; gap: 7px 12px; padding: 12px 2px 4px; font-size: 8px; }
  .page-footer p { flex: 1 0 100%; }
  .page-footer a { margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
