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

:root {
  --bg-dark: #0c0a1d;
  --bg-card: rgba(20, 17, 40, 0.9);
  --primary: #a855f7;
  --secondary: #ec4899;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --text: #f8fafc;
  --text-muted: #a1a1aa;
  --border: rgba(255, 255, 255, 0.1);
  --glow: rgba(168, 85, 247, 0.4);
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: -webkit-fill-available;
  min-height: 100vh;
}

.game-wrapper {
  position: relative;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Background */
.bg-mesh {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 10% 10%, rgba(168, 85, 247, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(236, 72, 153, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
    var(--bg-dark);
  z-index: 0;
}

.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Container */
.jw-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.6);
}

/* Header */
.jw-header {
  text-align: center;
  margin-bottom: 20px;
}

.jw-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.brand-icon {
  font-size: 2.5rem;
  animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.jw-brand h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Stats */
.jw-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 30px;
  border: 1px solid var(--border);
}

.stat-emoji {
  font-size: 1.2rem;
}

.stat-num {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-pill.streak .stat-num {
  color: var(--warning);
}

.stat-text {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Quote */
.jw-quote {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(236, 72, 153, 0.1));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  margin-bottom: 20px;
}

.quote-decoration {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

blockquote {
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 6px;
}

cite {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Scramble Section */
.jw-scramble {
  text-align: center;
  margin-bottom: 20px;
}

.scramble-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.scramble-letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.scramble-letter {
  width: 50px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(145deg, rgba(168, 85, 247, 0.3), rgba(236, 72, 153, 0.2));
  border: 2px solid var(--primary);
  border-radius: 12px;
  animation: letterPop 0.3s ease;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.2);
}

@keyframes letterPop {
  0% { transform: scale(0) rotate(-10deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.scramble-letter.used {
  opacity: 0.3;
  pointer-events: none;
}

/* Answer Display */
.jw-answer-display {
  margin-bottom: 20px;
}

.answer-slots {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.answer-slot {
  width: 42px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  border: 2px dashed var(--border);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.answer-slot.filled {
  background: linear-gradient(145deg, var(--accent), #22d3ee);
  border-style: solid;
  border-color: var(--accent);
  color: var(--bg-dark);
  animation: slotFill 0.2s ease;
}

@keyframes slotFill {
  0% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Letter Buttons */
.jw-input {
  margin-bottom: 16px;
}

.letter-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.letter-btn {
  width: 46px;
  height: 50px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  color: var(--text);
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.letter-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.letter-btn:active {
  transform: scale(0.95);
}

.letter-btn.used {
  opacity: 0.3;
  pointer-events: none;
}

/* Action Buttons */
.jw-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 10px;
}

.action-btn {
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
  transform: scale(0.97);
}

.backspace {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.clear {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.submit {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
}

.submit:hover {
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

/* Message */
.jw-message {
  text-align: center;
  min-height: 28px;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.jw-message.success {
  color: var(--success);
}

.jw-message.error {
  color: #ef4444;
  animation: shake 0.4s ease;
}

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

/* Skip */
.jw-skip {
  text-align: center;
}

.skip-btn {
  padding: 10px 24px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 25px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.skip-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* Mobile */
@media (max-width: 500px) {
  .game-wrapper { padding: 12px; }
  .jw-container { padding: 16px; border-radius: 20px; }
  .jw-brand h1 { font-size: 1.3rem; }
  .brand-icon { font-size: 2rem; }
  .stat-pill { padding: 8px 12px; }
  .stat-num { font-size: 1.1rem; }
  .scramble-letter { width: 44px; height: 48px; font-size: 1.4rem; }
  .answer-slot { width: 36px; height: 42px; font-size: 1.2rem; }
  .letter-btn { width: 40px; height: 44px; font-size: 1.1rem; }
  .jw-actions { gap: 8px; }
  .action-btn { padding: 10px; font-size: 0.8rem; }
}

@media (max-width: 380px) {
  .jw-stats { gap: 8px; }
  .stat-pill { padding: 6px 10px; gap: 5px; }
  .scramble-letter { width: 38px; height: 42px; font-size: 1.2rem; }
  .answer-slot { width: 32px; height: 38px; font-size: 1rem; }
  .letter-btn { width: 36px; height: 40px; font-size: 1rem; }
}

/* Landscape */
@media (max-height: 600px) and (orientation: landscape) {
  .game-wrapper { align-items: flex-start; padding: 10px; }
  .jw-container { max-width: 700px; padding: 12px; }
  .jw-header { margin-bottom: 10px; }
  .brand-icon { font-size: 1.5rem; }
  .jw-brand h1 { font-size: 1.2rem; }
  .subtitle { display: none; }
  .jw-stats { margin-bottom: 10px; }
  .stat-pill { padding: 6px 12px; }
  .jw-quote { padding: 10px; margin-bottom: 10px; }
  blockquote { font-size: 0.85rem; }
  .jw-scramble { margin-bottom: 10px; }
  .scramble-letter { width: 36px; height: 40px; font-size: 1.1rem; }
  .jw-answer-display { margin-bottom: 10px; }
  .answer-slot { width: 32px; height: 36px; font-size: 1rem; }
  .jw-input { margin-bottom: 10px; }
  .letter-btn { width: 34px; height: 38px; font-size: 1rem; }
}
