:root {
  --ink: #17202a;
  --muted: #64717f;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: rgba(23, 32, 42, 0.14);
  --charcoal: #263238;
  --teal: #118c8b;
  --rose: #e85d75;
  --marigold: #f9b115;
  --mint: #cceadf;
  --shadow: 0 22px 70px rgba(23, 32, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 250, 240, 0.88) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 250, 240, 0.88) 1px, transparent 1px),
    linear-gradient(135deg, #f8dfca 0%, #f8f3dd 38%, #d4ece5 100%);
  background-size: 28px 28px, 28px 28px, auto;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: rgba(255, 250, 240, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--charcoal);
  border-radius: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.round-status {
  max-width: 42vw;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
  text-align: right;
}

main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.setup-view {
  min-height: calc(100svh - 112px);
  display: none;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 520px);
  align-items: center;
  gap: clamp(28px, 6vw, 86px);
}

.setup-view.is-active {
  display: grid;
}

.setup-copy {
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 20px;
  font-size: clamp(3.2rem, 8vw, 7.6rem);
  line-height: 0.88;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.setup-copy p:not(.eyebrow),
.reveal-heading p,
.handoff-panel p:not(.eyebrow) {
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.55;
}

.setup-panel,
.handoff-panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.setup-panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

textarea,
input[type="number"],
input[type="file"] {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

textarea {
  resize: vertical;
  min-height: 120px;
  padding: 14px;
  line-height: 1.45;
}

input[type="number"],
input[type="file"] {
  min-height: 48px;
  padding: 10px 12px;
}

textarea:focus,
input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(17, 140, 139, 0.14);
}

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

.starter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.starter-row button,
.secondary-action {
  min-height: 42px;
  color: var(--charcoal);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 850;
}

.starter-row button {
  padding: 0 12px;
  font-size: 0.88rem;
}

.primary-action,
.secondary-action,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-action {
  gap: 10px;
  min-height: 52px;
  padding: 0 20px;
  color: #111827;
  background: var(--marigold);
  border: 0;
  border-radius: 8px;
  font-weight: 950;
  box-shadow: 0 14px 34px rgba(249, 177, 21, 0.25);
}

.primary-action svg,
.tool-button svg {
  width: 20px;
  height: 20px;
}

.handoff-view.is-active {
  min-height: calc(100svh - 112px);
  display: grid;
  place-items: center;
}

.handoff-panel {
  width: min(560px, 100%);
  padding: clamp(24px, 5vw, 48px);
  text-align: center;
}

.handoff-panel .primary-action {
  margin-top: 10px;
}

.play-view.is-active {
  display: grid;
  gap: 18px;
}

.play-topbar,
.play-actions,
.reveal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.play-topbar h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
}

.timer {
  min-width: 104px;
  padding: 12px 14px;
  color: #fff;
  background: var(--charcoal);
  border-radius: 8px;
  font-size: 1.35rem;
  font-weight: 950;
  text-align: center;
}

.timer.is-hidden {
  visibility: hidden;
}

.source-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
}

.prompt-source,
.drawing-source {
  min-height: 140px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px dashed rgba(38, 50, 56, 0.25);
  border-radius: 8px;
}

.prompt-source span,
.drawing-source span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.prompt-source p {
  margin-bottom: 12px;
  font-size: 1.18rem;
  font-weight: 850;
  line-height: 1.35;
}

.prompt-source img,
.drawing-source img {
  max-height: 220px;
  width: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.drawing-source {
  display: none;
}

.drawing-source.is-visible {
  display: block;
}

.prompt-source.is-hidden {
  display: none;
}

.studio {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.toolbox {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-row {
  display: grid;
  gap: 8px;
}

.tool-button {
  width: 54px;
  height: 54px;
  color: var(--charcoal);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-button.is-active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.color-control {
  display: block;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="color"] {
  width: 76px;
  height: 76px;
  padding: 0;
  border: 0;
  transform: translate(-11px, -11px);
}

.range-control {
  gap: 8px;
  align-items: center;
  text-align: center;
}

.range-control input {
  width: 54px;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: var(--teal);
}

.canvas-shell {
  min-width: 0;
  padding: clamp(8px, 1.5vw, 14px);
  background: var(--charcoal);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

canvas {
  width: 100%;
  aspect-ratio: 1100 / 720;
  display: block;
  touch-action: none;
  background: #fffdf7;
  border-radius: 6px;
}

.play-actions {
  padding-bottom: 18px;
}

.secondary-action {
  padding: 0 16px;
}

.reveal-view.is-active {
  display: grid;
  gap: 22px;
}

.reveal-heading {
  max-width: 780px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.timeline-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline-item strong {
  font-size: 1rem;
}

.timeline-item p {
  color: var(--muted);
  line-height: 1.45;
}

.timeline-item img {
  width: 100%;
  aspect-ratio: 1100 / 720;
  object-fit: contain;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 6px;
}

@media (max-width: 820px) {
  .round-status {
    max-width: 48vw;
    font-size: 0.82rem;
  }

  .setup-view.is-active,
  .source-area {
    grid-template-columns: 1fr;
  }

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

  .toolbox {
    grid-template-columns: auto auto auto 1fr;
    align-items: center;
  }

  .tool-row {
    grid-auto-flow: column;
  }

  .range-control {
    justify-self: end;
  }

  .range-control input {
    width: 110px;
    writing-mode: horizontal-tb;
    direction: ltr;
  }

  .play-topbar,
  .play-actions,
  .reveal-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  main {
    padding-inline: 12px;
  }

  .app-header {
    padding-inline: 12px;
  }

  .brand span:last-child {
    display: none;
  }

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

  .toolbox {
    grid-template-columns: 1fr 54px;
  }

  .tool-row {
    grid-auto-flow: column;
    justify-content: start;
  }

  .range-control {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: left;
  }

  .range-control input {
    width: 100%;
  }
}
