/* «Мышка и кот» — оформление в стиле Apricat (токены как в src/page.html). */
:root {
  --sky: #dff1fb;
  --card: #fffdf7;
  --apricot: #f7871f;
  --apricot-2: #ffc173;
  --apricot-ink: #a94a05;
  --ink: #4a2610;
  --ink-soft: #6e4429;
  --shade: rgb(74 38 16 / 0.85);
  --on-apricot: #2b1203;
  --f: "Rubik", "Arial Rounded MT Bold", system-ui, sans-serif;
  --r: 22px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--f); color: var(--ink); background: var(--sky);
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; letter-spacing: -0.015em; line-height: 1.05; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }

.panel { background: var(--card); border: 3px solid var(--ink); border-radius: var(--r); box-shadow: 5px 5px 0 var(--shade); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px;
  border-radius: 999px; border: 3px solid var(--ink); font: 800 16px var(--f); color: var(--ink); background: var(--card);
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: 3px 3px 0 var(--shade);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shade); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shade); }
.btn:focus-visible { outline: 3px solid var(--apricot); outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--shade); }
.btn-a { background: var(--apricot); color: var(--on-apricot); }
.btn.big { height: 56px; padding: 0 28px; font-size: 19px; }
.btn.sm { height: 38px; padding: 0 13px; font-size: 14px; box-shadow: 2px 2px 0 var(--shade); }
.btn[aria-pressed="false"] { background: #eadfce; color: var(--ink-soft); }

/* ---------- раскладка ---------- */
.game {
  height: 100vh; height: 100dvh; max-width: 1480px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.stage {
  position: relative; min-height: 0; overflow: hidden; background: #f3dcae;
  border: 3px solid var(--ink); border-radius: 26px; box-shadow: 6px 6px 0 var(--shade);
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

.hud, .tools { position: absolute; top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; }
.hud { left: 10px; }
.tools { right: 10px; justify-content: flex-end; }
.tools > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 13px; border-radius: 999px;
  background: var(--card); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--shade); font: 800 15px var(--f); white-space: nowrap;
}
.hearts svg { width: 22px; height: 22px; display: block; transition: transform 0.3s var(--spring); }
.hearts svg path { fill: #e8473f; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.hearts svg.lost { transform: scale(0.8); }
.hearts svg.lost path { fill: #eadfce; }

.toast {
  position: absolute; left: 50%; bottom: 16px; max-width: calc(100% - 28px); padding: 9px 18px; border-radius: 999px; text-align: center;
  background: var(--card); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--shade); font: 800 17px/1.2 var(--f); text-wrap: balance;
  transform: translate(-50%, 16px) scale(0.9); opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--spring);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.action { position: absolute; right: 12px; bottom: 70px; z-index: 2; }

/* ---------- листок со стихом ---------- */
.poem { align-self: start; max-height: 100%; overflow: auto; padding: 18px 20px 16px; transform: rotate(-1.2deg); margin-top: 6px; }
.poem h2, .sheet h2 { font-size: 26px; font-weight: 900; color: var(--apricot-ink); text-align: center; }
.lines { list-style: none; margin: 12px 0 0; padding: 0; text-align: center; font-weight: 500; font-size: 16px; line-height: 1.38; }
.lines li { white-space: nowrap; transition: opacity 0.6s var(--ease), color 0.2s, transform 0.2s var(--ease); }
.lines { overflow: hidden; }
.lines li:nth-child(4n + 1):not(:first-child) { margin-top: 10px; }
.lines li { width: fit-content; max-width: 100%; margin-inline: auto; border-radius: 999px; }
/* ещё не открытая строка: пустая плашка вместо бледного текста (контраст, доступность) */
.lines li.off { color: transparent; background: rgba(74, 38, 16, 0.09); user-select: none; }
html.booting .sheet, html.booting .poem, html.booting .hud, html.booting .tools { visibility: hidden; }
.lines li.now { color: var(--apricot-ink); font-weight: 800; transform: scale(1.05); }
.lines.big { font-size: 18px; }

/* ---------- экраны поверх игры ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 14px; overflow: auto;
  background: rgb(223 241 251 / 0.8);
}
.sheet { position: relative; width: min(480px, 100%); padding: 22px 22px 24px; text-align: center; animation: pop 0.45s var(--spring) both; }
.sheet h1 { font-size: clamp(34px, 9vw, 46px); font-weight: 900; color: var(--apricot-ink); }
.sheet .lang { position: absolute; top: 12px; right: 12px; }
.mascot { display: block; margin: -6px auto 8px; border-radius: 22px; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--shade); }
.how { margin-top: 12px; font-size: 16px; line-height: 1.4; font-weight: 500; text-wrap: pretty; }
.about { margin-top: 12px; text-align: left; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.about summary { cursor: pointer; text-align: center; font-weight: 800; color: var(--ink); list-style: none; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: ' ▾'; }
.about[open] summary::after { content: ' ▴'; }
.about p { margin-top: 8px; text-wrap: pretty; }
.eyebrow { margin-bottom: 6px; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.error { margin-top: 12px; padding: 8px 12px; border-radius: 12px; background: #ffe3dc; font-weight: 700; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.94); } to { opacity: 1; transform: none; } }

/* ---------- телефон: стих под игрой ---------- */
@media (max-width: 760px) {
  .game { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom)); }
  .stage { border-radius: 20px; box-shadow: 4px 4px 0 var(--shade); }
  .poem { transform: none; margin: 0 2px 0 0; padding: 10px 12px; align-self: stretch; max-height: 40dvh; box-shadow: 4px 4px 0 var(--shade); }
  .poem h2 { font-size: 19px; }
  .lines { margin-top: 5px; font-size: 13.5px; line-height: 1.3; }
  .lines li:nth-child(4n + 1):not(:first-child) { margin-top: 5px; }
  .hud, .tools { top: 8px; gap: 6px; }
  .hud { left: 8px; flex-direction: column; align-items: flex-start; }
  .tools { right: 8px; }
  .pill, .btn.sm { height: 34px; padding: 0 10px; font-size: 13px; }
  .hearts svg { width: 19px; height: 19px; }
  .toast { font-size: 15px; bottom: 10px; }
  .action { right: 8px; bottom: 58px; height: 50px; padding: 0 20px; font-size: 17px; }
  .lines.big { font-size: 16px; line-height: 1.34; }
  .sheet { padding: 18px 16px 20px; }
}

