* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  padding: 16px 12px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(180deg, #f3f0e4 0%, #e7e0c8 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: #3a3320;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.game {
  width: 100%;
  max-width: 640px;
  background: #fffdf5;
  border: 1.5px solid #b8862c;
  border-radius: 16px;
  padding: 20px 20px 22px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-head { text-align: center; }

h1 {
  margin: 0 0 4px;
  color: #4a6b2a;
  font-size: 26px;
}

.game-sub {
  margin: 0;
  color: #8a7a4a;
  font-size: 15px;
  line-height: 1.4;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.seg {
  display: inline-flex;
  border: 1.5px solid #b8a86c;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.seg-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: #6a6240;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn + .seg-btn { border-left: 1.5px solid #e3dcc2; }

.seg-btn.is-active {
  background: #5a8835;
  color: #fffdf5;
}

.btn-new {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 18px;
  border: 1.5px solid #5a8835;
  border-radius: 10px;
  background: #c8d8a4;
  color: #3a5520;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn-new:hover { background: #d6e4b6; }
.btn-new:active { transform: scale(0.97); }

.board-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

#board {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  background: #fffdf5;
  touch-action: none; /* критично: чтобы палец не скроллил страницу */
  cursor: crosshair;
}

/* экран победы */
.win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 253, 245, 0.82);
  border-radius: 12px;
  animation: fade-in 0.25s ease;
}

.win[hidden] { display: none; }

.win-card {
  text-align: center;
  background: #fffdf5;
  border: 2px solid #b8862c;
  border-radius: 16px;
  padding: 22px 30px 24px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.2);
  animation: pop 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.win-emoji { font-size: 54px; line-height: 1; animation: bounce 0.9s ease infinite; }
.win-title { font-size: 24px; font-weight: 700; color: #4a6b2a; margin: 8px 0 4px; }
.win-stars { font-size: 30px; letter-spacing: 4px; margin-bottom: 14px; }
.win-btn { font-size: 17px; padding: 11px 22px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.game-foot {
  margin: 0;
  text-align: center;
  color: #a59a6e;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .game-sub { font-size: 14px; }
  .seg-btn { padding: 8px 10px; font-size: 13px; }
  .game { padding: 16px 14px 18px; }
}
