@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/vazirmatn.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  color: #17201b;
  background: #f6f4ef;
  font-family: "Vazirmatn", "Segoe UI", Tahoma, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;

  /* Sizing tokens — desktop values; redeclared per breakpoint tier further down. */
  --shell-padding: 20px;
  --toolbar-btn-min-h: 40px;
  --active-clue-pad-v: 14px;
  --active-clue-pad-h: 16px;
  --active-clue-min-h: 84px;
  --stack-gap: 12px;
  --tray-tile-size: 2.4em;
  --font-h1: clamp(1.4rem, 3vw, 2rem);
  --font-h1-home: clamp(1.6rem, 3.5vw, 2.2rem);
  --index-label-font: clamp(0.52rem, 1.25vw, 0.72rem);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f6f4ef;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--shell-padding);
  padding-top: max(var(--shell-padding), var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  padding-right: max(var(--shell-padding), var(--safe-area-inset-right, env(safe-area-inset-right, 0px)));
  padding-bottom: max(var(--shell-padding), var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  padding-left: max(var(--shell-padding), var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.app-header-meta {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.header-back {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: var(--toolbar-btn-min-h);
  height: var(--toolbar-btn-min-h);
  padding: 0;
  border: 1px solid #8cbca0;
  border-radius: 8px;
  background: #edf6f0;
  color: #1e5c38;
  cursor: pointer;
}

.header-back:hover {
  background: #dff0e2;
}

.app-header h1 {
  margin: 0;
  font-size: var(--font-h1);
  line-height: 1.2;
  flex: 0 1 auto;
  min-width: 0;
}

.app-header p {
  margin: 6px 0 0;
  color: #5a645d;
  font-size: 0.95rem;
}

.toolbar {
  position: relative;
  display: flex;
  align-items: end;
  flex-wrap: nowrap;
  gap: 10px;
}

/* Overflow (⋮) menu: secondary and destructive actions, at every breakpoint. */
.toolbar .toolbar-menu-toggle {
  width: var(--toolbar-btn-min-h);
  padding: 0;
}

.toolbar-menu {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 100;
  display: none;
  width: min(240px, calc(100vw - 20px));
  padding: 6px;
  border: 1px solid #bac3bc;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(23, 32, 27, 0.2);
}

.toolbar-menu.toolbar-menu-open {
  display: grid;
  gap: 2px;
}

.toolbar .toolbar-menu button {
  width: 100%;
  min-height: 44px;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 12px;
  border-color: transparent;
  text-align: right;
}

.toolbar .toolbar-menu button span {
  display: inline;
}

.toolbar .toolbar-menu .toolbar-menu-danger {
  margin-top: 4px;
  border-top: 1px solid #e3e7e3;
  border-radius: 0 0 8px 8px;
  color: #8b1a1a;
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--toolbar-btn-min-h);
  padding: 0 14px;
  border: 1px solid #bac3bc;
  border-radius: 8px;
  background: #ffffff;
  color: #17201b;
  cursor: pointer;
}

.toolbar button:hover {
  background: #f0f4f2;
}

/* Check-mode switch: the thumb slides, the track fills; cell colors then ripple (see .cell). */
.toolbar .check-switch {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.toolbar .check-switch[aria-checked="true"] {
  background: #edf6f0;
  border-color: #8cbca0;
  color: #1e5c38;
}

.toolbar .switch-track {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: #c9d0cb;
  transition: background-color 150ms ease;
}

.toolbar .switch-thumb {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(23, 32, 27, 0.3);
  transition: transform 150ms ease;
}

.toolbar .check-switch[aria-checked="true"] .switch-track {
  background: #1e5c38;
}

/* RTL: the thumb starts on the right, so "on" slides it left. */
.toolbar .check-switch[aria-checked="true"] .switch-thumb {
  transform: translateX(-12px);
}

/* ---- Animated راهنما tutorial modal ---- */

.solution-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))
    max(20px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))
    max(20px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))
    max(20px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
  background: rgba(15, 25, 20, 0.78);
  backdrop-filter: blur(2px);
  animation: solution-fade-in 0.2s ease-out;
}

@keyframes solution-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.solution-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: min(95vw, 900px);
  max-height: 95vh;
  max-height: 95dvh;
  padding: 16px 20px;
  border-radius: 12px;
  background: #f7faf8;
  color: #17201b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  overflow: auto;
}

.solution-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.solution-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #1e5c38;
}

