@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

.game-window {
  background: #d4e4ed;
  border-radius: 16px;
  border: 3px solid #7ba3c4;
  box-shadow: 
    0 4px 0 #5a8ab4,
    0 8px 20px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 #e8f4fc;
  overflow: hidden;
  max-width: 1050px;
  width: 100%;
  font-family: 'VT323', monospace;
}

.game-window-header {
  background: linear-gradient(180deg, #a8d4f0 0%, #7bb8e0 100%);
  padding: 0;
  border-bottom: 2px solid #5a8ab4;
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.game-window-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255,255,255,0.5);
}

.game-window-title {
  color: #1a4a6e;
  font-weight: 400;
  font-size: 1.2rem;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  letter-spacing: 1px;
  padding: 8px 14px;
  flex: 1;
}

.settings-btn {
  background: transparent;
  border: none;
  color: #1a4a6e;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px 12px;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.settings-btn:hover {
  opacity: 1;
}

.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.settings-dialog {
  background: #d4e4ed;
  border: 3px solid #7ba3c4;
  border-radius: 12px;
  padding: 20px;
  min-width: 280px;
  max-width: 90vw;
  box-shadow: 0 4px 0 #5a8ab4, 0 8px 20px rgba(0,0,0,0.3);
  font-family: 'VT323', monospace;
}

.settings-dialog h3 {
  margin: 0 0 16px 0;
  color: #1a4a6e;
  font-size: 1.4rem;
  text-align: center;
}

.settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(255,255,255,0.5);
  border-radius: 8px;
  margin-bottom: 12px;
}

.settings-option:last-of-type {
  margin-bottom: 16px;
}

.settings-label {
  color: #2a4a5e;
  font-size: 1.1rem;
}

.settings-toggle {
  position: relative;
  width: 50px;
  height: 26px;
  background: #c8c4a8;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
  border: 2px solid #a8a488;
}

