@font-face {
  font-family: Onest;
  src: url("onest-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491;
}
@font-face {
  font-family: Onest;
  src: url("onest-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --ink: #191b18;
  --muted: #575b52;
  --lime: #d5f477;
  --olive: #6d8b2a;
  --line: #d9dbcf;
  --surface: #fffefa;
  --paper: #f6f5ef;
  --tabbar: 0px;
  font-family: Onest, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.55;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
a {
  color: inherit;
}
.topbar,
main {
  max-width: 1120px;
  margin: auto;
}
.topbar {
  padding: 18px 32px;
  padding-top: max(18px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.05em;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-height: 48px;
}
.brand-mark {
  background: var(--ink);
  color: var(--lime);
  border-radius: 11px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}
.tabs {
  display: flex;
  gap: 6px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 550;
  color: var(--muted);
  transition:
    background 140ms,
    color 140ms;
  -webkit-tap-highlight-color: transparent;
}
.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.tab:hover {
  color: var(--ink);
  background: #eceee5;
}
.tab[aria-current="page"] {
  color: var(--ink);
  background: var(--lime);
}
.tab-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.tab-name {
  font-size: 11px;
  font-weight: 450;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
main {
  padding: 40px 32px 48px;
}
.view {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 470px);
  column-gap: 80px;
  row-gap: 8px;
  align-items: start;
}
.view[hidden] {
  display: none;
}
.view-enter {
  animation: view-in 180ms ease-out;
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
h1 {
  font-size: clamp(42px, 5.5vw, 72px);
  line-height: 1.03;
  letter-spacing: -0.065em;
  margin: 12px 0 24px;
  font-weight: 650;
}
h1:focus {
  outline: none;
}
.dot {
  color: var(--olive);
}
.lead {
  font-size: 22px;
  line-height: 1.4;
  max-width: 360px;
  margin: 0;
}
.example {
  display: flex;
  gap: 22px;
  align-items: center;
  margin: 28px 0;
}
.example p {
  font-size: 13px;
  color: var(--muted);
}
.example strong {
  color: var(--ink);
  font-weight: 550;
}
.mini {
  display: grid;
  grid-template-columns: repeat(3, 26px);
  gap: 3px;
  flex-shrink: 0;
  background: #e7e8df;
  padding: 4px;
  border-radius: 8px;
}
.mini span {
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--surface);
  border-radius: 4px;
}
.mini .empty {
  background: transparent;
  border: 1px dashed #9ba18c;
}
.intro {
  grid-column: 1;
}
.game {
  grid-column: 2;
  grid-row: 1 / span 2;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 16px 60px #191b1808;
}
.aside {
  grid-column: 1;
  display: grid;
  gap: 12px;
  align-content: start;
}
details {
  border-top: 1px solid var(--line);
  font-size: 14px;
}
summary {
  cursor: pointer;
  padding: 13px 0;
  min-height: 48px;
}
details p {
  color: var(--muted);
}
.status-line {
  display: grid;
  gap: 2px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.text-link {
  font-size: 13px;
  color: var(--muted);
  text-underline-offset: 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-self: start;
}
.text-link:hover {
  color: var(--ink);
}
button {
  font: inherit;
  cursor: pointer;
  border: none;
  color: inherit;
  min-height: 48px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
summary:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #4d6514;
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.6;
}
.tile:disabled {
  opacity: 1;
}
.game-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}
.game-top .eyebrow {
  font-size: 10px;
}
.guidance {
  font-size: 14px;
  min-height: 44px;
  margin: 14px 0;
  color: var(--muted);
}
.board {
  position: relative;
  aspect-ratio: 1;
  background: #e8eadf;
  border-radius: 17px;
  padding: 7px;
}
.tile,
.hole {
  position: absolute;
  width: calc((100% - 28px) / 3);
  height: calc((100% - 28px) / 3);
  left: calc(7px + var(--x) * (100% - 7px) / 3);
  top: calc(7px + var(--y) * (100% - 7px) / 3);
  border-radius: 12px;
}
.tile {
  background: var(--surface);
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 550;
  box-shadow: 0 2px 0 #191b1814;
  transition:
    left 160ms ease,
    top 160ms ease,
    background 140ms;
}
.tile.movable {
  background: #f1f8de;
}
.tile:hover:not(:disabled) {
  background: var(--lime);
}
.tile.hint {
  background: var(--lime);
  box-shadow: inset 0 0 0 2px var(--olive);
}
.hole {
  border: 1.5px dashed #9ba18c;
  display: grid;
  place-items: center;
  color: #62704a;
  font-size: 22px;
}
.feedback {
  min-height: 44px;
  font-size: 13px;
  margin: 15px 0 10px;
  color: var(--muted);
}
.primary,
.secondary {
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 550;
}
.primary {
  background: var(--ink);
  color: var(--lime);
}
.primary:hover:not(:disabled) {
  background: #34392c;
}
.secondary {
  background: #eceee5;
}
.secondary:hover:not(:disabled) {
  background: #e2e5d8;
}
.small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}
.wide {
  width: 100%;
}
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 48px;
}
.controls {
  display: flex;
  gap: 10px;
}
.controls .primary {
  flex: 1;
}
.text-button {
  background: transparent;
  padding: 8px 4px;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}
#skip {
  color: var(--muted);
}
.game-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  gap: 10px;
}
.victory {
  background: #edf6d6;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.victory p {
  margin: 6px 0 0;
  font-size: 14px;
}
.result-status:empty {
  display: none;
}
.result-status {
  font-weight: 550;
}
h2 {
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0;
}