.solution-modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.solution-countdown {
  font-size: 0.9rem;
  color: #6b4a14;
  font-variant-numeric: tabular-nums;
}

.confirm-modal {
  max-width: min(90vw, 380px);
}

.confirm-modal-primary {
  background: #1e5c38;
  color: #f7faf8;
  border-color: #1e5c38;
}

.clue-edit-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid #bac3bc;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.clue-edit-answer {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
}

.clue-edit-answer input {
  min-height: 0;
}

.clue-edit-error {
  margin: 0;
  font-size: 0.85rem;
  color: #8b1a1a;
}

.clue-edit-modal-footer {
  display: flex;
  justify-content: flex-end;
}

.solution-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #bac3bc;
  border-radius: 8px;
  background: #ffffff;
  color: #17201b;
  cursor: pointer;
}

.solution-close-button:hover {
  background: #eef3ef;
}

.solution-image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.solution-image img {
  display: block;
  max-width: 100%;
  max-height: calc(95vh - 100px);
  max-height: calc(95dvh - 100px);
  height: auto;
  object-fit: contain;
}

.solver-layout {
  display: grid;
  grid-template-columns: minmax(320px, 680px) minmax(280px, 1fr);
  gap: 8px;
  align-items: start;
}

.board-column {
  display: grid;
  gap: 12px;
}

.board-panel {
  display: grid;
  gap: 12px;
}

.source-panel-container {
  margin-top: 18px;
  border: 1px solid #bac3bc;
  border-radius: 10px;
  background: #f7faf8;
  overflow: hidden;
}

.source-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid #bac3bc;
  background: #ffffff;
  color: #17201b;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease;
}

.source-panel-toggle:hover {
  background: #f0f4f2;
}

.source-panel-toggle > span {
  flex: 1;
  text-align: right;
}

.source-panel-toggle .chevron-collapsed {
  transform: rotate(-90deg);
  transition: transform 0.2s ease;
}

.source-panel-body {
  padding: 12px;
  overflow: auto;
}

.source-panel-body img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.clue-sidebar {
  display: grid;
  gap: 12px;
  align-items: start;
}

/* Board with row/column number labels */
.board-with-labels {
  width: min(100%, 680px);
  display: flex;
  flex-direction: column;
}

.board-top-row {
  display: flex;
  padding-bottom: 4px;
}

.corner-spacer {
  width: 28px;
  flex-shrink: 0;
}

.col-numbers {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
}

.col-number {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--index-label-font);
  color: #657068;
  direction: ltr;
  line-height: 1;
}

.board-bottom-row {
  display: flex;
}

.row-numbers {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.row-number {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--index-label-font);
  color: #657068;
  direction: ltr;
  line-height: 1;
}

.crossword-board {
  display: grid;
  flex: 1;
  aspect-ratio: 1 / 1;
  border: 2px solid #1e2a23;
  background: #1e2a23;
  gap: 1px;
  grid-auto-rows: 1fr;
  outline: none;
  direction: ltr;
  position: relative;
}

.crossword-board:focus-visible {
  box-shadow: 0 0 0 4px #4c9f7080;
}

/* Hidden input that captures mobile virtual-keyboard events. */
.cell-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  /* 16px avoids iOS zoom-on-focus. */
  font-size: 16px;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  z-index: -1;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #17201b;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  /* Android's tap highlight (and the orange focus ring on old WebViews) also covers the
     hidden clue tooltip, so it flashes on tap. Keyboard focus has its own style below
     (.cell-open:focus-visible); the selected-cell color is the tap feedback. */
  outline: none;
  -webkit-tap-highlight-color: transparent;
  /* --ripple = rings from the selected cell, so check-mode colors spread outward. */
  transition: color 200ms ease calc(var(--ripple, 0) * 20ms);
}

@media (prefers-reduced-motion: reduce) {
  .cell,
  .toolbar .switch-thumb {
    transition: none;
  }
}

.cell-open {
  background: #fffdf7;
  cursor: pointer;
}

.cell-open:hover,
.cell-open:focus-visible {
  overflow: visible;
  z-index: 20;
}

.cell-open:hover:not(.cell-selected),
.cell-open:focus-visible:not(.cell-selected) {
  box-shadow: inset 0 0 0 2px #3f6b4a;
}

.cell-clue-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  display: none; /* not visibility: hidden, which still takes up space and grows the page on mobile */
  gap: 4px;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 2px dashed #b23a3a;
  border-radius: 8px;
  background: #fbecea;
  box-shadow: 0 10px 24px #4a191933;
  color: #3a1414;
  direction: rtl;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.55;
  text-align: right;
  white-space: normal;
  pointer-events: none;
}

