* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --dim: #8b949e;
  --accent: #58a6ff;
  --accent-2: #d29922;
  --green: #3fb950;
  --red: #f85149;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html,
body {
  height: 100%;
  background: radial-gradient(1200px 800px at 70% -10%, #1a2332 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 17px;
}

.logo span {
  color: var(--accent-2);
}

.topbar .spacer {
  flex: 1;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: linear-gradient(180deg, #238636, #2ea043);
  border-color: #2ea043;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
}

.btn.large {
  font-size: 16px;
  padding: 14px 22px;
  width: 100%;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 24px 16px 40px;
}

/* Menu */
.menu {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.35s ease;
}

.hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 40px);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.hero h1 .w {
  color: var(--accent-2);
}

.hero h1 .s {
  color: var(--sheep, #e6edf3);
}

.hero p {
  color: var(--dim);
  line-height: 1.5;
  font-size: 15px;
}

.animals {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 18px 0 6px;
}

.animal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dim);
}

.animal .face {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--dim);
  font-weight: 600;
}

.side-pick .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rules {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--dim);
}

.rules h2 {
  color: var(--text);
  font-size: 16px;
  margin-bottom: 10px;
}

.rules ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rules b {
  color: var(--text);
}

/* Game */
.game-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(720px, 100%);
  animation: fadeUp 0.3s ease;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
}

.statusbar .dim {
  color: var(--dim);
  margin-left: auto;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--dim);
}

.dot.wolf {
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}

.dot.sheep {
  background: #e6edf3;
  box-shadow: 0 0 8px #fff;
}

.dot.thinking {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1s infinite;
}

.board-frame {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  padding: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

#board {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.hint-line {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  place-items: center;
  z-index: 20;
  padding: 20px;
}

.overlay.show {
  display: grid;
}

.overlay .dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 28px;
  width: min(400px, 100%);
  text-align: center;
  animation: pop 0.25s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.overlay h2 {
  font-size: 26px;
  margin-bottom: 10px;
}

.overlay p {
  color: var(--dim);
  margin-bottom: 22px;
  line-height: 1.45;
}

.overlay .btn {
  width: 100%;
  margin-bottom: 10px;
}

.overlay .btn:last-child {
  margin-bottom: 0;
}

/* Правила поверх игры: фон играет сквозь лёгкое размытие */
.overlay.rules-overlay {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay .rules-dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 28px;
  width: min(460px, 100%);
  text-align: left;
  animation: pop 0.25s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.overlay .rules-dialog h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.overlay .rules-dialog ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.55;
}

.overlay .rules-dialog ol b {
  color: var(--text);
}

.overlay .rules-dialog .btn {
  width: 100%;
  margin-top: 20px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .logo {
    font-size: 14px;
  }
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  .statusbar .dim {
    margin-left: 0;
    width: 100%;
  }
}
