:root {
  color-scheme: light dark;
  --bg-top: #f4f7fa;
  --bg-bottom: #dde6ee;
  --surface: #ffffff;
  --surface-alt: #edf3f7;
  --text: #0f1a2d;
  --muted: #4f6072;
  --brand: #0f4c5c;
  --brand-strong: #0a3440;
  --accent: #ea572e;
  --accent-strong: #c84a27;
  --danger: #9a1c1c;
  --outline: #9fb3c2;
  --secondary-button: #d3dce5;
  --yellow: #f4c430;
  --orange: #ea572e;
  --red: #b62626;
  --blue: #1f5fbf;
  --step-idle: #93a8bb;
  --shadow: 0 10px 24px rgba(11, 36, 57, 0.15);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #131c27;
    --bg-bottom: #1a2734;
    --surface: #1f2c3b;
    --surface-alt: #253648;
    --text: #ecf2f8;
    --muted: #c2d0de;
    --brand: #0f4c5c;
    --brand-strong: #0a3440;
    --accent: #ea572e;
    --accent-strong: #ff7b56;
    --danger: #ff8f8f;
    --outline: #5d7488;
    --secondary-button: #4f6174;
    --yellow: #d8af2c;
    --orange: #ea572e;
    --red: #c74444;
    --blue: #3a77d4;
    --step-idle: #607b92;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.app-header {
  padding: 1rem 1rem 0.75rem;
  background: radial-gradient(125% 85% at 100% 0%, #1a6c81 0%, var(--brand) 44%, var(--brand-strong) 100%);
  color: #f9fbff;
  box-shadow: var(--shadow);
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 2rem);
  letter-spacing: 0.01em;
}

h2,
h3 {
  text-align: center;
}

.subtitle {
  margin: 0.25rem 0 0;
  opacity: 0.94;
}

main {
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

#status {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rule-list {
  display: grid;
  gap: 0.7rem;
}

.rule-tile {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-alt));
  text-align: left;
  padding: 1rem;
  box-shadow: var(--shadow);
  color: var(--text);
}

.rule-tile:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.rule-code {
  display: block;
  font-size: clamp(1.45rem, 6vw, 2rem);
  font-weight: 800;
}

.rule-description {
  display: block;
  margin-top: 0.2rem;
  font-size: clamp(1rem, 4vw, 1.2rem);
  color: var(--muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 36, 0.66);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  width: min(680px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.step-indicator {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin: 0.2rem 0 0.5rem;
}

.step-orb {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--step-idle);
  opacity: 0.55;
}

.step-orb.active {
  opacity: 1;
  outline: 2px solid rgba(234, 87, 46, 0.65);
  outline-offset: 2px;
}

#modal-heading {
  text-align: center;
}

.wizard-step {
  margin-top: 0.5rem;
}

.step-title {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.choice-grid {
  display: grid;
  gap: 0.65rem;
}

.choice-button {
  width: 100%;
  text-align: center;
}

.choice-button.selected {
  box-shadow: inset 0 0 0 3px #ffffff;
  filter: brightness(1.05);
}

.choice-button[data-tone="yellow"] {
  background: var(--yellow);
  color: #1f1a10;
}

.choice-button[data-tone="orange"] {
  background: var(--orange);
  color: #fff9f7;
}

.choice-button[data-tone="red"] {
  background: var(--red);
  color: #fff7f7;
}

.choice-button[data-tone="blue"] {
  background: var(--blue);
  color: #f6f9ff;
}

.choice-button[data-tone="yellow"]:hover {
  background: #ffd147;
}

.choice-button[data-tone="orange"]:hover {
  background: #ff7149;
}

.choice-button[data-tone="red"]:hover {
  background: #cf3333;
}

.choice-button[data-tone="blue"]:hover {
  background: #2f71d1;
}

.selected-rule {
  margin-top: 0;
  color: var(--muted);
  text-align: center;
}

fieldset {
  margin: 0 0 1rem;
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
}

legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

label {
  display: block;
  margin-bottom: 0.45rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

input[type="text"],
input[type="number"],
input[type="tel"],
#team-number {
  width: 100%;
  border: 1px solid var(--outline);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 1rem;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.wizard-actions {
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
}

.wizard-actions-left {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #f9fcff;
  padding: 0.72rem 1rem;
  font-size: 1rem;
  font-weight: 700;
}

button.secondary {
  background: var(--secondary-button);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .actions button:hover,
  .wizard-actions button:hover {
    background: var(--accent-strong);
  }

  .actions button.secondary:hover,
  .wizard-actions button.secondary:hover {
    filter: brightness(1.08);
  }
}

#result-view {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1rem;
}

#result-view .actions {
  margin-top: 0.8rem;
}

#result-view .actions button {
  width: 100%;
}

.result-reminder {
  margin: 0 0 0.6rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
}

.result-note {
  margin: 0.2rem 0 0.8rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.95rem;
}

.script-output {
  font-size: clamp(1.2rem, 5vw, 1.85rem);
  line-height: 1.45;
  margin: 0.8rem 0;
}

.form-error {
  margin: 0.6rem 0 0;
  color: var(--danger);
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 760px) {
  main {
    padding: 1.25rem;
  }

  .rule-tile {
    padding: 1.1rem 1.2rem;
  }
}
