:root {
  color-scheme: dark;
  --bg: #0f1720;
  --panel: #17212d;
  --panel-2: #111b26;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #8ea1b6;
  --accent: #5b9bea;
  --accent-2: #ffcc66;
  --danger: #ff7171;
  --success: #77d79a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: #202b37;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 56px;
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 6px;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  background: #141e29;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 17px;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button:active,
.primary-button:active,
.row:active,
.card:active {
  transform: scale(0.99);
}

.screen {
  flex: 1;
  padding: 16px;
  overflow: auto;
}

.loading-screen {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  min-height: 100vh;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5b9bea, #9168ff 52%, #ffcc66);
  font-size: 32px;
  font-weight: 800;
}

.loading-title {
  font-size: 20px;
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 14px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.balance-card {
  display: grid;
  gap: 12px;
}

.salon-card {
  background:
    radial-gradient(circle at 88% 16%, rgba(255, 204, 102, 0.12), transparent 32%),
    radial-gradient(circle at 10% 88%, rgba(91, 155, 234, 0.14), transparent 36%),
    var(--panel-2);
}

.label {
  color: #69b3ff;
  font-size: 14px;
}

.balance-value {
  font-size: 19px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.secondary-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #1c2936;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.ref-card,
.reward-card {
  display: grid;
  grid-template-columns: 34px 1fr 24px;
  gap: 10px;
  align-items: center;
  cursor: pointer;
}

.fortune-card {
  display: grid;
  grid-template-columns: 42px 1fr 24px;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 204, 102, 0.18), transparent 36%),
    var(--panel-2);
}

.ref-icon,
.reward-icon,
.library-icon {
  font-size: 24px;
}

.library-card {
  display: grid;
  grid-template-columns: 42px 1fr 24px;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  background:
    radial-gradient(circle at 15% 18%, rgba(119, 215, 154, 0.14), transparent 35%),
    var(--panel-2);
}

.reward-option {
  border-bottom: 0;
}

.reward-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0 14px 14px;
  border-bottom: 1px solid var(--line);
}

.reward-actions:last-child {
  border-bottom: 0;
}

.fortune-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(91, 155, 234, 0.18);
}

.title {
  font-weight: 800;
  margin-bottom: 4px;
}

.copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.menu {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.row {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 28px 1fr auto 18px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.row:last-child {
  border-bottom: 0;
}

.row-value {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 145px;
}

.footer {
  margin-top: auto;
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: #17212d;
}

.section-caption {
  margin: 2px 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
}

.question-library-screen {
  gap: 14px;
}

.library-intro {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
}

.library-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(119, 215, 154, 0.15);
  font-size: 22px;
}

.library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}

.library-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: var(--panel-2);
  text-align: center;
  line-height: 1.2;
  font-size: 14px;
  cursor: pointer;
  flex: 1 1 auto;
  max-width: 100%;
}

.library-tab span:last-child {
  min-width: 0;
}

.library-tab.active {
  color: var(--text);
  border-color: rgba(91, 155, 234, 0.55);
  background:
    linear-gradient(180deg, rgba(91, 155, 234, 0.26), rgba(91, 155, 234, 0.14)),
    var(--panel-2);
}

.library-tab:nth-child(2),
.library-tab:nth-child(3),
.library-tab:nth-child(4) {
  font-size: 13px;
  padding-inline: 11px;
}

.library-section {
  display: grid;
  gap: 8px;
}

.library-heading {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 0 2px;
}

.library-heading-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #111b26;
}

.library-list {
  display: grid;
  gap: 8px;
}

.library-question {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.library-question-text {
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
}

.library-reading {
  justify-self: start;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(91, 155, 234, 0.18);
  color: #9bc8ff;
  font-size: 12px;
  font-weight: 800;
}

.library-reading.owned {
  background: rgba(119, 215, 154, 0.16);
  color: #9ef0ba;
}

.my-readings-screen {
  gap: 12px;
}

.my-readings-list {
  display: grid;
  gap: 8px;
}

.my-reading-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.my-reading-title {
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 4px;
}

.my-reading-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  white-space: nowrap;
}

.input-group {
  display: grid;
  gap: 8px;
}

.input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #101a24;
  color: var(--text);
}

.field-label {
  color: var(--muted);
  font-size: 13px;
}

.option {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
}

.option:last-child {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(91, 155, 234, 0.18);
  color: #9bc8ff;
  font-size: 12px;
  font-weight: 700;
}

.product-grid {
  display: grid;
  gap: 10px;
}

