@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;800;900&display=swap');

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

body {
  font-family: 'Nunito', sans-serif;
  min-height: 100dvh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.game {
  background: rgba(255,255,255,.95);
  border-radius: 32px;
  padding: 32px 24px 24px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
  position: relative;
  overflow: hidden;
}

h1 {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
  animation: titlePulse 2s ease-in-out infinite;
}

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

.welcome h1 {
  font-size: 3.2rem;
  margin-bottom: 4px;
  text-align: center;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: #fff;
  background-clip: unset;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,.3);
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.btn:active { transform: scale(.94); }

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102,126,234,.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(102,126,234,.5); transform: translateY(-2px); }

.btn-secondary {
  background: #eee;
  color: #555;
}
.btn-secondary:hover { background: #e0e0e0; }

.btn-success {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: #fff;
  box-shadow: 0 4px 12px rgba(46,204,113,.35);
}
.btn-success:hover { box-shadow: 0 6px 20px rgba(46,204,113,.5); transform: translateY(-2px); }

.btn-warning {
  background: linear-gradient(135deg, #f1c40f, #e67e22);
  color: #fff;
  box-shadow: 0 4px 12px rgba(241,196,15,.35);
}
.btn-warning:hover { box-shadow: 0 6px 20px rgba(241,196,15,.5); transform: translateY(-2px); }

.btn-pink {
  background: linear-gradient(135deg, #fd79a8, #e84393);
  color: #fff;
  box-shadow: 0 4px 12px rgba(253,121,168,.35);
}
.btn-pink:hover { box-shadow: 0 6px 20px rgba(253,121,168,.5); transform: translateY(-2px); }

.win-overlay {
  position: absolute;
  inset: 0;
  border-radius: 32px;
  background: rgba(255,255,255,.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s;
  z-index: 10;
}

.win-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.win-overlay h2 {
  font-size: 2.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #f1c40f, #e67e22);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: bounceIn .6s ease-out;
}

@keyframes bounceIn {
  0% { transform: scale(.2); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall linear forwards;
}

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

.score {
  font-size: 1.7rem;
  color: #999;
  font-weight: 700;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  body { padding: 12px; }
  .game { padding: 20px 12px 16px; border-radius: 24px; }
  h1 { font-size: 2.4rem; margin-bottom: 16px; }
  .welcome h1 { font-size: 3rem; }
  .btn { padding: 8px 12px; font-size: .8rem; }
  .buttons { gap: 6px; }
  .win-overlay h2 { font-size: 1.6rem; }
  .score { font-size: 1rem; }
}

@media (max-width: 400px) {
  .welcome h1 { font-size: 1.5rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .game { padding: 28px 20px 20px; }
}

/* Shared back-link */
.back-link {
  margin-top: 16px;
}

.back-link a {
  font-size: .95rem;
  font-weight: 700;
  color: #9988cc;
  text-decoration: none;
  transition: color .2s;
}

.back-link a:hover {
  color: #667eea;
}

/* Decorations */
.decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.deco {
  position: absolute;
  opacity: .15;
  font-size: 3rem;
  animation: decoFloat linear infinite;
}

@keyframes decoFloat {
  0% { transform: translateY(0) rotate(0); opacity: .15; }
  50% { transform: translateY(-30px) rotate(10deg); opacity: .2; }
  100% { transform: translateY(0) rotate(0); opacity: .15; }
}

/* Card float animation */
@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Cell base */
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  text-transform: uppercase;
  color: #333;
  background: #f8f8ff;
  transition: all .2s;
  border: 3px dashed;
}

/* Letters base */
.letters {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* Cell hover */
.cell:hover:not(.filled):not(.active) {
  border-color: #b0a0cc;
  background: #f5f0ff;
}

/* Cell filled state */
.cell.filled {
  border-style: solid;
  border-color: #667eea;
  background: #eef0ff;
  animation: cellPop .3s ease-out;
}

@keyframes cellPop {
  0% { transform: scale(.5); opacity: .3; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

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

/* Letter tile shared */
.letter-tile {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 10px rgba(102,126,234,.35);
  user-select: none;
  animation: tileIn .35s ease-out backwards;
}

.letter-tile:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 16px rgba(102,126,234,.45);
}

.letter-tile:active {
  transform: scale(.92);
}

.letter-tile.used {
  background: #ddd;
  color: #999;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  transform: scale(.92);
  opacity: .55;
}

@keyframes tileIn {
  0% { opacity: 0; transform: scale(.3) rotate(-10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
