:root {
  --bg: #17120e; --card: #2b2119; --line: #3d3025;
  --text: #f3ead8; --muted: #b9a88c; --gold: #e0ad4f; --gold2: #f5cf7e;
  --ok: #5fb36a; --bad: #d9584a;
  --cell: #fbf6ea; --given: #2b2118; --user: #2f63b5; --peer: #efe2c4; --same: #f3d48f; --selc: #f0c35e;
  --thin: #c9b99a; --thick: #3b2b1d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, "Noto Sans", system-ui, sans-serif; }
#app { width: 100%; max-width: 760px; margin: 0 auto; position: relative; overflow-x: clip;
  background: radial-gradient(ellipse at top, #2a2018 0%, var(--bg) 60%); }
.screen { display: none; padding: 16px 14px 24px; flex-direction: column; }
.screen.on { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
[hidden] { display: none !important; }
.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); margin-bottom: 4px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); box-shadow: none; font-weight: 600; }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
  font-size: 19px; display: grid; place-items: center; flex: none; }
.iconbtn.on { background: var(--gold); color: #2a1d0c; }
.muted { color: var(--muted); }

/* главная */
.hero { text-align: center; margin: 4px 0 12px; }
.hero h1 { margin: 6px 0 2px; font-size: 26px; }
.logo { width: 64px; height: 64px; margin: 0 auto; }
.logo svg { width: 100%; height: 100%; }
.pills { display: flex; gap: 8px; justify-content: center; margin: 6px 0 14px; 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: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.daycard .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.daycard .no { color: var(--gold2); font-weight: 700; }
.daycard .lvl { margin: 4px 0 10px; color: var(--muted); }
.status { font-weight: 700; margin-bottom: 10px; }
.status.ok { color: var(--ok); }
h3.sub { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.levels .btn { margin: 0; padding: 12px 8px; font-size: 16px; }
.levels .btn small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.setrow { display: flex; align-items: center; justify-content: space-between; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; gap: 10px; }
.seg { display: flex; gap: 6px; }
.seg button { background: #221a14; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 14px; }
.seg button.on { background: var(--gold); color: #2a1d0c; font-weight: 700; }
.other { display: block; text-align: center; color: var(--gold2); margin: 8px 0 0; font-weight: 600; text-decoration: none; }
.credit { text-align: center; font-size: 11px; color: #7d6e58; margin-top: 16px; letter-spacing: .15em; }

/* игра */
.hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.hdr h2 { flex: 1; margin: 0; font-size: 17px; text-align: center; line-height: 1.2; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold2); min-width: 52px; text-align: right; }
.boardscroll { flex: 1; min-width: 0; overflow: auto; border-radius: 8px; -webkit-overflow-scrolling: touch; }
.board { display: grid; width: 100%; aspect-ratio: 1; user-select: none; touch-action: manipulation; margin: 0 auto; }
.board.zoom { width: 190%; }
.c { position: relative; background: var(--cell); color: var(--user); display: grid; place-items: center;
  font-size: calc(var(--cs) * .62); font-weight: 600; line-height: 1; cursor: pointer;
  border-right: 1px solid var(--thin); border-bottom: 1px solid var(--thin); }
.c.bl { border-left: 2px solid var(--thick); } .c.bt { border-top: 2px solid var(--thick); }
.c.br { border-right: 2px solid var(--thick); } .c.bb { border-bottom: 2px solid var(--thick); }
.c.g { color: var(--given); font-weight: 700; }
.c.peer { background: var(--peer); }
.c.same { background: var(--same); }
.c.sel { background: var(--selc); }
.c.err { color: var(--bad); }
.c.conf { background: #f6c7bf; }
.c.sel.conf { background: #eea99d; }
.c.hint { animation: hint 1s ease; }
@keyframes hint { from { background: #9fd8a6; } }
.nts { position: absolute; inset: 1px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: calc(var(--cs) * .27); color: #6b5a44; font-weight: 600; }
.nts span { display: grid; place-items: center; }
.nts span.hl { color: #b0330e; }
.board.win .c { animation: winp .6s ease both; }
@keyframes winp { 50% { background: #cfe9c8; } }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 10px; }
.tool { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 4px; font-size: 20px; position: relative; }
.tool small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tool i { position: absolute; top: 4px; right: 6px; font-size: 10px; font-style: normal; color: var(--muted); }
.tool:disabled { opacity: .45; }
.tool.on { background: var(--gold); color: #2a1d0c; } .tool.on small, .tool.on i { color: #2a1d0c; }
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.pad button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 0 4px; font-size: 24px; font-weight: 700; color: var(--gold2); }
.pad button small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.pad button.done { opacity: .3; }
.pad.notes button { color: var(--text); font-size: 18px; }

.result { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; text-align: center; margin-top: 14px; }
.result h3 { margin: 0 0 6px; font-size: 22px; }
.result .big { font-size: 30px; font-weight: 800; color: var(--gold2); margin: 6px 0; font-variant-numeric: tabular-nums; }
.result .btns { display: grid; gap: 10px; margin-top: 12px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold2); }

.overlay { position: fixed; inset: 0; background: rgba(10, 7, 5, .7); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 120px 20px 20px; }
.overlay.on { display: flex; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; width: 100%; max-width: 320px; text-align: center; }
.spin { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; margin: 4px auto; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.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; text-align: center; }
.toast.on { display: block; }
@media (max-width: 380px) { .pad button { font-size: 20px; } .tool { font-size: 17px; } }

/* поле слева; справа два столбика: цифры 1–9 и кнопки «Отменить/Стереть/Пометки/Подсказка» */
.play { display: flex; gap: 8px; align-items: stretch; }
.side { flex: none; display: flex; gap: 8px; }
.side .pad { width: 56px; grid-template-columns: 1fr; grid-template-rows: repeat(9, 1fr); gap: 4px; }
.side .pad button { padding: 0; font-size: 22px; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 0; }
.side .pad button small { display: inline; font-size: 10px; }
.side .tools { width: 92px; grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); margin: 0; gap: 6px; }
.side .tool { font-size: 20px; padding: 4px 2px; }
.side .tool small { font-size: 11px; }
@media (max-width: 480px) {
  .play, .side { gap: 5px; }
  .side .pad { width: 40px; } .side .pad button { font-size: 18px; flex-direction: column; gap: 0; } .side .pad button small { font-size: 8px; }
  .side .tools { width: 52px; } .side .tool { font-size: 17px; } .side .tool small { font-size: 8px; } .side .tool i { display: none; }
}
/* Самурай на узком телефоне: поле на всю ширину, кнопки под ним (иначе клетки слишком мелкие) */
@media (max-width: 560px) {
  .samurai .play { flex-direction: column; } .samurai .boardscroll { flex: none; width: 100%; }
  .samurai .side { flex-direction: column; width: 100%; }
  .samurai .side .pad { width: 100%; grid-template-columns: repeat(9, 1fr); grid-template-rows: none; }
  .samurai .side .pad button { flex-direction: column; padding: 6px 0 3px; font-size: 22px; gap: 0; }
  .samurai .side .tools { width: 100%; grid-template-columns: repeat(4, 1fr); grid-template-rows: none; }
  .samurai .side .tool small { font-size: 11px; }
}

/* выпадающее меню цифр у клетки: квадрат 3×3 + стереть / пометки / закрыть */
.npop { position: fixed; z-index: 40; display: none; grid-template-columns: repeat(3, 44px); gap: 4px; padding: 6px;
  background: var(--card); border: 1px solid var(--gold); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.npop.on { display: grid; animation: fade .12s ease; }
.npop button { height: 44px; border-radius: 10px; background: #221a14; border: 1px solid var(--line);
  font-size: 22px; font-weight: 700; color: var(--gold2); display: grid; place-items: center; padding: 0; }
.npop button.on { background: var(--gold); color: #2a1d0c; }
.npop button.done { opacity: .3; }
.npop.notes button { color: var(--text); font-size: 18px; }
.npop.notes button.on { color: #2a1d0c; }
.npop .er, .npop .nt, .npop .cl { font-size: 18px; color: var(--muted); }
.npop.notes .nt { color: #2a1d0c; }
@media (max-width: 380px) { .npop { grid-template-columns: repeat(3, 40px); } .npop button { height: 40px; font-size: 20px; } }
