:root {
  color-scheme: dark;
  --bg-top: #06100f;
  --bg-bottom: #020404;
  --surface: rgba(7, 15, 16, 0.9);
  --surface-strong: rgba(13, 26, 29, 0.96);
  --surface-soft: rgba(16, 34, 31, 0.82);
  --line: rgba(157, 187, 176, 0.15);
  --ink: #f6f8f2;
  --ink-soft: #d9e3da;
  --muted: #9dafaa;
  --accent: #43d19e;
  --accent-soft: rgba(67, 209, 158, 0.16);
  --gold: #f3c15e;
  --warning: #ff8b74;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 18px 44px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  background: #020505;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(67, 209, 158, 0.16), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(243, 193, 94, 0.15), transparent 18%),
    radial-gradient(circle at 50% 130%, rgba(37, 118, 89, 0.22), transparent 34%),
    linear-gradient(145deg, var(--bg-top) 0%, #081514 45%, var(--bg-bottom) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(90deg, transparent 0, transparent 24px, rgba(255, 255, 255, 0.018) 25px),
    linear-gradient(0deg, transparent 0, transparent 24px, rgba(255, 255, 255, 0.018) 25px);
  background-size: 25px 25px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 70%);
}

body::after {
  background:
    radial-gradient(circle at 20% 22%, rgba(255, 255, 255, 0.1) 0 1px, transparent 1.6px),
    radial-gradient(circle at 68% 70%, rgba(255, 255, 255, 0.08) 0 1px, transparent 1.7px);
  background-size: 180px 180px, 220px 220px;
  opacity: 0.45;
}

.ambient-dice-layer {
  position: fixed;
  inset: -18vh 0 -18vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

.ambient-die {
  position: absolute;
  width: var(--die-size, 54px);
  height: var(--die-size, 54px);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.46), transparent 34%),
    linear-gradient(145deg, rgba(248, 252, 247, 0.94), rgba(188, 197, 193, 0.6));
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.22),
    0 0 26px rgba(243, 193, 94, 0.08);
  opacity: 0;
  will-change: transform, opacity;
  animation: ambient-fall var(--duration, 34s) linear infinite;
}

.ambient-die::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(7, 12, 11, 0.92);
}

.ambient-die::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 18px;
  background: radial-gradient(circle, rgba(67, 209, 158, 0.16), transparent 68%);
  filter: blur(10px);
  z-index: -1;
}

.die-a {
  left: 6%;
  --duration: 31s;
  animation-delay: -7s;
  --die-scale: 0.9;
  --die-drift: 26px;
  --die-size: 50px;
}

.die-b {
  left: 19%;
  --duration: 37s;
  animation-delay: -18s;
  --die-scale: 1.08;
  --die-drift: -22px;
  --die-size: 58px;
}

.die-c {
  left: 36%;
  --duration: 34s;
  animation-delay: -13s;
  --die-scale: 0.82;
  --die-drift: 18px;
  --die-size: 46px;
}

.die-d {
  left: 56%;
  --duration: 39s;
  animation-delay: -28s;
  --die-scale: 1.12;
  --die-drift: -28px;
  --die-size: 60px;
}

.die-e {
  left: 74%;
  --duration: 33s;
  animation-delay: -20s;
  --die-scale: 0.88;
  --die-drift: 24px;
  --die-size: 48px;
}

.die-f {
  left: 89%;
  --duration: 36s;
  animation-delay: -10s;
  --die-scale: 0.98;
  --die-drift: -18px;
  --die-size: 52px;
}

.face-one::before {
  top: 19px;
  left: 19px;
}

.face-two::before {
  top: 12px;
  left: 12px;
  box-shadow: 15px 15px rgba(6, 12, 11, 0.84);
}

.face-three::before {
  top: 12px;
  left: 12px;
  box-shadow:
    7px 7px rgba(6, 12, 11, 0.84),
    15px 15px rgba(6, 12, 11, 0.84);
}

.face-four::before {
  top: 10px;
  left: 10px;
  box-shadow:
    16px 0 rgba(6, 12, 11, 0.84),
    0 16px rgba(6, 12, 11, 0.84),
    16px 16px rgba(6, 12, 11, 0.84);
}

.face-five::before {
  top: 9px;
  left: 9px;
  box-shadow:
    16px 0 rgba(6, 12, 11, 0.84),
    8px 8px rgba(6, 12, 11, 0.84),
    0 16px rgba(6, 12, 11, 0.84),
    16px 16px rgba(6, 12, 11, 0.84);
}

