:root {
  --bg: #17120e; --bg2: #221a14; --card: #2b2119; --line: #3d3025;
  --text: #f3ead8; --muted: #b9a88c; --gold: #e0ad4f; --gold2: #f5cf7e;
  --ok: #5fb36a; --bad: #d9584a; --sqL: #ecd8b0; --sqD: #a6774c;
  --sel: rgba(245, 207, 126, .55); --last: rgba(224, 173, 79, .42); --hint: rgba(95, 179, 106, .6);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, "Noto Sans", system-ui, sans-serif; }
body { display: flex; justify-content: center; }
#app { width: 100%; max-width: 480px; min-height: 100%; position: relative; overflow-x: hidden;
  background: radial-gradient(ellipse at top, #2a2018 0%, var(--bg) 60%); }
.screen { display: none; padding: 16px 16px 28px; min-height: 100vh; flex-direction: column; }
.screen.on { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.btn { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2a1d0c; font-weight: 700;
  border-radius: 14px; padding: 14px 18px; font-size: 17px; width: 100%; box-shadow: 0 3px 0 #a57a2e; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #a57a2e; }
.btn.alt { background: var(--card); color: var(--text); box-shadow: 0 3px 0 #120d09; border: 1px solid var(--line); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); box-shadow: none; font-weight: 600; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
  font-size: 20px; display: grid; place-items: center; flex: none; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* splash */
#splash { justify-content: center; align-items: center; text-align: center; gap: 10px; }
#splash .logo { width: 120px; height: 120px; }
#splash h1 { font-size: 28px; margin: 8px 0 0; }
.brandmark { letter-spacing: .3em; font-size: 12px; color: var(--gold); font-weight: 700; margin-top: 24px; }

/* language */
#lang { justify-content: center; gap: 14px; }
#lang h2 { text-align: center; margin: 0 0 10px; }

/* header */
.hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.hdr h2 { flex: 1; margin: 0; font-size: 19px; text-align: center; }

/* home */
.hero { text-align: center; margin: 6px 0 14px; }
.hero h1 { margin: 6px 0 2px; font-size: 26px; }
.hero .logo { width: 64px; height: 64px; margin: 0 auto; }
.pills { display: flex; gap: 8px; justify-content: center; margin: 10px 0 16px; flex-wrap: wrap; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.pill b { color: var(--gold2); }
.daycard { background: linear-gradient(160deg, #3a2b1d, #261d15); border: 1px solid #5a4430; border-radius: 20px;
  padding: 16px; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.daycard .top { display: flex; justify-content: space-between; align-items: baseline; }
.daycard .no { color: var(--gold2); font-weight: 700; }
.daycard .lvl { margin: 4px 0 12px; color: var(--muted); }
.dots { display: flex; gap: 4px; margin: 0 0 12px; }
.dots i { flex: 1; height: 6px; border-radius: 3px; background: #4a3a2b; }
.dots i.on { background: var(--gold); }
.status { font-weight: 700; margin-bottom: 10px; }
.status.ok { color: var(--ok); } .status.bad { color: var(--bad); }
.menu { display: grid; gap: 10px; }
.foot { margin-top: auto; padding-top: 18px; }
.promo h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--gold); color: #2a1d0c; border-color: var(--gold); font-weight: 700; }
.credit { text-align: center; font-size: 11px; color: #7d6e58; margin-top: 12px; }

/* board */
.boardwrap { position: relative; width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 4px #3b2b1d, 0 10px 30px rgba(0,0,0,.5); margin: 6px 0 12px; touch-action: none; }
.board { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; }
.sq.l { background: var(--sqL); } .sq.d { background: var(--sqD); }
.sq.last::after, .sq.sel::after, .sq.hint::after, .sq.chk::after { content: ""; position: absolute; inset: 0; }
.sq.last::after { background: var(--last); }
.sq.sel::after { background: var(--sel); }
.sq.hint::after { background: var(--hint); animation: pulse 1s ease-in-out infinite alternate; }
.sq.chk::after { background: radial-gradient(circle, rgba(217,88,74,.95) 0%, rgba(217,88,74,.5) 45%, transparent 75%); }
@keyframes pulse { from { opacity: .5; } to { opacity: 1; } }
.sq .dot { position: absolute; inset: 37%; border-radius: 50%; background: rgba(40, 30, 20, .32); z-index: 2; pointer-events: none; }
.sq .ring { position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(40, 30, 20, .32); z-index: 2; pointer-events: none; }
.coord { position: absolute; font-size: 10px; font-weight: 700; z-index: 1; pointer-events: none; }
.coord.f { right: 3px; bottom: 1px; } .coord.r { left: 3px; top: 1px; }
.sq.l .coord { color: var(--sqD); } .sq.d .coord { color: var(--sqL); }
.pieces { position: absolute; inset: 0; pointer-events: none; }
.pce { position: absolute; width: 12.5%; height: 12.5%; transition: transform .22s ease; z-index: 3; }
.pce svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 1px rgba(0,0,0,.25)); }
.pce.fadeout { opacity: 0; transition: opacity .2s; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* puzzle info */
.info { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.turnflag { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.turnflag i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #8a7a62; display: inline-block; }
.turnflag i.w { background: #fbf6ea; } .turnflag i.b { background: #2b2622; }
.msg { min-height: 24px; text-align: center; font-weight: 600; margin: 4px 0 10px; transition: color .2s; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--bad); }
.hearts { letter-spacing: 2px; }
.goal { color: var(--gold2); font-weight: 700; }

/* result card */
.result { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; text-align: center; margin-top: 4px; }
.result h3 { margin: 0 0 6px; font-size: 22px; }
.result .grid { font-size: 22px; letter-spacing: 3px; margin: 6px 0; }
.result .san { font-family: ui-monospace, Consolas, monospace; color: var(--gold2); margin: 8px 0; line-height: 1.6; }
.result .delta { font-size: 20px; font-weight: 800; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.result .btns { display: grid; gap: 10px; margin-top: 12px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold2); }

/* archive & stats */
.list { display: grid; gap: 8px; }
.arc { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: left; width: 100%; }
.arc .n { font-weight: 800; color: var(--gold2); min-width: 44px; }
.arc .d { flex: 1; } .arc .d small { display: block; color: var(--muted); }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--gold2); }
.setrow { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; gap: 10px; }
.seg { display: flex; gap: 6px; }
.seg button { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.seg button.on { background: var(--gold); color: #2a1d0c; font-weight: 700; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(10, 7, 5, .82); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.overlay.on { display: flex; animation: fade .2s; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; width: 100%; max-width: 360px; text-align: center; }
.promos { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.promos button { width: 64px; height: 64px; border-radius: 12px; background: var(--sqL); }
.adbox { border: 2px dashed var(--gold); border-radius: 14px; padding: 28px 10px; margin: 10px 0; color: var(--gold2); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; display: none; }
.toast.on { display: block; animation: fade .2s; }

/* поворот доски на 90° (кнопка ⟳); фигуры и координаты остаются стоять ровно */
.boardwrap { transition: transform .3s ease; }
.boardwrap[data-rot="90"] { transform: rotate(90deg); } .boardwrap[data-rot="180"] { transform: rotate(180deg); } .boardwrap[data-rot="270"] { transform: rotate(270deg); }
.pce svg, .coord { transition: transform .3s ease; }
.boardwrap[data-rot="90"] .pce svg, .boardwrap[data-rot="90"] .coord { transform: rotate(-90deg); }
.boardwrap[data-rot="180"] .pce svg, .boardwrap[data-rot="180"] .coord { transform: rotate(-180deg); }
.boardwrap[data-rot="270"] .pce svg, .boardwrap[data-rot="270"] .coord { transform: rotate(-270deg); }
/* сайт: без внутренней полосы прокрутки (прокручивается вся страница, а не колонка) */
html, body { height: auto; min-height: 100%; }
body { display: block; }
#app { margin: 0 auto; overflow-x: clip; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
