:root {
  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-yellow: #ffcc00;
  --ios-orange: #ff9500;
  --ios-red: #ff3b30;
  --ios-mint: #00c7be;
  --bg: #f2f5f2;
  --bg-2: #eaf8ee;
  --ink: #17251b;
  --muted: #6b756f;
  --hairline: rgba(32, 58, 39, 0.1);
  --glass: rgba(255, 255, 255, 0.76);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --shadow: 0 18px 45px rgba(26, 67, 38, 0.12);
  --shadow-soft: 0 8px 24px rgba(26, 67, 38, 0.09);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% -8%, rgba(255, 204, 0, 0.45), transparent 20rem),
    radial-gradient(circle at 94% 8%, rgba(0, 199, 190, 0.28), transparent 18rem),
    radial-gradient(circle at 10% 92%, rgba(52, 199, 89, 0.26), transparent 18rem),
    linear-gradient(180deg, #f8fff6 0%, #f2f5f2 48%, #edf8ff 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.42;
}

body::before {
  width: 18rem;
  height: 18rem;
  left: -7rem;
  bottom: 2rem;
  background: rgba(52, 199, 89, 0.42);
}

body::after {
  width: 16rem;
  height: 16rem;
  right: -7rem;
  bottom: 12rem;
  background: rgba(255, 204, 0, 0.46);
}

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

button {
  border: 0;
  cursor: pointer;
  user-select: none;
}

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

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

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 40px;
}

.app-header,
.hero-card,
.map-layout,
.challenge-card,
.certificate {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
}

.app-header {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: 28px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4.8vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
  color: var(--ink);
}

.eyebrow,
.tag {
  margin: 0 0 7px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--ios-green);
}

.header-badges {
  display: flex;
  gap: 8px;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.header-badges span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-soft);
}

