:root {
  --ink: #33271f;
  --cream: #fff6d8;
  --sky: #bde7ef;
  --sun: #ffd34f;
  --clay-red: #ef715f;
  --clay-blue: #4e9fc2;
  --clay-green: #74ad67;
  --clay-orange: #ef9d42;
  --shadow: #9a7056;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: var(--ink);
  background: #d8c39a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; overscroll-behavior: none; }
body { min-height: 100dvh; background: #d8c39a; touch-action: manipulation; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 4px solid #2d78a0; outline-offset: 3px; }
[hidden] { display: none !important; }
.screen { min-height: 100dvh; width: min(100%, 1100px); margin: 0 auto; position: relative; overflow: hidden; }
.start-screen { background: #f6de9d; display: grid; grid-template-columns: 1.15fr .85fr; }
.morning-sky { position: relative; min-height: 100dvh; background: var(--sky); overflow: hidden; border-right: 8px solid rgba(51,39,31,.15); }
.sun, .result-sun { position: absolute; width: 170px; height: 170px; border-radius: 50%; background: var(--sun); box-shadow: inset -11px -12px 0 rgba(201,126,44,.18); }
.sun { left: 11%; top: 8%; }
.sun::after { content: ""; position: absolute; inset: 57px 39px auto; width: 92px; height: 38px; border-bottom: 7px solid var(--ink); border-radius: 50%; transform: rotate(-3deg); }
.cloud { position: absolute; width: 150px; height: 45px; border-radius: 50px; background: #fff9e9; box-shadow: 30px -23px 0 #fff9e9, 74px -12px 0 #fff9e9; opacity: .92; }
.cloud-a { top: 19%; right: 15%; transform: scale(.7); }
.cloud-b { top: 35%; left: -25px; transform: scale(.5); }
.alley-preview { position: absolute; left: 0; right: 0; bottom: 0; height: 57%; background: #e4b16d; border-top: 14px solid #a56448; }
.alley-preview::after { content: ""; position: absolute; inset: auto 0 0; height: 38%; background: repeating-linear-gradient(82deg,#b87553 0 4px,#c98a60 4px 74px); border-top: 10px solid #8f6047; }
.preview-house { position: absolute; left: 12%; bottom: 24%; width: 210px; height: 210px; background: var(--cream); border: 8px solid var(--ink); box-shadow: 12px 12px 0 rgba(74,51,37,.18); z-index: 2; }
.preview-house::before { content: ""; position: absolute; left: -35px; top: -135px; width: 280px; height: 150px; background: var(--clay-red); clip-path: polygon(50% 0,100% 100%,0 100%); border-radius: 20px; }
.preview-house i { position: absolute; left: 68px; bottom: 0; width: 70px; height: 110px; background: var(--clay-blue); border: 7px solid var(--ink); }
.preview-tree { position: absolute; right: 7%; bottom: 23%; width: 98px; height: 210px; background: #8c5d3d; border: 7px solid var(--ink); z-index: 2; }
.preview-tree::before { content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%; background: var(--clay-green); border: 7px solid var(--ink); left: -52px; top: -120px; }
.preview-cart { position: absolute; left: 34%; bottom: 8%; width: 245px; height: 100px; background: var(--clay-orange); border: 8px solid var(--ink); border-radius: 30px 45px 20px 20px; z-index: 4; }
.preview-cart::before, .preview-cart::after { content: ""; position: absolute; bottom: -46px; width: 72px; height: 72px; border-radius: 50%; background: #59463a; border: 8px solid var(--cream); }
.preview-cart::before { left: 25px; }.preview-cart::after { right: 25px; }
.preview-cart i { position: absolute; left: 74px; top: -78px; width: 105px; height: 83px; background: var(--clay-blue); border: 8px solid var(--ink); }
.start-copy { padding: clamp(28px,5vw,68px); display: flex; flex-direction: column; justify-content: center; background: var(--cream); position: relative; }
.start-copy::before { content: ""; position: absolute; inset: 0; opacity: .1; background: radial-gradient(circle at 12px 12px,#815b42 2px,transparent 3px); background-size: 24px 24px; pointer-events: none; }
.eyebrow { margin: 0 0 12px; font-weight: 900; letter-spacing: .08em; color: #9e493e; }
h1 { margin: 0; font-size: clamp(2.5rem,6vw,5.4rem); line-height: .95; letter-spacing: -.05em; }
h1 strong { color: #d35143; font-weight: 1000; }
.lead { font-weight: 800; line-height: 1.75; font-size: clamp(1rem,2vw,1.25rem); }
.shape-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 26px; }
.shape-legend span { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; }
.mini { display: inline-block; width: 28px; height: 28px; background: var(--clay-blue); border: 3px solid var(--ink); }
.mini.circle { border-radius: 50%; background: var(--clay-orange); }
.mini.triangle { background: var(--clay-red); clip-path: polygon(50% 0,100% 100%,0 100%); border: 0; }
.mini.rectangle { width: 38px; height: 23px; background: var(--clay-green); }
.clay-button { position: relative; border: 4px solid var(--ink); border-radius: 14px; padding: 15px 22px; font-weight: 1000; cursor: pointer; box-shadow: 0 7px 0 var(--ink); transform: translateY(-4px); }
.clay-button:active { box-shadow: 0 2px 0 var(--ink); transform: translateY(1px); }
.clay-button.primary { background: var(--sun); }
.clay-button.secondary { background: #fff; }
.quick-help { font-size: .83rem; font-weight: 700; opacity: .78; }

.play-screen { background: var(--sky); display: grid; grid-template-rows: auto minmax(320px,1fr) auto; }
.street-sign { min-height: 76px; display: grid; grid-template-columns: 120px 1fr 130px 70px; gap: 8px; align-items: center; padding: 8px 12px; background: #7b4e38; color: #fff8df; border-bottom: 7px solid var(--ink); position: relative; z-index: 10; }
.timer-wrap, .score-wrap { display: flex; align-items: baseline; justify-content: center; gap: 3px; }
.timer-wrap b, .score-wrap b { font-size: clamp(1.8rem,4vw,2.7rem); font-variant-numeric: tabular-nums; }
.timer-wrap.danger b { color: #ffe14e; animation: pulse .55s infinite alternate; }
.title-board { text-align: center; line-height: 1.05; }
.title-board span { display: block; font-weight: 1000; font-size: 1.1rem; }
.title-board strong { font-size: .78rem; color: #ffdc70; }
.score-wrap { flex-direction: column; align-items: center; gap: 0; }
.score-wrap small { font-weight: 800; }.score-wrap b { font-size: 1.65rem; }
.sound-button { border: 2px solid #fff6d8; background: transparent; color: inherit; padding: 10px 6px; font-weight: 900; border-radius: 6px; cursor: pointer; }
.world { position: relative; min-height: 330px; overflow: hidden; background: linear-gradient(#bde7ef 0 56%,#dfbd78 56%); }
.roofline { position: absolute; inset: auto 0 20% 0; height: 46%; display: flex; align-items: end; opacity: .42; }
.roofline span { flex: 1; min-width: 120px; height: 60%; background: #f6e2ad; border: 5px solid #80553f; clip-path: polygon(50% 0,100% 28%,91% 28%,91% 100%,9% 100%,9% 28%,0 28%); }
.roofline span:nth-child(2) { height: 82%; }.roofline span:nth-child(3) { height: 68%; }.roofline span:nth-child(4) { height: 92%; }
.task-ribbon { position: absolute; top: 12px; left: 12px; background: #fff6d8; border: 4px solid var(--ink); padding: 8px 14px; transform: rotate(-1deg); box-shadow: 5px 5px 0 rgba(51,39,31,.2); z-index: 4; }
.task-ribbon span { color: #ad4b3d; font-weight: 900; margin-right: 8px; }.task-ribbon strong { font-size: 1.05rem; }
.build-stage { position: absolute; inset: 46px 0 56px; display: grid; place-items: center; }
.target-board { position: relative; width: min(65vw,420px); height: min(43vw,270px); min-height: 210px; max-height: 270px; background: rgba(255,246,216,.57); border: 5px solid var(--ink); border-radius: 49% 45% 44% 48%; box-shadow: inset 0 -8px 0 rgba(133,86,56,.12),8px 8px 0 rgba(51,39,31,.14); }
.target-board::after { content: "かげの かたち"; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: .7rem; font-weight: 900; opacity: .55; white-space: nowrap; }
.slot { position: absolute; border: 4px dashed #765e4e; background: rgba(92,69,55,.12); display: grid; place-items: center; color: #6c5749; font-weight: 1000; font-size: 1.1rem; cursor: pointer; transition: transform .15s,background .15s; }
.slot::after { content: attr(data-symbol); }
.slot.circle { border-radius: 50%; }.slot.triangle { clip-path: polygon(50% 0,100% 100%,0 100%); border: 0; background: rgba(92,69,55,.25); }.slot.triangle::after { transform: translateY(15%); }
.slot.rectangle { border-radius: 11px; }.slot.square { border-radius: 8px; }
.slot.hovered, .slot:focus-visible { background: rgba(255,211,79,.5); transform: scale(1.06); }
.slot.filled { border-style: solid; animation: clay-pop .28s ease-out; }
.slot.filled::after { content: "✓"; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.slot.filled.circle { background: var(--clay-orange); }.slot.filled.square { background: var(--clay-blue); }.slot.filled.triangle { background: var(--clay-red); }.slot.filled.rectangle { background: var(--clay-green); }
.clay-character { position: absolute; right: clamp(8px,6vw,76px); bottom: 0; width: 82px; height: 100px; background: #f19c47; border: 5px solid var(--ink); border-radius: 48% 48% 40% 42%; transform-origin: bottom; }
.clay-character::before, .clay-character::after { content: ""; position: absolute; top: 35px; width: 10px; height: 14px; border-radius: 50%; background: var(--ink); }
.clay-character::before { left: 20px; }.clay-character::after { right: 20px; }
.clay-character i { position: absolute; left: 25px; top: 58px; width: 28px; height: 14px; border-bottom: 5px solid var(--ink); border-radius: 50%; }
.clay-character b { position: absolute; width: 42px; height: 28px; background: #fff6d8; border: 4px solid var(--ink); top: -20px; left: 16px; transform: rotate(-8deg); }
.clay-character.cheer { animation: cheer .55s ease-in-out 2; }.clay-character.oops { animation: nope .32s ease-in-out; }
.feedback { position: absolute; left: 3%; bottom: 8px; max-width: 48%; min-height: 28px; padding: 7px 11px; background: #fff6d8; border: 3px solid var(--ink); font-size: .82rem; font-weight: 900; opacity: 0; transform: translateY(8px); transition: .2s; z-index: 5; }
.feedback.show { opacity: 1; transform: translateY(0); }.feedback.good { background: #dff4be; }.feedback.try { background: #ffe3bc; }
.score-pop { position: absolute; font-size: 2rem; font-weight: 1000; color: #b63d35; text-shadow: 2px 2px 0 #fff6d8; opacity: 0; z-index: 8; }
.score-pop.fly { animation: score-fly .8s ease-out; }
.street { position: absolute; inset: auto 0 0; height: 58px; background: #9c6d52; border-top: 6px solid var(--ink); display: flex; justify-content: space-around; align-items: center; }
.street i { width: 10%; height: 8px; background: #f5d67d; transform: skew(-22deg); }
.completed-parade { position: absolute; left: 8px; bottom: 64px; display: flex; gap: 5px; align-items: end; max-width: 27%; overflow: hidden; }
.parade-token { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; background: #fff6d8; border: 3px solid var(--ink); border-radius: 50% 45% 48% 42%; font-size: 1.25rem; animation: token-in .3s ease-out; }
.shape-tray { background: #fff6d8; border-top: 7px solid var(--ink); padding: 7px 10px 11px; position: relative; z-index: 12; }
.tray-label { display: flex; justify-content: space-between; font-weight: 1000; font-size: .78rem; margin: 0 auto 5px; max-width: 680px; }.tray-label b { color: #ad4b3d; }
.piece-tray { min-height: 84px; display: flex; justify-content: center; align-items: center; gap: clamp(9px,2.5vw,22px); }
.piece { width: 70px; height: 70px; border: 5px solid var(--ink); box-shadow: 0 6px 0 rgba(51,39,31,.35); cursor: grab; position: relative; touch-action: none; transition: transform .14s,filter .14s; }
.piece:hover, .piece.selected { transform: translateY(-6px) rotate(-2deg); filter: brightness(1.08); }.piece:active { cursor: grabbing; }
.piece.circle { background: var(--clay-orange); border-radius: 50%; }.piece.square { background: var(--clay-blue); border-radius: 9px; }.piece.triangle { background: var(--clay-red); clip-path: polygon(50% 0,100% 100%,0 100%); border: 0; box-shadow: none; }.piece.rectangle { background: var(--clay-green); width: 94px; height: 58px; border-radius: 11px; }
.piece.used { opacity: .18; pointer-events: none; transform: scale(.7); }
.touch-hint { margin: 4px 0 0; text-align: center; font-weight: 700; font-size: .72rem; opacity: .75; }
.drag-ghost { position: fixed; z-index: 100; width: 68px; height: 68px; pointer-events: none; opacity: .9; transform: translate(-50%,-50%) rotate(5deg); border: 5px solid var(--ink); }
.drag-ghost.circle { background: var(--clay-orange); border-radius: 50%; }.drag-ghost.square { background: var(--clay-blue); }.drag-ghost.triangle { background: var(--clay-red); border: 0; clip-path: polygon(50% 0,100% 100%,0 100%); }.drag-ghost.rectangle { background: var(--clay-green); width: 92px; height: 56px; }

.quiz-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(51,39,31,.73); }
.quiz-paper { width: min(620px,100%); max-height: 94dvh; overflow: auto; background: #fff6d8; border: 6px solid var(--ink); padding: clamp(18px,4vw,34px); box-shadow: 12px 12px 0 #ef9d42; transform: rotate(-.5deg); }
.quiz-kicker { color: #a84a3f; font-weight: 1000; margin: 0; }.quiz-kicker span { float: right; }
.quiz-paper h2 { font-size: clamp(1.25rem,4vw,1.75rem); line-height: 1.5; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-choice { min-height: 58px; border: 4px solid var(--ink); background: #fff; font-weight: 900; cursor: pointer; }
.quiz-choice.correct { background: #dff4be; }.quiz-choice.wrong { background: #ffd0bd; }
.quiz-explanation { margin: 15px 0; padding: 12px; border-left: 8px solid var(--clay-blue); background: #e5f4f5; font-weight: 800; line-height: 1.55; }

.result-screen { min-height: 100dvh; padding: clamp(30px,7vw,70px) max(18px,env(safe-area-inset-left)); background: #fff6d8; text-align: center; }
.result-screen::before { content: ""; position: absolute; inset: 0; background: linear-gradient(175deg,#bde7ef 0 36%,transparent 36%); z-index: 0; }
.result-screen > * { position: relative; z-index: 2; }.result-sun { width: 145px; height: 145px; right: 8%; top: 3%; z-index: 1; }
.result-screen h2 { margin: 0; font-size: clamp(2rem,6vw,4.3rem); }
.result-parade { min-height: 80px; display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.result-parade .parade-token { width: 54px; height: 54px; flex-basis: 54px; font-size: 1.7rem; }
.result-stats { display: grid; grid-template-columns: repeat(4,1fr); max-width: 760px; margin: 18px auto; border: 5px solid var(--ink); background: #fff; }
.result-stats div { padding: 12px 8px; border-right: 3px solid var(--ink); }.result-stats div:last-child { border-right: 0; }
.result-stats dt { font-size: .78rem; font-weight: 900; }.result-stats dd { margin: 4px 0 0; font-size: 1.6rem; font-weight: 1000; }
.record-message { min-height: 28px; font-weight: 900; color: #a84339; }
.result-actions { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 22px 0; }
.ranking-panel { width: min(700px,100%); margin: 26px auto 0; text-align: left; background: #fff; border: 5px solid var(--ink); padding: 12px; }
.ranking-panel button { min-height: 42px; }.ranking-panel table { width: 100%; border-collapse: collapse; }.ranking-panel th,.ranking-panel td { padding: 7px; border-bottom: 1px solid #c9b998; }

@keyframes clay-pop { 0% { transform: scale(.65) rotate(-8deg); } 65% { transform: scale(1.12) rotate(3deg); } 100% { transform: scale(1); } }
@keyframes cheer { 50% { transform: translateY(-22px) rotate(6deg); } }
@keyframes nope { 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }
@keyframes score-fly { 0% { opacity: 0; transform: translateY(10px) scale(.7); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-70px) scale(1.2); } }
@keyframes token-in { from { transform: translateY(24px) scale(.5); opacity: 0; } }
@keyframes pulse { to { transform: scale(1.08); } }

@media (max-width: 720px) {
  .start-screen { display: block; }.morning-sky { min-height: 42dvh; border-right: 0; border-bottom: 7px solid var(--ink); }.start-copy { min-height: 58dvh; padding: 24px; }
  .preview-house { transform: scale(.65); transform-origin: bottom left; }.preview-tree { transform: scale(.65); transform-origin: bottom right; }.preview-cart { transform: scale(.62); transform-origin: bottom center; }
  .street-sign { grid-template-columns: 86px 1fr 86px 52px; min-height: 64px; padding: 5px; }.timer-wrap b { font-size: 1.75rem; }.score-wrap b { font-size: 1.25rem; }.title-board span { font-size: .93rem; }.sound-button { font-size: .67rem; padding: 8px 2px; }
  .world { min-height: 345px; }.build-stage { inset: 52px 0 58px; }.target-board { width: min(78vw,390px); height: 225px; }.clay-character { right: -5px; transform: scale(.72); transform-origin: bottom right; }
  .piece { width: 58px; height: 58px; border-width: 4px; }.piece.rectangle { width: 78px; height: 48px; }.piece-tray { gap: 10px; min-height: 72px; }.feedback { max-width: 72%; }
  .result-stats { grid-template-columns: 1fr 1fr; }.result-stats div { border-bottom: 3px solid var(--ink); }.result-stats div:nth-child(2) { border-right: 0; }.result-stats div:nth-child(n+3) { border-bottom: 0; }
}
@media (max-width: 410px) {
  .shape-legend { gap: 7px; }.shape-legend span { font-size: .78rem; }.mini { width: 22px; height: 22px; }.mini.rectangle { width: 30px; height: 18px; }
  .world { min-height: 320px; }.target-board { width: 80vw; height: 205px; min-height: 190px; }.piece-tray { gap: 7px; }.piece { width: 52px; height: 52px; }.piece.rectangle { width: 69px; height: 44px; }.touch-hint { font-size: .64rem; }
  .quiz-choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
