:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #f0f4f8;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8e0e8;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --gold: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 38px;
  height: 38px;
}

.nav-tabs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-tab {
  min-width: 84px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  font-weight: 700;
}

.nav-tab.is-active {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.wallet-pill {
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 12px;
  color: var(--teal-dark);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.auth-panel {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 36px;
  align-items: center;
  min-height: calc(100vh - 126px);
}

.auth-copy h1,
.box-copy h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.98;
}

.auth-copy p,
.box-copy p,
.section-heading p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-form,
.ship-form,
.settings-form,
.item-form {
  display: grid;
  gap: 14px;
}

.login-form,
.ship-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.primary-btn,
.secondary-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-btn {
  border: 1px solid var(--teal-dark);
  background: var(--teal);
  color: white;
}

.primary-btn:hover {
  background: var(--teal-dark);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-btn:hover {
  border-color: #b6c2cf;
  background: var(--surface-strong);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.view-grid {
  display: grid;
  gap: 20px;
}

.view-panel {
  display: none;
}

.view-panel.is-visible {
  display: grid;
  gap: 20px;
}

.notice {
  display: none;
  border: 1px solid #f6c47a;
  border-radius: 8px;
  background: #fff8eb;
  color: #7a4a00;
  padding: 12px 14px;
  font-weight: 700;
}

.notice.is-visible {
  display: block;
}

.box-stage {
  display: grid;
  grid-template-columns: minmax(260px, 430px) 1fr;
  gap: clamp(20px, 4vw, 44px);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(18px, 4vw, 34px);
}

.jumbotron-stage {
  position: relative;
  overflow: hidden;
  min-height: 470px;
  background:
    radial-gradient(circle at 18% 20%, rgba(251, 191, 36, 0.2), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(20, 184, 166, 0.18), transparent 26%),
    linear-gradient(135deg, #071b23 0%, #0e3334 52%, #1f2937 100%);
  color: white;
}

.jumbotron-stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 82px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.08));
  pointer-events: none;
}

.jumbotron-stage .box-copy {
  position: relative;
  z-index: 1;
}

.jumbotron-stage .box-copy p {
  color: rgba(255, 255, 255, 0.76);
}

.jumbotron-stage .eyebrow {
  color: #fbbf24;
}

.box-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    #fbfcfd;
  background-size: 28px 28px;
}

.jumbotron-clip {
  min-height: 390px;
  border-color: rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(251, 191, 36, 0.16), transparent 42%),
    rgba(4, 16, 24, 0.58);
  background-size: 34px 34px, 34px 34px, auto, auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 24px 80px rgba(0, 0, 0, 0.24);
}

.box-opening-shell {
  min-height: 380px;
  padding: 0;
  background: #101827;
}

.box-opening-shell .mbo-root {
  height: 100%;
}

.box-visual > img {
  position: relative;
  z-index: 3;
  width: min(72%, 290px);
  height: auto;
  filter: drop-shadow(0 20px 24px rgba(23, 32, 42, 0.18));
}

.jumbotron-clip > img {
  animation: heroBoxFloat 4.2s ease-in-out infinite;
  filter: drop-shadow(0 28px 34px rgba(0, 0, 0, 0.38));
}

.box-visual.is-opening > img {
  animation: boxShake 720ms ease-in-out infinite;
}

.scanner-line {
  position: absolute;
  inset: auto 16px 18%;
  height: 3px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.6);
  opacity: 0;
}

.box-visual.is-opening .scanner-line {
  animation: scan 1.1s ease-in-out infinite;
}

.clip-orbit {
  position: absolute;
  z-index: 1;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  transform: rotate(-16deg);
}

.orbit-one {
  width: 74%;
  height: 36%;
  animation: orbitDrift 6s linear infinite;
}

.orbit-two {
  width: 58%;
  height: 58%;
  border-color: rgba(20, 184, 166, 0.26);
  animation: orbitDriftReverse 7.4s linear infinite;
}

.loot-ticket {
  position: absolute;
  z-index: 2;
  min-width: 64px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
}

.ticket-one {
  top: 18%;
  left: 11%;
  animation: ticketFly 4.8s ease-in-out infinite;
}

.ticket-two {
  top: 22%;
  right: 11%;
  animation: ticketFly 5.3s ease-in-out 500ms infinite;
}

.ticket-three {
  right: 16%;
  bottom: 18%;
  animation: ticketFly 5.1s ease-in-out 900ms infinite;
}

.clip-spark {
  position: absolute;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.95);
  animation: sparkle 2.7s ease-in-out infinite;
}

.spark-one {
  top: 27%;
  left: 27%;
}

.spark-two {
  top: 34%;
  right: 25%;
  animation-delay: 700ms;
}