.screen {
  animation: riseIn 0.32s ease both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  padding: clamp(18px, 4vw, 34px);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.hero-copy h2,
.section-title h2,
.certificate h2,
.challenge-card h2 {
  margin: 0 0 12px;
  font-size: clamp(1.65rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.hero-copy p,
.certificate p {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.name-field,
.form-row {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.name-field {
  max-width: 360px;
  margin: 22px 0;
}

.form-row {
  margin: 16px 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 122, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.primary-btn,
.ghost-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 16px;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(180deg, #42d66c 0%, var(--ios-green) 100%);
  box-shadow: 0 12px 22px rgba(52, 199, 89, 0.24);
}

.ghost-btn,
.small-btn {
  color: var(--ios-blue);
  border: 1px solid rgba(0, 122, 255, 0.14);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.small-btn {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 13px;
  font-size: 0.92rem;
}

.primary-btn:hover,
.ghost-btn:hover,
.small-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(26, 67, 38, 0.14);
}

.primary-btn:active,
.ghost-btn:active,
.small-btn:active,
.option-label:active,
.level-card:active {
  transform: scale(0.985);
}

.preview-card {
  align-self: center;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-soft);
}

.preview-card img {
  border-radius: 18px;
}

.preview-card figcaption {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  padding: 18px;
  border-radius: var(--radius-xl);
}

.route-panel,
.rules-panel {
  min-width: 0;
}

.level-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.level-card,
.word-card,
.question-card,
.problem-card,
.scene-task,
.rules-panel,
.reading-text,
.feedback,
.stamp {
  border: 1px solid var(--hairline);
  background: var(--glass-strong);
  box-shadow: var(--shadow-soft);
}

.level-card {
  position: relative;
  min-height: 208px;
  padding: 18px;
  border-radius: 24px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(52, 199, 89, 0.12), rgba(255, 204, 0, 0.1));
  pointer-events: none;
}

.level-card::after {
  content: attr(data-icon);
  position: absolute;
  right: 14px;
  bottom: 2px;
  font-size: 5rem;
  opacity: 0.12;
}

.level-card > * {
  position: relative;
}

.level-card h3 {
  margin: 10px 0 8px;
  font-size: 1.36rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.level-card p {
  margin: 8px 0;
  line-height: 1.55;
  color: var(--muted);
}

.level-card.is-active {
  border-color: rgba(52, 199, 89, 0.28);
}

.level-card.is-completed {
  background: rgba(244, 255, 241, 0.94);
}

.card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(52, 199, 89, 0.12);
  color: #1b7d34;
  font-size: 0.86rem;
  font-weight: 800;
}

.rules-panel {
  padding: 18px;
  border-radius: 24px;
}

.rules-panel h3 {
  margin: 0 0 10px;
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}

.rules-panel ol {
  margin-bottom: 0;
  padding-left: 22px;
}

.rules-panel li {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.stamp-board,
.certificate-stamps {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.stamp {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  color: var(--muted);
  font-weight: 800;
}

.stamp-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(120, 120, 128, 0.12);
}

.stamp.is-earned {
  color: #1b7d34;
  background: rgba(235, 255, 232, 0.95);
}

.stamp.is-earned .stamp-icon {
  color: #fff;
  background: linear-gradient(180deg, #42d66c, var(--ios-green));
  animation: stampPop 0.38s ease both;
}

@keyframes stampPop {
  from { transform: scale(0.55) rotate(-10deg); }
  to { transform: scale(1) rotate(0deg); }
}

.level-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.level-kicker {
  color: var(--muted);
  font-weight: 800;
}

.challenge-card {
  padding: clamp(18px, 4vw, 30px);
  border-radius: var(--radius-xl);
}

.challenge-intro {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 204, 0, 0.22);
  border-radius: 18px;
  background: rgba(255, 250, 225, 0.82);
  color: #6f5a00;
  line-height: 1.65;
}

.grid-3,
.grid-2 {
  display: grid;
  gap: 12px;
}

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

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

.word-card,
.question-card,
.problem-card,
.scene-task {
  padding: 15px;
  border-radius: 22px;
}

.word-card h3,
.problem-card h3 {
  margin: 0 0 12px;
}

.word-text {
  display: block;
  margin-bottom: 12px;
  font-size: 1.9rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: -0.03em;
}

.read-confirmed {
  color: #1b7d34;
  background: rgba(52, 199, 89, 0.12);
}

.question-options {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid rgba(52, 199, 89, 0.08);
  border-radius: 16px;
  background: rgba(243, 251, 238, 0.92);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.option-label:has(input:checked) {
  border-color: rgba(52, 199, 89, 0.42);
  background: rgba(229, 255, 226, 0.96);
}

.option-label input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--ios-green);
  appearance: auto;
  -webkit-appearance: radio;
}

.option-label span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.reading-text {
  padding: 16px;
  border-radius: 20px;
  color: #2b362e;
  font-size: 1.08rem;
  line-height: 1.95;
}

.market-scene {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 16px;
}

.market-item {
  padding: 9px 13px;
  border: 1px solid rgba(255, 149, 0, 0.12);
  border-radius: 999px;
  background: rgba(255, 248, 219, 0.9);
  color: #8a5b00;
  font-weight: 800;
}

.scene-board {
  position: relative;
  min-height: 320px;
  margin: 16px 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 204, 0, 0.7), transparent 54px),
    linear-gradient(#9bdcff 0 44%, #c8f2aa 44% 100%);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.scene-board::before {
  content: "";
  position: absolute;
  left: -4%;
  right: -4%;
  bottom: 18%;
  height: 52px;
  border-radius: 50%;
  background: rgba(52, 199, 89, 0.32);
}

.scene-item {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 74px;
  min-height: 64px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 18px rgba(23, 37, 27, 0.12);
  font-weight: 800;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.scene-item span {
  display: block;
  font-size: 1.9rem;
}

.scene-item.is-selected {
  border-color: rgba(52, 199, 89, 0.62);
  background: rgba(231, 255, 226, 0.94);
  transform: scale(1.04);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.feedback {
  margin-top: 16px;
  padding: 14px 15px;
  border-radius: 18px;
  font-weight: 800;
  line-height: 1.6;
}

.feedback.error {
  border-color: rgba(255, 59, 48, 0.15);
  background: rgba(255, 236, 235, 0.94);
  color: #b4231c;
}

.feedback.success {
  border-color: rgba(52, 199, 89, 0.18);
  background: rgba(232, 255, 228, 0.94);
  color: #1b7d34;
}

.certificate {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
  border-radius: var(--radius-xl);
}

.certificate-stamps {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 22px auto;
  max-width: 560px;
}

.certificate-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 860px) {
  .app-header,
  .level-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-card,
  .map-layout,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .level-cards {
    grid-template-columns: 1fr;
  }

  .rules-panel {
    order: -1;
  }
}

@media (max-width: 560px) {
  body {
    background:
      radial-gradient(circle at 14% -4%, rgba(255, 204, 0, 0.42), transparent 12rem),
      radial-gradient(circle at 95% 15%, rgba(0, 199, 190, 0.22), transparent 12rem),
      linear-gradient(180deg, #f8fff6 0%, #f5f5f7 52%, #eef8ff 100%);
  }

  body::before,
  body::after {
    display: none;
  }

  .page-shell {
    width: min(100% - 18px, 1120px);
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .app-header,
  .hero-card,
  .map-layout,
  .challenge-card,
  .certificate {
    border-radius: 24px;
    padding: 14px;
  }

  .app-header {
    top: 8px;
    gap: 10px;
    margin-bottom: 12px;
  }

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

  .eyebrow,
  .tag {
    font-size: 0.76rem;
  }

  .header-badges {
    gap: 6px;
  }

  .header-badges span {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .hero-copy h2,
  .section-title h2,
  .certificate h2,
  .challenge-card h2 {
    font-size: 1.55rem;
  }

  .hero-copy p,
  .certificate p {
    font-size: 1rem;
    line-height: 1.68;
  }

  .preview-card {
    display: none;
  }

  .level-cards {
    gap: 12px;
    margin-top: 12px;
  }

  .level-card {
    min-height: 0;
    padding: 15px;
    border-radius: 22px;
  }

  .level-card::after {
    font-size: 3.8rem;
  }

  .level-card h3 {
    font-size: 1.2rem;
  }

  .level-card p {
    margin: 7px 0;
    line-height: 1.48;
  }

  .rules-panel {
    padding: 15px;
  }

  .rules-panel ol {
    padding-left: 22px;
  }

  .primary-btn,
  .ghost-btn,
  .small-btn {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 16px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .challenge-intro,
  .word-card,
  .question-card,
  .problem-card,
  .scene-task,
  .reading-text {
    padding: 13px;
    border-radius: 18px;
  }

  .word-text {
    font-size: 1.58rem;
  }

  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
    border-radius: 16px;
  }

  textarea {
    min-height: 84px;
  }

  .option-label {
    align-items: center;
    padding: 12px;
    min-height: 50px;
  }

  .option-label input[type="radio"] {
    width: 18px;
    height: 18px;
  }

  .market-scene {
    gap: 8px;
  }

  .market-item {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .certificate-stamps {
    grid-template-columns: 1fr;
  }

  .scene-board {
    min-height: 430px;
    border-radius: 22px;
  }

  .scene-item {
    min-width: 64px;
    min-height: 58px;
    padding: 6px;
    border-radius: 17px;
    font-size: 0.82rem;
  }

  .scene-item span {
    font-size: 1.5rem;
  }
}

@media (max-width: 380px) {
  .page-shell {
    width: min(100% - 12px, 1120px);
  }

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

  .scene-item {
    min-width: 58px;
    min-height: 54px;
    font-size: 0.76rem;
  }

  .scene-item span {
    font-size: 1.32rem;
  }
}
