:root {
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #f3eadb;
  color: #3c2c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f1ebdf 0%, #d4c4ae 40%, #c5af90 100%);
}

.app {
  width: 100%;
  max-width: 1080px;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.25rem;
  padding: clamp(1rem, 4vw, 2.5rem);
  margin: 0 auto;
}

.app__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app__title {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3c2c1c;
}

.screen {
  display: none;
  animation: fadeIn 320ms ease;
}

.screen--active {
  display: block;
}

.card {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: clamp(1rem, 3vw, 2.4rem);
  box-shadow: 0 24px 65px rgba(60, 42, 26, 0.18);
  backdrop-filter: blur(16px);
  color: #3c2c1c;
}

.card__title {
  margin: 0 0 1.5rem 0;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
}

.form {
  display: grid;
  gap: 1.25rem;
}

.form__field {
  display: grid;
  gap: 0.55rem;
  font-size: 0.95rem;
}

.form__field.is-hidden {
  display: none;
}

.segmented {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  background: rgba(138, 104, 70, 0.12);
  border-radius: 12px;
  padding: 0.25rem;
  gap: 0.25rem;
}

.segmented input {
  display: none;
}

.segmented label {
  padding: 0.65rem;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
  color: #3c2c1c;
}

.segmented input:checked + label {
  background: linear-gradient(135deg, #f2c572, #de9a47);
  color: #402c1c;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(156, 103, 43, 0.35);
}

.select {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #3c2c1c;
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px rgba(96, 75, 49, 0.15);
}

.button {
  font: inherit;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  color: #3c2c1c;
  background: linear-gradient(135deg, #ffcf6b, #f2a34f);
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(204, 143, 57, 0.4);
}

.button--ghost {
  background: rgba(118, 86, 56, 0.12);
  color: #3c2c1c;
  box-shadow: inset 0 0 0 1px rgba(118, 86, 56, 0.2);
}

.game {
  display: grid;
  gap: 1.5rem;
  color: #3c2c1c;
  max-width: 100%;
  width: 100%;
}

.game__status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
}

.status__label {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-right: 0.35rem;
}

.status__value {
  font-weight: 600;
}

.status__divider {
  opacity: 0.5;
  margin: 0 0.5rem;
}

.status__actions {
  margin-left: auto;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;
}

.board {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: min(95vw, 500px);
  aspect-ratio: 1;
  padding: clamp(0.6rem, 2vw, 1rem);
  border-radius: 28px;
  background: linear-gradient(135deg, #b78345 0%, #8c5b2a 100%);
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.18),
    inset 0 0 0 14px rgba(78, 50, 22, 0.35),
    0 28px 60px rgba(80, 53, 25, 0.4);
  overflow: hidden;
}

.board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
      120deg,
      rgba(255, 255, 255, 0.04) 0px,
      rgba(255, 255, 255, 0.04) 12px,
      rgba(0, 0, 0, 0) 12px,
      rgba(0, 0, 0, 0) 24px
    );
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.board__grid {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(46, 28, 14, 0.45);
}

.board__cell {
  position: relative;
  isolation: isolate;
  border: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.board__cell:focus-visible {
  outline: 3px solid rgba(242, 197, 114, 0.7);
  outline-offset: -6px;
}

.board__cell--light {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.45), transparent 60%),
    linear-gradient(145deg, #f3d6a4 0%, #dcb37a 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 84, 46, 0.25);
}

.board__cell--dark {
  background: radial-gradient(circle at 70% 70%, rgba(0, 0, 0, 0.2), transparent 60%),
    linear-gradient(145deg, #915d28 0%, #5f3815 100%);
  box-shadow: inset 0 0 0 1px rgba(32, 18, 9, 0.5);
}

.piece {
  position: relative;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 14%;
  display: grid;
  place-items: center;
  font-size: clamp(0.65rem, 2vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow:
    0 10px 18px rgba(34, 22, 11, 0.45),
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    inset 0 -4px 6px rgba(0, 0, 0, 0.35);
}

.piece::before {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), inset 0 0 18px rgba(0, 0, 0, 0.25);
}

.piece::after {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.piece--dark {
  background: linear-gradient(145deg, #3b2a1b 0%, #1f140c 100%);
  color: rgba(255, 226, 188, 0.9);
}

.piece--light {
  background: linear-gradient(145deg, #f7e2c3 0%, #d3b184 100%);
  color: rgba(66, 45, 23, 0.9);
}

.piece--king::after {
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.4),
    inset 0 0 0 6px rgba(242, 197, 114, 0.5),
    inset 0 0 12px rgba(242, 197, 114, 0.6);
}

.piece--king::before {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.45),
    inset 0 0 0 4px rgba(242, 197, 114, 0.4);
}

.piece--selected {
  transform: translateY(-6px) scale(1.05);
  box-shadow:
    0 18px 28px rgba(72, 48, 20, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.45),
    inset 0 -4px 8px rgba(0, 0, 0, 0.35);
}

.move-indicator {
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 3px solid rgba(242, 197, 114, 0.85);
  box-shadow: 0 0 18px rgba(242, 197, 114, 0.5);
  animation: pulse 1.2s infinite ease-in-out;
}

.capture-indicator {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 3px dashed rgba(209, 67, 67, 0.9);
  animation: dash 640ms linear infinite;
}

.game__actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.app__footer {
  margin-top: 2rem;
  width: 100%;
}

.ad-slot {
  width: 100%;
  max-width: 100%;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(143, 109, 72, 0.08);
  border-radius: 12px;
  padding: 0.5rem;
  overflow: hidden;
  box-sizing: border-box;
}

.ad-slot iframe {
  max-width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }

  50% {
    opacity: 0.9;
    transform: scale(1.05);
  }
}

@keyframes dash {
  to {
    transform: rotate(360deg);
  }
}

/* Victory Modal */
.victory-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.victory-modal[aria-hidden="false"] {
  display: flex;
}

.victory-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 20, 12, 0.85);
  backdrop-filter: blur(8px);
  animation: fadeIn 400ms ease;
}

