:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-raised: #eef3ff;
  --segment: #edf1f8;
  --selected: #314da3;
  --text: #121826;
  --muted: #667085;
  --rule: #d8e0f0;
  --accent: #314da3;
  --accent-strong: #243b86;
  --accent-soft: #e7edff;
  --success: #16835f;
  --shadow: 0 18px 46px rgba(49, 77, 163, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.phone-app {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.brand-strip {
  padding: 22px clamp(18px, 5vw, 46px) 6px;
}

.brand-strip img {
  display: block;
  width: min(100%, 520px);
  height: auto;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) 0 max(26px, env(safe-area-inset-bottom));
}

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

.app-header,
.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto minmax(56px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 16px clamp(18px, 5vw, 46px) 12px;
  background: rgba(246, 248, 252, 0.92);
  backdrop-filter: blur(18px);
}

.detail-header {
  grid-template-columns: minmax(118px, 1fr) minmax(0, auto) minmax(46px, 1fr);
  border-bottom: 1px solid var(--rule);
}

h1,
h2,
p {
  margin: 0;
}

h1,
.detail-header h2 {
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.42rem, 4.3vw, 2rem);
  font-weight: 750;
  line-height: 1.12;
  text-align: center;
}

.detail-header h2 {
  max-width: min(58vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-spacer {
  min-width: 44px;
}

.circle-button,
.material-button {
  justify-self: end;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 900;
  cursor: pointer;
}

.material-button {
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 1.9rem;
}

.material-button.is-hidden {
  visibility: hidden;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 320px);
  align-items: center;
  gap: 20px;
  padding: 18px clamp(18px, 5vw, 46px) 12px;
}

.total-check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  line-height: 1;
}

.total-check strong {
  font-weight: 500;
}

.clear-button {
  min-height: 62px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: clamp(1.65rem, 5vw, 2.55rem);
  font-weight: 800;
  cursor: pointer;
}

.completion-text {
  padding: 0 clamp(18px, 5vw, 46px) 12px;
  color: var(--muted);
  font-size: 1rem;
}

.result-card {
  margin: 22px clamp(18px, 5vw, 46px) 40px;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-card.is-hidden {
  display: none;
}

.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-label {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-card h2 {
  margin-top: 2px;
  font-size: clamp(1.1rem, 4vw, 1.45rem);
}

.copy-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  cursor: pointer;
}

.copy-button.did-copy {
  background: var(--success);
}

#resultText {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
  color: var(--text);
  font: 600 1rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

#resultText:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.copy-feedback {
  min-height: 20px;
  margin-top: 8px;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 700;
}

.install-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 22px clamp(18px, 5vw, 46px) 40px;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.install-panel h2 {
  margin: 2px 0 4px;
  font-size: clamp(1rem, 3.8vw, 1.35rem);
}

.install-panel p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.secondary-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--accent);
  font-weight: 850;
  cursor: pointer;
}

.install-hint {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--accent-strong) !important;
  font-weight: 700;
}

.item-list {
  display: grid;
  padding: 0 clamp(18px, 5vw, 46px);
}

.scale-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 48px;
  column-gap: 16px;
  padding: 24px 0 10px;
  border-bottom: 1px solid var(--rule);
}

.item-title {
  min-width: 0;
  font-size: clamp(1.65rem, 5.8vw, 2.4rem);
  font-weight: 430;
  line-height: 1.12;
}

.inline-material-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  align-self: start;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
}

.inline-material-placeholder {
  width: 44px;
}

.status-line {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--accent);
  font-size: clamp(1.45rem, 5vw, 2.15rem);
  line-height: 1.08;
}

.status-line.is-scored {
  color: var(--accent-strong);
}

.info-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  justify-self: end;
  align-self: start;
  border: 4px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}

.score-control {
  grid-column: 1 / -1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(58px, 1fr);
  width: fit-content;
  max-width: 100%;
  min-height: 78px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--segment);
}

.score-control label {
  position: relative;
  display: grid;
  min-width: 78px;
  place-items: center;
  color: var(--text);
  font-size: clamp(1.35rem, 4.7vw, 1.95rem);
  cursor: pointer;
}

.score-control label + label {
  border-left: 2px solid #d7ddea;
}

.score-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.score-control span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 0 14px;
}

.score-control input:checked + span {
  background: var(--selected);
  color: white;
}

.score-control input:focus-visible + span {
  outline: 2px solid var(--accent-strong);
  outline-offset: -3px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: start;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  cursor: pointer;
}

.back-button span:first-child {
  font-size: 2.8rem;
  line-height: 0.7;
}

.back-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-content {
  padding: 52px 0 160px;
}

