:root {
  --bg: #0e1014;
  --bg-soft: #161922;
  --panel: #171b24;
  --panel-2: #1e2330;
  --border: #2a3040;
  --text: #eef1f6;
  --muted: #8b94a7;
  --accent: #f4b740;
  --accent-2: #f59e0b;
  --green: #34d399;
  --red: #f87171;
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body { background: var(--bg); }

/* ----- fundo: padrão + brilhos suaves ----- */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    radial-gradient(circle at center, rgba(244, 183, 64, 0.14) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px, 64px 64px, 64px 64px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, black 15%, transparent 72%);
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  filter: blur(90px);
  will-change: transform, opacity;
}

.bg-glow--gold {
  width: min(70vw, 520px);
  height: min(70vw, 520px);
  top: -18%;
  left: -12%;
  background: rgba(244, 183, 64, 0.16);
  animation: bg-drift-gold 22s ease-in-out infinite alternate;
}

.bg-glow--green {
  width: min(60vw, 440px);
  height: min(60vw, 440px);
  bottom: -20%;
  right: -10%;
  background: rgba(52, 211, 153, 0.11);
  animation: bg-drift-green 26s ease-in-out infinite alternate;
}

@keyframes bg-drift-gold {
  from { transform: translate(0, 0) scale(1); opacity: 0.85; }
  to { transform: translate(6%, 8%) scale(1.08); opacity: 1; }
}

@keyframes bg-drift-green {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-5%, -6%) scale(1.06); }
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
}

body.modal-open,
body.panel-open { overflow: hidden; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  margin: 1rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
}

.app {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===================== STAGE ===================== */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stage__top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stage__actions { display: flex; gap: 8px; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(244, 183, 64, 0.18), 0 0 18px rgba(244, 183, 64, 0.6);
  flex-shrink: 0;
}
.brand h1 {
  font-family: "Sora", sans-serif;
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 800;
  letter-spacing: -0.4px;
  white-space: nowrap;
}
.brand h1 span { color: var(--muted); font-weight: 600; }

.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: 0.18s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.icon-btn--panel { display: none; }

.spin-value {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  width: 100%;
}
.spin-value__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  width: min(100%, 320px);
}
.spin-value__label { font-size: 12px; color: var(--muted); }
.spin-value__input { display: flex; align-items: center; gap: 6px; }
.spin-value__input > span { color: var(--accent); font-weight: 700; font-family: "Sora", sans-serif; }
.spin-value__input input {
  width: 100%;
  max-width: 120px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  font-family: "Sora", sans-serif;
}
.spin-value__profit {
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
  line-height: 1.4;
}

/* ===================== WHEEL ===================== */
.wheel-wrap {
  position: relative;
  margin: 26px auto 8px;
  width: min(520px, 88vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.wheel-rim-glow {
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  box-shadow:
    inset 0 0 48px rgba(244, 183, 64, 0.12),
    0 0 42px rgba(244, 183, 64, 0.18),
    0 0 80px rgba(255, 220, 140, 0.08);
}

.wheel-wrap--spinning .wheel-rim-glow {
  opacity: 1;
  animation: rim-pulse 1.8s ease-in-out infinite;
}

@keyframes rim-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 40px rgba(244, 183, 64, 0.14),
      0 0 36px rgba(244, 183, 64, 0.22),
      0 0 70px rgba(255, 220, 140, 0.1);
  }
  50% {
    box-shadow:
      inset 0 0 56px rgba(244, 200, 100, 0.22),
      0 0 52px rgba(244, 183, 64, 0.35),
      0 0 100px rgba(255, 230, 160, 0.14);
  }
}

.wheel-shadow {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  z-index: 0;
  pointer-events: none;
}

#wheel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  z-index: 1;
  transition:
    transform 5.2s cubic-bezier(0.16, 1, 0.16, 1),
    filter 0.45s ease;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
  touch-action: manipulation;
}

.wheel-wrap--spinning #wheel {
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.6))
    drop-shadow(0 0 14px rgba(244, 183, 64, 0.28))
    drop-shadow(0 0 28px rgba(255, 220, 150, 0.12));
}

.wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 30px solid var(--accent);
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
  pointer-events: none;
}

.spin-hub {
  position: absolute;
  z-index: 6;
  width: 23%;
  height: 23%;
  border-radius: 50%;
  border: 5px solid var(--bg);
  background: radial-gradient(circle at 35% 30%, #fff3d6, var(--accent) 55%, var(--accent-2));
  color: #4a3500;
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: clamp(12px, 2.2vw, 17px);
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), inset 0 -3px 8px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.2s;
  touch-action: manipulation;
}
.spin-hub:hover { transform: scale(1.05); }
.spin-hub:active { transform: scale(0.96); }
.spin-hub:disabled { cursor: not-allowed; filter: grayscale(0.4) brightness(0.8); }

