:root {
  --paper: #fffdf7;
  --paper-deep: #f8f2e3;
  --ink: #174f49;
  --muted: #6f8480;
  --line: #ded3b5;
  --green: #4ba47f;
  --green-dark: #276f59;
  --gold: #efb43a;
  --coral: #ef765f;
  --success: #e9f7ed;
  --error: #fff0ed;
  --shadow: 0 10px 0 rgba(104, 87, 45, 0.14);
}

* { box-sizing: border-box; }
html { min-width: 320px; overflow-y: scroll; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 9px 9px, rgba(69, 151, 121, 0.08) 1.5px, transparent 1.8px) 0 0 / 28px 28px,
    linear-gradient(135deg, #fff8e8 0%, #fbf9ef 52%, #eef8ef 100%);
}
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible {
  outline: 4px solid rgba(239, 180, 58, 0.75);
  outline-offset: 4px;
}
.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 66px;
  margin-bottom: 18px;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}
.brand-link strong, .brand-link small { display: block; }
.brand-link strong { font-size: 1.16rem; line-height: 1.1; }
.brand-link small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-icon {
  position: relative;
  display: block;
  width: 54px;
  height: 54px;
  border: 3px solid #b7ddd2;
  border-radius: 18px;
  background: #eff9f3;
  box-shadow: 0 5px 0 rgba(43, 113, 90, 0.14);
}
.brand-triangle, .brand-square { position: absolute; display: block; }
.brand-triangle {
  left: 10px; top: 10px; width: 25px; height: 25px;
  background: var(--coral); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.brand-square {
  right: 8px; bottom: 8px; width: 18px; height: 18px;
  border-radius: 4px; background: var(--gold); transform: rotate(18deg);
}
.sound-button, .primary-button, .secondary-button, .rotate-button {
  border: 0;
  cursor: pointer;
  font-weight: 900;
}
.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.92);
}
.screen { display: none; }
.screen--active { display: block; }
.hero-card, .task-card, .complete-card {
  border: 3px solid var(--line);
  border-radius: 36px;
  background: var(--paper);
  box-shadow: 0 18px 40px rgba(59, 77, 55, 0.12);
}
.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 0.82fr);
  min-height: 470px;
  overflow: hidden;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 58px;
}
.eyebrow, .panel-kicker {
  margin: 0 0 12px;
  color: #8c6a36;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 650px;
  margin-bottom: 20px;
  font-size: clamp(2.65rem, 5.4vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}
.hero-text {
  max-width: 620px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.55;
}
.hero-actions, .complete-actions, .task-actions, .task-actions__right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}
.primary-button, .secondary-button {
  min-height: 58px;
  padding: 0 24px;
  border-radius: 18px;
}
.primary-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 0 var(--green-dark);
}
.primary-button:hover { background: #54ad88; transform: translateY(-1px); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--green-dark); }
.secondary-button {
  border: 2px solid var(--line);
  background: var(--paper);
}
.secondary-button:hover { border-color: #c5aa69; background: #fff9e9; }
.secondary-button--hint { border-color: #e7c46e; background: #fff8dc; }
.progress-pill {
  display: inline-grid;
  min-height: 58px;
  padding: 0 20px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 18px;
  font-weight: 900;
  background: #fffefb;
}
.hero-art {
  position: relative;
  min-height: 470px;
  background:
    radial-gradient(circle at 72% 18%, rgba(255,255,255,.8) 0 7%, transparent 7.3%),
    linear-gradient(145deg, #dff4eb, #fff0cf);
}
.hero-art::after {
  content: "";
  position: absolute;
  inset: 12% 10%;
  border: 4px dashed rgba(53, 126, 103, 0.18);
  border-radius: 32px;
}
.hero-shape { position: absolute; z-index: 1; filter: drop-shadow(0 7px 0 rgba(35,76,61,.14)); }
.hero-shape--one { left: 35%; top: 38%; width: 36%; aspect-ratio: 1; background: #ef765f; clip-path: polygon(50% 0,100% 100%,0 100%); transform: rotate(45deg); }
.hero-shape--two { left: 43%; top: 50%; width: 36%; aspect-ratio: 1; background: #3f9da4; clip-path: polygon(50% 0,100% 100%,0 100%); transform: rotate(225deg); }
.hero-shape--three { left: 34%; top: 24%; width: 25%; aspect-ratio: 1; background: #efb438; clip-path: polygon(50% 0,100% 100%,0 100%); transform: rotate(180deg); }
.hero-shape--four { left: 24%; top: 27%; width: 17%; aspect-ratio: 1; background: #62a9d1; clip-path: polygon(50% 0,100% 100%,0 100%); transform: rotate(315deg); }
.hero-shape--five { left: 57%; top: 27%; width: 17%; aspect-ratio: 1; background: #7cab51; clip-path: polygon(50% 0,100% 100%,0 100%); transform: rotate(45deg); }
.hero-shape--six { left: 25%; top: 58%; width: 15%; aspect-ratio: 1; background: #9a6ca5; transform: rotate(45deg); }
.hero-shape--seven { left: 61%; top: 60%; width: 22%; aspect-ratio: 1.45; background: #68a85f; clip-path: polygon(22% 0,100% 0,78% 100%,0 100%); transform: rotate(-18deg); }
.rule-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 24px 0 48px;
  padding: 22px 28px;
  border: 2px solid #ecd07c;
  border-radius: 24px;
  background: #fff5d5;
}
.rule-icon {
  display: grid;
  flex: 0 0 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: var(--coral);
  font-family: Georgia, serif;
  font-size: 1.7rem;
  font-weight: 900;
}
.rule-card strong { font-size: 1.08rem; }
.rule-card p { margin: 5px 0 0; color: #796e57; line-height: 1.45; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 20px;
}
.section-heading h2 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1; }
.section-heading > p { max-width: 360px; margin-bottom: 4px; color: var(--muted); font-weight: 800; text-align: right; }
.route-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.route-card {
  display: flex;
  min-height: 320px;
  flex-direction: column;
  padding: 26px;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.route-card__icon {
  display: grid;
  width: 60px;
  height: 60px;
  margin-bottom: 28px;
  place-items: center;
  border: 3px solid color-mix(in srgb, var(--route-accent), white 55%);
  border-radius: 18px;
  background: color-mix(in srgb, var(--route-accent), white 83%);
  font-size: 1.8rem;
}
.route-card small { color: #8e6b36; font-family: Georgia, serif; font-weight: 900; letter-spacing: .11em; }
.route-card h3 { margin: 12px 0 8px; font-size: 1.65rem; line-height: 1.08; }
.route-card p { margin-bottom: 24px; color: var(--muted); font-weight: 700; line-height: 1.45; }
.route-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 18px; border-top: 1px dashed var(--line); }
.route-card__progress { color: #8e6b36; font-weight: 900; }
.route-button {
  min-height: 46px;
  padding: 0 18px;
  border: 2px solid var(--route-accent);
  border-radius: 15px;
  color: #fff;
  background: var(--route-accent);
  cursor: pointer;
  font-weight: 900;
}
.task-card { padding: 34px; }
.task-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.task-topline h2 { margin-bottom: 8px; font-size: clamp(2.15rem, 4.6vw, 3.7rem); line-height: 1; }
.task-topline p:last-child { margin-bottom: 0; color: var(--muted); font-size: 1.04rem; font-weight: 700; }
.task-progress { display: flex; align-items: center; gap: 14px; min-width: 260px; }
.progress-track { width: 210px; height: 14px; overflow: hidden; border-radius: 20px; background: #e4e1d6; }
.progress-track span { display: block; height: 100%; width: 10%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(300px, .62fr); gap: 22px; align-items: stretch; }
.stage-panel, .pieces-panel {
  min-width: 0;
  padding: 22px;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: #fffefb;
}
.pieces-panel { background: #f0f8ef; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading h3 { margin: 0; font-size: 1.35rem; }
.panel-kicker { display: block; margin-bottom: 5px; font-size: .75rem; }
.placed-counter {
  padding: 9px 13px;
  border-radius: 14px;
  color: var(--green-dark);
  background: #e4f4e8;
  font-weight: 900;
}
.tangram-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  border: 3px solid #c2dcd2;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.8), rgba(255,255,255,.14) 58%, transparent 59%),
    linear-gradient(145deg, #dff1ea, #f9ecd1);
}
.tangram-stage::after {
  content: "";
  position: absolute;
  inset: 10%;
  border: 2px dashed rgba(44, 102, 84, .12);
  border-radius: 50%;
  pointer-events: none;
}
.target-slot, .placed-piece {
  --piece-color: #aaa;
  --piece-angle: 0deg;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--piece-width);
  aspect-ratio: var(--piece-ratio);
  transform: translate(-50%, -50%) rotate(var(--piece-angle));
  clip-path: var(--piece-shape);
}
.target-slot {
  z-index: 1;
  border: 0;
  cursor: pointer;
  background: color-mix(in srgb, var(--piece-color), white 66%);
  filter: drop-shadow(0 0 0 rgba(0,0,0,0));
  opacity: .76;
  transition: opacity .18s ease, filter .18s ease;
}
.target-slot::after {
  content: "";
  position: absolute;
  inset: 6%;
  clip-path: inherit;
  background: rgba(255,255,255,.28);
}
.target-slot:hover, .target-slot--hint {
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(239,180,58,.9));
}
.target-slot--selected {
  z-index: 2;
  opacity: 1;
}
.tangram-stage--silhouette .target-slot {
  background: #55716a;
  opacity: .18;
}
.tangram-stage--silhouette .target-slot:hover { opacity: .34; }
.tangram-stage--silhouette .target-slot--hint { background: var(--piece-color); opacity: .88; }
.placed-piece {
  z-index: 3;
  border: 0;
  background: var(--piece-color);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.7);
  filter: drop-shadow(0 6px 0 rgba(36, 78, 64, .15));
  pointer-events: none;
  animation: piece-pop .24s ease-out;
}
@keyframes piece-pop { from { transform: translate(-50%,-50%) rotate(var(--piece-angle)) scale(.8); opacity: .3; } }
.pieces-help { margin-bottom: 14px; color: var(--muted); font-weight: 700; line-height: 1.4; }
.piece-tray { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.tray-piece {
  display: grid;
  min-height: 84px;
  padding: 9px;
  place-items: center;
  border: 3px solid transparent;
  border-radius: 18px;
  cursor: grab;
  background: rgba(255,255,255,.86);
  box-shadow: 0 5px 0 rgba(71, 97, 77, .12);
  touch-action: none;
}
.tray-piece:hover { border-color: #b7d8cc; }
.tray-piece--selected { border-color: var(--gold); background: #fff8d9; }
.tray-piece--placed { visibility: hidden; pointer-events: none; }
.piece-visual {
  width: var(--tray-width);
  aspect-ratio: var(--piece-ratio);
  clip-path: var(--piece-shape);
  background: var(--piece-color);
  transform: rotate(var(--piece-angle));
  filter: drop-shadow(0 4px 0 rgba(35, 78, 63, .14));
  transition: transform .16s ease;
}
.rotate-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rotate-button {
  min-height: 50px;
  border: 2px solid #b8d6cc;
  border-radius: 16px;
  background: #fff;
}
.rotate-button:disabled { cursor: not-allowed; opacity: .45; }
.selected-note { min-height: 48px; margin-top: 12px; padding: 12px 14px; border-radius: 15px; color: var(--muted); background: rgba(255,255,255,.72); font-weight: 800; line-height: 1.35; }
.feedback { display: none; margin-top: 22px; padding: 19px 22px; border: 3px solid; border-radius: 22px; font-weight: 800; line-height: 1.45; }
.feedback--visible { display: flex; align-items: center; gap: 14px; }
.feedback--success { border-color: #80bf99; background: var(--success); }
.feedback--error { border-color: #e49990; background: var(--error); }
.feedback--hint { border-color: #e2bf61; background: #fff7da; }
.feedback__icon { display: grid; flex: 0 0 46px; height: 46px; place-items: center; border-radius: 15px; color: #fff; background: currentColor; }
.feedback__icon span { color: #fff; }
.task-actions { justify-content: space-between; margin-top: 22px; }
.complete-card { padding: 70px 54px; text-align: center; }
.complete-badge { display: grid; width: 76px; height: 76px; margin: 0 auto 24px; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 2.4rem; font-weight: 900; }
.complete-card h2 { margin-bottom: 14px; font-size: clamp(2.6rem, 6vw, 5rem); line-height: 1; }
.complete-card > p:not(.eyebrow) { max-width: 650px; margin: 0 auto 30px; color: var(--muted); font-size: 1.08rem; font-weight: 700; }
.stars { min-height: 64px; margin-bottom: 28px; color: var(--gold); font-size: 3.5rem; letter-spacing: 8px; }
.complete-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 780px; margin: 0 auto 34px; }
.complete-stats div { padding: 20px; border: 2px solid #d4e3d0; border-radius: 20px; background: #f1f8ee; }
.complete-stats strong, .complete-stats span { display: block; }
.complete-stats strong { font-size: 2rem; }
.complete-stats span { margin-top: 5px; color: var(--muted); font-weight: 800; }
.complete-actions { justify-content: center; }
.drag-ghost {
  position: fixed;
  z-index: 9999;
  width: 88px;
  aspect-ratio: var(--piece-ratio);
  clip-path: var(--piece-shape);
  background: var(--piece-color);
  transform: translate(-50%,-50%) rotate(var(--piece-angle));
  filter: drop-shadow(0 9px 8px rgba(23,79,73,.25));
  pointer-events: none;
  opacity: .92;
}
@media (max-width: 900px) {
  .hero-card { grid-template-columns: 1fr; }
  .hero-copy { padding: 44px; }
  .hero-art { min-height: 360px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 0; }
  .play-layout { grid-template-columns: 1fr; }
  .pieces-panel { order: -1; }
  .piece-tray { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .task-progress { min-width: 210px; }
  .progress-track { width: 150px; }
}
@media (max-width: 700px) {
  .app { width: min(100% - 20px, 1120px); padding-top: 10px; }
  .game-header { align-items: flex-start; }
  .sound-button { padding: 0 12px; }
  .sound-button span:last-child { display: none; }
  .hero-copy { padding: 34px 24px; }
  h1 { font-size: clamp(2.5rem, 14vw, 4.1rem); }
  .section-heading, .task-topline { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .task-card { padding: 18px; border-radius: 26px; }
  .task-progress { width: 100%; }
  .progress-track { flex: 1; width: auto; }
  .stage-panel, .pieces-panel { padding: 14px; border-radius: 22px; }
  .piece-tray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tray-piece { min-height: 72px; }
  .task-actions, .task-actions__right { width: 100%; }
  .task-actions > button, .task-actions__right > button { flex: 1 1 180px; }
  .complete-card { padding: 48px 20px; }
  .complete-stats { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .brand-link strong { font-size: .98rem; }
  .brand-link small { font-size: .65rem; }
  .brand-icon { width: 48px; height: 48px; }
  .hero-art { min-height: 300px; }
  .rule-card { align-items: flex-start; padding: 18px; }
  .route-card { padding: 22px; }
  .task-topline h2 { font-size: 2.35rem; }
  .panel-heading { align-items: flex-start; }
  .piece-tray { gap: 8px; }
  .tray-piece { min-height: 64px; padding: 6px; }
  .rotate-button span { display: none; }
  .secondary-button, .primary-button { min-height: 54px; padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
