@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800&family=Rubik:wght@400;500;600;700;800&display=swap");

:root {
  --page: #101010;
  --surface: #171d28;
  --surface-dark: #111620;
  --surface-soft: #1c2330;
  --surface-input: #10151e;
  --border: #404b5e;
  --border-soft: #303a4c;
  --text: #eef3ff;
  --muted: #aeb9cc;
  --muted-dark: #7f8a9d;
  --gold: #f4c95d;
  --purple: #b79aff;
  --blue: #68a9ff;
  --green: #75d37c;
  --accent: var(--gold);
  --accent-rgb: 244, 201, 93;
  --font: "Rubik", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--page); }

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px 20px 44px;
  background: #101010;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.app-page {
  position: relative;
  width: min(1224px, 100%);
  margin: 0 auto;
  padding: 30px 38px 24px;
  border: 1px solid #272e3b;
  border-radius: 10px;
  background: #171a22;
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.42);
}
.app-page.accent-blue { --accent: var(--blue); --accent-rgb: 104, 169, 255; }

.page-hero {
  position: relative;
  overflow: hidden;
  margin: 8px 0 12px;
  min-height: 184px;
  padding: 40px 44px;
  border: 1px solid #343d4e;
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  background:
    linear-gradient(112deg, rgba(var(--accent-rgb), 0.09), transparent 48%),
    #121722;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.hero-content { position: relative; z-index: 2; }

.eyebrow {
  position: relative;
  z-index: 1;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow.purple { color: var(--purple); }

.page-hero h1 {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 6px 0 0;
  color: #fff;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.04;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.page-hero p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 11px 0 0;
  color: #cbd5e7;
  font-size: 16px;
  line-height: 1.55;
}

.calculator-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin: 14px 0 30px;
  padding: 9px;
  border: 1px solid #343d4e;
  border-radius: 14px;
  background: rgba(17, 22, 32, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.calculator-nav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: #202838;
  color: #dce6f7;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.calculator-nav a:hover { background: #222b3b; color: #fff; }
.calculator-nav a.active { background: var(--accent); color: #18140a; }

.help-button {
  margin-left: auto;
  padding: 8px 14px;
  border: 1px solid #465267;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e7;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.help-button:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.08); color: #fff; }

.section-heading, .subsection-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 28px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #354056;
}

.section-heading h2, .subsection-heading h2 {
  margin: 3px 0 0;
  color: #f7f9ff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.section-heading p, .subsection-heading p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 26px;
  align-items: start;
}

.calculator-content { min-width: 0; }
.input-section .subsection-heading { margin-top: 0; }

.input-panel {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border: 1px solid #343f51;
  border-radius: 10px;
  background: #121722;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-wide { grid-column: 1 / -1; }
.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: #d9e2f2;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field small { display: block; margin-top: 5px; color: var(--muted-dark); font-size: 11px; line-height: 1.4; }

input, select {
  width: 100%;
  height: 54px;
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid #3e4a5e;
  border-radius: 10px;
  outline: 0;
  background: var(--surface-input);
  color: #edf2fb;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input::placeholder { color: #697589; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.13); }

.input-with-prefix, .input-with-suffix { position: relative; }
.input-with-prefix > span, .input-with-suffix > span {
  position: absolute;
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
  color: #8f9bad;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}
.input-with-prefix > span { left: 16px; }
.input-with-prefix input { padding-left: 34px; }
.input-with-suffix > span { right: 16px; }
.input-with-suffix input { padding-right: 34px; }

.mutation-picker { margin-top: 34px; }
.mutation-picker .subsection-heading { margin-top: 0; }

.mutation-group { margin-top: 18px; padding: 20px; border: 1px solid #303a4b; border-radius: 16px; background: rgba(18, 24, 33, 0.82); box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18); }
.mutation-group:first-child { margin-top: 0; }

.mutation-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 15px; padding: 0 0 13px; border-bottom: 1px solid #303a4b; }
.mutation-group-heading h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}
.mutation-group-heading > span { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border: 1px solid #3b4759; border-radius: 999px; background: #1a2230; color: #8f9bad; font-size: 11px; font-weight: 700; }

.mutation-group h4 {
  margin: 18px 0 10px;
  color: var(--subgroup-color, var(--purple));
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}
.mutation-group h4.is-moonlit-event { color: color-mix(in srgb, var(--subgroup-color, var(--purple)) 45%, #cbd5e7); }
.mutation-group h4.is-rain-event { color: color-mix(in srgb, var(--subgroup-color, #0072ff) 38%, #cbd5e7); }

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

.mutation-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  grid-template-areas:
    "name check"
    "value check";
  column-gap: 9px;
  row-gap: 5px;
  align-items: center;
  min-width: 0;
  min-height: 68px;
  padding: 11px 11px 11px 14px;
  border: 1px solid #364255;
  border-radius: 9px;
  background: linear-gradient(140deg, #1a2230, #141a24);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18), inset 3px 0 var(--mutation-glow);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.mutation-card.has-gradient::before {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 2px;
  border-radius: inherit;
  background: var(--mutation-gradient);
  z-index: 2;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.mutation-card.has-gradient { border-color: transparent; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18); }
.mutation-card.has-gradient > * { z-index: 3; }
.mutation-card:hover { transform: translateY(-2px); border-color: #526078; background: linear-gradient(140deg, #202a3a, #171e29); }
.mutation-card.is-selected { border-color: var(--mutation-glow); background: linear-gradient(125deg, color-mix(in srgb, var(--mutation-glow), #18202c 86%), #18202c); box-shadow: 0 0 0 1px var(--mutation-glow), 0 12px 28px rgba(0, 0, 0, 0.27); }
.mutation-card.has-gradient.is-selected { border-color: transparent; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3), 0 0 14px rgba(169, 133, 255, 0.2); }
.mutation-card.is-disabled { cursor: not-allowed; opacity: 0.55; filter: saturate(0.55); }
.mutation-card.is-disabled:hover { transform: none; background: #171d28; }
.mutation-card.is-disabled .mutation-check { background: #202633; }
.mutation-card.is-requirement-disabled { cursor: not-allowed; opacity: 0.48; filter: saturate(0.55); }
.mutation-card.is-requirement-disabled:hover { transform: none; background: linear-gradient(140deg, #1a2230, #141a24); }
.mutation-card:has(input:focus-visible) { outline: 2px solid #fff; outline-offset: 2px; }
.mutation-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.mutation-check {
  grid-area: check;
  align-self: center;
  position: relative;
  width: 20px;
  height: 20px;
  border: 1px solid #657086;
  border-radius: 50%;
  background: #10151e;
}

.mutation-card.is-selected .mutation-check { border-color: var(--mutation-glow); background: var(--mutation-glow); box-shadow: 0 0 12px color-mix(in srgb, var(--mutation-glow), transparent 45%); }
.mutation-card.is-selected .mutation-check::after { content: ""; position: absolute; top: 4px; left: 6px; width: 5px; height: 8px; border: solid #10151e; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.mutation-copy { grid-area: name; min-width: 0; }
.mutation-name { display: block; min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 800; line-height: 1.2; }
.mutation-value { grid-area: value; justify-self: start; max-width: 100%; padding: 3px 6px; overflow: hidden; border: 1px solid #3a4659; border-radius: 5px; background: #10151e; color: #bac4d4; font-size: 10px; font-weight: 800; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }

.result {
  position: sticky;
  top: 20px;
  overflow: hidden;
  border: 1px solid #384458;
  border-radius: 16px;
  background: linear-gradient(155deg, #19212d, #111720);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.32);
}

.result-topline { height: 5px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent), white 25%)); }
.result > .eyebrow { margin: 18px 18px 0; }
.result > h2 { margin: 4px 18px 16px; color: #fff; font-size: 21px; font-weight: 800; line-height: 1.25; }

.final-value {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 17px 18px;
  border-top: 1px solid #354056;
  border-bottom: 1px solid #354056;
  background: radial-gradient(circle at 100% 0, rgba(var(--accent-rgb), 0.12), transparent 58%), #111620;
}

.final-value span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.final-value b { display: block; width: 100%; overflow: hidden; color: var(--green); font-size: clamp(30px, 3.5vw, 40px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; overflow-wrap: normal; text-overflow: clip; white-space: nowrap; }
.accent-blue .final-value b { color: var(--blue); }

.result-list { margin: 0; }
.result-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 10px 13px; border-bottom: 1px solid #303a4d; }
.result-list dt { color: #aeb9cc; font-size: 11px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.result-list dd { min-width: 0; margin: 0; color: #edf2fb; font-size: 13px; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.result-list .selected-mutations { grid-template-columns: 1fr; }
.result-list .selected-mutations dd { text-align: left; }
.result-list .total-row { background: #1b2230; }
.result-list .total-row dd { color: var(--accent); }

.active-multipliers { display: flex; flex-wrap: wrap; gap: 5px; }
.active-mutation { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--mutation-color); border-radius: 5px; background: color-mix(in srgb, var(--mutation-color), #111620 91%); color: #dfe6f2; font-size: 10px; font-weight: 700; box-shadow: inset 0 0 12px color-mix(in srgb, var(--mutation-color), transparent 88%); }
.active-mutation.has-gradient { border-color: transparent; background: linear-gradient(#111620, #111620) padding-box, var(--mutation-gradient) border-box; }
.active-mutation-name { font-size: 10px; font-weight: 800; }
.active-mutation-value { color: #aeb9cc; white-space: nowrap; }
.no-selection { color: #7f8a9d; font-size: 12px; font-weight: 500; }

.reset-button {
  width: calc(100% - 26px);
  margin: 13px;
  padding: 10px 12px;
  border: 1px solid #465267;
  border-radius: 6px;
  background: #202838;
  color: #dce6f7;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.reset-button:hover { transform: translateY(-1px); background: #2a3549; color: #fff; }

.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 13px; }
.result-actions .reset-button { width: auto; margin: 0; }
.copy-result-button { padding: 10px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #15140e; font-size: 12px; font-weight: 800; cursor: pointer; transition: filter 0.16s ease, transform 0.16s ease; }
.copy-result-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.copy-result-button:disabled { cursor: wait; filter: saturate(0.5); opacity: 0.65; transform: none; }
.copy-status { min-height: 22px; padding: 0 13px 12px; color: var(--green); font-size: 10px; font-weight: 700; line-height: 1.4; text-align: center; }

.mutation-loading, .mutation-error {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 82px;
  padding: 16px 18px;
  border: 1px solid #3f4a5d;
  border-radius: 9px;
  background: linear-gradient(145deg, #1c2330, #141923);
}
.mutation-loading > span { width: 25px; height: 25px; flex: 0 0 auto; border: 3px solid #354056; border-top-color: var(--purple); border-radius: 50%; animation: mutation-spin 0.8s linear infinite; }
.mutation-loading div, .mutation-error { color: #aeb9cc; }
.mutation-loading strong, .mutation-error strong { display: block; color: #eef3ff; font-size: 13px; }
.mutation-loading small, .mutation-error span { display: block; margin-top: 2px; color: #8894a8; font-size: 11px; }
.mutation-error { display: block; border-color: #79505a; border-left: 4px solid #ff7f87; }
@keyframes mutation-spin { to { transform: rotate(360deg); } }

.guide-dialog {
  width: min(520px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid #536178;
  border-top: 4px solid var(--blue);
  border-radius: 11px;
  background: #171d28;
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.guide-dialog::backdrop { background: rgba(5, 7, 10, 0.78); backdrop-filter: blur(4px); }
.guide-shell { position: relative; padding: 23px 24px 20px; }

.guide-close {
  position: absolute;
  top: 13px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #465267;
  border-radius: 6px;
  background: #202838;
  color: #dce5f5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.guide-close:hover { background: #2a3549; color: #fff; }
.guide-progress { display: flex; gap: 6px; padding-right: 50px; }
.guide-progress span { width: 26px; height: 3px; border-radius: 3px; background: #354056; transition: background 0.18s ease, width 0.18s ease; }
.guide-progress span.active { width: 38px; background: var(--blue); }
.guide-step { display: none; min-height: 220px; padding: 27px 0 18px; }
.guide-step.active { display: block; }
.guide-number { float: right; margin-top: 20px; color: rgba(104, 169, 255, 0.13); font-size: 76px; font-weight: 800; letter-spacing: -0.06em; line-height: 0.8; }
.guide-step .eyebrow { color: var(--blue); }
.guide-step h2 { max-width: 350px; margin: 7px 0 11px; color: #fff; font-size: 27px; font-weight: 800; line-height: 1.16; }
.guide-step p { max-width: 405px; margin: 0; color: #bdc8dc; font-size: 14px; line-height: 1.65; }

.guide-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; padding-top: 15px; border-top: 1px solid #354056; }
.guide-actions > span { color: #8e9aaf; font-size: 11px; font-weight: 700; text-align: center; }
.guide-actions button { min-height: 38px; padding: 8px 13px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }
.guide-secondary { border: 1px solid #465267; background: #202838; color: #dce5f5; }
.guide-secondary:disabled { opacity: 0.35; cursor: default; }
.guide-primary { border: 1px solid var(--blue); background: var(--blue); color: #101721; }
.guide-primary:hover { background: #87bbff; }

.footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 26px; padding: 16px 18px 7px; color: #8f9095; font-family: "Montserrat", sans-serif; font-size: 12px; font-weight: 800; }
.footer a { color: #c9cbd1; text-decoration: none; transition: color 0.16s ease; }
.footer a:hover { color: #fff; }
.footer-github { display: inline-flex; align-items: center; justify-content: center; color: #d3d5da !important; }
.footer-github svg { width: 17px; height: 17px; fill: currentColor; }

@media (max-width: 980px) {
  .calculator-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .mutation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  body { padding: 16px 12px 34px; }
  .app-page { padding: 20px 18px 18px; }
  .calculator-layout { grid-template-columns: 1fr; }
  .result { position: relative; top: auto; }
  .page-hero { padding: 25px 22px 24px; }
  .section-heading, .subsection-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .section-heading p, .subsection-heading p { text-align: left; }
}

@media (max-width: 520px) {
  .inputs, .reverse-inputs, .mutation-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .input-panel { padding: 16px; }
  .page-hero h1 { font-size: 30px; }
  .page-hero p { font-size: 14px; }
  .help-button { margin-left: 0; }
  .guide-shell { padding: 20px 18px 17px; }
  .guide-step { min-height: 245px; }
  .guide-number { font-size: 62px; }
  .app-page { padding: 14px 12px; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