.result {
  min-height: 56px;
  margin-top: 14px;
  text-align: center;
  font-family: "Sora", sans-serif;
  font-size: clamp(16px, 4vw, 19px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}
.result .pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.result .won { color: var(--accent); }
.result .pill--test {
  border-color: rgba(139, 148, 167, 0.5);
  background: rgba(139, 148, 167, 0.08);
}
.result .pill--test .won { color: var(--muted); }
.result .pill__tag {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

/* ===================== PANEL ===================== */
.panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.65);
  z-index: 40;
  backdrop-filter: blur(3px);
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  height: fit-content;
  max-height: calc(100dvh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 28px;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.panel__head h2 { font-family: "Sora", sans-serif; font-size: 18px; }
.panel__close { display: none; margin-left: auto; }

.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}
@media (min-width: 881px) {
  .panel__head .chip { margin-left: auto; }
}
@media (max-width: 880px) {
  .panel__close { margin-left: auto; }
  .panel__head .chip { margin-left: 4px; }
}

.panel__hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
  line-height: 1.5;
  flex-shrink: 0;
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: 0.15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 183, 64, 0.15);
}
.input::placeholder { color: #5d6678; }

.add-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.add-form__row { display: flex; gap: 10px; }
.pct-field { position: relative; width: 110px; flex-shrink: 0; }
.pct-field .input { padding-right: 26px; }
.pct-field__suffix {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: 0.15s;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); }
.btn--add {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #3a2a00;
}
.btn--add:hover { box-shadow: 0 8px 20px rgba(244, 183, 64, 0.28); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--text); border-color: var(--accent); }
.btn--block { width: 100%; margin-top: 14px; flex-shrink: 0; }

.totalbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  flex-shrink: 0;
}
.totalbar__track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.totalbar__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 0.3s;
}
.totalbar__text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}
.totalbar__btn {
  flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.opt-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}
.opt-list::-webkit-scrollbar { width: 6px; }
.opt-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
}
.opt-item__color {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.opt-item__name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.opt-item__pct {
  width: 70px;
  flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 16px;
  text-align: right;
  outline: none;
}
.opt-item__rm {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
}
.opt-item__rm:hover { color: var(--red); border-color: var(--red); }

/* ===================== MODAL ===================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(4px);
}
.modal__box {
  position: relative;
  width: min(520px, 100%);
  max-height: min(88dvh, 88vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.modal__head,
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  gap: 12px;
  flex-shrink: 0;
}
.modal__head { border-bottom: 1px solid var(--border); }
.modal__foot { border-top: 1px solid var(--border); }
.modal__head h3 { font-family: "Sora", sans-serif; font-size: 17px; }
.modal__body { padding: 20px 22px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.setting-row strong { font-size: 15px; font-family: "Sora", sans-serif; }
.setting-row small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 3px;
  line-height: 1.5;
  max-width: 320px;
}

.switch { position: relative; width: 48px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.2s;
}
.switch__slider::before {
  content: "";
  position: absolute;
  height: 19px;
  width: 19px;
  left: 3px;
  top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .switch__slider {
  background: rgba(244, 183, 64, 0.25);
  border-color: var(--accent);
}
.switch input:checked + .switch__slider::before {
  transform: translateX(21px);
  background: var(--accent);
}

.synthetic-body {
  margin-top: 18px;
  opacity: 0.4;
  pointer-events: none;
  transition: 0.2s;
}
.synthetic-body.active { opacity: 1; pointer-events: auto; }

.field { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.field span {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.field span em { color: var(--accent); font-style: normal; font-weight: 700; }
.range { width: 100%; accent-color: var(--accent); }
.micro { color: var(--muted); font-size: 12px; margin-top: 10px; line-height: 1.55; }
.micro b { color: var(--text); }

.sub { font-family: "Sora", sans-serif; font-size: 14px; margin: 20px 0 10px; }
.sub--divider { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 22px; }

.tier-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tier-item { display: flex; align-items: center; gap: 10px; }
.tier-item__dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.tier-item__name {
  flex: 1;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tier-item__select {
  width: min(168px, 45vw);
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 12.5px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}
.stat b {
  font-family: "Sora", sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat--profit {
  background: rgba(52, 211, 153, 0.06);
  border-color: rgba(52, 211, 153, 0.35);
}
.stat--profit b { color: var(--green); }

.projection {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.proj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
}
.proj-row span { color: var(--muted); line-height: 1.35; }
.proj-row span b { color: var(--text); font-size: 11px; }
.proj-row b {
  font-family: "Sora", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}
.proj-row--highlight {
  border-color: rgba(244, 183, 64, 0.45);
  background: rgba(244, 183, 64, 0.06);
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.backup-actions .btn { flex: 1; min-width: 120px; text-align: center; }
.backup-import { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 0.25s;
  pointer-events: none;
  max-width: min(90vw, 400px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== RESPONSIVO ===================== */
@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 0;
  }

  .icon-btn--panel { display: grid; }

  .panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 45;
    max-height: 85dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    margin: 0;
  }

  .panel--open { transform: translateY(0); }

  .panel-backdrop { display: block; }

  .panel__close { display: grid; }

  .wheel-wrap { width: min(400px, 92vw); }
}

@media (prefers-reduced-motion: reduce) {
  #wheel { transition: none !important; }
  .panel { transition: none; }
  .btn:hover, .icon-btn:hover { transform: none; }
  .bg-glow--gold, .bg-glow--green, .wheel-rim-glow { animation: none; }
}
