:root {
  --ink: #171a21;
  --ink-soft: #292d37;
  --paper: #f1eee6;
  --paper-bright: #fffdf7;
  --line: #cbc6b8;
  --muted: #696a66;
  --acid: #d7ff4f;
  --acid-dark: #94bc00;
  --coral: #ff6b4a;
  --sky: #88d8ff;
  --violet: #9d8cff;
  --gold: #f2c94c;
  --green: #19a974;
  --red: #d94a45;
  --shadow: 0 10px 32px rgba(23, 26, 33, .11);
  --radius: 18px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); min-height: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(23, 26, 33, .96);
  color: white;
  border-bottom: 3px solid var(--acid);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px 5px 11px 5px;
  color: var(--ink);
  background: var(--acid);
  font-weight: 950;
  font-size: 23px;
  transform: rotate(-3deg);
}
.brand b { display: block; font-size: 16px; line-height: 1; letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; color: #c8cbc9; font-size: 8px; letter-spacing: .21em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.role-pill { padding: 6px 9px; border: 1px solid #5a5f6b; border-radius: 999px; color: var(--acid); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.icon-button { width: 44px; min-height: 44px; border: 1px solid #555b66; border-radius: 12px; background: #232731; color: white; font-size: 23px; }

.app-shell { width: min(100%, 1120px); margin: 0 auto; padding: 18px 14px calc(48px + env(safe-area-inset-bottom)); }
.stack { display: grid; gap: 14px; }
.wide-stack { display: grid; gap: 18px; }
.two-column { display: grid; gap: 14px; }
.three-column { display: grid; gap: 12px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.hidden { display: none !important; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 27px 22px;
  border-radius: 24px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -55px;
  top: -80px;
  border: 28px solid var(--acid);
  border-radius: 50%;
  opacity: .14;
}
.eyebrow { margin: 0 0 8px; color: var(--acid-dark); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: var(--acid); }
h1, h2, h3, p { margin-top: 0; }
h1 { position: relative; z-index: 1; margin-bottom: 10px; font-size: clamp(34px, 10vw, 66px); line-height: .95; letter-spacing: -.055em; }
h2 { margin-bottom: 9px; font-size: 24px; line-height: 1.08; letter-spacing: -.03em; }
h3 { margin-bottom: 7px; font-size: 16px; line-height: 1.2; }
.hero-copy { position: relative; z-index: 1; max-width: 680px; margin-bottom: 18px; color: #d9dbdc; font-size: 16px; line-height: 1.5; }
.lede { color: var(--muted); font-size: 15px; line-height: 1.5; }
.micro { color: var(--muted); font-size: 12px; line-height: 1.45; }

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-bright);
  box-shadow: 0 3px 0 rgba(23, 26, 33, .06);
}
.card-dark { color: white; background: var(--ink-soft); border-color: #3a3f4a; }
.card-acid { background: var(--acid); border-color: var(--ink); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading p { margin-bottom: 0; }
.step-number { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--ink); color: var(--acid); font-weight: 900; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font-weight: 850;
  line-height: 1.1;
  text-decoration: none;
  box-shadow: 3px 3px 0 var(--acid-dark);
  transition: transform .14s ease, box-shadow .14s ease;
}
.button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--acid-dark); }
.button-acid { color: var(--ink); background: var(--acid); box-shadow: 3px 3px 0 var(--coral); }
.button-coral { background: var(--coral); box-shadow: 3px 3px 0 #9f2b16; }
.button-quiet { color: var(--ink); background: transparent; border-color: var(--line); box-shadow: none; }
.button-danger { color: var(--red); background: white; border-color: #efb1ad; box-shadow: none; }
.button-small { min-height: 40px; padding: 8px 12px; font-size: 12px; box-shadow: none; }
.button-wide { width: 100%; }

label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1.5px solid #aaa79f;
  border-radius: 11px;
  outline: none;
  background: white;
  color: var(--ink);
  font-weight: 600;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(136, 216, 255, .5); }
.input-help { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.4; }
.form-grid { display: grid; gap: 13px; }
.form-actions { display: flex; flex-direction: column; gap: 9px; }
.field-row { display: grid; gap: 10px; }

.template-grid { display: grid; gap: 10px; }
.template-option { position: relative; }
.template-option input { position: absolute; opacity: 0; pointer-events: none; }
.template-label { display: block; min-height: 100%; padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: white; }
.template-label strong { display: block; margin-bottom: 5px; font-size: 15px; }
.template-label span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.template-option input:checked + .template-label { border-color: var(--ink); background: var(--acid); box-shadow: 4px 4px 0 var(--ink); }

.rule-list { display: grid; gap: 9px; }
.rule-row { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.rule-main { display: grid; grid-template-columns: 28px 1fr 82px; gap: 9px; align-items: center; }
.rule-main input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--ink); }
.rule-main input[type="number"] { min-height: 40px; padding: 7px; text-align: center; }
.rule-meta { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 37px; }
.rule-meta label { flex: 1 1 120px; font-size: 10px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.metric { padding: 13px; border-radius: 13px; background: #ece9e0; }
.metric b { display: block; font-size: 24px; line-height: 1; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.verdict { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; font-weight: 800; }
.verdict-pass { background: #dff8eb; color: #0c6c49; }
.verdict-warn { background: #fff0c9; color: #7a5200; }

.status-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 999px; background: #e5e1d7; color: var(--ink); font-size: 10px; font-weight: 850; }
.chip-core { background: var(--sky); }
.chip-surprise { background: var(--acid); }
.chip-chaos { background: #ffd0c5; }
.chip-community { background: #ddd7ff; }
.chip-live { color: white; background: var(--red); }

.link-list { display: grid; gap: 9px; }
.share-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.share-copy { min-width: 0; padding: 10px; border: 1px dashed #99958b; border-radius: 10px; background: #f5f2ea; }
.share-copy b, .share-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-copy b { font-size: 12px; }
.share-copy span { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

.draw-stage { text-align: center; }
.draw-orb {
  display: grid;
  width: 132px;
  height: 132px;
  margin: 12px auto 18px;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 10px 10px 0 var(--coral);
  transform: rotate(-2deg);
}
.draw-orb b { max-width: 100px; font-size: 18px; line-height: 1.05; }
.draw-orb.revealing { animation: reveal-pop .62s cubic-bezier(.2, .8, .2, 1); }
.draw-next { margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.progress-track { height: 10px; overflow: hidden; border: 1px solid var(--ink); border-radius: 999px; background: #d9d5ca; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--coral); transition: width .35s ease; }
.commitment { overflow-wrap: anywhere; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

.roster-grid { display: grid; gap: 10px; }
.roster-card { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.roster-card.current { border-color: var(--coral); box-shadow: 0 0 0 2px #ffd0c5; }
.roster-card.mine { background: #f8ffd9; }
.roster-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 900; }
.entrant-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.entrant-tag { padding: 5px 8px; border-radius: 8px; background: #eeece6; font-size: 10px; font-weight: 750; }

.leaderboard { display: grid; gap: 9px; }
.leader-row { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; }
.leader-row.mine { border: 2px solid var(--ink); }
.leader-head { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; padding: 13px; }
.leader-rank { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--ink); color: var(--acid); font-weight: 900; }
.leader-name { font-weight: 900; }
.leader-total { font-size: 25px; font-weight: 950; letter-spacing: -.04em; }
.leader-breakdown { padding: 0 13px 13px 57px; }
.owned-list { display: grid; gap: 6px; padding: 11px 13px; border-top: 1px solid #e1ddd3; background: #f7f5ef; }
.owned-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; font-size: 12px; }
.owned-row b { font-size: 14px; }
.score-lines { grid-column: 1 / -1; display: grid; gap: 3px; color: var(--muted); font-size: 10px; }

.story-feed { display: grid; gap: 9px; }
.story-card { padding: 13px; border-left: 5px solid var(--coral); border-radius: 0 13px 13px 0; background: white; }
.story-card h3 { margin-bottom: 4px; }
.story-card p { margin-bottom: 7px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.story-card a { color: #075c87; font-size: 11px; font-weight: 750; }

.award-card { display: grid; gap: 11px; padding: 14px; border: 2px solid var(--violet); border-radius: 15px; background: #f6f3ff; }
.award-card.winner { border-color: var(--acid-dark); background: #f8ffd9; }
.nomination-list { display: grid; gap: 8px; }
.nomination { padding: 11px; border: 1px solid #c9c1f5; border-radius: 11px; background: white; }
.nomination.winner { border-color: var(--ink); background: var(--acid); }
.nomination p { margin-bottom: 7px; color: var(--muted); font-size: 12px; }

.empty-state { padding: 22px; border: 1px dashed #aaa69b; border-radius: 14px; text-align: center; color: var(--muted); }
.empty-state b { display: block; margin-bottom: 5px; color: var(--ink); }
.loading-card { display: grid; min-height: 50vh; place-items: center; align-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 32px; height: 32px; border: 4px solid #d0ccc2; border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; z-index: 50; left: 14px; right: 14px; bottom: max(16px, env(safe-area-inset-bottom)); padding: 13px 15px; border: 2px solid var(--ink); border-radius: 13px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; font-weight: 750; }
.toast.error { background: var(--red); }
.noscript { padding: 20px; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal-pop {
  0% { transform: rotate(-12deg) scale(.75); opacity: .2; }
  55% { transform: rotate(6deg) scale(1.12); opacity: 1; }
  100% { transform: rotate(-2deg) scale(1); }
}

@media (min-width: 760px) {
  .app-shell { padding: 28px 24px 70px; }
  .site-header { padding-left: 28px; padding-right: 28px; }
  .two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-direction: row; }
  .form-actions .button { width: auto; }
  .hero { padding: 42px; }
}

@media (min-width: 1020px) {
  .dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(310px, .6fr); gap: 18px; align-items: start; }
  .dashboard-side { position: sticky; top: 92px; }
  .roster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .template-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