@keyframes ambient-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -14vh, 0) rotate(0deg) scale(var(--die-scale, 1));
  }

  10% {
    opacity: 0.48;
  }

  50% {
    opacity: 0.34;
    transform: translate3d(calc(var(--die-drift, 18px) * 0.55), 48vh, 0) rotate(135deg) scale(var(--die-scale, 1));
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--die-drift, 18px), 118vh, 0) rotate(265deg) scale(var(--die-scale, 1));
  }
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
.site-brand strong {
  font-family: Georgia, "Times New Roman", serif;
}

.page-shell {
  position: relative;
  z-index: 2;
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  display: grid;
  gap: 20px;
}

.hero-card,
.panel,
.control-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 18%),
    linear-gradient(155deg, rgba(10, 26, 24, 0.96), rgba(5, 12, 12, 0.94));
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card::before,
.panel::before,
.control-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.05), transparent 28%);
}

.hero-card {
  padding: 26px;
  display: grid;
  gap: 0;
}

.hero-top {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
}

.hero-top {
  grid-template-columns: minmax(0, 1.02fr) minmax(380px, 0.98fr);
  align-items: start;
}

.hero-copy {
  position: relative;
  padding: 8px 6px 6px;
  display: grid;
  align-content: start;
}

.hero-copy::after {
  content: "";
  position: absolute;
  top: -46px;
  right: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(67, 209, 158, 0.18), transparent 72%);
  filter: blur(10px);
  pointer-events: none;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--glow);
}

.site-brand strong,
.site-brand small {
  display: block;
}

.site-brand strong {
  font-size: 1.04rem;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.site-brand small {
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.3;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(145deg, #f3c15e, #43d19e);
  color: #07120e;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
}

.eyebrow,
.panel-kicker,
.metric-label,
.scene-badge {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  font-size: 0.76rem;
  color: var(--gold);
}

h1,
h2 {
  margin: 0;
  line-height: 0.98;
  color: #ffffff;
}

h1 {
  font-size: clamp(2.15rem, 4.4vw, 4.05rem);
  max-width: 11ch;
  text-wrap: balance;
}

h2 {
  font-size: 1.4rem;
}

.lead,
.table-caption,
.validation-message,
.table-note,
.field small,
.hero-metric small,
.result-card small {
  color: var(--ink-soft);
}

.lead {
  margin: 15px 0 0;
  max-width: 58ch;
  line-height: 1.74;
  font-size: 1rem;
}

.hero-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  margin-top: 18px;
}

.scene-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(243, 193, 94, 0.24);
  background: rgba(243, 193, 94, 0.12);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
}

.hero-meta-note {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.control-panel-hero,
.panel {
  padding: 22px;
}

.control-panel {
  display: grid;
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

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

.field,
.hero-metric,
.result-card,
.sheet-row,
.formula-bar {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 100%),
    rgba(255, 255, 255, 0.035);
  box-shadow: var(--glow);
}

.field {
  border-radius: 20px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: #ffffff;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(188, 222, 206, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(4, 12, 13, 0.92);
  color: #f8faf6;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.02);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(67, 209, 158, 0.18);
  border-color: rgba(67, 209, 158, 0.5);
  box-shadow: 0 0 0 4px rgba(67, 209, 158, 0.08);
}

.field small {
  display: block;
  margin-top: 1px;
  line-height: 1.45;
}

.formula-bar {
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
}

.formula-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

.validation-message {
  min-height: 1.35em;
  margin: 0;
}

.action-row {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, #f3c15e, #43d19e);
  color: #08120e;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(17, 22, 20, 0.4);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.hero-summary-inline {
  margin-top: 16px;
}

.hero-metric,
.result-card {
  border-radius: 22px;
  padding: 16px;
}

.metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.hero-metric strong,
.result-card strong {
  display: block;
  margin-top: 10px;
  color: #ffffff;
  font-size: clamp(1.7rem, 3.7vw, 2.55rem);
  line-height: 1;
}

.hero-summary-inline .hero-metric strong {
  font-size: clamp(1.55rem, 3vw, 2.2rem);
}

.hero-metric small,
.result-card small {
  display: block;
  margin-top: 7px;
  line-height: 1.46;
}

.hero-scene {
  position: relative;
  min-height: 198px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    radial-gradient(circle at 65% 18%, rgba(243, 193, 94, 0.16), transparent 22%),
    radial-gradient(circle at 18% 78%, rgba(67, 209, 158, 0.16), transparent 22%),
    linear-gradient(165deg, rgba(3, 8, 8, 0.96), rgba(9, 22, 19, 0.98));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05), var(--glow);
}

.hero-scene-inline {
  margin-top: 16px;
  min-height: 176px;
}

.hero-scene::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 22px;
  border: 1px solid rgba(214, 237, 230, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 26%),
    linear-gradient(140deg, rgba(255, 255, 255, 0.02), transparent 70%);
}

