:root {
  --ink: #32261d;
  --leaf: #4d7a58;
  --leaf-dark: #2f5f46;
  --ramie: #e8d8b8;
  --paper: #fff8ea;
  --clay: #b76043;
  --berry: #8c3f4d;
  --sky: #cfe6df;
  --gold: #e7ad4f;
  --soft: #f6ead4;
  --stage-a: #8a5a3c;
  --stage-b: #4d7a58;
  --stage-c: #3f75a6;
  --stage-d: #d47a38;
  --stage-e: #b84e4b;
  --stage-feedback: #7a5ca6;
  --shadow: 0 18px 42px rgba(73, 50, 31, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background:
    linear-gradient(135deg, rgba(77, 122, 88, 0.16) 25%, transparent 25%) 0 0 / 34px 34px,
    linear-gradient(225deg, rgba(183, 96, 67, 0.13) 25%, transparent 25%) 0 0 / 34px 34px,
    #f9efd9;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  padding: 10px clamp(14px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-btn,
.score-chip,
.progress-pill {
  min-height: 48px;
  border: 3px solid rgba(50, 38, 29, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 248, 234, 0.92);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(73, 50, 31, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.home-btn {
  cursor: pointer;
}

.home-btn span:first-child {
  font-size: 1.45rem;
  line-height: 1;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 900;
  text-align: center;
}

.woven-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 42%, rgba(255, 255, 255, 0.7) 42% 58%, transparent 58%),
    linear-gradient(var(--clay), var(--berry));
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 2px rgba(50, 38, 29, 0.18);
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
}

.page {
  display: none;
  width: min(1180px, calc(100vw - 28px));
  min-height: calc(100dvh - 86px);
  margin: 0 auto 14px;
}

.page.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body[data-page="home"] {
  overflow: hidden;
  background: #0d241b;
}

body[data-page="home"] .topbar {
  display: none;
}

.cover-page {
  width: 100vw;
  min-height: 100dvh;
  margin: 0;
  position: relative;
  overflow: hidden;
  background: #0d241b;
}

.cover-page.active {
  display: block;
}

.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.cover-title-panel {
  position: absolute;
  left: clamp(28px, 5.5vw, 92px);
  bottom: clamp(34px, 8vh, 92px);
  max-width: 68vw;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(20px, 3vw, 30px);
  z-index: 2;
}

.cover-title-panel h1 {
  margin: 0;
  color: #fff4d8;
  line-height: 1.04;
  font-weight: 950;
  text-shadow:
    0 3px 6px rgba(0, 0, 0, 0.55),
    0 14px 34px rgba(0, 0, 0, 0.36);
}

.cover-main-title,
.cover-sub-title {
  display: block;
  letter-spacing: 0;
  white-space: nowrap;
}

.cover-main-title {
  font-size: clamp(2.4rem, 4.9vw, 6.2rem);
}

.cover-sub-title {
  margin-top: 0.34em;
  font-size: clamp(1.35rem, 2.75vw, 3.45rem);
}

.explore-btn {
  min-width: clamp(190px, 24vw, 290px);
  min-height: clamp(62px, 7vw, 82px);
  border: 4px solid rgba(255, 244, 216, 0.88);
  border-radius: var(--radius);
  color: #fff4d8;
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(255, 244, 216, 0.22) 12% 18%, transparent 18% 32%, rgba(255, 244, 216, 0.2) 32% 38%, transparent 38%),
    repeating-linear-gradient(45deg, rgba(231, 173, 79, 0.28) 0 10px, rgba(184, 78, 75, 0.28) 10px 20px, rgba(47, 95, 70, 0.28) 20px 30px),
    #7b332f;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  font-weight: 950;
  cursor: pointer;
}

.explore-btn:hover,
.explore-btn:focus-visible {
  outline: 5px solid rgba(255, 244, 216, 0.42);
  transform: translateY(-2px);
}

.select-page .compact-hero {
  min-height: 180px;
  grid-template-columns: 1fr;
}

.nickname-page,
.certificate-page {
  justify-content: center;
}

.nickname-card,
.certificate-card {
  position: relative;
  overflow: hidden;
  margin: auto;
  width: min(860px, 100%);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.98), rgba(232, 216, 184, 0.88)),
    repeating-linear-gradient(45deg, rgba(140, 63, 77, 0.1) 0 14px, rgba(77, 122, 88, 0.1) 14px 28px);
  border: 5px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.nickname-card {
  min-height: 480px;
  padding: clamp(28px, 5vw, 58px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.nickname-card p {
  margin: 0;
  font-size: clamp(1.08rem, 2vw, 1.28rem);
  font-weight: 800;
  line-height: 1.55;
}

.nickname-field {
  display: grid;
  gap: 10px;
  font-weight: 950;
}

.nickname-field input {
  width: 100%;
  min-height: 68px;
  border: 4px solid rgba(50, 38, 29, 0.14);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: #fffdf5;
  color: var(--ink);
  font: inherit;
  font-size: clamp(1.12rem, 2.2vw, 1.4rem);
  font-weight: 900;
}

.certificate-card {
  min-height: min(760px, calc(100dvh - 110px));
  padding: clamp(26px, 4vw, 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  border-image: repeating-linear-gradient(45deg, var(--stage-a) 0 14px, var(--stage-b) 14px 28px, var(--stage-c) 28px 42px, var(--stage-e) 42px 56px) 18;
}

.certificate-sparkles {
  position: absolute;
  inset: 8% auto auto 8%;
  color: rgba(231, 173, 79, 0.58);
  font-size: clamp(2.3rem, 6vw, 5rem);
  font-weight: 950;
  animation: sparkle 1500ms ease-in-out infinite alternate;
}

.medal {
  width: clamp(86px, 13vw, 132px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff4c4, #e7ad4f 58%, #9c6726);
  box-shadow: 0 16px 34px rgba(73, 50, 31, 0.25);
  font-size: clamp(3rem, 7vw, 5rem);
  animation: pop 800ms ease both;
}

.certificate-card h2 {
  font-size: clamp(1.8rem, 3.5vw, 3rem);
}

.certificate-grid {
  width: min(680px, 100%);
  display: grid;
  gap: 12px;
}

.certificate-grid div {
  border-radius: var(--radius);
  padding: 14px 18px;
  background: rgba(255, 253, 245, 0.9);
  border: 3px solid rgba(50, 38, 29, 0.12);
}

.certificate-grid span {
  display: block;
  color: var(--leaf-dark);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 950;
}

.certificate-grid strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.45rem, 3.4vw, 2.6rem);
  line-height: 1.18;
}

.passphrase strong {
  color: var(--stage-e);
  letter-spacing: 0.08em;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
}

.service-note {
  margin: 0;
  font-size: clamp(1.12rem, 2.2vw, 1.45rem);
  font-weight: 900;
  line-height: 1.5;
}

.hero-panel,
.complete-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 248, 234, 0.97), rgba(255, 248, 234, 0.78)),
    linear-gradient(135deg, var(--sky), var(--soft));
  box-shadow: var(--shadow);
  border: 4px solid rgba(255, 255, 255, 0.76);
}