.victory-modal__content {
  position: relative;
  background: linear-gradient(145deg, #fff9f0 0%, #f5e8d5 100%);
  border-radius: 32px;
  padding: clamp(2rem, 5vw, 3.5rem);
  max-width: 520px;
  width: 100%;
  box-shadow: 
    0 40px 100px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  animation: victorySlideIn 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  overflow: hidden;
}

.victory-modal__confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.victory-modal__confetti::before,
.victory-modal__confetti::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, #ffcf6b, #f2a34f);
  animation: confettiFall 3s ease-in-out infinite;
}

.victory-modal__confetti::before {
  left: 20%;
  animation-delay: 0.2s;
  border-radius: 50%;
}

.victory-modal__confetti::after {
  left: 80%;
  animation-delay: 0.8s;
  border-radius: 2px;
  transform: rotate(45deg);
}

.victory-modal__icon {
  margin-bottom: 1.5rem;
  animation: victoryBounce 1s ease infinite;
}

.victory-trophy {
  position: relative;
  width: 120px;
  height: 140px;
  margin: 0 auto;
}

.trophy-cup {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 80px;
  background: linear-gradient(145deg, #ffd966 0%, #f2a34f 100%);
  border-radius: 12px 12px 40px 40px;
  box-shadow: 
    0 15px 30px rgba(204, 143, 57, 0.4),
    inset 0 -8px 16px rgba(0, 0, 0, 0.2),
    inset 0 4px 8px rgba(255, 255, 255, 0.4);
}

.trophy-cup::before {
  content: '';
  position: absolute;
  top: 15px;
  left: -20px;
  width: 30px;
  height: 40px;
  background: linear-gradient(145deg, #ffd966 0%, #f2a34f 100%);
  border-radius: 20px 0 0 20px;
  box-shadow: inset -4px 0 8px rgba(0, 0, 0, 0.2);
}

.trophy-cup::after {
  content: '';
  position: absolute;
  top: 15px;
  right: -20px;
  width: 30px;
  height: 40px;
  background: linear-gradient(145deg, #ffd966 0%, #f2a34f 100%);
  border-radius: 0 20px 20px 0;
  box-shadow: inset 4px 0 8px rgba(0, 0, 0, 0.2);
}

.trophy-base {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 35px;
  background: linear-gradient(145deg, #8c5b2a 0%, #5f3815 100%);
  border-radius: 8px;
  box-shadow: 
    0 8px 16px rgba(60, 30, 10, 0.4),
    inset 0 -4px 8px rgba(0, 0, 0, 0.3);
}

.trophy-base::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 20px;
  background: linear-gradient(145deg, #a0713a 0%, #7a4e20 100%);
  border-radius: 4px;
}

.victory-modal__title {
  margin: 0 0 0.75rem 0;
  font-size: clamp(2rem, 5vw, 3rem);
  color: #3c2c1c;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  animation: victoryTitlePulse 2s ease-in-out infinite;
}

.victory-modal__message {
  margin: 0 0 2rem 0;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: #6b5540;
  line-height: 1.5;
}

.victory-modal__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

@keyframes victorySlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes victoryBounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-10px) rotate(-5deg);
  }
  75% {
    transform: translateY(-10px) rotate(5deg);
  }
}

@keyframes victoryTitlePulse {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 2px 8px rgba(242, 163, 79, 0.3);
  }
  50% {
    transform: scale(1.05);
    text-shadow: 0 4px 16px rgba(242, 163, 79, 0.6);
  }
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(600px) rotate(720deg);
    opacity: 0;
  }
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -20px;
  border-radius: 50%;
  animation: confettiFall 3s ease-in-out infinite;
  pointer-events: none;
}

@media (max-width: 720px) {
  .app {
    padding: 1.25rem;
  }

  .board {
    width: min(92vw, 420px);
    border-radius: 24px;
  }

  .game__status {
    flex-direction: column;
    align-items: flex-start;
  }

  .game__actions {
    flex-wrap: wrap;
  }

  .status__actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .victory-modal__content {
    padding: 2rem 1.5rem;
  }

  .victory-trophy {
    width: 90px;
    height: 110px;
  }

  .trophy-cup {
    width: 70px;
    height: 65px;
  }
}

