:root {
  --bg: #06101a;
  --bg-deep: #02070c;
  --card: rgba(10, 25, 39, 0.94);
  --card-strong: #0d2134;
  --card-soft: #132c43;
  --line: rgba(116, 151, 178, 0.26);
  --line-strong: rgba(114, 230, 211, 0.42);
  --text: #f3fbff;
  --muted: #a3b7c8;
  --faint: #708699;
  --accent: #00e0b8;
  --accent-strong: #07b99b;
  --accent-dark: #067f71;
  --warn: #ffbf57;
  --danger: #ff5d5d;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  color-scheme: dark;
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Segoe UI",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0, 224, 184, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(255, 93, 93, 0.08), transparent 30rem),
    linear-gradient(160deg, #081c2b 0%, #06101a 44%, #02070c 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  min-height: 100svh;
  padding: 18px;
  display: grid;
  place-items: center;
}

.card {
  width: min(100%, 1080px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 34%),
    var(--card);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 34px);
  animation: cardIn 180ms ease-out;
}

.start-card {
  max-width: 620px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.35rem, 9vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.start-subtitle {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: clamp(1.1rem, 3.5vw, 1.45rem);
  font-weight: 750;
}

.note {
  margin: 0 auto 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(16, 40, 61, 0.86);
  color: var(--text);
  font-size: 1.04rem;
  line-height: 1.45;
}

.mode-actions {
  display: grid;
  gap: 12px;
}

.mode-actions .btn {
  min-height: 62px;
}

.mode-wide {
  grid-column: 1 / -1;
}

.btn {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card-soft);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  font-weight: 800;
  text-align: center;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  outline: none;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled,
.mini-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.btn.primary {
  border-color: rgba(0, 224, 184, 0.45);
  background: linear-gradient(180deg, var(--accent-strong), var(--accent-dark));
  color: #ecfffb;
}

.btn.ghost {
  background: rgba(18, 38, 58, 0.9);
}

.btn.warn {
  border-color: rgba(255, 191, 87, 0.45);
  background: rgba(95, 65, 24, 0.92);
}

.btn.danger {
  border-color: rgba(255, 93, 93, 0.45);
  background: rgba(92, 36, 42, 0.9);
}

.top-row {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.progress-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #61ffe2);
}

.play-area {
  display: grid;
  gap: 18px;
}

.scenario-panel,
.stage-panel,
.order-panel,
.review-panel,
.result-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(9, 23, 36, 0.82);
  padding: clamp(16px, 2.4vw, 22px);
}

.scenario-panel {
  position: relative;
  overflow: hidden;
}

.scenario-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 0%, rgba(0, 224, 184, 0.16), transparent 16rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 40%);
}

.scenario-panel > * {
  position: relative;
}

.scenario-title {
  margin-bottom: 12px;
  font-size: clamp(1.75rem, 5.8vw, 3rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.scenario-prompt {
  margin-bottom: 0;
  color: #dcebf4;
  font-size: clamp(1.04rem, 2.8vw, 1.26rem);
  line-height: 1.48;
}

.compact-scenario {
  margin-bottom: 18px;
}

.compact-scenario .scenario-title {
  font-size: clamp(1.7rem, 5vw, 2.6rem);
}

.stage-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-title {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 4.2vw, 2rem);
  line-height: 1.08;
}

.stage-help {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.current-question {
  margin: 14px 0 0;
  color: #f4fbff;
  font-size: 1.05rem;
  font-weight: 900;
}

.stage-dots {
  display: flex;
  gap: 7px;
  margin-top: 16px;
}

.stage-dot {
  height: 8px;
  flex: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.stage-dot.active {
  background: var(--accent);
}

.stage-dot.done {
  background: rgba(0, 224, 184, 0.36);
}

.update-line,
.hint-line {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 191, 87, 0.12);
  color: #ffe2aa;
  line-height: 1.35;
}

.hint-line {
  background: rgba(0, 224, 184, 0.11);
  color: #bcfff1;
}

.order-panel {
  padding-bottom: 12px;
}

.order-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.order-head h3 {
  margin: 0;
  font-size: 1rem;
}

.order-head span {
  color: var(--faint);
  font-size: 0.9rem;
  font-weight: 800;
}

.order-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
}

.order-item {
  width: auto;
  min-height: 38px;
  justify-content: flex-start;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.92rem;
}

.empty-order {
  margin: 0;
  color: var(--faint);
}

.choice-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.choice {
  justify-content: flex-start;
  min-height: 60px;
  text-align: left;
}

.choice small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.25;
}

