:root {
  color-scheme: light;
  --paper: #f5f0e8;
  --ink: #29241f;
  --muted: #716b63;
  --line: #d8cabb;
  --card: #fffaf0;
  --accent: #285b68;
  --accent-2: #8b4f78;
  --accent-3: #bd7f35;
  --shadow: 0 18px 44px rgba(47, 39, 30, 0.15);
  font-family: "Droid Sans Fallback", "Hiragino Sans", "Yu Gothic", "YuGothic", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    linear-gradient(90deg, rgba(40, 91, 104, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(139, 79, 120, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
}
a { color: inherit; }
button, textarea { font: inherit; }

.page-shell { width: min(100%, 1080px); margin: 0 auto; padding: 24px clamp(14px, 3vw, 32px) 30px; }
.lab-header { display: grid; gap: 9px; margin: 0 0 18px; }
.lab-mark, .lab-kicker { width: fit-content; margin: 0; border: 1px solid var(--line); background: rgba(255, 250, 240, 0.78); color: var(--muted); font-size: 0.82rem; letter-spacing: 0; }
.lab-mark { padding: 7px 10px; text-decoration: none; font-weight: 800; }
.lab-kicker { padding: 5px 9px; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4.65rem); line-height: 0.98; letter-spacing: 0; }
h1 span { display: block; margin-top: 8px; color: var(--accent); font-size: clamp(1.05rem, 2.5vw, 1.55rem); }
.lead { max-width: 690px; margin: 0; color: var(--muted); line-height: 1.75; }

.game-card { display: grid; gap: 14px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 250, 240, 0.94); box-shadow: var(--shadow); padding: clamp(14px, 2.4vw, 24px); }
.rule-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rule-strip div, .score-row { border: 1px solid var(--line); border-radius: 6px; background: #fffdf7; }
.rule-strip div { min-width: 0; padding: 10px; }
.rule-strip strong, .rule-strip span { display: block; }
.rule-strip strong { color: var(--accent-2); font-size: 0.78rem; }
.rule-strip span { margin-top: 4px; color: var(--muted); font-size: 0.88rem; }
.score-row { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; padding: 10px 12px; font-weight: 800; color: var(--accent); }

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.primary-button, .ghost-button { min-height: 44px; border-radius: 8px; border: 1px solid var(--accent); padding: 0 18px; font-weight: 900; cursor: pointer; }
.primary-button { background: var(--accent); color: #fffdf8; }
.ghost-button { background: #fffdf8; color: var(--accent); }
.status-text { margin: 0; color: var(--accent-2); font-weight: 900; }
.game-card.is-clear .status-text { color: var(--accent); }
.game-card.is-trapped .status-text { color: #ad3b2f; }
.game-card.is-complete .status-text { color: #72540d; }

.echo-stage { position: relative; min-height: 265px; overflow: hidden; border: 1px solid #cbbba4; border-radius: 8px; background: radial-gradient(circle at 18% 20%, rgba(139, 79, 120, 0.12), transparent 34%), radial-gradient(circle at 82% 76%, rgba(40, 91, 104, 0.13), transparent 30%), #fbf6eb; }
.stage-guide { position: absolute; inset: 18px auto auto 18px; z-index: 4; max-width: min(480px, calc(100% - 36px)); border: 1px dashed #b9aa93; border-radius: 6px; background: rgba(255, 250, 240, 0.86); padding: 12px 14px; color: var(--muted); line-height: 1.6; }
[hidden] { display: none !important; }
.echo-layer { position: absolute; inset: 0; pointer-events: none; }
.echo-card { position: absolute; width: min(74%, 540px); border: 1px solid rgba(40, 91, 104, 0.34); border-radius: 8px; background: rgba(255, 253, 247, 0.5); color: rgba(41, 36, 31, 0.34); padding: 13px 18px; font-weight: 900; font-size: clamp(1rem, 2.3vw, 1.7rem); line-height: 1.35; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); white-space: normal; overflow-wrap: anywhere; }
.echo-layer.is-hard .echo-card { animation: echo-drift var(--speed, 3.4s) ease-in-out infinite alternate; }
.echo-card:nth-child(2) { color: rgba(139, 79, 120, 0.28); }
.echo-card:nth-child(3) { color: rgba(189, 127, 53, 0.32); }
.target-card { position: absolute; z-index: 3; left: 50%; top: 50%; width: min(88%, 590px); transform: translate(-50%, -50%); border: 2px solid var(--accent); border-radius: 8px; background: rgba(255, 253, 247, 0.97); box-shadow: 0 12px 24px rgba(39, 35, 29, 0.18); padding: 16px clamp(14px, 3vw, 24px); text-align: center; }
.target-label { display: inline-block; margin-bottom: 8px; border: 1px solid var(--accent); border-radius: 999px; padding: 4px 10px; color: var(--accent); font-size: 0.78rem; font-weight: 900; }
#targetText { margin: 0; font-size: clamp(1.25rem, 3vw, 2.05rem); font-weight: 900; line-height: 1.35; overflow-wrap: anywhere; }
.input-label { font-weight: 900; color: var(--accent); }
#answerInput { width: 100%; resize: vertical; min-height: 70px; border: 2px solid #c9baa2; border-radius: 8px; background: #fffdf8; color: var(--ink); padding: 13px 14px; line-height: 1.55; }
#answerInput:focus { outline: 3px solid rgba(40, 91, 104, 0.22); border-color: var(--accent); }
.site-footer { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.site-footer a { border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 250, 240, 0.82); padding: 10px 12px; text-decoration: none; color: var(--muted); font-weight: 800; }

@keyframes echo-drift { from { transform: translate(calc(-50% - 2px), calc(-50% + 1px)) rotate(var(--rot, 0deg)); } to { transform: translate(calc(-50% + 5px), calc(-50% - 3px)) rotate(calc(var(--rot, 0deg) + 2deg)); } }

@media (max-width: 620px) {
  .page-shell { padding: 14px 10px 22px; }
  .lab-header { gap: 7px; margin-bottom: 12px; }
  h1 { font-size: 2.15rem; }
  .lead { font-size: 0.95rem; }
  .game-card { gap: 11px; padding: 12px; }
  .rule-strip { grid-template-columns: 1fr; }
  .rule-strip div { padding: 8px 10px; }
  .rule-strip span { font-size: 0.84rem; }
  .echo-stage { min-height: 230px; }
  .stage-guide { inset: 12px 12px auto 12px; }
  .echo-card { width: calc(100% - 36px); padding: 10px 12px; }
  .target-card { width: calc(100% - 24px); padding: 14px 12px; }
  #answerInput { min-height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .echo-layer.is-hard .echo-card { animation: none !important; }
}
