@font-face {
  font-family: 'Comic Neue';
  src: url('/fonts/ComicNeue-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Comic Neue';
  src: url('/fonts/ComicNeue-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --pink: #f8c8dc;
  --lavender: #c8b8e8;
  --mint: #b8e8c8;
  --peach: #f8d8b8;
  --sky: #b8d8f8;
  --cream: #fdf6ec;
  --text: #4a3728;
  --text-light: #8a7768;
}

html, body {
  height: 100%;
  font-family: 'Comic Neue', sans-serif;
  background: var(--cream);
  color: var(--text);
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
}

#title-screen, #setup-screen, #win-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

#game-screen {
  flex-direction: row;
  padding: 1rem;
  gap: 1rem;
}

#board-area {
  flex: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#sidebar {
  flex: 3;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.game-board {
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  background: white;
  display: block;
  width: calc(100vh - 3rem);
  height: calc(100vh - 3rem);
  max-width: 100%;
}

/* ── Title Screen ── */

.game-title {
  font-size: 3rem;
  color: var(--text);
  text-shadow: 2px 2px 0 var(--pink);
  letter-spacing: 0.05em;
}

.game-subtitle {
  font-size: 1.2rem;
  color: var(--text-light);
}

.title-cat {
  animation: catBounce 1.5s ease-in-out infinite;
}

@keyframes catBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.btn {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 2rem;
  font-size: 1.2rem;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
  background: var(--pink);
  color: var(--text);
}

.btn-secondary {
  background: var(--lavender);
  color: var(--text);
}

/* ── Setup Screen ── */

.screen-title {
  font-size: 2rem;
  color: var(--text);
}

.setup-section {
  text-align: center;
}

.setup-section h3 {
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-option {
  padding: 0.5rem 1.2rem;
  background: white;
  border: 2px solid var(--lavender);
  border-radius: 1rem;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}

.btn-option.active {
  background: var(--lavender);
  border-color: var(--lavender);
  color: white;
}

.cat-selection {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.8rem;
  border: 3px solid transparent;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  min-width: 100px;
}

.cat-card:hover {
  border-color: var(--pink);
}

.cat-card.selected {
  border-color: var(--lavender);
  background: #f0ecf8;
}

.cat-card .cat-name {
  font-weight: bold;
  font-size: 0.9rem;
}

.cat-card .cat-desc {
  font-size: 0.75rem;
  color: var(--text-light);
}

.cat-card .player-label {
  font-size: 0.7rem;
  background: var(--lavender);
  color: white;
  padding: 0.1rem 0.5rem;
  border-radius: 0.5rem;
  margin-top: 0.2rem;
}

/* ── Sidebar & Game UI ── */

.sidebar-section {
  padding: 0.8rem;
  background: var(--cream);
  border-radius: 0.8rem;
}

.sidebar-section h3 {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

#dice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dice {
  width: 60px;
  height: 60px;
  background: white;
  border: 3px solid var(--lavender);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: var(--text);
  position: relative;
}

.dice.rolling {
  animation: diceRoll 0.6s ease-out;
}

@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s;
}

.player-row.active {
  background: var(--pink);
}

.player-row .player-pos {
  margin-left: auto;
  font-weight: bold;
  font-size: 0.85rem;
}

.player-row .shield-icon {
  font-size: 0.8rem;
}

#current-player-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
}

#log-messages {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-light);
}

#log-messages p {
  margin: 0.2rem 0;
}

.btn-icon {
  background: none;
  border: 1px solid var(--lavender);
  border-radius: 0.5rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-light);
  font-family: inherit;
}

/* ── Win Screen ── */

#win-screen {
  position: relative;
  overflow: hidden;
}

.win-content {
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.win-title {
  font-size: 2.5rem;
  color: var(--text);
  text-shadow: 2px 2px 0 var(--pink);
}

.win-message {
  font-size: 1.2rem;
  color: var(--text-light);
}

#confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  top: -10px;
  animation: confettiFall linear forwards;
}

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

#win-cat {
  animation: catBounce 1.5s ease-in-out infinite;
}

.dice-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--text);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ── Responsive ── */

@media (max-width: 900px) {
  #game-screen {
    flex-direction: column;
  }

  #board-area {
    flex: none;
    width: 100%;
    max-height: 60vh;
    min-height: 0;
  }

  #sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .sidebar-section {
    flex: 1;
    min-width: 140px;
  }
}

@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
  }

  .cat-selection {
    gap: 0.5rem;
  }

  .cat-card {
    min-width: 80px;
    padding: 0.5rem;
  }
}

/* ── Polish ── */

.screen {
  transition: opacity 0.3s ease;
}

#roll-btn:not(:disabled) {
  animation: pulse 1.5s ease-in-out infinite;
}

#roll-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}

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