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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', cursive, sans-serif;
  cursor: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === UI OVERLAY === */
#ui-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

#title-bar {
  position: absolute;
  top: 12px;
  left: 14px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 24px;
  border-radius: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  font-size: 18px;
  color: rgba(68, 68, 68, 0.7);
  letter-spacing: 0.5px;
}

/* === ZOOM CONTROLS === */
#zoom-controls {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.zoom-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 22px;
  font-weight: bold;
  color: rgba(68, 68, 68, 0.7);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.zoom-btn:active {
  transform: scale(0.9);
  background: rgba(255, 107, 107, 0.2);
}

#title-bar span {
  color: #FF6B6B;
  font-weight: bold;
}

#word-counter {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: rgba(102, 102, 102, 0.7);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#word-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 52px;
  color: white;
  text-shadow: 0 3px 15px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

#word-label.visible {
  opacity: 1;
}

/* === SCROLL HINT === */
#scroll-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  color: rgba(153, 153, 153, 0.7);
  animation: hintFade 4s ease 2s forwards;
}

@keyframes hintFade {
  0% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

/* === LOADING SCREEN === */
#loading-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 50%, #E1F5FE 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#loading-screen h1 {
  font-size: 42px;
  color: #333;
  margin-bottom: 10px;
}

#loading-screen p {
  font-size: 18px;
  color: #666;
}

/* === START SCREEN (audio unlock) === */
#start-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 40%, #C8E6C9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.6s ease;
}

#start-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

#start-content {
  text-align: center;
  padding: 30px;
  max-width: 500px;
}

#start-content h1 {
  font-size: 48px;
  color: #333;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#start-content p {
  font-size: 17px;
  color: #555;
  margin-bottom: 35px;
  line-height: 1.5;
}

#start-btn {
  background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
  color: white;
  border: none;
  padding: 18px 55px;
  border-radius: 35px;
  font-size: 22px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.5px;
}

#start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 107, 107, 0.45);
}

#start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

/* === ROTATE HINT (portrait) === */
#rotate-hint {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 40%, #C8E6C9 100%);
  z-index: 300;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#rotate-content {
  text-align: center;
  padding: 30px;
}

#rotate-icon {
  font-size: 60px;
  animation: rotatePhone 2s ease-in-out infinite;
  display: inline-block;
  margin-bottom: 20px;
}

@keyframes rotatePhone {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-90deg); }
  50%, 75% { transform: rotate(-90deg); }
}

#rotate-content p {
  font-size: 20px;
  color: #444;
  margin-top: 10px;
}

/* Show rotate hint on mobile portrait */
@media (max-width: 768px) and (orientation: portrait) {
  #rotate-hint { display: flex; }
  #gameCanvas { display: none; }
  #ui-overlay { display: none; }
  #start-screen { display: none; }
}

/* === MOBILE === */
@media (max-width: 768px) {
  #title-bar {
    font-size: 14px;
    padding: 6px 16px;
    top: 8px;
    left: 8px;
  }

  .zoom-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  #zoom-controls {
    bottom: 8px;
    left: 8px;
  }

  #word-counter {
    font-size: 12px;
    padding: 5px 12px;
    bottom: 8px;
    right: 8px;
  }

  #word-label {
    font-size: 36px;
  }

  #scroll-hint {
    font-size: 11px;
    bottom: 8px;
  }

  #start-content h1 {
    font-size: 32px;
  }

  #start-content p {
    font-size: 14px;
    margin-bottom: 25px;
  }

  #start-btn {
    padding: 14px 40px;
    font-size: 18px;
  }

  body {
    cursor: auto;
  }
}