.product-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.purchase-screen,
.checkout-screen {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.checkout-screen {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.payment-menu,
.product-options {
  display: grid;
}

.payment-method,
.checkout-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.payment-method:last-child,
.checkout-option:last-child {
  border-bottom: 0;
}

.payment-method {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.payment-method small,
.checkout-option small,
.reading-price small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.reading-price .owned-note {
  color: #9ef0ba;
  font-weight: 700;
}

.warning-note {
  color: #ffd27a !important;
  font-weight: 700;
}

.success-note {
  padding: 10px 12px;
  border: 1px solid rgba(119, 215, 154, 0.3);
  border-radius: 8px;
  background: rgba(119, 215, 154, 0.1);
  color: #b7f2cb;
  font-size: 13px;
  line-height: 1.45;
}

.payment-method.disabled {
  opacity: 0.55;
}

.checkmark {
  color: #69b3ff;
  font-weight: 800;
}

.checkout-option {
  min-height: 72px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.checkout-option.selected,
.payment-method.selected {
  background: rgba(91, 155, 234, 0.08);
}

.radio-dot {
  width: 18px;
  height: 18px;
  border: 1px solid #6f8499;
  border-radius: 50%;
  display: block;
  position: relative;
}

.checkout-option.selected .radio-dot {
  border-color: #69b3ff;
}

.checkout-option.selected .radio-dot::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #69b3ff;
}

.checkout-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.checkout-price {
  color: var(--accent-2);
  font-weight: 800;
  white-space: nowrap;
}

.checkout-copy .pill {
  justify-self: start;
  min-height: 22px;
  padding: 0 8px;
}

.checkout-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  gap: 8px;
  margin: 0 -16px calc(-88px - env(safe-area-inset-bottom));
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: rgba(23, 33, 45, 0.96);
  border-top: 1px solid var(--line);
}

.purchase-screen .checkout-footer {
  position: static;
  margin: 0;
  padding: 0;
  background: transparent;
  border-top: 0;
}

.checkout-screen .checkout-footer {
  position: static;
  margin: 0;
  padding: 0;
  background: transparent;
  border-top: 0;
}

.price-details {
  overflow: hidden;
  border: 1px solid rgba(105, 179, 255, 0.22);
  border-radius: 8px;
  background: rgba(91, 155, 234, 0.07);
  transition: border-color 160ms ease, background 160ms ease;
}

.price-details summary {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  outline: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.price-details summary::-webkit-details-marker {
  display: none;
}

.price-details summary:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(105, 179, 255, 0.72);
}

.price-details:hover,
.price-details[open] {
  border-color: rgba(105, 179, 255, 0.42);
  background: rgba(91, 155, 234, 0.11);
}

.details-chevron {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin: -4px 3px 0 0;
  border-right: 2px solid #8fc6ff;
  border-bottom: 2px solid #8fc6ff;
  transform: rotate(45deg);
  transition: transform 160ms ease, margin 160ms ease;
}

.price-details[open] .details-chevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.price-list {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.summary-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.summary-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 4px auto 0;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.2), transparent 52%),
    conic-gradient(from 20deg, #5b9bea, #ffcc66, #9168ff, #77d79a, #5b9bea);
  font-size: 34px;
}

.summary-value,
.summary-price {
  font-size: 18px;
  font-weight: 800;
}

.summary-price {
  color: var(--accent-2);
}

.price {
  color: var(--accent-2);
  font-weight: 800;
}

.fortune-screen {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 16px;
}

.fortune-wheel-wrap {
  width: 206px;
  height: 206px;
  position: relative;
  display: grid;
  place-items: center;
  margin: 2px auto 8px;
}

.fortune-pointer {
  position: absolute;
  top: 3px;
  z-index: 5;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 22px solid #ffcf6f;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.fortune-wheel {
  width: 188px;
  height: 188px;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.3));
}

.fortune-wheel-disc {
  transform-origin: 100px 100px;
  transition: transform 4.15s cubic-bezier(0.08, 0.78, 0.12, 1);
}

.fortune-wheel-labels {
  transform-origin: 100px 100px;
  transition: transform 4.15s cubic-bezier(0.08, 0.78, 0.12, 1);
}

.fortune-label-car {
  transform-box: fill-box;
  transform-origin: center;
}

.fortune-wheel.starting .fortune-wheel-disc {
  transition: transform 180ms ease-out;
  filter: brightness(1.06);
}

.fortune-wheel.settling .fortune-wheel-disc {
  transition: transform 4.15s cubic-bezier(0.08, 0.78, 0.12, 1);
}

.fortune-wheel.settling .fortune-wheel-labels {
  transition: transform 4.15s cubic-bezier(0.08, 0.78, 0.12, 1);
}

.fortune-wheel-wrap.spinning .fortune-pointer {
  animation: fortune-pointer-tick 210ms ease-in-out infinite;
}

.fortune-segment {
  stroke: rgba(17, 27, 38, 0.88);
  stroke-width: 2.4;
}

.fortune-segment.common {
  filter: saturate(1.06);
}

.fortune-segment.rare {
  filter: saturate(0.98);
}

.fortune-wheel-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 2.5;
}

.fortune-wheel-inner-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 1.7;
}

.fortune-label {
  dominant-baseline: middle;
  font-family: inherit;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.32);
  stroke-width: 2.4px;
  text-anchor: middle;
  pointer-events: none;
}

.fortune-label.common {
  font-size: 18px;
  font-weight: 950;
}

.fortune-label.rare {
  font-size: 14px;
  font-weight: 850;
}

.fortune-wheel-center {
  position: absolute;
  z-index: 4;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 30%, rgba(105, 179, 255, 0.34), transparent 36%),
    #17212d;
  border: 2px solid rgba(255, 255, 255, 0.26);
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgba(105, 179, 255, 0.28), 0 7px 20px rgba(0, 0, 0, 0.32);
}

.fortune-gem {
  display: block;
  line-height: 1;
  transform: translate(0, 1px);
}

@keyframes fortune-pointer-tick {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  50% {
    transform: rotate(-7deg) translateY(1px);
  }
}

.reading-price {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
}

.reading-price strong,
.reading-price small {
  display: block;
}

.reading-price small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(76px, calc(64px + env(safe-area-inset-bottom)));
  z-index: 20;
  width: min(calc(100% - 32px), 398px);
  transform: translateX(-50%);
  background: rgba(31, 91, 153, 0.98);
  color: #ffffff;
  border: 1px solid rgba(145, 205, 255, 0.85);
  border-radius: 10px;
  padding: 13px 15px;
  font-weight: 650;
  line-height: 1.35;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(91, 155, 234, 0.18);
}

.hidden {
  display: none !important;
}