.table-glow {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 80%;
  height: 76px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    radial-gradient(circle at center, rgba(67, 209, 158, 0.28), rgba(67, 209, 158, 0.08) 50%, transparent 72%);
  filter: blur(14px);
}

.dice-cube,
.chip-stack {
  position: absolute;
  box-shadow: 0 18px 26px rgba(0, 0, 0, 0.32);
}

.dice-cube {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.38), transparent 34%),
    linear-gradient(145deg, #f4f5ef, #bcc7bf);
}

.dice-cube::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0d1412;
}

.cube-a {
  right: 48px;
  bottom: 24px;
  transform: rotate(-10deg);
}

.cube-b {
  right: 136px;
  bottom: 66px;
  transform: rotate(12deg);
}

.cube-c {
  right: 226px;
  bottom: 28px;
  transform: rotate(-18deg);
}

.dice-cube.face-five::before {
  top: 14px;
  left: 14px;
  box-shadow:
    34px 0 #0d1412,
    17px 17px #0d1412,
    0 34px #0d1412,
    34px 34px #0d1412;
}

.dice-cube.face-three::before {
  top: 14px;
  left: 14px;
  box-shadow:
    17px 17px #0d1412,
    34px 34px #0d1412;
}

.dice-cube.face-two::before {
  top: 14px;
  left: 14px;
  box-shadow: 34px 34px #0d1412;
}

.chip-stack {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.08);
}

.chip-stack::before,
.chip-stack::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.4);
}

.chip-stack::after {
  inset: 16px;
  border-style: solid;
  border-width: 3px;
}

.chip-a {
  left: 34px;
  bottom: 30px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.18), transparent 35%), linear-gradient(145deg, #d44949, #6b1111);
}

.chip-b {
  left: 92px;
  bottom: 54px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.18), transparent 35%), linear-gradient(145deg, #1fb489, #0e4737);
}

.scene-caption {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 14px;
  margin: 0;
  color: rgba(246, 248, 242, 0.86);
  font-size: 0.92rem;
  line-height: 1.42;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.results-panel,
.table-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.result-cards {
  display: none;
}

.accent-card {
  background:
    linear-gradient(180deg, rgba(67, 209, 158, 0.16), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.035);
}

.warning-card {
  background:
    linear-gradient(180deg, rgba(255, 139, 116, 0.16), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.035);
}

.mini-sheet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sheet-row {
  border-radius: 18px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.sheet-row span {
  color: var(--ink-soft);
}

.sheet-row strong {
  color: #ffffff;
  text-align: right;
  font-size: 1rem;
}

.table-caption {
  margin: 3px 0 0;
  max-width: 42ch;
  line-height: 1.55;
}

.sheet-wrap {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(67, 209, 158, 0.18), rgba(6, 17, 16, 0.98));
  color: #f8fff9;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(207, 230, 222, 0.08);
  text-align: left;
}

tbody td {
  color: #eef6f0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.94rem;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

.row-safe-last {
  background: rgba(67, 209, 158, 0.12);
}

.row-bust {
  background: rgba(255, 139, 116, 0.12);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  border: 1px solid transparent;
}

.status-ok {
  background: rgba(67, 209, 158, 0.16);
  color: #9ff0ca;
  border-color: rgba(67, 209, 158, 0.22);
}

.status-limit {
  background: rgba(243, 193, 94, 0.16);
  color: #ffd680;
  border-color: rgba(243, 193, 94, 0.22);
}

.status-bust {
  background: rgba(255, 111, 111, 0.16);
  color: #ffaaa0;
  border-color: rgba(255, 111, 111, 0.24);
}

.negative {
  color: #ff9f93;
}

.table-note {
  margin: 0;
  line-height: 1.66;
}

code {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #f8faf6;
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 1120px) {
  .hero-top {
    grid-template-columns: 1fr;
  }

  .hero-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 18px, 860px);
    padding: 18px 0 28px;
  }

  .hero-card,
  .control-panel,
  .panel {
    border-radius: 24px;
  }

  .hero-card,
  .results-panel,
  .table-panel,
  .control-panel-hero {
    padding: 18px;
  }

  .field-grid,
  .hero-summary,
  .result-cards,
  .mini-sheet {
    grid-template-columns: 1fr;
  }

  .hero-meta-row {
    align-items: flex-start;
  }

  .panel-head {
    flex-direction: column;
  }

  .sheet-row {
    grid-template-columns: 1fr;
  }

  .sheet-row strong {
    text-align: left;
  }

  .hero-scene,
  .hero-scene-inline {
    min-height: 220px;
  }

  .cube-a {
    right: 18px;
  }

  .cube-b {
    right: 92px;
  }

  .cube-c {
    right: 166px;
  }

  .ambient-die {
    --die-size: 44px;
  }
}
