:root {
  color-scheme: light;
  --ink: #20313d;
  --muted: #5f6d76;
  --paper: #ffffff;
  --canvas: #f7f3e8;
  --line: #d8e0e5;
  --blue: #245f73;
  --blue-soft: #e3f0f4;
  --yellow: #f6c95e;
  --yellow-soft: #fff4cc;
  --coral: #e66b5b;
  --coral-soft: #ffebe7;
  --green: #3f7d64;
  --green-soft: #e3f2eb;
  --focus: #165cca;
  --shadow: 0 14px 34px rgba(32, 49, 61, 0.1);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin-inline: auto;
  background: var(--paper);
  border-inline: 1px solid rgba(32, 49, 61, 0.08);
}

.app-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 42px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  text-decoration: none;
}

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(32, 49, 61, 0.12);
}

.language-picker select,
.select-control select {
  min-height: 44px;
  padding: 0 36px 0 12px;
  background: var(--paper);
  border: 1px solid #b8c4cb;
  border-radius: 6px;
  font-weight: 800;
}

.screen {
  width: 100%;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.55rem, 7vw, 5.2rem);
}

h2 {
  font-size: clamp(1.65rem, 4vw, 2.5rem);
}

p {
  line-height: 1.55;
}

.hero-band {
  min-height: 500px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  align-items: center;
  gap: clamp(38px, 7vw, 88px);
  padding: clamp(52px, 8vw, 92px) clamp(22px, 6vw, 76px);
  background: var(--yellow-soft);
  border-bottom: 1px solid #eadba7;
}

.hero-copy .lead {
  max-width: 650px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.14rem;
}

.paper-preview {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 4 / 5;
  justify-self: center;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 18px 18px 0 var(--coral);
}

.paper-preview::before,
.paper-preview::after,
.paper-line {
  position: absolute;
  inset-inline: 10%;
  height: 0;
  border-top: 2px dashed #d8e0e5;
  content: "";
}

.paper-preview::before {
  top: 28%;
}

.paper-preview::after {
  top: 72%;
}

.paper-line {
  top: 50%;
}

.paper-letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #dce5e9;
  font-size: clamp(6.5rem, 16vw, 11rem);
  font-weight: 900;
}

.paper-stroke {
  position: absolute;
  width: 50%;
  height: 22%;
  left: 23%;
  top: 52%;
  border-bottom: 16px solid var(--blue);
  border-left: 16px solid var(--blue);
  border-radius: 0 0 0 80px;
  transform: rotate(-14deg);
}

.resume-band,
.quick-band,
.promise-band {
  display: grid;
  align-items: center;
  gap: 28px;
  padding: 34px clamp(22px, 6vw, 76px);
}

.resume-band {
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--green-soft);
  border-bottom: 1px solid #bfdccc;
}

.quick-band {
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--blue-soft);
  border-bottom: 1px solid #c8dde4;
}

.quick-actions {
  min-width: 180px;
  display: grid;
  gap: 10px;
}

.resume-actions {
  min-width: 190px;
  display: grid;
  gap: 10px;
}

.resume-band p:not(.eyebrow),
.quick-band p:not(.eyebrow),
.promise-band p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.danger-button,
.icon-text-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 6px;
  font-weight: 900;
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 7px 0 #183f4d;
}

.primary-button:hover {
  background: #1d5264;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 #183f4d;
}

.secondary-button {
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
}

.danger-button {
  color: #ffffff;
  background: #9d2e25;
}

.danger-button:hover {
  background: #84241d;
}

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

.full-button {
  width: 100%;
}

.progress-band,
.practice-band {
  padding: clamp(46px, 7vw, 72px) clamp(22px, 6vw, 76px);
}

.progress-band {
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.text-button {
  min-height: 44px;
  padding: 0 4px;
  color: var(--blue);
  background: transparent;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.stat {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  border: 1px solid rgba(32, 49, 61, 0.12);
  border-radius: 8px;
}

.stat strong {
  font-size: 2.3rem;
}

.stat span {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
}

.stat-blue {
  background: var(--blue-soft);
}

.stat-coral {
  background: var(--coral-soft);
}

.status-line,
.draw-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: #9d2e25;
  font-weight: 800;
}

.practice-band {
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1.45fr);
  gap: 28px 38px;
  margin: 34px 0;
}

.select-control {
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-weight: 900;
}