.choice.danger-choice {
  border-color: rgba(255, 93, 93, 0.36);
}

.choice.weak-choice {
  border-color: rgba(255, 191, 87, 0.36);
}

.question-choice.correct-choice {
  border-color: rgba(0, 224, 184, 0.72);
  background: rgba(0, 127, 113, 0.82);
}

.question-choice.wrong-choice {
  border-color: rgba(255, 93, 93, 0.72);
  background: rgba(92, 36, 42, 0.9);
}

.question-choice:disabled {
  opacity: 1;
}

.question-explain {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(6, 16, 26, 0.62);
}

.question-explain h3 {
  margin: 0;
  color: var(--accent);
}

.question-explain p {
  margin: 0;
  color: #dcebf4;
  line-height: 1.45;
}

.question-card {
  max-width: 780px;
}

.question-control-bar {
  grid-template-columns: 1fr 1.2fr;
}

.no-choices {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.review-card {
  max-width: 840px;
}

.review-panel {
  background: rgba(9, 22, 35, 0.88);
}

.review-order-list {
  display: grid;
  gap: 10px;
}

.review-order-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(19, 44, 67, 0.86);
  padding: 12px;
  transition:
    border-color 120ms ease,
    opacity 120ms ease,
    transform 120ms ease;
}

.review-order-item.dragging {
  border-color: var(--accent);
  opacity: 0.58;
  transform: scale(0.99);
}

.drag-handle {
  display: grid;
  width: 32px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--faint);
  cursor: grab;
  font-weight: 950;
  letter-spacing: -0.12em;
  touch-action: none;
}

.review-order-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.review-order-copy strong {
  color: var(--text);
  line-height: 1.2;
}

.review-order-copy span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.3;
}

.review-order-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(18, 38, 58, 0.92);
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
}

.mini-btn:not(:disabled):hover,
.mini-btn:not(:disabled):focus-visible {
  border-color: var(--line-strong);
  outline: none;
}

.danger-mini {
  border-color: rgba(255, 93, 93, 0.36);
  background: rgba(92, 36, 42, 0.82);
}

.control-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 10px;
  margin: 18px -6px -10px;
  padding: 12px 6px 10px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(6, 16, 26, 0), rgba(6, 16, 26, 0.95) 18%);
  backdrop-filter: blur(12px);
}

.result-card {
  max-width: 900px;
}

.score-lockup {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 18px;
  text-align: center;
}

.score {
  font-size: clamp(3.8rem, 16vw, 7rem);
  font-weight: 950;
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.score.good {
  color: var(--accent);
}

.score.warn {
  color: var(--warn);
}

.score.danger {
  color: var(--danger);
}

.result-label {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 2rem);
}

.result-grid {
  display: grid;
  gap: 14px;
}

.result-section h3 {
  margin-bottom: 9px;
  font-size: 1rem;
}

.result-section p {
  margin-bottom: 0;
  color: #dcebf4;
  line-height: 1.45;
  white-space: pre-line;
}

.result-section .quiet {
  color: var(--muted);
}

.result-section:nth-child(2) h3,
.result-section:nth-child(3) h3 {
  color: var(--warn);
}

.result-section:nth-child(4) h3 {
  color: var(--danger);
}

.suggested-order {
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.tiny {
  color: var(--faint);
  font-size: 0.86rem;
}

@media (min-width: 680px) {
  .app {
    padding: 32px;
  }

  .mode-actions {
    grid-template-columns: 1fr 1fr;
  }

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

@media (min-width: 940px) {
  .play-area {
    grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
    align-items: start;
  }

  .left-stack,
  .right-stack {
    display: grid;
    gap: 18px;
  }

  .control-bar {
    position: static;
    margin: 18px 0 0;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
  }

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

  .result-section.suggested {
    grid-column: 1 / -1;
  }

  .review-order-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .review-order-controls {
    grid-column: auto;
    grid-template-columns: repeat(3, auto);
  }
}

@media (max-width: 430px) {
  .app {
    padding: 10px;
    align-items: stretch;
  }

  .card {
    border-radius: 24px;
  }

  .control-bar {
    grid-template-columns: 0.8fr 0.8fr 1.1fr;
  }

  .btn {
    padding-inline: 10px;
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.992);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