.cell-clue-across {
  color: #1f7a44;
}

.cell-clue-down {
  color: #2c5a8a;
}

.cell-clue-tooltip-left {
  left: calc(100% + 6px);
}

.cell-clue-tooltip-right {
  right: calc(100% + 6px);
}

.cell-open:focus-visible .cell-clue-tooltip {
  display: grid;
}

@media (hover: hover) and (pointer: fine) {
  .cell-open:hover .cell-clue-tooltip {
    display: grid;
  }
}

.cell-block {
  background: #1e2a23;
}

.cell-block-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  flex-shrink: 0;
}

.cell-active-word {
  background: #d7eadf;
}

.cell-down-word {
  background: #e9edf1;
}

.cell-selected {
  background: #f0c96a;
  /* box-shadow: inset 0 0 0 1px #86630d; */
  z-index: 1;
}

.cell.cell-correct {
  color: #145c35;
}

.cell.cell-incorrect {
  color: #8b1a1a;
}

.cell-number {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: var(--index-label-font);
  line-height: 1;
  color: #4d574f;
  direction: ltr;
}

.cell-value {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.cell-value svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* WebView < 88 (unupdated Android 11 and older) has no aspect-ratio: square each cell
   with a padding spacer instead, which squares the board too. */
@supports not (aspect-ratio: 1) {
  .cell::before {
    content: "";
    grid-area: 1 / 1;
    padding-bottom: 100%;
  }

  .cell-value {
    grid-area: 1 / 1;
  }

  .cell-block-icon {
    position: absolute;
    top: 0;
    left: 0;
  }
}

.active-clue {
  border: 1px solid #d3d8d2;
  border-radius: 8px;
  background: #ffffff;
}

.active-clue {
  padding: var(--active-clue-pad-v) var(--active-clue-pad-h);
  min-height: var(--active-clue-min-h);
}

.active-clue-block + .active-clue-block {
  margin-top: 8px;
  border-top: 1px solid #d3d8d2;
}

/* Below the divider, the icon column needs room from the line, like the text beside it. */
.active-clue-block + .active-clue-block .active-clue-head-actions {
  inset-block-start: 6px;
}

.active-clue-block-active {
  border-inline-start: 3px solid #1e5c38;
  padding-inline-start: calc(var(--active-clue-pad-h) - 3px);
  margin-inline-start: calc(var(--active-clue-pad-h) * -1);
}

.active-clue-block-active-down {
  border-inline-start-color: #2f5673;
}

.active-clue p {
  margin: 8px 0 0;
  font-size: 1.1rem;
  line-height: 1.7;
}

/* A tinted pill in the direction's color, with an arrow showing which way the word runs. */
.active-clue-label {
  --label-fg: #1e5c38;
  --label-bg: #e9efeb;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-inline-end: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--label-bg);
  color: var(--label-fg);
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1.35;
  vertical-align: baseline;
  white-space: nowrap;
}

.active-clue-label-down {
  --label-fg: #2f5673;
  --label-bg: #eaeef1;
}

.active-clue-label svg {
  width: 0.95em;
  height: 0.95em;
  opacity: 0.75;
}

.letter-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--stack-gap);
}

.tray-tile {
  width: var(--tray-tile-size);
  height: var(--tray-tile-size);
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d3d8d2;
  border-radius: 4px;
  background: #fffdf7;
  color: #17201b;
  cursor: pointer;
  transition: transform 0.1s;
}

.tray-tile:active {
  transform: scale(0.9);
}

.word-cells-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--stack-gap);
}

/* The delete key is the row's last box, so a long word wraps it along with its letters. */
.word-cells-row > .clue-backspace-btn {
  width: var(--tray-tile-size);
  height: var(--tray-tile-size);
}

.word-cells-row > .clue-backspace-btn svg {
  width: 60%;
  height: 60%;
}

.word-cell {
  width: var(--tray-tile-size);
  height: var(--tray-tile-size);
  display: grid;
  place-items: center;
  border: 1px solid #d3d8d2;
  border-radius: 4px;
  background: #f4f7f2;
  transition: background-color 0.15s, border-color 0.15s, color 0.2s;
}

.word-cell-filled {
  cursor: grab;
}

.word-cell-target {
  border-color: #1e5c38;
  box-shadow: inset 0 0 0 1px #1e5c38;
}