/* Лидерборд и профиль */
.panel {
  grid-column: 1 / -1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 14px;
  align-content: start;
}
.panel h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 56px);
}
.panel-status {
  margin: 0;
  font-size: 16px;
  min-height: 1.55em;
}
.panel-status:empty {
  display: none;
}
.panel-note {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.panel > .secondary,
.panel > .primary {
  justify-self: start;
}
.table-wrap {
  overflow-x: auto;
}
.leaderboard {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.leaderboard th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
  padding: 14px 16px 10px;
}
.leaderboard td {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.leaderboard td:first-child,
.leaderboard th:first-child {
  width: 64px;
}
.leaderboard td:nth-child(n + 3),
.leaderboard th:nth-child(n + 3) {
  text-align: right;
  white-space: nowrap;
}
.leaderboard .mine td {
  background: #f1f8de;
  font-weight: 550;
}
.leaderboard .highlight td {
  background: var(--lime);
}
.leaderboard tr:last-child td:first-child {
  border-bottom-left-radius: 17px;
}
.leaderboard tr:last-child td:last-child {
  border-bottom-right-radius: 17px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--ink);
  color: var(--lime);
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: 2px;
}
.login-form {
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}
.login-form label {
  font-size: 14px;
  font-weight: 550;
}
.login-form input {
  font: inherit;
  font-size: 18px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid #b9bdaf;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.login-form input[aria-invalid="true"] {
  border-color: #a3341f;
}
.field-error {
  margin: 0;
  min-height: 1.4em;
  font-size: 13px;
  color: #a3341f;
}
.push-block {
  display: grid;
  gap: 8px;
  padding-top: 6px;
}
.push-status {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.push-status:empty {
  display: none;
}
.panel-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
}

/* Лист установки */
.sheet {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(16px + var(--tabbar) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 24px 70px #191b1830;
}
.sheet-enter {
  animation: sheet-in 220ms ease-out;
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}
.sheet-icon {
  border-radius: 14px;
  flex-shrink: 0;
}
.sheet-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.sheet h2 {
  font-size: 20px;
}
.sheet p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.install-hint {
  background: #edf6d6;
  color: var(--ink) !important;
  border-radius: 10px;
  padding: 10px 12px;
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.update-bar {
  max-width: 1120px;
  margin: 12px auto 0;
  padding: 10px 14px 10px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: #f6f5ef;
  border-radius: 14px;
  font-size: 14px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  width: min(460px, calc(100% - 32px));
  background: var(--surface);
}
dialog::backdrop {
  background: #191b1880;
}
[hidden] {
  display: none !important;
}
@media (max-width: 900px) {
  main {
    padding: 28px 24px 40px;
  }
  .topbar {
    padding-left: 24px;
    padding-right: 24px;
  }
  .view {
    column-gap: 32px;
  }
}
/* Мобильная раскладка: нижняя таб-панель с учётом safe-area. */
@media (max-width: 720px) {
  :root {
    --tabbar: 64px;
  }
  .topbar {
    padding: 8px 20px;
    padding-top: max(8px, env(safe-area-inset-top));
    border-bottom: none;
  }
  .brand {
    font-size: 19px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  .tabs {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    background: #fffefaf2;
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }
  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 4px;
    font-size: 12px;
    text-align: center;
    min-width: 0;
  }
  .tab-text {
    align-items: center;
    max-width: 100%;
  }
  .tab-name {
    max-width: 100%;
    font-size: 10px;
  }
  .tab:hover {
    background: transparent;
  }
  .tab[aria-current="page"] {
    background: transparent;
    color: var(--ink);
  }
  .tab[aria-current="page"] svg {
    background: var(--lime);
    border-radius: 999px;
    width: 46px;
    padding: 2px 12px;
    box-sizing: content-box;
  }
  .update-bar {
    margin: 4px 12px 0;
  }
  main {
    padding: 8px 16px 24px;
  }
  .view {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .intro,
  .game,
  .aside {
    width: 100%;
  }
  .intro {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    align-items: center;
  }
  h1 {
    font-size: 38px;
    margin: 0;
  }
  .lead {
    font-size: 15px;
    margin: 4px 0 0;
  }
  .example {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    gap: 0;
  }
  .example p {
    display: none;
  }
  .game {
    padding: 14px;
    border-radius: 22px;
  }
  .guidance {
    margin: 10px 0;
    min-height: 0;
  }
  .tile {
    font-size: 34px;
  }
  .panel h1 {
    font-size: 36px;
  }
  .leaderboard td,
  .leaderboard th {
    padding-left: 10px;
    padding-right: 10px;
  }
  .leaderboard td:first-child,
  .leaderboard th:first-child {
    width: 52px;
  }
  .sheet {
    left: 8px;
    right: 8px;
    width: auto;
    transform: none;
    bottom: calc(8px + var(--tabbar) + env(safe-area-inset-bottom));
    padding: 16px;
  }
  @keyframes sheet-in {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
  .sheet-icon {
    width: 44px;
    height: 44px;
  }
  .sheet-actions > * {
    flex: 1 1 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
