:root {
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #1b2430;
  --muted: #6b7684;
  --accent: #0a5ca8;
  --accent-contrast: #ffffff;
  --cell-empty-bg: #eef1f4;
  --cell-marked-bg: #0a5ca8;
  --cell-marked-text: #ffffff;
  --win-bg: #1a8a4a;
  --double-bg: #7a4fd1;
  --full-bg: #b8860b;
  --error-bg: #c0392b;
  --border: #dde2e7;
  --overlay: rgba(10, 14, 20, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --card-bg: #1a2027;
    --text: #eef1f4;
    --muted: #93a0ad;
    --accent: #4fa3e3;
    --accent-contrast: #0b1420;
    --cell-empty-bg: #232b33;
    --cell-marked-bg: #4fa3e3;
    --cell-marked-text: #0b1420;
    --win-bg: #2fae66;
    --double-bg: #9b7ae8;
    --full-bg: #d4a72c;
    --error-bg: #e35d4f;
    --border: #2c3540;
    --overlay: rgba(0, 0, 0, 0.65);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100dvh;
}

.header h1 {
  font-size: 20px;
  line-height: 1.3;
  margin: 0 0 4px;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.status {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 16px;
}

.status.error {
  background: var(--error-bg);
  color: #fff;
  border-color: transparent;
}

.card-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-box h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.card-box p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.progress-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.badges {
  font-size: 13px;
  line-height: 1.6;
}

.tier-banner {
  text-align: center;
  padding: 14px;
  border-radius: 14px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 14px;
}

.tier-bingo { background: var(--win-bg); }
.tier-double { background: var(--double-bg); }
.tier-full { background: var(--full-bg); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.cell {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--cell-empty-bg);
  color: var(--text);
  padding: 8px;
  font-size: 12.5px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.cell:active {
  transform: scale(0.96);
}

.cell.marked {
  background: var(--cell-marked-bg);
  color: var(--cell-marked-text);
  font-weight: 600;
  border-color: transparent;
}

.cell .mark {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: transparent;
}

.btn-secondary {
  background: var(--cell-empty-bg);
  border-color: transparent;
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
}

.btn-link {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0;
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.leaderboard-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.leaderboard-row:last-of-type {
  border-bottom: none;
}

/* --- Пятнашки Севастополя ---------------------------------------- */

.puzzle-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.puzzle-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center;
  position: relative;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.puzzle-thumb:active {
  transform: scale(0.97);
}

.puzzle-thumb-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px;
  font-size: 11.5px;
  line-height: 1.25;
  font-weight: 600;
  color: #fff;
  text-align: left;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72));
}

.puzzle-thumb-soon {
  background: var(--cell-empty-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  cursor: default;
}

.puzzle-thumb-soon .puzzle-thumb-title {
  position: static;
  background: none;
  color: var(--muted);
  text-align: center;
}

.puzzle-thumb-soon-label {
  font-size: 13px;
  font-weight: 700;
}

.puzzle-status {
  margin-bottom: 10px;
  font-size: 13px;
}

.puzzle-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  aspect-ratio: 1 / 1;
  margin-bottom: 14px;
  background: var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.puzzle-tile {
  background-color: var(--cell-empty-bg);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.puzzle-tile-empty {
  background-color: var(--bg) !important;
  background-image: none !important;
  cursor: default;
}
