:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #5f6d67;
  --paper: #fffdf8;
  --canvas: #f5efe6;
  --line: #ded6c9;
  --green: #17695f;
  --green-dark: #0e423c;
  --red: #b4433f;
  --gold: #e9a93d;
  --blue: #2f6fa3;
  --shadow: 0 18px 48px rgba(34, 39, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(23, 105, 95, 0.08), transparent 34%),
    linear-gradient(245deg, rgba(233, 169, 61, 0.14), transparent 36%),
    var(--canvas);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#root {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}

span,
strong,
button,
label,
div,
section,
article {
  min-width: 0;
}

.welcome-shell {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(420px, 510px);
  justify-content: center;
  align-items: center;
  gap: 32px;
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 38px 0;
}

.welcome-art {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(160, 122, 88, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 249, 239, 0.46)),
    linear-gradient(145deg, rgba(23, 105, 95, 0.1), transparent 48%),
    #eadfd1;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.welcome-art img {
  width: min(84%, 430px);
  filter: drop-shadow(0 18px 22px rgba(44, 37, 28, 0.16));
}

.welcome-panel,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.welcome-panel {
  justify-self: center;
  width: 100%;
  max-width: 510px;
  padding: 36px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.25;
  text-transform: uppercase;
}

.eyebrow.compact {
  font-size: 0.78rem;
}

.welcome-panel h1,
.result-card h1 {
  max-width: 760px;
  margin: 14px 0 12px;
  font-size: 3.35rem;
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.52;
}

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

