/* Self-hosted Nunito (variable font, covers weights 700–900) */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('fonts/nunito-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

:root {
  --primary-bg: #87CEEB;
  --header-bg: #ffffff;
  --card-bg: #ffffff;
  --shadow-color: rgba(0, 0, 0, 0.15);
  --success-color: #2ECC71;
  --accent-color: #FFB300;
  /* Fredoka has no Cyrillic glyphs; Nunito supports full Cyrillic incl. Ѓ Ќ Ѕ Џ Љ Њ */
  --font-family: 'Nunito', 'Segoe UI', Roboto, -apple-system, sans-serif;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #74ebd5 0%, #9face6 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px;
}

#game-container {
  width: 100%;
  max-width: 480px;
  height: 96vh;
  height: 96dvh;
  max-height: 900px;
  background: #fdfbf7;
  border-radius: 28px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 4px solid #ffffff;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 2px solid #f0f0f0;
}

.stars-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff8e1;
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid #ffe082;
  font-size: 1.25rem;
  font-weight: 700;
  color: #f57f17;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #333;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: #f5f5f5;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.icon-btn:active {
  transform: scale(0.92);
  background: #e0e0e0;
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #eaeaea;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff9a9e, #fad0c4, #fbc2eb);
  transition: width 0.4s ease-out;
}

/* Main Play Area */
.play-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 14px 16px;
  gap: 16px;
  overflow-y: auto;
}

/* Target slots */
.targets-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.target-card {
  background: #ffffff;
  border: 3px dashed #bdc3c7;
  border-radius: 20px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 140px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.05);
  transition: all 0.25s ease;
  position: relative;
}

.target-card.highlight {
  border-color: #f39c12;
  background: #fffdf5;
  transform: scale(1.03);
}

.target-card.matched {
  border-style: solid;
  border-color: #2ecc71;
  background: #f0fff4;
  animation: bounceIn 0.4s ease;
}

.target-visual {
  font-size: 3rem;
  line-height: 1;
  margin: 6px 0;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.target-word {
  font-size: clamp(0.7rem, 3.4vw, 1.05rem);
  font-weight: 700;
  color: #2d3436;
  text-align: center;
  letter-spacing: 0.3px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.target-word .first-letter {
  display: inline-block;
  min-width: 0.7em;
  border-bottom: 3px solid #b2bec3;
  color: transparent;
}

.target-card.matched .target-word .first-letter {
  color: #e74c3c;
  border-bottom-color: transparent;
  font-size: 1.25em;
}

.target-slot {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f1f2f6;
  border: 2px dashed #a4b0be;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: #2f3542;
  margin-top: 6px;
}

.target-card.matched .target-slot {
  background: #2ecc71;
  color: #fff;
  border: none;
  box-shadow: 0 4px 8px rgba(46, 204, 113, 0.4);
}

/* Letters Pool */
.letters-pool {
  background: #f7f9fc;
  border-radius: 22px;
  padding: 16px 12px;
  border: 2px solid #e3e8ee;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-height: 100px;
}

/* Letter Tile */
.letter-tile {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #ff7675, #d63031);
  color: #ffffff;
  font-size: 2.3rem;
  font-weight: 900;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(214, 48, 49, 0.35), 0 3px 0 #b32425;
  cursor: grab;
  touch-action: none;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
}

.letter-tile.ghost {
  opacity: 0.3;
}

.letter-tile.shake {
  animation: wrongShake 0.4s ease;
}

.letter-tile:active {
  cursor: grabbing;
}

.letter-tile.selected {
  transform: scale(1.15) translateY(-6px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.25);
  border: 3px solid #fffa65;
}

.letter-tile.dragging {
  opacity: 0.9;
  transform: scale(1.18);
  z-index: 1000;
  pointer-events: none;
  position: fixed;
  margin: 0;
  transition: none;
}

/* Celebration Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.celebration-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 30px 24px;
  width: 85%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.celebration-badge {
  font-size: 1.8rem;
  font-weight: 900;
  color: #ff7675;
  margin-bottom: 8px;
}

.celebration-stars {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.celebration-text {
  font-size: 1.15rem;
  color: #636e72;
  margin-bottom: 22px;
}

.big-btn {
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: white;
  border: none;
  padding: 14px 28px;
  font-size: 1.25rem;
  font-weight: 800;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0, 184, 148, 0.35), 0 3px 0 #009174;
  width: 100%;
  transition: transform 0.15s ease;
}

.big-btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 8px rgba(0, 184, 148, 0.3);
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* Keyframes */
@keyframes bounceIn {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: wrongShake 0.4s ease;
}