.word-cell-drop-hover {
  background: #dff0e2;
  border-color: #1e5c38;
}

.word-cell-correct {
  color: #145c35;
}

.word-cell-incorrect {
  color: #8b1a1a;
}

.tile-ghost {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
}

.active-clue-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

/* The icons stand in a column at the top of the block's left edge (RTL end): the block
   reserves that strip, so they cost width but no height. */
.active-clue-block {
  position: relative;
  padding-inline-end: calc(26px + var(--stack-gap));
}

.active-clue-head-actions {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Per-clue actions: small squares like the letter boxes, each in its own color; filled on hover. */
.clue-icon-btn,
.clue-backspace-btn {
  --icon-fg: #486151;
  --icon-bg: #eef3ef;
  --icon-border: #c8d0cb;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--icon-border);
  border-radius: 4px;
  background: var(--icon-bg);
  color: var(--icon-fg);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}

.clue-icon-btn svg,
.clue-backspace-btn svg {
  width: 16px;
  height: 16px;
}

.clue-icon-btn:hover,
.clue-backspace-btn:hover {
  background: var(--icon-fg);
  color: #fff;
}

.clue-icon-btn:active,
.clue-backspace-btn:active {
  transform: scale(0.92);
}

.clue-icon-search {
  --icon-fg: #1a73e8;
  --icon-bg: #e8f0fe;
  --icon-border: #bad5f8;
}

.clue-icon-ai {
  --icon-fg: #7c3aed;
  --icon-bg: #f1eafe;
  --icon-border: #d8c4fa;
}

.clue-icon-edit {
  --icon-fg: #b45309;
  --icon-bg: #fdf1e3;
  --icon-border: #e8cbb5;
}

.clue-backspace-btn {
  --icon-fg: #c62828;
  --icon-bg: #fdecec;
  --icon-border: #eebfbf;
}

@media (max-width: 1024px) {
  :root {
    --toolbar-btn-min-h: 36px;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar button {
    padding: 0 10px;
    gap: 0;
  }

  .toolbar button span {
    display: none;
  }

  .toolbar .check-switch {
    gap: 6px;
  }

  .toolbar .switch-track,
  .toolbar .switch-thumb {
    display: block;
  }
}

@media (max-width: 860px) {
  :root {
    --shell-padding: 10px;
    --active-clue-pad-v: 8px;
    --active-clue-pad-h: 10px;
    --active-clue-min-h: 52px;
    --stack-gap: 6px;
    --tray-tile-size: 2.3em;
  }

  .solver-layout {
    grid-template-columns: 1fr;
  }

  .board-with-labels {
    width: 100%;
  }

  .crossword-board {
    width: auto;
  }

  .active-clue p {
    margin: 6px 0 0;
  }
}

@media (max-width: 480px) {
  :root {
    --shell-padding: 4px;
    --toolbar-btn-min-h: 32px;
    --active-clue-pad-v: 6px;
    --active-clue-pad-h: 8px;
    --active-clue-min-h: 40px;
    --stack-gap: 4px;
    --tray-tile-size: 2.25em;
    --font-h1: clamp(1.1rem, 5.4vw, 1.45rem);
  }

  .app-header {
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .app-header-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .app-header h1 {
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-header .puzzle-meta {
    display: flex;
    flex: 0 0 auto;
    overflow: visible;
    font-size: 0.82rem;
  }

  .app-header .puzzle-meta-item {
    display: none;
  }

  .app-header .puzzle-meta-item-difficulty {
    display: inline-flex;
    padding: 1px 7px;
    border: 1px solid #d3d8d2;
    border-radius: 999px;
    background: #f1f4f2;
  }

  .app-header .puzzle-meta-item-difficulty .puzzle-meta-icon,
  .app-header .puzzle-meta-item-difficulty .puzzle-meta-label {
    display: none;
  }

  .toolbar {
    flex-wrap: nowrap;
    flex: 0 0 auto;
    width: auto;
    justify-content: flex-start;
  }

  .toolbar > button {
    flex: 0 0 auto;
    padding: 0 8px;
  }

  .cell-number {
    top: 2px;
    left: 2px;
  }

  /* Drop the row/column index labels and let the grid bleed into the
     shell's padding so it gets the most space on small screens. */
  .board-top-row,
  .row-numbers {
    display: none;
  }

  .board-with-labels {
    width: calc(100% + 4px);
    margin-inline: -2px;
  }

  .active-clue p {
    margin: 4px 0 0;
  }

  /* Tighter gaps keep a 7-letter word and its delete key on one line. */
  .word-cells-row,
  .letter-tray {
    gap: 4px;
  }
}

/* ─────────────── Home page ─────────────── */

.home-shell {
  max-width: 960px;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.home-header h1 {
  margin: 0 0 6px;
  font-size: var(--font-h1-home);
  line-height: 1.2;
}


/* ──────────── Jadval app shell (home / name / sheets) — palette matches the solver ──────────── */
html,body{height:100%}
#app{max-width:680px;margin:0 auto;height:100%}
.screen{height:100%;display:flex;flex-direction:column;padding:max(12px,env(safe-area-inset-top)) 14px max(12px,env(safe-area-inset-bottom));gap:12px;overflow:auto}
#s-game{padding:0;display:block}
[hidden]{display:none!important}
.center{text-align:center}.muted{color:#5a645d}.small{font-size:.85rem}
.card{margin:auto 0;background:#fff;border:1px solid #d3d8d2;border-radius:16px;padding:28px 20px;display:flex;flex-direction:column;gap:14px;align-items:center}
.logo{width:84px;height:84px;border-radius:20px}
h1{margin:0}
#name-input{width:100%;font:inherit;font-size:1.1rem;padding:12px 14px;border-radius:10px;border:1px solid #bac3bc;background:#fffdf7;color:#17201b;text-align:center}
#name-input:focus{outline:2px solid #4c9f70;border-color:#4c9f70}
.btn{font:inherit;color:#17201b;background:#fff;border:1px solid #bac3bc;border-radius:10px;padding:10px 14px;cursor:pointer}
.btn:hover{background:#f0f4f2}.btn:active{transform:scale(.98)}
.btn.primary{background:#1e5c38;border-color:#1e5c38;color:#f7faf8;font-weight:700}
.btn.big{padding:16px;font-size:1.15rem}
.top{display:flex;align-items:center;gap:12px;justify-content:space-between}
.stats{display:flex;flex-direction:column;align-items:center;background:#fff;border:1px solid #d3d8d2;border-radius:12px;padding:6px 14px;min-width:70px}
.stats span{font-weight:700;font-size:1.1rem;color:#1e5c38}.stats small{color:#657068;font-size:.7rem}
.row{display:flex;gap:8px;flex-wrap:wrap}.row .btn{flex:1;white-space:nowrap}
.levels{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;padding-bottom:20px}
.lv{font:inherit;border:1px solid #d3d8d2;border-radius:10px;background:#fff;color:#17201b;padding:12px 0 8px;cursor:pointer;display:flex;flex-direction:column;align-items:center}
.lv small{font-size:.65rem;color:#1e5c38;min-height:1em}
.lv.done{background:#edf6f0;border-color:#8cbca0}.lv.cur{outline:2px solid #1e5c38}.lv.lock{opacity:.4;pointer-events:none}
.modal{position:fixed;inset:0;background:rgba(15,25,20,.6);display:flex;align-items:flex-end;justify-content:center;z-index:900}
.sheet{width:100%;max-width:560px;max-height:85vh;overflow:auto;background:#f7faf8;border-radius:16px 16px 0 0;padding:18px 16px max(16px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px}
.sheet h2{margin:0;text-align:center;color:#1e5c38}
.board{width:100%;border-collapse:collapse}.board td{padding:8px 6px;border-bottom:1px solid #d3d8d2}.board td:last-child{text-align:left;color:#1e5c38;font-weight:700}
.win{text-align:center}.win .big-score{font-size:2.4rem;color:#1e5c38;font-weight:800}
#toast{position:fixed;bottom:90px;left:50%;transform:translateX(-50%);background:#17201bdd;color:#fff;padding:10px 16px;border-radius:10px;z-index:1100;max-width:90%}

/* rectangular boards (the original is square-only) and the level timer */
.crossword-board{aspect-ratio:var(--grid-cols)/var(--grid-rows,var(--grid-cols))}
.app-header .puzzle-meta-item-time{display:inline-flex!important;color:#5a645d;direction:ltr}
.app-header .puzzle-meta-item-time .puzzle-meta-value{unicode-bidi:isolate}

.tabs{display:flex;gap:6px}.tabs button{flex:1;font:inherit;padding:10px;border:1px solid #bac3bc;background:#fff;border-radius:10px;cursor:pointer}
.tabs button.on{background:#1e5c38;color:#f7faf8;border-color:#1e5c38;font-weight:700}