.meta-grid div,
.summary-card,
.mini-score {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.meta-grid div {
  min-height: 78px;
  padding: 12px;
}

.meta-grid span,
.summary-card span,
.mini-score span,
.start-form label span,
.comment-field span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.meta-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

.start-form {
  display: grid;
  gap: 15px;
}

.start-form label,
.comment-field {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfc5b7;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input,
select {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 116px;
  padding: 13px 14px;
  line-height: 1.48;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(23, 105, 95, 0.13);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.primary-action {
  border: 1px solid var(--green-dark);
  color: #fff;
  background: var(--green);
}

.primary-action:hover:not(:disabled) {
  background: var(--green-dark);
}

.secondary-action {
  border: 1px solid var(--line);
  color: var(--green-dark);
  background: #fffdf8;
}

.secondary-action:hover:not(:disabled) {
  border-color: #b9ad9d;
  background: #fff8eb;
}

.connection-note,
.error-banner,
.review-note {
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 8px;
}

.connection-note {
  margin: 16px 0 0;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.connection-note.ready {
  color: var(--green-dark);
  background: rgba(23, 105, 95, 0.1);
}

.connection-note.demo {
  color: #7b4b18;
  background: rgba(233, 169, 61, 0.18);
}

.app-shell {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 32px rgba(34, 39, 36, 0.08);
}

.app-header h1 {
  margin: 8px 0 6px;
  font-size: 2.15rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

.timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 112px;
  min-height: 46px;
  border: 1px solid rgba(23, 105, 95, 0.22);
  border-radius: 8px;
  color: var(--green-dark);
  background: rgba(23, 105, 95, 0.09);
  font-size: 1.1rem;
  font-weight: 860;
}

.timer.danger {
  border-color: rgba(180, 67, 63, 0.28);
  color: var(--red);
  background: rgba(180, 67, 63, 0.1);
}

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

.stage-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffaf1;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.stage-tab small {
  color: var(--muted);
  font-weight: 800;
}

.stage-tab.active {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.stage-tab.active small {
  color: rgba(255, 255, 255, 0.78);
}

.error-banner {
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--red);
  background: rgba(180, 67, 63, 0.1);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.stage-panel,
.summary-panel {
  display: grid;
  gap: 14px;
}

.stage-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
}

.stage-heading h2 {
  margin: 5px 0 0;
  font-size: 2.2rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.stage-heading p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.stage-number,
.question-kicker {
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.question-stack {
  display: grid;
  gap: 14px;
}

.question-card,
.creative-card {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.question-card h3,
.creative-card h3 {
  margin: 4px 0 0;
  font-size: 1.1rem;
  line-height: 1.42;
}

.options-grid {
  display: grid;
  gap: 10px;
}

.option {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid #d6cdbf;
  border-radius: 8px;
  color: var(--ink);
  background: #fffaf3;
  text-align: left;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.option:hover {
  border-color: rgba(23, 105, 95, 0.46);
}

.option.selected {
  border-color: var(--green);
  background: rgba(23, 105, 95, 0.1);
  box-shadow: inset 4px 0 0 var(--green);
}

.option-letter {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--green-dark);
  background: #e8f1ed;
  font-weight: 900;
}

.option.selected .option-letter {
  color: #fff;
  background: var(--green);
}

.prompt-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.prompt-list li {
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  color: var(--muted);
  font-weight: 720;
  line-height: 1.35;
}

.comment-field.large textarea {
  min-height: 240px;
}

.summary-panel {
  position: sticky;
  top: 18px;
}

.summary-card,
.mini-score {
  padding: 15px;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  color: var(--green-dark);
  font-size: 2.1rem;
}

.summary-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.mini-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mini-score strong {
  color: var(--green-dark);
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
}

.result-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
}

.result-card {
  display: grid;
  justify-items: center;
  width: min(620px, 100%);
  padding: 40px;
  text-align: center;
}

.result-card h1 {
  font-size: 3.15rem;
}

.result-card p {
  color: var(--muted);
}

.email-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 760;
  overflow-wrap: anywhere;
  text-align: left;
}

.email-status.success {
  color: var(--green-dark);
  background: rgba(23, 105, 95, 0.1);
}

.email-status.warning {
  color: #7b4b18;
  background: rgba(233, 169, 61, 0.18);
}

.result-icon {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin-bottom: 8px;
}

.result-icon.success {
  color: var(--green-dark);
  background: rgba(23, 105, 95, 0.12);
}

.result-icon.local {
  color: #7b4b18;
  background: rgba(233, 169, 61, 0.18);
}

.result-score {
  display: grid;
  gap: 4px;
  min-width: 210px;
  margin: 12px 0 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.result-score span {
  color: var(--muted);
  font-weight: 760;
}

.result-score strong {
  color: var(--green-dark);
  font-size: 2.4rem;
}

.review-note {
  max-width: 480px;
  margin-bottom: 22px;
  padding: 12px 14px;
  color: var(--green-dark);
  background: rgba(23, 105, 95, 0.1);
  text-align: left;
}

@media (max-width: 980px) {
  .welcome-shell,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .welcome-shell {
    width: min(720px, calc(100% - 28px));
    min-height: auto;
    gap: 18px;
    padding: 22px 0 28px;
  }

  .welcome-art {
    aspect-ratio: 16 / 7;
  }

  .welcome-art img {
    width: min(70%, 420px);
  }

  .welcome-panel {
    max-width: none;
  }

  .summary-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .welcome-shell {
    width: min(100% - 20px, 640px);
    padding: 10px 0 22px;
  }

  .welcome-art {
    aspect-ratio: 16 / 8;
  }

  .welcome-art img {
    width: min(78%, 320px);
  }

  .welcome-panel {
    padding: 20px;
  }

  .welcome-panel h1,
  .result-card h1 {
    font-size: 2.25rem;
    line-height: 1.08;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0;
  }

  .meta-grid div {
    min-height: 72px;
  }

  .prompt-list,
  .summary-panel {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 10px;
  }

  .app-header {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .app-header h1 {
    font-size: 1.65rem;
  }

  .timer {
    width: 100%;
  }

  .stage-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stage-tab {
    min-height: 44px;
    padding: 8px;
  }

  .stage-heading,
  .controls {
    flex-direction: column;
  }

  .stage-heading {
    padding: 15px;
  }

  .stage-heading h2 {
    font-size: 1.75rem;
  }

  .stage-heading p {
    max-width: none;
  }

  .question-card,
  .creative-card {
    padding: 15px;
  }

  .option {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .option-letter {
    width: 32px;
    height: 32px;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .result-card {
    padding: 24px 18px;
  }
}

@media (max-width: 420px) {
  .welcome-panel h1,
  .result-card h1 {
    font-size: 1.92rem;
  }

  .eyebrow {
    font-size: 0.75rem;
  }

  .lead,
  .connection-note {
    font-size: 0.9rem;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  input,
  select {
    min-height: 46px;
  }
}

@media (max-width: 360px) {
  .stage-nav {
    grid-template-columns: 1fr;
  }

  .stage-tab {
    justify-content: flex-start;
  }
}
