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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: #f0f2f5;
  gap: 1rem;
}
.egg-spinner {
  font-size: 3rem;
  animation: bounce 0.6s ease infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-15px); }
}
.loading p { color: #888; font-size: 1.1rem; }

/* Not found */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: #f0f2f5;
  text-align: center;
  padding: 2rem;
}
.not-found h1 { font-size: 5rem; margin-bottom: 1rem; }
.not-found p { font-size: 1.2rem; color: #666; line-height: 1.6; }

/* Clue container */
.clue-container {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Text clue */
.clue-text {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
.clue-text .clue-emoji { font-size: 4rem; margin-bottom: 1.5rem; }
.clue-text .clue-body {
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.4;
  max-width: 800px;
  white-space: pre-line;
}

/* Image clue */
.clue-image {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  padding: 1rem;
  gap: 1rem;
}
.clue-image img {
  max-width: 100%;
  max-height: 80vh;
  max-height: 80dvh;
  border-radius: 12px;
  cursor: zoom-in;
  transition: transform 0.3s ease;
  touch-action: pinch-zoom;
}
.clue-image img.zoomed {
  cursor: zoom-out;
  position: fixed;
  inset: 0;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 100;
  border-radius: 0;
  background: #000;
}
.clue-image .caption {
  color: #ccc;
  font-size: 1.2rem;
  text-align: center;
  font-style: italic;
}

/* Anagram */
.clue-anagram {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 2rem;
  gap: 2rem;
}
.clue-anagram .anagram-title {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.letter-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.letter-slot {
  width: clamp(40px, 12vw, 64px);
  height: clamp(40px, 12vw, 64px);
  border: 3px dashed rgba(255,255,255,0.4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 800;
  color: white;
  transition: border-color 0.2s;
}
.letter-slot.filled { border-color: rgba(255,255,255,0.8); }
.letter-slot.correct {
  border-color: #00e676;
  background: rgba(0, 230, 118, 0.2);
}

.letter-pool {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.letter-tile {
  width: clamp(44px, 13vw, 68px);
  height: clamp(44px, 13vw, 68px);
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.3rem, 4.5vw, 2.2rem);
  font-weight: 800;
  color: #333;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.letter-tile:active { cursor: grabbing; transform: scale(1.1); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.letter-tile.placed { opacity: 0.3; pointer-events: none; }

/* Input area for anagram-input type */
.anagram-input-area {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
}
.anagram-input-area input {
  width: clamp(44px, 13vw, 68px);
  height: clamp(44px, 13vw, 68px);
  text-align: center;
  font-size: clamp(1.3rem, 4.5vw, 2.2rem);
  font-weight: 800;
  border: 3px solid rgba(255,255,255,0.5);
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  color: white;
  text-transform: uppercase;
  caret-color: white;
}
.anagram-input-area input:focus {
  outline: none;
  border-color: #ffeb3b;
  background: rgba(255,255,255,0.25);
}
.anagram-input-area .instruction {
  width: 100%;
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.anagram-success {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.anagram-success .success-emoji { font-size: 4rem; animation: bounce 0.6s ease infinite alternate; }
.anagram-success .success-text { color: white; font-size: 1.8rem; font-weight: 800; }

/* Hint button */
.hint-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.5rem;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 50;
  animation: fadeIn 0.5s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: background 0.2s;
}
.hint-btn:hover { background: rgba(0,0,0,0.85); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.hint-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  backdrop-filter: blur(4px);
}
.hint-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.hint-card p { font-size: 1.2rem; color: #333; line-height: 1.5; margin-bottom: 1.5rem; }
.btn-hint-close {
  padding: 0.6rem 2rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* === GAME STYLES === */
.game-wrapper {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #1a1a2e;
  position: relative;
  overflow: hidden;
  padding: 0;
  padding-top: env(safe-area-inset-top, 0);
}
.game-wrapper.is-fullscreen {
  padding-top: 0;
}
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.75rem;
  background: rgba(0,0,0,0.5);
  color: white;
  flex-shrink: 0;
  z-index: 10;
  font-size: 0.85rem;
}
.game-title { font-weight: 700; font-size: 0.85rem; }
.game-score { font-weight: 700; font-size: 0.95rem; color: #FFD700; }
.fullscreen-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.fullscreen-btn:hover { background: rgba(255,255,255,0.15); }

#gameCanvas {
  display: block;
  flex: 1;
  width: 100%;
  max-width: 100%;
  touch-action: none;
}

.game-start-overlay, .game-over-overlay, .game-win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(4px);
}
.game-start-card {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: slideUp 0.3s ease;
}
.game-start-emoji { font-size: 4rem; margin-bottom: 0.5rem; }
.game-start-card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: #333; }
.game-start-card p { font-size: 1rem; color: #666; margin-bottom: 1rem; line-height: 1.4; }
.orient-hint { color: #667eea; font-weight: 600; font-size: 0.95rem; }
.game-start-btn {
  padding: 0.75rem 2.5rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}

/* === AUDIO CLUE === */
.clue-audio {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 2rem;
  gap: 1.5rem;
}
.audio-title {
  color: white;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
}
.audio-instruction {
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
  text-align: center;
  max-width: 300px;
}
.audio-play-btn {
  padding: 1rem 3rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(102,126,234,0.4);
  transition: transform 0.15s;
}
.audio-play-btn:active { transform: scale(0.95); }
.audio-answer-area {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 350px;
}
.audio-answer-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 1.1rem;
  font-family: inherit;
}
.audio-answer-area input:focus {
  outline: none;
  border-color: #667eea;
}
.audio-submit-btn {
  padding: 0.75rem 1.5rem;
  background: #00e676;
  color: #1a1a2e;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.audio-feedback {
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.5em;
}

/* Star letter - 50/50 split layout */
.star-section {
  flex: 0 0 33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  width: 100%;
  padding: 1rem;
  min-height: 0;
}
.star-shape {
  position: relative;
  width: min(55vw, 55vh);
  height: min(55vw, 55vh);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: starPulse 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(255, 200, 0, 0.5));
}
.star-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.star-letter-char {
  position: relative;
  z-index: 1;
  font-size: min(20vw, 20vh);
  font-weight: 900;
  color: #fff;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.4);
  line-height: 1;
  margin-top: 0.15em;
}
.star-instruction {
  color: #FFD700;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.5rem;
  text-align: center;
  letter-spacing: 0.05em;
}
.clue-section {
  flex: 1;
  display: flex;
  width: 100%;
  min-height: 0;
}
.clue-section > * {
  flex: 1;
  width: 100%;
  min-height: 0 !important;
  justify-content: flex-start;
  padding-top: 1rem;
}
/* Star fullscreen overlay */
.star-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.star-fullscreen.visible {
  opacity: 1;
  pointer-events: all;
}
.star-shape-full {
  width: min(75vw, 75vh);
  height: min(75vw, 75vh);
}
.star-fullscreen-msg {
  color: #FFD700;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
}
.star-fullscreen-tap {
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.star-section {
  cursor: pointer;
}
@keyframes starPulse {
  0%, 100% { transform: scale(0.95); }
  50% { transform: scale(1.12); }
}
