/* refurrsi/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pink: #f4a7bb;
  --lavender: #c3b1e1;
  --lilac: #d4b8e0;
  --board-light: #f0e8f8;
  --board-dark: #e8e0f4;
  --board-border: #d4b8e0;
  --bg: #faf5ff;
  --text: #4a3f5c;
  --text-light: #7a6f8c;
  --cell-size: 60px;
}

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

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

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  width: 100%;
  max-width: 600px;
}

.screen.hidden { display: none; }

/* --- Title Screen --- */
.title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 32px;
}

.side-picker {
  text-align: center;
  margin-bottom: 24px;
}

.picker-label {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text-light);
}

.side-options {
  display: flex;
  align-items: center;
  gap: 16px;
}

.side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border: 3px solid #e0d4f0;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.side-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(180, 160, 200, 0.3);
}

.side-btn.selected {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(195, 177, 225, 0.3);
}

.vs-text {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-light);
}

/* --- Difficulty Buttons --- */
.difficulty {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.btn-diff {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 20px;
  border: 2px solid #e0d4f0;
  border-radius: 50px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-diff:hover { border-color: var(--lavender); }

.btn-diff.selected {
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  color: #fff;
  border-color: transparent;
}

/* --- Play / Action Buttons --- */
.btn-big {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  padding: 14px 48px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  color: #fff;
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
  letter-spacing: 0.02em;
}

.btn-big:hover { filter: brightness(1.08); transform: scale(1.04); }
.btn-big:active { transform: scale(0.98); }

.back-link {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: rgba(255,255,255,0.8);
}

/* --- Board --- */
#board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  border: 4px solid var(--board-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(180, 160, 200, 0.25);
  background: var(--board-dark);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  transition: background-color 0.15s;
}

.cell-light { background: var(--board-light); }
.cell-dark { background: var(--board-dark); }

.cell.valid {
  cursor: pointer;
}

.cell.valid::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(100, 80, 140, 0.15);
  transition: transform 0.15s, background-color 0.15s;
}

.cell.valid:hover::after {
  transform: scale(1.6);
  background: rgba(100, 80, 140, 0.3);
}

.cell.valid:hover {
  background: rgba(195, 177, 225, 0.2);
}

.cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(195, 177, 225, 0.5);
}

/* --- Tokens --- */
.token {
  width: calc(var(--cell-size) - 8px);
  height: calc(var(--cell-size) - 8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.token svg {
  width: 100%;
  height: 100%;
}

/* --- Flip Animation --- */
.token.flipping {
  animation: flipToken 0.5s ease-in-out;
}

@keyframes flipToken {
  0%   { transform: scaleX(1); }
  45%  { transform: scaleX(0); }
  55%  { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

/* --- Place Animation --- */
.token.placing {
  animation: placeToken 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes placeToken {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Particles --- */
.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 10;
  animation: particleBurst 0.6s ease-out forwards;
}

@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--px), var(--py)) scale(0) rotate(var(--pr));
  }
}

.particle-star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.particle-paw {
  border-radius: 50%;
}

/* --- HUD --- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(var(--cell-size) * 8 + 8px);
  padding: 12px 16px;
  margin-bottom: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(180, 160, 200, 0.2);
}

.hud-side {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
}

.hud-icon {
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#hud-turn-text {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.hud-diff {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  background: #f0e8f8;
  padding: 2px 10px;
  border-radius: 50px;
}

.hud-side.active .hud-icon {
  animation: hudPulse 1s ease-in-out infinite;
}

@keyframes hudPulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 2px 12px rgba(195, 177, 225, 0.5); }
}

/* --- Toast (skip-turn message) --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 10px 28px;
  border-radius: 50px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(180, 160, 200, 0.3);
  z-index: 100;
  animation: toastIn 0.3s ease-out;
}

.toast.hidden { display: none; }

@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- Game Over Screen --- */
#over-title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 2.8rem;
  background: linear-gradient(135deg, var(--pink), var(--lavender));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
}

#over-score-display {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.over-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.over-icon {
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.over-count {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 2rem;
}

.over-vs {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text-light);
}

.over-winner .over-icon {
  animation: winnerBounce 0.6s ease-in-out infinite alternate;
}

@keyframes winnerBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.08); }
}

/* --- Responsive --- */
@media (max-width: 560px) {
  :root { --cell-size: 42px; }

  .title { font-size: 2.4rem; }
  .subtitle { font-size: 0.95rem; }
  .side-btn { padding: 12px 16px; }
  .pick-token { width: 56px !important; height: 56px !important; }
  .btn-big { font-size: 1.1rem; padding: 12px 36px; }

  #hud {
    width: calc(var(--cell-size) * 8 + 8px);
    padding: 8px 10px;
  }

  .hud-side { font-size: 1.1rem; }

  #over-title { font-size: 2rem; }
  .over-count { font-size: 1.5rem; }
}
