/* «Ёлочные игрушки» — страница игры. Бордо, золото, сливки; бархатная шкатулка. */
:root {
  --velvet: #1e0509; --bordo: #4c0d16; --bordo2: #6a1a26; --gold: #c8a559; --gold-soft: #e6cb86; --cream: #f3e6d3; --card: #f7efe6;
  --ink: #2a0b11; --muted: #6e5359;
  --serif: "Cormorant Garamond", Georgia, serif; --sans: Montserrat, "Segoe UI", Arial, sans-serif;
  --bar-h: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; animation-timing-function: cubic-bezier(.2,.7,.2,1); }
}
html { background: var(--velvet); overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; color: var(--cream); font: 400 16px/1.5 var(--sans);
  background: radial-gradient(120% 70% at 50% -10%, #4a0c18 0%, var(--velvet) 62%) fixed;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--gold-soft); color: var(--velvet); }
:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.bar { display: flex; align-items: center; justify-content: space-between; height: var(--bar-h); max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.bar .logo img { display: block; height: 44px; width: auto; }
.bar .back { display: inline-flex; align-items: center; min-height: 44px; color: var(--cream); font-weight: 600; text-decoration: none; }
.bar .back:hover { color: var(--gold-soft); }

.game {
  display: grid; grid-template-columns: minmax(240px, 300px) auto; justify-content: center; align-items: start;
  gap: clamp(24px, 4vw, 56px); max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 40px;
}
.title { margin: 0; font: 500 clamp(40px, 4.4vw, 60px)/.95 var(--serif); letter-spacing: -.02em; }
.title em { font-style: italic; color: var(--gold-soft); }
.lead { margin: 14px 0 22px; color: #e7d3bf; max-width: 30ch; }

.hud { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin: 0; }
.hud > div { padding: 10px 14px; border: 1px solid rgb(200 165 89 / .32); border-radius: 14px; background: rgb(255 240 220 / .04); }
.hud dt { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: #cdb197; }
.hud dd { margin: 2px 0 0; font: 600 26px/1.1 var(--sans); font-variant-numeric: tabular-nums; color: #fff6e8; }
.hud-next { display: grid; place-items: center; padding: 6px 10px !important; }
.hud-next dd { margin: 0; }
.hud-next canvas { display: block; width: 48px; height: 48px; }
.hud-score dd.bump { animation: bump .32s cubic-bezier(.2,.9,.3,1.4); }
@keyframes bump { 40% { transform: scale(1.12); color: var(--gold-soft); } }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tool {
  min-height: 44px; padding: 0 16px; border: 1px solid rgb(200 165 89 / .45); border-radius: 999px;
  background: transparent; color: var(--cream); font: 600 14px var(--sans); cursor: pointer;
}
.tool:hover { border-color: var(--gold-soft); color: #fff; }
.tool[aria-pressed="false"] { color: #b9a08c; text-decoration: line-through; text-decoration-color: rgb(230 203 134 / .7); }

.chain { margin-top: 26px; }
.chain h2 { margin: 0 0 10px; font: 600 13px var(--sans); letter-spacing: .04em; color: #cdb197; }
.chain ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 4px; }
.chain li { display: grid; justify-items: center; gap: 2px; font-size: 11px; line-height: 1.2; text-align: center; color: #cdb197; }
.chain li canvas { width: 44px; height: 48px; }
.chain li.locked canvas { filter: grayscale(1) brightness(.45); opacity: .55; }
.chain li.locked span { opacity: .55; }

.stage { position: relative; justify-self: center; }
#field {
  display: block; border-radius: 22px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: none; outline: none;
}
#field:focus-visible { box-shadow: 0 0 0 3px var(--velvet), 0 0 0 5px var(--gold-soft); }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 18px; border-radius: 22px;
  background: rgb(20 3 7 / .58); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.card {
  width: min(100%, 360px); padding: 26px 24px 22px; border-radius: 20px; background: var(--card); color: var(--ink); text-align: center;
  box-shadow: 0 0 0 1px rgb(200 165 89 / .6), 0 30px 60px -30px #000;
}
.card h2 { margin: 0 0 10px; font: 500 34px/1 var(--serif); color: var(--bordo); }
.card h2 em { font-style: italic; color: #a77f2c; }
.card p { margin: 0 0 10px; }
.card .small { font-size: 14px; color: var(--muted); }
.primary, .ghost {
  display: inline-grid; place-items: center; min-height: 52px; padding: 0 26px; border-radius: 999px; font: 600 16px var(--sans); cursor: pointer; text-decoration: none;
}
.primary { border: 0; background: var(--bordo); color: #fff; margin-top: 6px; }
.primary:hover { background: var(--bordo2); }
.ghost { border: 1px solid #d8c6b4; background: transparent; color: var(--bordo); }
.card :focus-visible { outline-color: var(--bordo); }
#over-top { display: block; width: 100px; height: 110px; margin: 2px auto 0; }
.over-top-name { font: italic 500 22px/1.1 var(--serif); color: var(--bordo); }
.over-score { font: 600 40px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); }
.over-score small { font-size: 15px; font-weight: 500; color: var(--muted); }
.over-best { font-size: 14px; color: var(--muted); min-height: 1.4em; }
.over-best.record { color: #8a6416; font-weight: 700; }
.over-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0 14px; }
.over-shop { font-size: 14px; color: var(--muted); }
.over-shop a { color: var(--bordo); font-weight: 700; }
.share-note { font-size: 13px; color: var(--muted); min-height: 1.2em; margin: 0 !important; }

/* Телефон: игра целиком в экране — счёт сверху, поле, список игрушек ниже сгиба. */
@media (max-width: 760px) {
  :root { --bar-h: 52px; }
  .bar .logo img { height: 36px; }
  .game { grid-template-columns: 1fr; gap: 10px; padding: 0 12px 28px; }
  .side { display: contents; }
  .title, .lead { display: none; }
  .hud { order: 1; grid-template-columns: 1fr 1fr auto auto; align-items: stretch; gap: 6px; }
  .hud > div { padding: 6px 10px; border-radius: 12px; }
  .hud dt { font-size: 11px; }
  .hud dd { font-size: 20px; }
  .hud-next canvas { width: 38px; height: 38px; }
  .tools { order: 3; margin: 2px 0 0; justify-content: center; }
  .stage { order: 2; }
  .chain { order: 4; margin-top: 14px; }
  .chain ol { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 360px) {
  .hud dd { font-size: 18px; }
  .tool { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-score dd.bump { animation: none; }
}