.section-kicker {
  padding: 0 clamp(18px, 5vw, 46px) 16px;
  color: var(--muted);
  font-size: clamp(1.05rem, 3.6vw, 1.5rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.instruction-panel,
.definition-list {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.instruction-panel {
  padding: 26px clamp(18px, 5vw, 46px);
  color: var(--text);
  font-size: clamp(1.45rem, 5vw, 2.05rem);
  line-height: 1.35;
}

.auto-note {
  padding: 18px clamp(18px, 5vw, 46px) 56px;
  color: var(--muted);
  font-size: clamp(1.05rem, 3.7vw, 1.45rem);
  line-height: 1.28;
}

.definition-row {
  padding: 22px clamp(18px, 5vw, 46px);
  color: var(--text);
  font-size: clamp(1.35rem, 4.7vw, 1.95rem);
  line-height: 1.28;
}

.definition-row + .definition-row {
  border-top: 1px solid var(--rule);
}

.score-dock {
  position: fixed;
  right: max(0px, calc((100vw - 980px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 980px) / 2));
  z-index: 20;
  padding: 14px clamp(18px, 5vw, 46px) max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(246, 248, 252, 0.72), #f6f8fc 34%);
}

.score-dock p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: clamp(1rem, 3.8vw, 1.35rem);
}

.detail-options {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(54px, 1fr);
  width: fit-content;
  max-width: 100%;
  min-height: 62px;
  overflow: hidden;
  border-radius: 13px;
  background: var(--segment);
}

.detail-options button {
  min-width: 62px;
  border: 0;
  border-left: 1px solid #d7ddea;
  background: transparent;
  color: var(--text);
  font-size: 1.45rem;
  cursor: pointer;
}

.detail-options button:first-child {
  border-left: 0;
}

.detail-options button.is-selected {
  background: var(--selected);
  color: white;
}

.material-screen {
  overflow: auto;
}

.material-content {
  display: grid;
  min-height: calc(100dvh - 100px);
  align-items: center;
  padding: 10px clamp(10px, 3vw, 24px) 50px;
}

.material-slide {
  display: none;
  min-height: calc(100dvh - 170px);
  place-items: center;
  padding: 8px 0 56px;
}

.material-slide.is-active {
  display: grid;
}

.scene-card {
  width: 100%;
  padding: 0;
  background: white;
  color: #111;
}

.stimulus-image,
.scene-card img,
.object-grid img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 190px);
  height: auto;
  object-fit: contain;
  object-position: center;
}

.object-grid {
  width: 100%;
  margin: auto;
  padding: 0;
  background: white;
  color: #111;
}

.sentence-board,
.word-board {
  width: 100%;
  min-height: calc(100vh - 180px);
  display: grid;
  align-content: space-evenly;
  justify-items: center;
  gap: 34px;
  padding: 16px clamp(18px, 8vw, 90px) 70px;
  color: var(--text);
  text-align: center;
}

.sentence-board p,
.word-board p {
  font-size: clamp(2.1rem, 8vw, 4.5rem);
  font-weight: 850;
  line-height: 1.15;
}

.word-board p {
  text-transform: uppercase;
}

.pager {
  position: fixed;
  right: 0;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
}

.pager button {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  background: #747478;
  cursor: pointer;
}

.pager button.is-active {
  background: var(--accent);
}

.material-slide:not(.is-active) {
  display: none !important;
}

.guidelines-dialog {
  width: min(92vw, 900px);
  min-height: min(76vh, 900px);
  border: 0;
  border-radius: 18px;
  padding: clamp(28px, 6vw, 56px);
  background: var(--surface);
  color: var(--text);
}

.guidelines-dialog::backdrop {
  background: rgba(18, 24, 38, 0.42);
}

.guidelines-dialog h2,
.guidelines-dialog ul,
.dialog-action {
  position: relative;
}

.guidelines-dialog h2 {
  margin-bottom: 34px;
  font-size: clamp(1.8rem, 5vw, 2.9rem);
  font-weight: 500;
  text-align: center;
}

.guidelines-dialog ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 0 0 1.25em;
  font-size: clamp(1.35rem, 4.7vw, 2.15rem);
  line-height: 1.18;
}

.dialog-action {
  display: block;
  width: min(100%, 320px);
  margin-top: 44px;
  margin-right: auto;
  margin-left: auto;
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

@media (min-width: 760px) {
  .phone-app {
    border-right: 1px solid var(--rule);
    border-left: 1px solid var(--rule);
  }
}

@media (max-width: 520px) {
  .score-row {
    grid-template-columns: 1fr 140px;
    gap: 12px;
  }

  .clear-button {
    min-height: 58px;
    border-radius: 14px;
  }

  .score-control {
    grid-auto-columns: minmax(50px, 1fr);
    min-height: 62px;
  }

  .score-control label {
    min-width: 56px;
  }

  .install-panel {
    grid-template-columns: 1fr;
  }

  .install-actions {
    justify-content: stretch;
  }

  .install-actions button {
    flex: 1 1 140px;
  }
}
