:root {
  --bg: #07080c;
  --ink: #f4f1ea;
  --muted: #9b968c;
  --line: rgba(244, 241, 234, 0.12);
  --panel: #12151c;
  --panel-2: #1a1e28;
  --lime: #d6ff4a;
  --lime-ink: #14180a;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  --font: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Unbounded", "Avenir Next", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(90% 50% at 50% -10%, rgba(214, 255, 74, 0.16), transparent 60%),
    radial-gradient(70% 40% at 110% 110%, rgba(255, 77, 109, 0.14), transparent 55%),
    radial-gradient(50% 30% at -10% 80%, rgba(46, 230, 166, 0.08), transparent 50%),
    var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, a { font-family: inherit; }
button { cursor: pointer; }
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(18px + var(--safe-top)) 18px calc(22px + var(--safe-bot));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand { display: flex; flex-direction: column; gap: 4px; }
.kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lime);
  font-weight: 700;
}
h1 {
  font-family: var(--display);
  font-size: 34px;
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.04em;
}
.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  max-width: 34ch;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn[aria-pressed="true"] { color: var(--lime); border-color: rgba(214, 255, 74, 0.45); }

.tray-label, .section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.slot {
  min-height: 108px;
  border-radius: 18px;
  border: 1px dashed rgba(244, 241, 234, 0.22);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  position: relative;
}
.slot.filled {
  border-style: solid;
  border-color: var(--die);
  background: var(--panel);
  color: var(--ink);
}
.slot .idx { font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }
.slot strong { font-family: var(--display); font-size: 13px; letter-spacing: -0.03em; }
.slot .x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 16px;
}

.dice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.die-card {
  cursor: pointer;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--ink);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 168px;
}
.die-card:active { transform: translateY(1px) scale(0.99); }
.die-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #12140a;
  background:
    linear-gradient(160deg, #fff 0%, transparent 42%),
    var(--die);
  box-shadow: inset 0 -8px 12px rgba(0, 0, 0, 0.18), 0 8px 16px rgba(0, 0, 0, 0.25);
}
.die-card h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
}
.die-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.die-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--die);
}
.linkish {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  padding: 0 14px;
}
.btn:disabled { opacity: 0.4; }
.btn.primary {
  background: var(--lime);
  color: var(--lime-ink);
  border-color: transparent;
  font-family: var(--display);
  letter-spacing: -0.03em;
  font-size: 16px;
}
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.notice {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--lime);
  font-size: 13px;
  font-weight: 600;
}

.stage {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  perspective: 900px;
  margin: 28px 0 18px;
}
.cube-wrap { display: grid; justify-items: center; gap: 10px; }
.cube {
  width: 92px;
  height: 92px;
  position: relative;
  transform-style: preserve-3d;
}
.cube.spin {
  animation: tumble 1.35s cubic-bezier(0.15, 0.7, 0.2, 1) forwards;
}
.cube.spin:nth-child(1) { animation-delay: 0s; }
.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-family: var(--display);
  font-size: 13px;
  color: #14180a;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.55), transparent 40%),
    var(--die);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}
.face.front  { transform: rotateY(0deg) translateZ(46px); }
.face.back   { transform: rotateY(180deg) translateZ(46px); }
.face.right  { transform: rotateY(90deg) translateZ(46px); }
.face.left   { transform: rotateY(-90deg) translateZ(46px); }
.face.top    { transform: rotateX(90deg) translateZ(46px); }
.face.bottom { transform: rotateX(-90deg) translateZ(46px); }
.land-name {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  min-height: 2.5em;
}
@keyframes tumble {
  0% { transform: rotateX(0deg) rotateZ(0deg) translateY(0); }
  35% { transform: rotateX(480deg) rotateZ(240deg) translateY(-28px); }
  100% { transform: rotateX(720deg) rotateZ(360deg) translateY(0); }
}

.line-head { margin-bottom: 16px; }
.line-head h1 { font-size: 40px; }
.progress {
  margin-top: 12px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--lime);
  width: 0%;
}
.cards { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-body { padding: 16px 16px 14px; }
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #14180a;
  background: var(--die);
}
.num {
  font-family: var(--display);
  color: var(--muted);
  font-size: 13px;
}
.card h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: -0.04em;
  line-height: 1.02;
}
.card .desc {
  margin: 0;
  color: #d9d4ca;
  font-size: 15.5px;
  line-height: 1.45;
}
.clip {
  margin-top: 14px;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}
.clip img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.clip.missing {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    #10131a;
}
.video-cap {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.video-cap a { color: var(--ink); }
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 16px;
}
.card.flown { outline: 1px solid rgba(214, 255, 74, 0.35); }
.card.flown h2 { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(214, 255, 74, 0.7); }

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  padding: 12px;
}
.sheet-card {
  width: min(480px, 100%);
  max-height: min(78dvh, 680px);
  overflow: auto;
  background: #10131a;
  border-radius: 24px 24px 18px 18px;
  border: 1px solid var(--line);
  padding: 16px 16px calc(16px + var(--safe-bot));
}
.sheet-card h2 { margin: 0 0 4px; font-family: var(--display); letter-spacing: -0.04em; }
.face-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.face-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.face-list strong { display: block; margin-bottom: 3px; }
.face-list span { color: var(--muted); font-size: 13px; line-height: 1.35; }

.credit {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.credit a { color: var(--ink); }

.install {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.install strong { color: var(--ink); }
.install button {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--lime);
  font-weight: 800;
  padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  .cube.spin { animation: none; }
  .die-card:active { transform: none; }
}