/* ---------- телефон боком ---------- */
@media (max-height: 480px) and (min-width: 600px) {
  .game { grid-template-columns: minmax(0, 1fr) 240px; gap: 10px; padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
  .poem { transform: none; margin: 0; padding: 8px 10px; }
  .poem h2 { font-size: 17px; }
  .lines { margin-top: 4px; font-size: 12px; line-height: 1.24; }
  .lines li:nth-child(4n + 1):not(:first-child) { margin-top: 4px; }
  .hud { flex-direction: column; align-items: flex-start; gap: 6px; }
  .pill, .btn.sm { height: 34px; padding: 0 10px; font-size: 13px; }
  .sheet { padding: 12px 16px 14px; width: min(720px, 100%); }
  .sheet h2 { font-size: 21px; }
  .mascot { width: 52px; height: 52px; margin: 0 auto 4px; }
  .lines.big { margin-top: 8px; font-size: 13.5px; line-height: 1.3; columns: 3; column-gap: 14px; }
  .lines.big li { break-inside: avoid; }
  .lines.big li:nth-child(4n + 1):not(:first-child) { margin-top: 0; }
  .how { margin-top: 6px; font-size: 14px; }
  .row { margin-top: 10px; }
  .btn.big { height: 46px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .btn, .toast, .lines li { transition: none; }
}
