* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px 12px 40px;
  background: linear-gradient(180deg, #f3f0e4 0%, #e7e0c8 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: #3a3320;
}

.wrap { max-width: 1200px; margin: 0 auto; }

.head h1 { margin: 0 0 4px; color: #4a6b2a; font-size: 28px; }
.head .sub { margin: 0 0 14px; color: #8a7a4a; font-size: 14px; }

/* панель настроек */
.bar {
  background: #fffdf5;
  border: 1.5px solid #b8862c;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
  margin-bottom: 12px;
}

.pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-label { font-weight: 700; color: #4a6b2a; font-size: 13px; }

.target-tiles, .counts, .levels { display: flex; gap: 4px; flex-wrap: wrap; }

.t-tile {
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  cursor: pointer;
  line-height: 0;
}
.t-tile[aria-pressed="true"] { background: #c8d8a4; border-color: #5a8835; }
.t-tile:hover { border-color: #5a8835; }
.t-tile.theme-tile { font-size: 21px; line-height: 34px; min-width: 40px; text-align: center; }

.cnt-btn, .lvl, .btn {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border: 1.5px solid #b8a86c;
  border-radius: 8px;
  background: #fff;
  color: #3a3320;
  cursor: pointer;
}
.cnt-btn { min-width: 38px; font-weight: 700; }
.cnt-btn[aria-pressed="true"], .lvl[aria-pressed="true"] {
  background: #c8d8a4; border-color: #5a8835; color: #3a5520; font-weight: 700;
}
.cnt-btn:hover, .lvl:hover, .btn:hover { border-color: #5a8835; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn.primary { background: #c8d8a4; border-color: #5a8835; color: #3a5520; font-weight: 700; }

/* игровое поле: картинка + панель счёта рядом (на широком экране) */
.board {
  position: relative;
  background: #fffdf5;
  border: 1.5px solid #b8862c;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.scene-box { line-height: 0; flex: 1 1 62%; min-width: 0; }
.scene-box .scene-svg {
  width: 100%;
  height: auto;
  border: 2px solid #b8862c;
  border-radius: 10px;
  background: #fff;
  touch-action: manipulation;
}
.scene-svg .tgt { cursor: pointer; }

/* панель со списком типов и полями ввода */
.count-panel {
  flex: 1 1 34%;
  min-width: 220px;
  background: rgba(255, 253, 245, 0.9);
  border: 1.5px dashed #b8862c;
  border-radius: 10px;
  padding: 12px;
}
.cp-hint { font-size: 12px; color: #8a7a4a; margin-bottom: 10px; font-style: italic; }

.count-list { display: flex; flex-direction: column; gap: 8px; }

.crow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1.5px solid #d8cfa4;
  border-radius: 10px;
  background: #fff;
}
.crow .cdot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; }
.crow .spr-icon { flex: 0 0 auto; width: 38px; height: 38px; }
.crow .cname { flex: 1 1 auto; font-size: 14px; min-width: 0; }
.crow .cin {
  flex: 0 0 auto;
  width: 56px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding: 6px 4px;
  border: 2px solid #b8862c;
  border-radius: 8px;
  color: #3a5520;
}
.crow .cmark { flex: 0 0 auto; width: 20px; font-size: 20px; font-weight: 700; text-align: center; }

.crow.ok { border-color: #43a047; background: #eef7e8; }
.crow.ok .cmark { color: #43a047; }
.crow.bad { border-color: #e53935; background: #fdecea; }
.crow.bad .cmark { color: #e53935; }

.cp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* подсветка предметов кликом */
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.mark-ring { animation: pop 0.3s ease-out; transform-origin: center; transform-box: fill-box; }

/* тост-подсказка */
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: #4a6b2a;
  color: #fff;
  font-size: 15px;
  padding: 9px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 6;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* победа */
.win[hidden] { display: none; }
.win {
  position: absolute;
  inset: 0;
  background: rgba(58, 51, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 8;
  overflow: hidden;
}
.win-card {
  background: #fffdf5;
  border: 2px solid #5a8835;
  border-radius: 16px;
  padding: 28px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  z-index: 2;
}
.win-emoji { font-size: 52px; }
.win-card h2 { margin: 8px 0 4px; color: #4a6b2a; }
.win-card p { margin: 0 0 16px; color: #8a7a4a; }

/* конфетти */
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti-bit {
  position: absolute;
  top: -14px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(560px) rotate(540deg); opacity: 0.2; }
}

/* полноэкранный режим */
.game-area:fullscreen {
  display: flex;
  flex-direction: column;
  background: #f3f0e4;
  padding: 8px 10px;
  overflow: auto;
}
.game-area:fullscreen .bar { margin-bottom: 8px; }
.game-area:fullscreen .board { flex: 1; min-height: 0; }

#cfg-btn { display: none; }
@media (max-width: 820px) {
  .game-area:fullscreen #cfg-btn { display: inline-block; }
  .game-area:fullscreen .bar:not(.open) .pick { display: none; }
  .game-area:fullscreen .bar { margin-bottom: 6px; padding: 6px 10px; gap: 8px 14px; }
  .game-area:fullscreen .actions { margin-left: 0; }
}

/* на узком экране: картинка сверху, панель снизу */
@media (max-width: 720px) {
  .board { flex-direction: column; }
  .scene-box, .count-panel { flex: 1 1 auto; width: 100%; }
}

@media (max-width: 640px) {
  body { padding: 12px 6px 24px; }
  .head h1 { font-size: 22px; }
  .actions { margin-left: 0; }
}
