* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #14231a radial-gradient(circle at 50% 0%, #24382b 0%, #14231a 70%);
  color: #f3ead8;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  user-select: none;
  overflow-x: hidden;
}
#app {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 8px 10px; width: 100%;
}
header { text-align: center; margin: 2px 0 4px; }
h1 { font-size: 1.2rem; margin: 0; text-shadow: 0 2px 6px #000; }
.status { font-size: 1rem; color: #ffd97a; min-height: 1.4em; }

#board-wrap { position: relative; width: min(100%, 480px, calc(100vh - 215px)); min-width: 220px; border: 6px solid #5a3d22; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%; aspect-ratio: 1;
  position: relative;
  touch-action: manipulation;
}
.sq { position: relative; }
.sq.light { background: #ecd9b0; }
.sq.dark  { background: #a06b3c; }
.sq.sel::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(255, 214, 90, .45);
}
.sq.last::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(120, 200, 255, .28);
}
.sq.hint::before {
  content: ""; position: absolute; inset: 38%;
  border-radius: 50%; background: rgba(30, 90, 40, .55);
}
.sq.cap::before {
  content: ""; position: absolute; inset: 6%;
  border-radius: 50%; border: 4px solid rgba(200, 40, 30, .75);
}
.sq.check { background: #c0392b !important; }

.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  transition: transform .28s ease, opacity .35s ease;
  will-change: transform;
  z-index: 2;
}
.piece img { width: 96%; height: 96%; pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.45)); }
.piece.moving { z-index: 5; transition-duration: .38s; }
.piece.dying { transition: transform .55s ease-in, opacity .55s ease-in;
  transform-origin: 50% 90%; z-index: 4; }

#fx { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.clash {
  position: absolute; width: 25%; height: 25%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9vw; animation: clashAnim .6s ease-out forwards;
}
@keyframes clashAnim {
  0% { transform: scale(.3) rotate(-30deg); opacity: 0; }
  25% { transform: scale(1.35) rotate(8deg); opacity: 1; }
  60% { transform: scale(1.1) rotate(-6deg); opacity: 1; }
  100% { transform: scale(.8) rotate(0); opacity: 0; }
}
.shake { animation: shakeAnim .4s ease; }
@keyframes shakeAnim {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-4px,2px); }
  40% { transform: translate(4px,-2px); }
  60% { transform: translate(-3px,-2px); }
  80% { transform: translate(3px,2px); }
}

.captured { display: flex; flex-wrap: nowrap; overflow: hidden; gap: 1px; min-height: 24px; max-width: 100%;
  align-items: center; justify-content: center; padding: 2px; }
.captured img { width: 20px; height: 20px; opacity: .9; }

#controls { display: flex; gap: 6px; margin-top: 6px; width: 100%;
  max-width: 480px; justify-content: center; flex-wrap: wrap; }
.btn {
  background: #2c4a35; color: #f3ead8; border: 1px solid #4a7050;
  border-radius: 10px; padding: 8px 10px; font-size: .9rem;
  font-family: inherit; cursor: pointer;
}
.btn:active { transform: scale(.96); background: #38604a; }
.btn.big { font-size: 1.1rem; padding: 12px 22px; margin-top: 12px; }
select.btn { appearance: none; }

#overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(10, 18, 12, .72);
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
#overlay.hidden { display: none; }
#overlay-card {
  background: #20332a; border: 2px solid #ffd97a; border-radius: 14px;
  padding: 20px 26px; text-align: center; box-shadow: 0 8px 30px #000;
}
#overlay-text { font-size: 1.25rem; line-height: 1.6; }

#promo {
  position: absolute; z-index: 11; inset: auto 0 38% 0;
  display: flex; gap: 8px; justify-content: center;
  background: rgba(10,18,12,.85); padding: 10px; border-radius: 12px;
}
#promo.hidden { display: none; }
#promo button { background: #ecd9b0; border: none; border-radius: 8px;
  width: 56px; height: 56px; cursor: pointer; }
#promo img { width: 48px; height: 48px; }

footer { margin-top: 4px; font-size: .75rem; color: #8fa896; }