.spark-three {
  left: 43%;
  bottom: 21%;
  animation-delay: 1.1s;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics-row.compact {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.metric-card,
.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  min-height: 92px;
  padding: 16px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.panel-section {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.24rem;
}

.section-heading p {
  margin: 0;
}

.odds-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.odds-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.odds-card strong {
  font-size: 1.35rem;
}

.tier-chip {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: capitalize;
}

.tier-no_reward {
  background: #475467;
}

.tier-common {
  background: var(--teal);
}

.tier-uncommon {
  background: var(--blue);
}

.tier-rare {
  background: #7c3aed;
}

.tier-legendary {
  background: var(--gold);
}

.tier-queued {
  background: #344054;
}

.free-entry-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(260px, 1.2fr);
  gap: 12px;
  align-items: end;
}

.free-entry-status {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.free-entry-status span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.free-entry-status strong {
  font-size: 1.25rem;
}

.inline-form,
.free-entry-form {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: 1fr auto;
}

.captcha-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 7px 9px 7px 12px;
  font-weight: 900;
}

.entry-code-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.entry-code-card span,
.entry-code-card small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.entry-code-card strong {
  color: var(--teal-dark);
  font-size: 1.32rem;
}

.mail-requirements {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mail-requirements li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.reward-list {
  display: grid;
  gap: 12px;
}

.reward-card {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.reward-card img {
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  object-fit: contain;
}

.reward-card h3 {
  margin: 0 0 6px;
}

.reward-card p {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  min-height: 140px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.admin-layout {
  display: grid;
  gap: 20px;
}

.settings-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.settings-form .primary-btn,
.tier-editor {
  grid-column: 1 / -1;
}

.profit-guard {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.4fr);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
}

.profit-guard.is-warning {
  border-left-color: #dc6803;
}

.profit-guard h3 {
  margin: 6px 0 8px;
  font-size: 1.08rem;
}

.profit-guard p {
  margin: 0;
  color: var(--muted);
}

.profit-guard dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.profit-guard dl div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.profit-guard dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.profit-guard dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-weight: 900;
}

.toggle-label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.toggle-label input {
  width: 18px;
  min-height: 18px;
}

.tier-editor {
  display: grid;
  gap: 10px;
}

.tier-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(90px, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.item-form {
  grid-template-columns: 1.5fr 0.9fr repeat(4, minmax(80px, 1fr)) auto;
  align-items: end;
}

.mail-review-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.mail-review-form textarea,
.mail-review-form .toggle-label,
.mail-review-form .action-row {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: var(--ink);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.mini-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.mini-btn.danger {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--red);
}

dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(23, 32, 42, 0.28);
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.46);
}

.reveal-card,
.ship-form {
  position: relative;
  padding: 24px;
}

.reveal-card {
  display: grid;
  justify-items: center;
  text-align: center;
}

.reveal-card img {
  width: 178px;
  height: 178px;
  object-fit: contain;
}

.reveal-card h2 {
  margin: 10px 0 4px;
  font-size: 1.8rem;
}

.reveal-card p {
  margin: 0;
  color: var(--muted);
}

.icon-btn {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.close-dialog {
  position: absolute;
  top: 12px;
  right: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100% - 36px));
  transform: translateY(20px);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@keyframes boxShake {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  30% {
    transform: translateY(-8px) rotate(-2deg);
  }
  65% {
    transform: translateY(4px) rotate(2deg);
  }
}

@keyframes scan {
  0% {
    transform: translateY(-120px);
    opacity: 0;
  }
  20%,
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(120px);
    opacity: 0;
  }
}

@keyframes heroBoxFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg) scale(1);
  }
  50% {
    transform: translateY(-14px) rotate(2deg) scale(1.04);
  }
}

@keyframes orbitDrift {
  to {
    transform: rotate(344deg);
  }
}

@keyframes orbitDriftReverse {
  to {
    transform: rotate(-376deg);
  }
}

@keyframes ticketFly {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
    opacity: 0.72;
  }
  50% {
    transform: translateY(-18px) rotate(4deg);
    opacity: 1;
  }
}

@keyframes sparkle {
  0%,
  100% {
    transform: scale(0.5);
    opacity: 0.25;
  }
  45% {
    transform: scale(1.35);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .topbar,
  .auth-panel,
  .box-stage {
    grid-template-columns: 1fr;
  }

  .nav-tabs,
  .account-strip {
    justify-content: start;
  }

  .metrics-row,
  .metrics-row.compact,
  .odds-grid,
  .settings-form,
  .item-form,
  .profit-guard,
  .free-entry-grid,
  .mail-requirements,
  .mail-review-form {
    grid-template-columns: 1fr 1fr;
  }

  .profit-guard > div:first-child,
  .profit-guard dl {
    grid-column: 1 / -1;
  }

  .free-entry-form {
    grid-column: 1 / -1;
  }

  .item-form input:first-child,
  .item-form .secondary-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    gap: 12px;
    padding: 12px;
  }

  .nav-tabs {
    overflow-x: auto;
    justify-content: start;
  }

  .nav-tab {
    min-width: 78px;
  }

  .account-strip {
    flex-wrap: wrap;
  }

  .auth-copy h1,
  .box-copy h1 {
    font-size: 2.5rem;
  }

  .box-visual {
    min-height: 240px;
  }

  .box-opening-shell {
    min-height: 285px;
  }

  .jumbotron-stage {
    min-height: auto;
  }

  .jumbotron-clip {
    min-height: 280px;
  }

  .metrics-row,
  .metrics-row.compact,
  .odds-grid,
  .settings-form,
  .item-form,
  .tier-row,
  .profit-guard,
  .profit-guard dl,
  .free-entry-grid,
  .mail-requirements,
  .mail-review-form,
  .inline-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .reward-card {
    grid-template-columns: 72px 1fr;
  }

  .reward-card img {
    width: 72px;
    height: 72px;
  }

  .reward-card .action-row {
    grid-column: 1 / -1;
    margin-top: 4px;
  }
}