.settings-toggle.active {
  background: #88c888;
  border-color: #68a868;
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.settings-toggle.active::after {
  transform: translateX(24px);
}

.settings-close {
  width: 100%;
  padding: 10px;
  background: linear-gradient(180deg, #f8f4e8 0%, #e8e4d8 100%);
  border: 2px solid #c8c4a8;
  border-radius: 8px;
  color: #5a5a4a;
  font-size: 1.2rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  box-shadow: 0 2px 0 #a8a488;
}

.settings-close:hover {
  background: linear-gradient(180deg, #fff 0%, #f4f0e0 100%);
}

.game-window-content {
  padding: 24px;
  background: 
    linear-gradient(45deg, #c8dce8 25%, transparent 25%),
    linear-gradient(-45deg, #c8dce8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c8dce8 75%),
    linear-gradient(-45deg, transparent 75%, #c8dce8 75%);
  background-size: 4px 4px;
  background-position: 0 0, 0 2px, 2px -2px, -2px 0px;
  background-color: #d4e4ed;
}

.spellcast {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
  user-select: none;
}

.spellcast-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.spellcast-right {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 240px;
  flex: 1;
}

.spellcast-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: #e8dce8;
  border: 2px solid #c4a8d4;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #a888b8;
}

.spellcast-gems-display {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px 6px;
}

.gem-slot {
  font-size: 1.3rem;
  color: #d8c8e0;
  text-shadow: 0 1px 0 #fff;
  line-height: 1;
}

.gem-slot.filled {
  color: #d46a98;
  text-shadow: 0 0 6px rgba(212, 106, 152, 0.6);
}

.spellcast-round-display {
  background: linear-gradient(180deg, #a8d4f0 0%, #7bb8e0 100%);
  border: 2px solid #5a8ab4;
  border-radius: 20px;
  padding: 12px 24px;
  text-align: center;
  color: #1a4a6e;
  font-size: 1.5rem;
  box-shadow: 0 2px 0 #4878a8;
}

.spellcast-player-panel {
  background: #f0e6f4;
  border: 2px solid #c4a8d4;
  border-radius: 8px;
  padding: 12px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #a888b8;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(180deg, #b8d8f8 0%, #88b8e8 100%);
  border: 2px solid #6898c8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2a5a7a;
  font-size: 0.8rem;
}

.player-score {
  font-size: 2.8rem;
  color: #6a4a7a;
}

.spellcast-stats {
  background: #e8f0e8;
  border: 2px solid #a8c8a8;
  border-radius: 8px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #88a888;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed #c8d8c8;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  color: #5a7a5a;
  font-size: 0.95rem;
}

.stat-value {
  color: #3a5a3a;
  font-size: 1rem;
}

.spellcast-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 16px;
  background: #b8d0b8;
  border: 3px solid #88a888;
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 3px 0 #6a8a6a;
  position: relative;
  touch-action: none;
  width: 100%;
  max-width: 450px;
  box-sizing: border-box;
}

.spellcast-line-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.spellcast-tile {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fffef0 0%, #f4f0d8 100%);
  border: 2px solid #c8c4a8;
  border-radius: 10px;
  font-size: 2.2rem;
  font-weight: 400;
  color: #4a4a3a;
  cursor: pointer;
  transition: all 0.1s ease;
  text-transform: uppercase;
  box-shadow: 0 3px 0 #a8a488, inset 0 1px 0 #fff;
  font-family: 'VT323', monospace;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
}

.spellcast-tile:hover {
  background: linear-gradient(180deg, #fff 0%, #f8f4e0 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 #a8a488, inset 0 1px 0 #fff;
}

.spellcast-tile.selected {
  background: linear-gradient(180deg, #a8e0f8 0%, #78c8f0 100%);
  border-color: #4898c8;
  transform: translateY(1px);
  box-shadow: 0 1px 0 #3878a8, inset 0 2px 4px rgba(0,0,0,0.1);
  color: #1a4a6e;
}

.spellcast-tile.adjacent {
  background: linear-gradient(180deg, #e8f8e8 0%, #c8e8c8 100%);
  border-color: #88b888;
}

.spellcast-tile.invalid {
  animation: shake-tile 0.3s ease;
}

@keyframes shake-tile {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.tile-points {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 0.95rem;
  color: #8a8a7a;
}

.tile-bonus {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.75rem;
  font-weight: 400;
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'VT323', monospace;
}

.tile-bonus.dl {
  background: #78a8d8;
  color: #fff;
  border: 1px solid #4878a8;
}

.tile-bonus.tl {
  background: #e8c868;
  color: #6a5a2a;
  border: 1px solid #c8a848;
}

.tile-bonus.dw {
  background: #e888a8;
  color: #fff;
  border: 1px solid #c86888;
}

/* Double Word tile styling */
.spellcast-tile.has-dw {
  border: 2px solid #e888a8;
  box-shadow: 0 2px 0 #c86888, 0 0 8px rgba(232, 136, 168, 0.4);
}

.spellcast-tile.has-dw.selected {
  box-shadow: 0 1px 0 #c86888, inset 0 2px 4px rgba(0,0,0,0.1), 0 0 8px rgba(232, 136, 168, 0.4);
}

/* DW Roulette highlight */
.spellcast-tile.dw-highlight {
  border: 3px solid #e888a8 !important;
  box-shadow: 0 0 15px rgba(232, 136, 168, 0.8), inset 0 0 8px rgba(232, 136, 168, 0.3) !important;
  transform: scale(1.05);
}

/* DW landing effect */
.spellcast-tile.dw-land {
  animation: dw-land 0.5s ease;
}

@keyframes dw-land {
  0% { transform: scale(1.05); box-shadow: 0 0 20px rgba(232, 136, 168, 1); }
  50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(232, 136, 168, 1); }
  100% { transform: scale(1); box-shadow: 0 2px 0 #c86888, 0 0 8px rgba(232, 136, 168, 0.4); }
}

/* Hint highlight */
.spellcast-tile.hint-highlight {
  background: linear-gradient(180deg, #f8e8a8 0%, #e8d078 100%) !important;
  border-color: #c8a838 !important;
  animation: hint-pulse 0.5s ease;
  box-shadow: 0 0 12px rgba(232, 200, 80, 0.8), 0 3px 0 #a88828 !important;
}

@keyframes hint-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.tile-gem {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.85rem;
  color: #d46a98;
}

.spellcast-word {
  min-height: 48px;
  padding: 10px 24px;
  background: #fff;
  border: 2px solid #c8c4a8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 260px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.spellcast-word-text {
  color: #4a4a3a;
  font-size: 1.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.spellcast-word-points {
  color: #88a888;
  font-size: 1.4rem;
}

.spellcast-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.spellcast-btn {
  padding: 12px 24px;
  background: linear-gradient(180deg, #f8f4e8 0%, #e8e4d8 100%);
  border: 2px solid #c8c4a8;
  border-radius: 10px;
  color: #5a5a4a;
  font-size: 1.4rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 2px 0 #a8a488;
}

.spellcast-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff 0%, #f0ece0 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 #a8a488;
}

.spellcast-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #a8a488;
}

.spellcast-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spellcast-btn.primary {
  background: linear-gradient(180deg, #a8e0a8 0%, #88c888 100%);
  border-color: #68a868;
  color: #2a5a2a;
  box-shadow: 0 2px 0 #488848;
}

.spellcast-btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #b8f0b8 0%, #98d898 100%);
}

.spellcast-abilities {
  display: flex;
  gap: 4px;
}

.ability-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 8px 16px;
  background: linear-gradient(180deg, #f4e8f8 0%, #e4d8ec 100%);
  border: 2px solid #c8b8d4;
  border-radius: 10px;
  color: #6a5a7a;
  font-size: 1.7rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 2px 0 #a898b8;
  min-width: 50px;
}

.ability-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #fcf0ff 0%, #ece0f4 100%);
  transform: translateY(-1px);
}

.ability-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ability-cost {
  color: #d46a98;
  font-size: 0.95rem;
}

.spellcast-message {
  color: #5a5a4a;
  font-size: 1.1rem;
  text-align: center;
  min-height: 20px;
  padding: 4px 8px;
}

.spellcast-message.success {
  color: #4a8a4a;
}

.spellcast-message.error {
  color: #c85858;
}

.spellcast-message.bonus {
  color: #c8a828;
}

.spellcast-game-over {
  text-align: center;
  padding: 20px;
}

.spellcast-final-score {
  font-size: 2.5rem;
  color: #4a4a3a;
  margin-bottom: 8px;
}

.spellcast-best-word {
  color: #6a6a5a;
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.swap-mode .spellcast-tile:not(.selected) {
  cursor: crosshair;
  animation: swap-wobble 1.8s ease-in-out infinite;
}

.swap-mode .spellcast-tile:not(.selected):hover {
  background: linear-gradient(180deg, #f8d8e8 0%, #e8b8d0 100%);
  border-color: #c888a8;
  animation: none;
  transform: scale(1.05);
}

@keyframes swap-wobble {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}

.swap-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.swap-dialog {
  background: #d4e4ed;
  border: 3px solid #7ba3c4;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 4px 0 #5a8ab4, 0 8px 20px rgba(0,0,0,0.3);
  font-family: 'VT323', monospace;
}

.swap-dialog h3 {
  color: #1a4a6e;
  margin-bottom: 12px;
  font-size: 1.3rem;
  font-weight: 400;
}

.swap-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 280px;
}

.swap-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fffef0 0%, #f4f0d8 100%);
  border: 2px solid #c8c4a8;
  border-radius: 4px;
  color: #4a4a3a;
  font-weight: 400;
  font-size: 1.2rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 2px 0 #a8a488;
}

.swap-letter:hover {
  background: linear-gradient(180deg, #a8e0f8 0%, #78c8f0 100%);
  border-color: #4898c8;
  transform: translateY(-1px);
}

.swap-cancel {
  margin-top: 12px;
  padding: 6px 16px;
  background: linear-gradient(180deg, #f8f4e8 0%, #e8e4d8 100%);
  border: 2px solid #c8c4a8;
  border-radius: 6px;
  color: #5a5a4a;
  font-size: 1rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  box-shadow: 0 2px 0 #a8a488;
}

.swap-cancel:hover {
  background: linear-gradient(180deg, #fff 0%, #f0ece0 100%);
}

@media (max-width: 850px) {
  .spellcast {
    flex-direction: column;
    gap: 16px;
  }
  
  .spellcast-right {
    min-width: auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  
  .spellcast-round-display {
    order: -1;
    flex: 0 0 auto;
  }
  
  .spellcast-player-panel {
    flex: 0 0 auto;
  }
  
  .spellcast-stats {
    flex: 1 1 100%;
  }
  
  .spellcast-message {
    flex: 1 1 100%;
  }
  
  .spellcast-tile {
    width: 56px;
    height: 56px;
    font-size: 1.7rem;
  }
  
  .spellcast-board {
    gap: 5px;
    padding: 10px;
  }
  
  .game-window {
    max-width: 100%;
  }
  
  .game-window-content {
    padding: 14px;
  }
  
  .spellcast-controls {
    padding: 8px 12px;
  }
  
  .spellcast-gems-display {
    gap: 3px 5px;
  }
  
  .gem-slot {
    font-size: 1.1rem;
  }
}

@media (max-width: 500px) {
  .game-container {
    padding: 0 8px;
  }
  
  .game-window {
    border-width: 2px;
  }
  
  .spellcast-board {
    gap: 3px;
    padding: 6px;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }
  
  .spellcast-tile {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    font-size: clamp(1rem, 5vw, 1.4rem);
    border-radius: 6px;
  }
  
  .tile-points {
    font-size: 0.65rem;
    bottom: 1px;
    right: 2px;
  }
  
  .tile-bonus {
    font-size: 0.5rem;
    padding: 1px 2px;
    top: 1px;
    left: 1px;
  }
  
  .tile-gem {
    font-size: 0.6rem;
    top: 1px;
    right: 2px;
  }
  
  .spellcast-word {
    min-width: auto;
    width: 100%;
    padding: 6px 12px;
    min-height: 36px;
  }
  
  .spellcast-word-text {
    font-size: 1.3rem;
  }
  
  .spellcast-word-points {
    font-size: 1rem;
  }
  
  .spellcast-controls {
    padding: 6px 8px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .spellcast-gems-display {
    gap: 2px 4px;
  }
  
  .gem-slot {
    font-size: 0.9rem;
  }
  
  .spellcast-abilities {
    gap: 4px;
  }
  
  .ability-btn {
    padding: 5px 10px;
    font-size: 1.2rem;
    min-width: 36px;
  }
  
  .ability-cost {
    font-size: 0.7rem;
  }
  
  .spellcast-actions {
    gap: 6px;
  }
  
  .spellcast-btn {
    padding: 8px 14px;
    font-size: 1.1rem;
  }
  
  .spellcast-round-display {
    padding: 6px 12px;
    font-size: 1.1rem;
  }
  
  .spellcast-player-panel {
    padding: 8px;
  }
  
  .player-score {
    font-size: 1.8rem;
  }
  
  .spellcast-stats {
    padding: 8px;
  }
  
  .stat-label, .stat-value {
    font-size: 0.85rem;
  }
  
  .spellcast-message {
    font-size: 0.95rem;
  }
  
  .game-window-content {
    padding: 10px;
  }
  
  .spellcast-left {
    gap: 10px;
  }
  
  .spellcast-round-display {
    padding: 8px 16px;
    font-size: 1.2rem;
  }
  
  .player-score {
    font-size: 2rem;
  }
}

@media (max-width: 380px) {
  .spellcast-tile {
    font-size: clamp(0.9rem, 4.5vw, 1.2rem);
  }
  
  .spellcast-board {
    gap: 2px;
    padding: 5px;
  }
  
  .game-window-content {
    padding: 6px;
  }
  
  .spellcast-controls {
    padding: 5px 6px;
  }
  
  .gem-slot {
    font-size: 0.75rem;
  }
  
  .ability-btn {
    padding: 4px 8px;
    font-size: 1rem;
    min-width: 32px;
  }
  
  .spellcast-left {
    gap: 8px;
  }
}

/* ========== ANIMATIONS ========== */

/* Success pulse on tiles */
.spellcast-tile.success-pulse {
  animation: success-pulse 0.5s ease;
}

@keyframes success-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); box-shadow: 0 0 20px rgba(72, 152, 200, 0.8); }
  100% { transform: scale(1); }
}

/* Reject shake */
.spellcast-tile.reject-shake {
  animation: reject-shake 0.6s ease;
}

@keyframes reject-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.spellcast-tile.invalid {
  background: linear-gradient(180deg, #ffd8d8 0%, #f8b8b8 100%) !important;
  border-color: #d88888 !important;
}

.spellcast-word.reject-flash {
  animation: reject-flash 0.6s ease;
}

@keyframes reject-flash {
  0%, 100% { background: #fff; }
  25%, 75% { background: #ffd8d8; border-color: #d88888; }
}

/* Tile flip out */
.spellcast-tile.tile-flip-out {
  animation: tile-flip-out 0.5s ease forwards;
}

@keyframes tile-flip-out {
  0% { transform: rotateY(0) scale(1); opacity: 1; }
  100% { transform: rotateY(90deg) scale(0.8); opacity: 0; }
}

/* Tile flip in */
.spellcast-tile.tile-flip-in {
  animation: tile-flip-in 0.6s ease backwards;
}

@keyframes tile-flip-in {
  0% { transform: rotateY(-90deg) scale(0.8); opacity: 0; }
  100% { transform: rotateY(0) scale(1); opacity: 1; }
}

/* Floating word container */
.floating-word {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 4px;
  z-index: 50;
  pointer-events: none;
}

.floating-word.suction {
  animation: word-suction 0.6s ease forwards;
}

@keyframes word-suction {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(100%, -100%) scale(0.3); opacity: 0; }
}

.floating-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(180deg, #a8e0f8 0%, #78c8f0 100%);
  border: 2px solid #4898c8;
  border-radius: 6px;
  color: #1a4a6e;
  font-size: 1.3rem;
  font-family: 'VT323', monospace;
  box-shadow: 0 2px 8px rgba(72, 152, 200, 0.5);
  animation: letter-pop-in 0.5s ease backwards;
}

@keyframes letter-pop-in {
  0% { transform: scale(0) translateY(20px); opacity: 0; }
  60% { transform: scale(1.2) translateY(-5px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Flying gem */
.flying-gem {
  position: fixed;
  font-size: 1.2rem;
  color: #d46a98;
  z-index: 100;
  pointer-events: none;
  animation: gem-fly 0.8s ease forwards;
  text-shadow: 0 0 10px rgba(212, 106, 152, 0.8);
}

@keyframes gem-fly {
  0% { 
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translate(calc(var(--target-x) * 0.5), calc(var(--target-y) * 0.5 - 40px)) scale(1.4);
  }
  100% { 
    transform: translate(var(--target-x), var(--target-y)) scale(0.5);
    opacity: 0;
  }
}

/* Points float */
.points-float {
  position: fixed;
  font-family: 'VT323', monospace;
  font-size: 2rem;
  color: #4a8a4a;
  z-index: 100;
  pointer-events: none;
  animation: points-float 1.2s ease forwards;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@keyframes points-float {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-50px) scale(1.3); opacity: 0; }
}

/* Combo popup */
.combo-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: 'VT323', monospace;
  font-size: 2.5rem;
  text-align: center;
  z-index: 60;
  pointer-events: none;
  animation: combo-pop 1.8s ease forwards;
  text-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

@keyframes combo-pop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.3) rotate(5deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  75% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8) rotate(-5deg); opacity: 0; }
}

.combo-popup.nice {
  color: #4a8a4a;
}

.combo-popup.great {
  color: #4898c8;
}

.combo-popup.amazing {
  color: #c8a828;
}

.combo-popup.legendary {
  color: #d46a98;
  font-size: 3rem;
  animation: combo-pop-legendary 1.8s ease forwards;
}

@keyframes combo-pop-legendary {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.5) rotate(5deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1.2) rotate(0deg); }
  75% { transform: translate(-50%, -50%) scale(1.2) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8) rotate(-5deg); opacity: 0; }
}

/* Gem slot pulse when receiving */
.gem-slot.pulse {
  animation: gem-slot-pulse 0.4s ease;
}

@keyframes gem-slot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

/* ========== BUTTON PRESS EFFECTS ========== */

.spellcast-btn {
  transition: all 0.1s ease;
}

.spellcast-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 #a8a488;
}

.spellcast-btn.primary:active:not(:disabled) {
  box-shadow: 0 0 0 #68a868;
}

.ability-btn {
  transition: all 0.1s ease;
}

.ability-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 0 0 #a898b8;
}

.back-btn:active {
  background: linear-gradient(180deg, #98b8d0 0%, #88a8c8 100%);
}

.settings-btn:active {
  opacity: 1;
  transform: scale(0.95);
}

/* ========== FLOATING WORD BACKDROP ========== */

.floating-word-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 45;
  animation: backdrop-fade-in 0.3s ease forwards;
  border-radius: 10px;
}

@keyframes backdrop-fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.floating-word-backdrop.fade-out {
  animation: backdrop-fade-out 0.3s ease forwards;
}

@keyframes backdrop-fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== RESPONSIVE FLOATING LETTERS ========== */

.floating-letter {
  width: clamp(36px, 10vw, 52px);
  height: clamp(36px, 10vw, 52px);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
}

.floating-word {
  gap: clamp(4px, 1vw, 8px);
}

/* ========== ROUND TRANSITION OVERLAY ========== */

.round-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border-radius: 10px;
  animation: round-overlay-in 0.4s ease forwards;
}

@keyframes round-overlay-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.round-overlay.fade-out {
  animation: round-overlay-out 0.4s ease forwards;
}

@keyframes round-overlay-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.round-title {
  font-family: 'VT323', monospace;
  font-size: clamp(2rem, 8vw, 3rem);
  color: #fff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: round-title-in 0.5s ease backwards;
  animation-delay: 0.2s;
}

@keyframes round-title-in {
  0% { transform: scale(0.5) translateY(20px); opacity: 0; }
  60% { transform: scale(1.1) translateY(-5px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.round-score {
  font-family: 'VT323', monospace;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  color: #a8e0f8;
  margin-top: 12px;
  animation: round-score-in 0.4s ease backwards;
  animation-delay: 0.5s;
}

@keyframes round-score-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ========== GAME START ANIMATION ========== */

.spellcast-tile.initial-flip {
  animation: tile-flip-in 0.5s ease backwards;
}

/* ========== GAME OVER OVERLAY ========== */

.game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border-radius: 10px;
  animation: round-overlay-in 0.5s ease forwards;
}

.game-over-title {
  font-family: 'VT323', monospace;
  font-size: clamp(2.5rem, 10vw, 4rem);
  color: #f8d878;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 30px rgba(248, 216, 120, 0.3);
  animation: game-over-title-in 0.8s ease backwards;
}

@keyframes game-over-title-in {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(3deg); }
  70% { transform: scale(0.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.game-over-score {
  font-family: 'VT323', monospace;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  color: #fff;
  margin-top: 20px;
  animation: round-score-in 0.5s ease backwards;
  animation-delay: 0.4s;
}

.game-over-best {
  font-family: 'VT323', monospace;
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  color: #a8d4f0;
  margin-top: 10px;
  animation: round-score-in 0.5s ease backwards;
  animation-delay: 0.6s;
}

.game-over-btn {
  margin-top: 30px;
  padding: 12px 28px;
  background: linear-gradient(180deg, #88c888 0%, #68a868 100%);
  border: 2px solid #4a8a4a;
  border-radius: 10px;
  color: #fff;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-family: 'VT323', monospace;
  cursor: pointer;
  box-shadow: 0 3px 0 #3a6a3a;
  transition: all 0.1s ease;
  animation: round-score-in 0.5s ease backwards;
  animation-delay: 0.8s;
}

.game-over-btn:hover {
  background: linear-gradient(180deg, #98d898 0%, #78b878 100%);
}

.game-over-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #3a6a3a;
}

/* ========== SCORE TICK ANIMATION ========== */

.player-score.tick {
  animation: score-tick 0.15s ease;
}

@keyframes score-tick {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); color: #8a6a9a; }
}