.hero-panel {
  min-height: 34dvh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: stretch;
}

.hero-copy {
  padding: clamp(24px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--leaf-dark);
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.7vw, 4.1rem);
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3.2vw, 2.7rem);
  line-height: 1.12;
}

h3 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}

.hero-text {
  max-width: 34em;
  margin: 18px 0 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
  font-weight: 700;
}

.loom-scene {
  min-height: 280px;
  position: relative;
  background: linear-gradient(#cfe6df 0 53%, #9ec38f 53% 100%);
}

.sun {
  position: absolute;
  right: 11%;
  top: 12%;
  width: 74px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 14px rgba(231, 173, 79, 0.16);
}

.mountain {
  position: absolute;
  bottom: 27%;
  width: 46%;
  aspect-ratio: 1;
  transform: rotate(45deg);
  border-radius: 8px;
  background: var(--leaf);
}

.m1 {
  left: 4%;
}

.m2 {
  left: 34%;
  background: var(--leaf-dark);
}

.ramie {
  position: absolute;
  left: 13%;
  bottom: 8%;
  width: 72%;
  height: 19%;
  background:
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(255, 248, 234, 0.8) 26px 31px),
    linear-gradient(var(--ramie), #d9c28f);
  border: 5px solid #886543;
  border-radius: var(--radius);
}

.weave-board {
  position: absolute;
  right: 9%;
  bottom: 12%;
  width: min(42%, 250px);
  aspect-ratio: 1.22;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: #6f4832;
  border-radius: var(--radius);
  transform: rotate(-3deg);
}

.weave-board span {
  background:
    linear-gradient(45deg, var(--berry) 25%, var(--paper) 25% 50%, var(--clay) 50% 75%, var(--leaf) 75%);
  border-radius: 4px;
}

.game-menu {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.five-stage-menu {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.menu-card,
.answer-btn,
.process-card-item,
.match-card {
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

.menu-card {
  min-height: 245px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  text-align: center;
}

.stage-a {
  background: linear-gradient(135deg, #fff2d9, #c49367);
}

.stage-b {
  background: linear-gradient(135deg, #e9f4df, #91c595);
}

.stage-c {
  background: linear-gradient(135deg, #e1f1fb, #7fb0d3);
}

.stage-e {
  background: linear-gradient(135deg, #ffe4df, #d77770);
}

.stage-feedback {
  background: linear-gradient(135deg, #efe7ff, #b9a5dc);
}

.menu-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 248, 234, 0.82);
  font-size: 2rem;
  font-weight: 900;
}

.stage-a .menu-icon {
  color: white;
  background: var(--stage-a);
}

.stage-b .menu-icon {
  color: white;
  background: var(--stage-b);
}

.stage-c .menu-icon {
  color: white;
  background: var(--stage-c);
}

.stage-e .menu-icon {
  color: white;
  background: var(--stage-e);
}

.stage-feedback .menu-icon {
  color: white;
  background: var(--stage-feedback);
}

.menu-title-block {
  min-height: 92px;
  width: 100%;
  display: grid;
  grid-template-rows: 38px 1fr;
  align-items: start;
  gap: 8px;
}

.menu-title-block strong {
  display: block;
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  line-height: 1.1;
  white-space: nowrap;
}

.menu-title-block span {
  display: block;
  min-height: 46px;
  font-size: clamp(1.05rem, 1.65vw, 1.35rem);
  line-height: 1.18;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.menu-card small {
  margin-top: auto;
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 0 9px, rgba(50, 38, 29, 0.08) 9px 18px),
    rgba(255, 248, 234, 0.62);
  font-size: clamp(0.98rem, 1.45vw, 1.08rem);
  line-height: 1.2;
  font-weight: 950;
}

.school-footer {
  text-align: center;
  font-weight: 900;
  padding: 6px 0;
}

.game-page {
  justify-content: flex-start;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.stage-theme-a .page-head {
  border-left: 12px solid var(--stage-a);
  padding-left: 14px;
}

.stage-theme-b .page-head {
  border-left: 12px solid var(--stage-b);
  padding-left: 14px;
}

.stage-theme-c .page-head {
  border-left: 12px solid var(--stage-c);
  padding-left: 14px;
}

.stage-theme-e .page-head {
  border-left: 12px solid var(--stage-e);
  padding-left: 14px;
}

.stage-theme-feedback .page-head {
  border-left: 12px solid var(--stage-feedback);
  padding-left: 14px;
}

.story-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
}

.storybook-card,
.question-panel,
.match-column {
  background: rgba(255, 248, 234, 0.95);
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.storybook-card {
  min-height: 100%;
  padding: clamp(16px, 3vw, 28px);
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
  gap: 16px;
}

.story-illustration {
  border-radius: var(--radius);
  background: var(--story-art, linear-gradient(135deg, #cfe6df, #4d7a58));
  position: relative;
  overflow: hidden;
}

.story-illustration::before,
.story-illustration::after {
  content: "";
  position: absolute;
  inset: auto auto 12% 8%;
  width: 34%;
  aspect-ratio: 1;
  transform: rotate(45deg);
  background: rgba(47, 95, 70, 0.82);
  border-radius: 8px;
}

.story-illustration::after {
  left: 36%;
  width: 42%;
  background: rgba(183, 96, 67, 0.76);
}

.storybook-card p,
.question-panel p {
  font-size: clamp(1.05rem, 1.8vw, 1.28rem);
  line-height: 1.65;
  font-weight: 700;
}

.question-panel {
  padding: clamp(16px, 3vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.answer-btn {
  min-height: 72px;
  padding: 14px 18px;
  text-align: left;
  background: #fffdf5;
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 900;
}

.answer-btn:hover,
.answer-btn:focus-visible,
.menu-card:hover,
.menu-card:focus-visible,
.process-card-item:hover,
.process-card-item:focus-visible,
.match-card:hover,
.match-card:focus-visible {
  outline: 4px solid rgba(231, 173, 79, 0.62);
  transform: translateY(-2px);
}

.answer-btn.correct {
  background: #dff1d5;
}

.answer-btn.wrong {
  background: #f8ddd5;
}

.hint-text {
  min-height: 1.6em;
  margin: 0;
  color: #7e3f34;
  font-weight: 900;
  line-height: 1.45;
}

.center {
  text-align: center;
}

.instruction-strip {
  border-radius: var(--radius);
  background: rgba(255, 248, 234, 0.94);
  border: 3px solid rgba(50, 38, 29, 0.12);
  padding: 12px 16px;
  font-weight: 900;
  text-align: center;
}

.process-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.process-card-item {
  min-height: 126px;
  padding: 10px;
  background: rgba(255, 253, 245, 0.98);
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: center;
  user-select: none;
}

.process-card-item.selected,
.match-card.selected {
  outline: 5px solid var(--gold);
  background: #fff4cf;
}

.process-card-item.maybe-wrong {
  border-color: #d77c65;
}

.card-number {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--leaf);
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
}

.process-icon,
.tool-icon {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
}

.process-card-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: clamp(0.98rem, 1.6vw, 1.18rem);
}

.process-card-item small {
  display: block;
  font-weight: 800;
  line-height: 1.35;
  font-size: clamp(0.86rem, 1.45vw, 1rem);
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  min-width: 174px;
  min-height: 58px;
  border-radius: var(--radius);
  border: 0;
  padding: 12px 22px;
  font-weight: 900;
  font-size: 1.12rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(73, 50, 31, 0.16);
}

.primary-btn {
  background: var(--leaf-dark);
  color: white;
}

.secondary-btn {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid rgba(50, 38, 29, 0.14);
}

.matching-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.spotter-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 14px;
}

.spotter-card,
.keeper-panel {
  background: rgba(255, 248, 234, 0.95);
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.spotter-card {
  min-height: 100%;
  padding: clamp(22px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 253, 245, 0.96), rgba(232, 216, 184, 0.88)),
    repeating-linear-gradient(45deg, rgba(140, 63, 77, 0.12) 0 14px, rgba(77, 122, 88, 0.12) 14px 28px);
}

.spotter-icon {
  width: clamp(100px, 18vw, 180px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--leaf-dark);
  color: white;
  font-size: clamp(3.3rem, 9vw, 7rem);
  font-weight: 900;
  box-shadow: 0 16px 30px rgba(73, 50, 31, 0.22);
}

.spotter-card h3 {
  margin-top: 18px;
  font-size: clamp(3rem, 9vw, 6.8rem);
  line-height: 1;
}

.spotter-card p:last-child {
  margin: 14px 0 0;
  color: var(--berry);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  line-height: 1;
}

.keeper-panel {
  padding: clamp(18px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.keeper-panel p {
  margin: 0;
  font-weight: 800;
  line-height: 1.5;
}

.keeper-btn {
  width: 100%;
}

.tool-match-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.tool-match-column {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 253, 245, 0.96), rgba(225, 241, 251, 0.88)),
    repeating-linear-gradient(45deg, rgba(63, 117, 166, 0.1) 0 14px, rgba(231, 173, 79, 0.09) 14px 28px);
  border: 4px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.tool-match-column h3 {
  text-align: center;
  color: var(--stage-c);
}

.tool-match-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tool-match-card {
  position: relative;
  min-height: 92px;
  border: 4px solid rgba(63, 117, 166, 0.2);
  border-radius: var(--radius);
  background: #fffdf5;
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 12px 10px;
  font: inherit;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(43, 69, 92, 0.12);
  touch-action: manipulation;
}

.tool-match-card strong {
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  line-height: 1.15;
}

.match-status {
  position: absolute;
  top: 7px;
  right: 9px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: transparent;
  font-weight: 950;
}

.tool-match-card.selected {
  outline: 5px solid rgba(231, 173, 79, 0.72);
  background: #fff4cf;
}

.tool-match-card.matched {
  border-color: rgba(47, 125, 75, 0.5);
  background: #dff1d5;
  color: #285d36;
  cursor: default;
}

.tool-match-card.matched .match-status {
  background: #2f7d4b;
}

.tool-match-card.wrong {
  border-color: #c94f4f;
  background: #ffe3dc;
  animation: shake 360ms ease-in-out;
}

.mission-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
}

.mission-card,
.reminder-card,
.survey-form {
  background: rgba(255, 248, 234, 0.96);
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mission-card,
.reminder-card {
  padding: clamp(18px, 3vw, 32px);
}

.mission-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.96), rgba(255, 229, 222, 0.92)),
    repeating-linear-gradient(45deg, rgba(184, 78, 75, 0.11) 0 14px, rgba(77, 122, 88, 0.1) 14px 28px);
}

.mission-card p {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.38rem);
  font-weight: 850;
  line-height: 1.55;
}

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

.check-list label,
.survey-form label,
.feedback-box {
  border: 3px solid rgba(50, 38, 29, 0.12);
  border-radius: var(--radius);
  background: #fffdf5;
  font-weight: 900;
}

.check-list label {
  min-height: 92px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.compact-check-list {
  grid-template-columns: 1fr;
}

.compact-check-list label {
  min-height: 76px;
  border-color: rgba(184, 78, 75, 0.24);
}

.check-list input,
.survey-form input {
  width: 24px;
  height: 24px;
  accent-color: var(--stage-e);
  flex: 0 0 auto;
}

.reminder-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  border-color: rgba(184, 78, 75, 0.18);
}

.reminder-card p {
  margin: 0;
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  font-weight: 800;
  line-height: 1.55;
}

.challenge-confirm {
  background:
    linear-gradient(180deg, rgba(255, 253, 245, 0.98), rgba(255, 238, 233, 0.96));
}

.photo-reminder {
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(184, 78, 75, 0.1);
  border: 3px solid rgba(184, 78, 75, 0.16);
}

.photo-reminder h3 {
  margin-bottom: 8px;
}

.photo-reminder p {
  font-size: clamp(1rem, 1.6vw, 1.18rem);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  background: #a7a29b;
}

.survey-form {
  flex: 1;
  min-height: 0;
  padding: clamp(14px, 2.4vw, 24px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: auto;
}

.survey-form fieldset,
.feedback-box {
  margin: 0;
  padding: 14px;
}

.survey-form fieldset {
  border: 3px solid rgba(50, 38, 29, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 253, 245, 0.9);
  display: grid;
  gap: 8px;
}

.survey-form legend,
.feedback-box span {
  font-weight: 900;
  line-height: 1.35;
}

.survey-form label {
  min-height: 44px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  line-height: 1.25;
}

.feedback-box {
  grid-column: span 2;
  display: grid;
  gap: 10px;
}

.feedback-box textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 3px solid rgba(50, 38, 29, 0.14);
  border-radius: var(--radius);
  padding: 12px;
  font: inherit;
  font-weight: 800;
  background: white;
}

.survey-form .action-row {
  grid-column: span 2;
}

.match-column {
  min-height: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-column h3 {
  text-align: center;
}

.match-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.match-card {
  min-height: 112px;
  padding: 12px;
  background: #fffdf5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-weight: 900;
  line-height: 1.35;
}

.match-card.done {
  background: #dff1d5;
  color: #315d39;
  cursor: default;
  opacity: 0.78;
}

.complete-page {
  justify-content: center;
}

.complete-card {
  margin: auto;
  width: min(760px, 100%);
  min-height: 420px;
  padding: clamp(28px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.complete-card::before,
.complete-card::after {
  content: "✦ ✧ ✦";
  position: absolute;
  color: rgba(184, 78, 75, 0.34);
  font-size: clamp(2rem, 5vw, 4.5rem);
  font-weight: 900;
  animation: sparkle 1500ms ease-in-out infinite alternate;
}

.complete-card::before {
  left: 7%;
  top: 10%;
}

.complete-card::after {
  right: 7%;
  bottom: 10%;
  animation-delay: 350ms;
}

.celebrate {
  width: 86px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  font-size: 3rem;
  animation: pop 800ms ease both;
}

#completeMessage {
  white-space: pre-line;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 850;
  line-height: 1.55;
}

.final-score {
  padding: 12px 18px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  font-size: 1.35rem;
  font-weight: 900;
}

@keyframes pop {
  0% {
    transform: scale(0.4) rotate(-18deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.12) rotate(8deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes sparkle {
  from {
    transform: translateY(0) rotate(-6deg) scale(0.96);
    opacity: 0.45;
  }
  to {
    transform: translateY(-10px) rotate(6deg) scale(1.06);
    opacity: 0.95;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

@media (orientation: portrait) and (min-width: 700px) {
  .hero-panel,
  .story-layout {
    grid-template-columns: 1fr;
  }

  .loom-scene {
    min-height: 240px;
  }

  .game-menu {
    grid-template-columns: 1fr;
  }

  .five-stage-menu {
    grid-template-columns: 1fr;
  }

  .mission-layout,
  .survey-form {
    grid-template-columns: 1fr;
  }

  .feedback-box,
  .survey-form .action-row {
    grid-column: span 1;
  }

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

  .menu-card {
    min-height: 170px;
  }

  .menu-title-block {
    min-height: 70px;
  }
}

@media (max-width: 760px) {
  .cover-title-panel {
    left: 22px;
    bottom: 26px;
    max-width: calc(100vw - 44px);
  }

  .cover-main-title {
    font-size: clamp(1.45rem, 5.25vw, 2.5rem);
  }

  .cover-sub-title {
    font-size: clamp(0.9rem, 3vw, 1.45rem);
  }

  .explore-btn {
    min-width: 190px;
  }

  .topbar {
    height: auto;
    flex-wrap: wrap;
  }

  .brand-mark {
    order: -1;
    width: 100%;
    justify-content: center;
  }

  .page {
    min-height: calc(100dvh - 126px);
    width: min(100vw - 20px, 1180px);
  }

  .hero-panel,
  .story-layout,
  .matching-board,
  .spotter-board,
  .tool-match-board,
  .mission-layout,
  .survey-form {
    grid-template-columns: 1fr;
  }

  .game-menu,
  .process-grid,
  .match-list,
  .tool-match-list,
  .check-list {
    grid-template-columns: 1fr;
  }

  .feedback-box,
  .survey-form .action-row {
    grid-column: span 1;
  }

  .process-card-item,
  .match-card {
    min-height: 96px;
  }

  .menu-card {
    min-height: 168px;
    padding: 16px;
  }

  .menu-icon {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
    font-size: 1.65rem;
  }

  .menu-title-block {
    min-height: 66px;
    grid-template-rows: 28px 1fr;
    gap: 6px;
  }

  .hero-panel {
    min-height: auto;
  }

  .loom-scene {
    min-height: 210px;
  }
}

@media (max-height: 720px) and (orientation: landscape) {
  .topbar {
    height: 60px;
    padding-block: 6px;
  }

  .page {
    min-height: calc(100dvh - 70px);
    gap: 10px;
  }

  .hero-panel {
    min-height: 30dvh;
  }

  .menu-card {
    min-height: 210px;
    padding: 16px;
  }

  .menu-title-block {
    min-height: 82px;
  }

  .process-card-item {
    min-height: 98px;
  }

  .match-card {
    min-height: 88px;
  }

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

  .tool-match-card {
    min-height: 76px;
  }
}
