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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, #1a1d24 0%, #232838 60%, #1c2230 100%);
  background-attachment: fixed;
  color: #e8eaf0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hidden { display: none !important; }

.screen { display: flex; flex-direction: column; gap: 22px; }

/* --- меню --- */
h1 { font-size: 40px; text-align: center; letter-spacing: .5px; }
h1 .accent { color: #7cb8ff; }
.sub { text-align: center; color: #9aa3b5; font-size: 16px; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.card {
  width: 220px;
  padding: 30px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  text-align: center;
  cursor: pointer;
  color: #e8eaf0;
  font-family: inherit;
  transition: transform .15s ease, border-color .15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.card:hover, .card:active { transform: translateY(-3px); border-color: #7cb8ff; }
.card .ico { font-size: 52px; line-height: 1; }
.card .title { font-size: 20px; font-weight: 700; margin-top: 6px; }
.card .desc { font-size: 13px; color: #9aa3b5; }
.card .badge {
  display: inline-block; margin-top: 6px;
  font-size: 12px; color: #9aa3b5;
  padding: 4px 12px; border-radius: 999px;
  background: rgba(255,255,255,.08);
}

/* --- игра --- */
.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.back {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: #c7d0e0;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: #c7d0e0;
  font-size: 16px;
  width: 36px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  margin-left: auto;
}
.status { flex: 1; text-align: center; font-size: 15px; color: #c7d0e0; }

/* --- доска --- */
.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: min(92vw, 480px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 3px solid #2a2f3d;
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 7vw, 40px);
  cursor: pointer;
  position: relative;
  line-height: 1;
}
.cell.light { background: #f0d9b5; }
.cell.dark { background: #b58863; }

.cell.last-move { background: rgba(255, 213, 79, 0.45); }

.cell.selected { box-shadow: inset 0 0 0 4px #a5c34b; }

.coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  line-height: 1;
}
.coord.rank { top: 3px; left: 3px; }
.coord.file { bottom: 3px; right: 3px; }
.cell.light .coord { color: #b58863; }
.cell.dark .coord { color: #f0d9b5; }

.cell .piece.white { color: #f8f8f8; text-shadow: 0 0 2px #000, 0 1px 3px #000; }
.cell .piece.black { color: #161616; text-shadow: 0 0 2px #fff, 0 1px 2px #fff; }

.piece-ico { width: 100%; height: 100%; display: block; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }

.piece-ico.just-moved { animation: piece-pop 0.28s cubic-bezier(.2,.7,.3,1.2); }
@keyframes piece-pop {
  0% { transform: scale(0.5) translateY(-8px); opacity: 0; }
  60% { transform: scale(1.06) translateY(2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

/* эффект взятия: шоквейв + вспышка */
.cell.capture-fx::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 4px solid rgba(255, 120, 70, .9);
  border-radius: 50%;
  animation: shockwave .5s ease-out forwards;
  pointer-events: none;
}
@keyframes shockwave {
  from { transform: scale(.3); opacity: 1; }
  to { transform: scale(1.5); opacity: 0; }
}
.cell.capture-fx::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 200, 80, .85) 0%, transparent 70%);
  animation: capture-flash .35s ease-out forwards;
  pointer-events: none;
}
@keyframes capture-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

.cell.move-target::after {
  content: '';
  width: 32%; height: 32%;
  background: rgba(20, 60, 20, .35);
  border-radius: 50%;
  position: absolute;
}
.cell.move-target.capture::after {
  width: 90%; height: 90%;
  background: transparent;
  border: 5px solid rgba(20, 60, 20, .35);
}

.placeholder {
  text-align: center;
  color: #6b7385;
  font-size: 22px;
  line-height: 1.6;
  padding-top: 60px;
}

/* --- выбор режима --- */
.setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.setup-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.mode-btn, .lvl-btn {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.05);
  color: #c7d0e0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.mode-btn.active, .lvl-btn.active {
  background: #7cb8ff;
  color: #0d1117;
  border-color: #7cb8ff;
  font-weight: 600;
}
.start-btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  background: #7cb8ff;
  color: #0d1117;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-family: inherit;
}

.setup-label { color: #9aa3b5; font-size: 13px; align-self: center; }

/* --- часы --- */
.clocks { display: flex; flex-direction: column; gap: 8px; width: min(92vw, 480px); margin: 0 auto; }
.clock {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; border-radius: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  font-variant-numeric: tabular-nums;
}
.clock.active { border-color: #7cb8ff; background: rgba(124,184,255,.10); }
.clock.low .clock-time { color: #ff6b6b; }
.clock-label { color: #9aa3b5; font-size: 13px; }
.clock-time { font-size: 20px; font-weight: 700; letter-spacing: .5px; }

/* --- 3D доска --- */
.board3d { width: min(92vw, 480px); aspect-ratio: 1; margin: 0 auto; }
.board3d canvas { display: block; width: 100%; height: 100%; border-radius: 6px; }
