:root {
  color-scheme: light;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #f4f6fb;
  color: #1d1f23;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.app {
  margin: 3rem 1rem;
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 36px -18px rgba(18, 42, 66, 0.25);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app__header h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  text-align: center;
}

.app__header p {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  color: #444c56;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.scoreboard__item {
  background: #eef4ff;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.scoreboard__label {
  display: block;
  font-size: 0.85rem;
  color: #5a6478;
  margin-bottom: 0.35rem;
}

.scoreboard__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #213c89;
}

.scoreboard__value--x {
  color: #1f6feb;
}

.scoreboard__value--o {
  color: #d97706;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.cell {
  aspect-ratio: 1 / 1;
  border: 2px solid #2d6cdf;
  border-radius: 12px;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: #2d6cdf;
  background: linear-gradient(225deg, #ffffff, #dbe9ff);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell--filled {
  background: linear-gradient(225deg, #ffffff, #f2f4ff);
}

.cell--mark-x {
  color: #1f6feb;
}

.cell--mark-o {
  color: #d97706;
}

.cell:hover:not(.cell--disabled),
.cell:focus-visible:not(.cell--disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -8px rgba(45, 108, 223, 0.6);
  outline: none;
}

.cell--disabled {
  cursor: default;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.cell--winner {
  background: linear-gradient(225deg, #ffe29f, #ffa99f);
  border-color: #f97316;
  color: #b45309;
  box-shadow: 0 10px 24px -16px rgba(249, 115, 22, 0.8);
  animation: winner-pulse 0.6s ease-in-out 2;
}

@keyframes winner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.app__footer {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: #2d6cdf;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
  background: #254ea3;
  transform: translateY(-1px);
  outline: none;
}

.btn--secondary {
  background: #6b7280;
}

.btn--secondary:hover {
  background: #4b5563;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background-color: white;
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  min-width: 300px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modal-pop 0.25s ease;
}

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

.modal h2 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  color: #1d1f23;
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 1rem;
  margin: 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  background-color: #2d6cdf;
  color: white;
  border: none;
  border-radius: 8px;
  transition: background 0.2s ease, transform 0.1s ease;
}

.modal-btn:hover {
  background-color: #254ea3;
  transform: translateY(-1px);
}

.modal-btn--green {
  background-color: #10b981;
}

.modal-btn--green:hover {
  background-color: #059669;
}

.rust-badge {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
}

@media (max-width: 480px) {
  .app {
    margin-top: 2rem;
    padding: 1.5rem;
  }

  .board {
    gap: 0.5rem;
  }

  .scoreboard {
    gap: 0.75rem;
  }
}
