:root {
  color-scheme: light;
  --ink: #27313c;
  --muted: #5c6470;
  --line: #d7cdbd;
  --blue: #0b4f76;
  --blue-soft: #dff1fb;
  --pink: #8a1643;
  --pink-soft: #ffe5ee;
  --orange: #84400b;
  --green: #14553f;
  --green-soft: #dcf5e9;
  --purple: #4e2d78;
  --focus: #132d4a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: linear-gradient(145deg, #fff8e9, #f4fbff 70%, #fff3f7);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 18px;
  line-height: 1.45;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.app-shell { width: min(1120px, 100%); margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) 36px max(16px, env(safe-area-inset-left)); overflow: hidden; }
.app-header { text-align: center; }
.eyebrow { margin: 0; color: var(--blue); font-weight: 800; font-size: 0.95rem; }
h1 { margin: 2px 0; font-size: clamp(1.8rem, 5vw, 2.8rem); line-height: 1.2; }
.pattern-description { min-height: 1.5em; margin: 0; color: var(--muted); font-weight: 700; }
.entrance-section, .sentence-area, .shelf-section { margin-top: 18px; }
.entrance-tabs, .pattern-tabs, .category-tabs { display: flex; gap: 10px; align-items: stretch; }
.entrance-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entrance-tab, .pattern-tab, .category-tab { border: 2px solid var(--line); background: #fff; border-radius: 16px; cursor: pointer; font-weight: 800; }
.entrance-tab { min-height: 70px; padding: 8px; font-size: clamp(1rem, 2.8vw, 1.25rem); }
.entrance-tab[aria-selected="true"] { color: white; border-color: var(--blue); background: var(--blue); box-shadow: 0 4px 0 #155276; }
.pattern-tabs { margin-top: 10px; overflow-x: auto; padding: 2px 1px 7px; }
.pattern-tab { min-height: 48px; padding: 6px 14px; white-space: nowrap; font-size: 1rem; }
.pattern-tab[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-soft); color: #7c1737; }
.sentence-area { padding: 16px; border: 3px solid #d8e7ed; border-radius: 24px; background: rgba(255,255,255,.86); box-shadow: 0 7px 18px rgba(39,49,60,.08); }
.guide { margin: 0 0 10px; color: var(--muted); font-weight: 700; }
.sentence-strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; min-height: 122px; }
.sentence-slot { position: relative; flex: 1 1 145px; min-width: 132px; min-height: 112px; padding: 8px; border: 3px dashed var(--line); border-radius: 18px; background: #fffdf8; text-align: center; cursor: pointer; }
.sentence-slot.can-drop { border-style: solid; border-color: var(--blue); background: var(--blue-soft); }
.sentence-slot.drop-target { transform: translateY(-4px); border-color: var(--green); background: var(--green-soft); }
.sentence-slot .slot-label { display: block; color: var(--muted); font-size: .85rem; font-weight: 800; }
.particle { padding: 0 3px; font-size: 1.55rem; font-weight: 900; }
.placed-card { display: flex; width: 100%; min-height: 96px; border: 0; border-radius: 14px; padding: 5px; background: var(--card-soft); color: var(--card-ink); cursor: pointer; font-size: 1.05rem; font-weight: 900; flex-direction: column; align-items: center; justify-content: center; }
.placed-card img { display: block; width: 68px; height: 68px; border-radius: 10px; object-fit: contain; }
.placed-card .card-emoji { display: block; width: 68px; height: 68px; font-size: 58px; line-height: 68px; }
.completed-sentence { min-height: 64px; margin: 12px 0; padding: 10px; border-radius: 16px; background: #fff4cd; text-align: center; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 900; word-break: keep-all; }
.sentence-part { display: inline-block; padding: 1px 3px; border-radius: 7px; }
.sentence-part.is-speaking { color: white; background: var(--orange); transform: scale(1.05); }
.actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.speak-button, .clear-button { border: 0; border-radius: 18px; cursor: pointer; font-weight: 900; }
.speak-button { min-width: min(100%, 320px); min-height: 64px; padding: 10px 28px; color: white; background: var(--green); box-shadow: 0 4px 0 #155440; font-size: 1.35rem; }
.speak-button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.clear-button { min-height: 48px; padding: 8px 18px; border: 2px solid #af4725; background: #fff6ee; color: #842d13; }
.shelf-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
h2 { margin: 0; font-size: 1.35rem; }
.shelf-heading p { margin: 0; color: var(--muted); font-size: .95rem; font-weight: 700; }
.category-tabs { overflow-x: auto; padding: 4px 1px 10px; }
.category-tab { min-height: 48px; padding: 8px 16px; white-space: nowrap; }
.category-tab[aria-selected="true"] { border-color: var(--purple); color: white; background: var(--purple); }
.character-choice { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 10px; border: 2px solid #ecd5de; border-radius: 16px; background: rgba(255,255,255,.78); }
.character-choice[hidden] { display: none; }
.character-choice-label { margin-right: 2px; color: var(--muted); font-size: .9rem; font-weight: 800; white-space: nowrap; }
.character-choice-button { min-height: 48px; padding: 7px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; font-weight: 900; white-space: nowrap; }
.character-choice-button[aria-pressed="true"] { border-color: var(--pink); color: #7c1737; background: var(--pink-soft); box-shadow: 0 3px 0 #c795a8; }
.card-shelf { display: flex; gap: 14px; min-height: 186px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px 14px; scroll-snap-type: x proximity; touch-action: pan-x; }
.word-card { flex: 0 0 156px; min-width: 156px; min-height: 170px; padding: 8px; border: 3px solid var(--card-border); border-radius: 20px; background: var(--card-soft); color: var(--card-ink); cursor: grab; font-size: 1.05rem; font-weight: 900; text-align: center; scroll-snap-align: start; touch-action: pan-x; user-select: none; }
.word-card.is-selected { box-shadow: 0 0 0 5px #1c4165; transform: translateY(-3px); }
.word-card.is-dragging { opacity: .65; }
.word-card:active { cursor: grabbing; }
.word-card img { display: block; width: 100px; height: 100px; margin: 0 auto 4px; border-radius: 14px; object-fit: contain; }
.word-card .card-emoji { display: block; width: 100px; height: 100px; margin: 0 auto 4px; font-size: 82px; line-height: 100px; }
.word-card .role-mark { display: block; margin-top: 2px; font-size: .78rem; }
.empty-message { padding: 26px 10px; color: var(--muted); font-weight: 800; }
.drag-ghost { position: fixed; z-index: 10; width: 120px; min-height: 100px; padding: 8px; border: 3px solid var(--card-border); border-radius: 18px; background: var(--card-soft); color: var(--card-ink); text-align: center; font-weight: 900; opacity: .92; pointer-events: none; transform: translate(-50%, -50%) rotate(-2deg); box-shadow: 0 10px 22px rgba(0,0,0,.2); }
.drag-ghost img { display: block; width: 72px; height: 72px; margin: 0 auto 2px; border-radius: 10px; object-fit: contain; }
.drag-ghost .card-emoji { display: block; width: 72px; height: 72px; margin: 0 auto 2px; font-size: 60px; line-height: 72px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* LiNest共通テーマより、このアプリの子ども向けタッチ寸法を優先する。 */
body.linest-themed .entrance-tab { min-height: 70px; }
body.linest-themed .pattern-tab,
body.linest-themed .category-tab,
body.linest-themed .clear-button,
body.linest-themed .character-choice-button { min-height: 48px; }
body.linest-themed .sentence-slot { min-height: 112px; }
body.linest-themed .placed-card { min-height: 96px; }
body.linest-themed .speak-button { min-height: 64px; }
body.linest-themed .word-card { min-height: 170px; }

@media (max-width: 560px) {
  .app-shell { padding-top: 14px; }
  .entrance-tabs { gap: 6px; }
  .entrance-tab { min-height: 76px; font-size: .96rem; line-height: 1.2; }
  body.linest-themed .entrance-tab { min-height: 76px; }
  .sentence-area { padding: 12px; border-radius: 20px; }
  .sentence-slot { flex-basis: 100px; min-width: 100px; }
  .particle { font-size: 1.25rem; }
  .shelf-heading { align-items: flex-start; flex-direction: column; gap: 1px; }
  .character-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .character-choice-label { grid-column: 1 / -1; }
  .character-choice-button { width: 100%; padding-right: 8px; padding-left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .sentence-part.is-speaking { transform: none; }
}