.control-group {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.control-group legend {
  margin-bottom: 9px;
  font-weight: 900;
}

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

.option-grid label,
.segmented-control label {
  position: relative;
  min-width: 0;
}

.option-grid input,
.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-grid span,
.segmented-control span {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid #b8c4cb;
  border-radius: 6px;
  background: var(--paper);
  font-weight: 850;
  cursor: pointer;
}

.option-grid input:checked + span,
.segmented-control input:checked + span {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.option-grid input:focus-visible + span,
.segmented-control input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.option-grid input:disabled + span,
.segmented-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.scope-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.promise-band {
  grid-template-columns: 72px minmax(0, 1fr);
  background: var(--green-soft);
}

.promise-mark,
.result-mark {
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--green);
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 900;
}

.promise-mark {
  width: 64px;
  height: 64px;
}

.game-screen {
  min-height: calc(100vh - 78px);
  padding: 28px clamp(18px, 6vw, 76px) 58px;
  background: #fbfcfd;
}

.game-topbar {
  min-height: 52px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
}

.game-topbar > strong {
  text-align: center;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #b8c4cb;
  border-radius: 6px;
  font-size: 1.45rem;
}

.calm-label {
  padding: 7px 10px;
  color: #265c49;
  background: var(--green-soft);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 900;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 14px 0 34px;
  background: #e1e7eb;
  border-radius: 4px;
}

.progress-track span {
  width: 20%;
  height: 100%;
  display: block;
  background: var(--coral);
  transition: width 180ms ease;
}

.trace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.trace-heading h1 {
  font-size: clamp(3.2rem, 10vw, 6rem);
}

.trace-heading > p {
  max-width: 320px;
  margin: 0 0 8px;
  color: var(--muted);
}

.canvas-frame {
  width: min(100%, 650px);
  aspect-ratio: 1;
  margin-inline: auto;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#trace-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.tool-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  margin: 22px 0 6px;
}

.pen-control {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.pen-control input {
  width: 100%;
  accent-color: var(--blue);
}

.icon-text-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #b8c4cb;
  border-radius: 6px;
  font-weight: 900;
}

.result-screen {
  min-height: calc(100vh - 78px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 54px 22px;
  text-align: center;
  background: var(--yellow-soft);
}

.result-mark {
  width: 92px;
  height: 92px;
  margin-bottom: 30px;
  background: var(--blue);
  font-size: 3.2rem;
}

.result-screen h1 {
  max-width: 760px;
}

.result-copy {
  max-width: 620px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 34px;
}

.share-status {
  min-height: 24px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.share-fallback-link {
  margin-top: 8px;
  color: var(--blue);
  font-weight: 900;
  text-underline-offset: 4px;
}

.confirm-dialog {
  width: min(calc(100% - 32px), 480px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(32, 49, 61, 0.22);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(32, 49, 61, 0.24);
}

.confirm-dialog::backdrop {
  background: rgba(32, 49, 61, 0.58);
}

.confirm-dialog-body {
  padding: 28px;
}

.confirm-dialog-body p {
  margin: 14px 0 0;
  color: var(--muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
}

.app-footer {
  min-height: 86px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 22px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.app-footer a {
  color: var(--muted);
  font-weight: 800;
  text-underline-offset: 4px;
}

@media (max-width: 760px) {
  .app-shell {
    border: 0;
  }

  .app-header {
    min-height: 70px;
  }

  .brand img {
    width: 42px;
    height: 42px;
  }

  .hero-band {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 34px;
    padding-block: 42px 56px;
  }

  .paper-preview {
    width: min(78vw, 310px);
    box-shadow: 12px 12px 0 var(--coral);
  }

  .resume-band,
  .quick-band {
    grid-template-columns: 1fr;
  }

  .resume-actions,
  .resume-actions button,
  .quick-actions,
  .quick-actions button {
    width: 100%;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .section-heading {
    align-items: center;
  }

  .promise-band {
    grid-template-columns: 1fr;
  }

  .trace-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .tool-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pen-control {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .app-header {
    gap: 10px;
    padding-inline: 14px;
  }

  .brand {
    gap: 8px;
    font-size: 1rem;
  }

  .language-picker select {
    max-width: 130px;
  }

  .hero-band,
  .resume-band,
  .quick-band,
  .progress-band,
  .practice-band,
  .promise-band {
    padding-inline: 18px;
  }

  h1 {
    font-size: 2.65rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  .stat-grid,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: 96px;
  }

  .game-screen {
    padding-inline: 14px;
  }

  .game-topbar {
    grid-template-columns: 44px 1fr auto;
  }

  .calm-label {
    max-width: 104px;
    text-align: center;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
/* Local, read-only drawing previews; no scoring or editable canvas in history. */
.history-screen {
  max-width: 720px;
  margin-inline: auto;
  padding: 28px clamp(18px, 6vw, 76px) 58px;
}
.history-entry { margin-block: 16px; padding: 16px; background: white; border: 1px solid #ccd8df; border-radius: 8px; }
.history-entry summary { cursor: pointer; min-height: 44px; font-weight: 700; }
.history-canvas { display: block; width: 100%; max-width: 360px; height: auto; border: 1px solid #ccd8df; border-radius: 8px; }
.history-note { font-size: .875rem; line-height: 1.5; }

@media (max-width: 430px) {
  .history-screen { padding-inline: 14px; }
}
