* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #050010;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: #fff;
  touch-action: none;
}
#game-canvas { position: fixed; inset: 0; display: block; z-index: 1; }
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 20px 16px; text-align: center; z-index: 10;
  background: radial-gradient(ellipse at center, #1a0040 0%, #050010 70%);
  overflow-y: auto;
}
.hidden { display: none !important; }
h1 {
  font-size: clamp(34px, 8.5vw, 64px);
  background: linear-gradient(180deg, #00fff0 0%, #ff00ff 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(0,255,240,0.5);
  letter-spacing: 2px; margin: 8px 0 4px;
  font-weight: 900;
}
h2 {
  font-size: clamp(20px, 5vw, 28px);
  color: #ff00aa; margin-bottom: 12px;
  text-shadow: 0 0 12px #ff00aa;
}
.subtitle {
  color: #b380ff; font-size: clamp(13px, 3.6vw, 18px);
  margin-bottom: 16px; font-style: italic;
  text-shadow: 0 0 10px #b380ff;
}
.tagline {
  color: #00fff0; font-size: clamp(11px, 3vw, 14px);
  margin-bottom: 16px; opacity: 0.85;
}
.btn {
  background: linear-gradient(135deg, #ff00aa, #00fff0);
  color: #050010; border: none; padding: 14px 30px;
  font-size: clamp(16px, 4.5vw, 20px); font-weight: 900;
  border-radius: 50px; cursor: pointer;
  box-shadow: 0 0 30px rgba(0,255,240,0.6), 0 4px 0 #006666;
  margin: 8px; min-width: 200px;
  letter-spacing: 1px; transition: transform 0.08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 30px rgba(0,255,240,0.6), 0 2px 0 #006666; }
.btn.secondary {
  background: transparent; color: #00fff0;
  border: 2px solid #00fff0; box-shadow: 0 0 20px rgba(0,255,240,0.3);
}
.btn.small { padding: 10px 18px; font-size: 14px; min-width: 0; margin: 6px; }
.input-name {
  background: rgba(0,0,0,0.5); border: 2px solid #ff00aa;
  color: #fff; padding: 12px 20px; font-size: 18px;
  border-radius: 30px; text-align: center; margin: 10px;
  width: 260px; max-width: 80vw;
  box-shadow: 0 0 20px rgba(255,0,170,0.4);
}
.input-name:focus { outline: none; border-color: #00fff0; box-shadow: 0 0 25px rgba(0,255,240,0.6); }
.jado-logo {
  width: clamp(100px, 25vw, 150px); height: clamp(100px, 25vw, 150px);
  margin-bottom: 4px;
  filter: drop-shadow(0 0 25px #00fff0);
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.05); }
}

/* Game cards */
.games-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; width: 100%; max-width: 480px;
  margin: 12px 0;
}
.game-card {
  background: linear-gradient(135deg, rgba(255,0,170,0.15), rgba(0,255,240,0.15));
  border: 2px solid #ff00aa;
  border-radius: 16px; padding: 18px 12px;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 20px rgba(255,0,170,0.3);
}
.game-card:active { transform: scale(0.95); }
.game-card.cyan { border-color: #00fff0; box-shadow: 0 0 20px rgba(0,255,240,0.3); }
.game-card .icon { font-size: 42px; margin-bottom: 6px; filter: drop-shadow(0 0 10px currentColor); }
.game-card .title { font-size: 16px; font-weight: 900; letter-spacing: 1px; color: #fff; }
.game-card .desc { font-size: 11px; opacity: 0.8; margin-top: 4px; line-height: 1.4; }
.game-card.cyan .title { color: #00fff0; }
.game-card.pink .title { color: #ff66cc; }
.game-card.coming-soon {
  border-color: #444; box-shadow: none; background: rgba(80,40,120,0.15);
  color: #888; cursor: default;
}
.game-card.coming-soon .title { color: #888; }
.game-card.coming-soon .icon { filter: grayscale(1); }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 10px 14px; display: flex; justify-content: space-between;
  align-items: center; z-index: 5;
  pointer-events: none; font-weight: 900;
  text-shadow: 0 0 8px currentColor, 0 0 2px #000;
  flex-wrap: wrap; gap: 6px;
}
.hud-block {
  background: rgba(0,0,0,0.6); padding: 6px 12px;
  border-radius: 20px; border: 1px solid rgba(0,255,240,0.4);
  font-size: clamp(13px, 3.6vw, 16px);
  backdrop-filter: blur(4px);
}
.hud-block.score { color: #00fff0; }
.hud-block.coins { color: #ffd700; }
.hud-block.qprog { color: #ff66cc; }
.hud-block.lives { color: #ff4477; }

/* Question modal */
#question-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5,0,16,0.85);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 30px 16px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#question-overlay.show { opacity: 1; pointer-events: all; }
.q-card-wrap { position: relative; margin-top: 6vh; display: flex; flex-direction: column; align-items: center; }
.countdown-ring { position: relative; width: 100px; height: 100px; margin-bottom: 12px; }
.countdown-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown-ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.15); stroke-width: 6; }
.countdown-ring .ring-fg {
  fill: none; stroke: #00fff0; stroke-width: 6;
  stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s;
  filter: drop-shadow(0 0 8px #00fff0);
}
.countdown-ring.warn .ring-fg { stroke: #ffd700; filter: drop-shadow(0 0 8px #ffd700); }
.countdown-ring.danger .ring-fg { stroke: #ff4477; filter: drop-shadow(0 0 8px #ff4477); }
.countdown-number {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-size: 38px; font-weight: 900; color: #fff;
  text-shadow: 0 0 10px currentColor;
}
.q-question {
  background: rgba(0,0,0,0.7); padding: 20px 36px;
  border-radius: 24px; border: 3px solid #ff00aa;
  box-shadow: 0 0 40px rgba(255,0,170,0.6);
  font-size: clamp(28px, 9vw, 56px); font-weight: 900;
  color: #fff; text-align: center;
  text-shadow: 0 0 15px #00fff0;
  margin-bottom: 8px;
}
.q-hint { color: #b380ff; font-size: 14px; margin-bottom: 16px; opacity: 0.9; }

.balloons-row {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 12px; padding: 20px 8px; flex-wrap: wrap;
  width: 100%; max-width: 600px;
  margin-bottom: 4vh;
}
.balloon {
  width: clamp(85px, 26vw, 130px); height: clamp(95px, 30vw, 150px);
  position: relative; cursor: pointer;
  animation: balloonFloat 2.5s ease-in-out infinite;
  transition: transform 0.15s;
}
.balloon:active { transform: scale(0.9); }
.balloon:nth-child(2) { animation-delay: -0.5s; }
.balloon:nth-child(3) { animation-delay: -1.2s; }
@keyframes balloonFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.balloon .body {
  width: 100%; height: 80%;
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(28px, 8vw, 42px); font-weight: 900;
  color: #fff;
  text-shadow: 0 0 8px rgba(0,0,0,0.5);
  box-shadow: inset -10px -10px 25px rgba(0,0,0,0.3), 0 0 30px currentColor;
  position: relative;
}
.balloon .body::before {
  content: ''; position: absolute; top: 15%; left: 22%;
  width: 25%; height: 25%; border-radius: 50%;
  background: rgba(255,255,255,0.3); filter: blur(3px);
}
.balloon .string {
  position: absolute; bottom: 0; left: 50%;
  width: 2px; height: 20%; background: rgba(255,255,255,0.4);
  transform: translateX(-50%);
}
.balloon.pink .body { background: radial-gradient(circle at 30% 30%, #ff66cc, #c2185b); color: #fff; }
.balloon.cyan .body { background: radial-gradient(circle at 30% 30%, #4dffff, #0088aa); color: #fff; }
.balloon.gold .body { background: radial-gradient(circle at 30% 30%, #ffec80, #cc9900); color: #fff; }
.balloon.disabled { pointer-events: none; opacity: 0.5; animation: none; }
.balloon.correct .body {
  animation: correctPop 0.8s ease-out;
  background: radial-gradient(circle at 30% 30%, #66ff99, #009933) !important;
  box-shadow: 0 0 50px #66ff99;
}
.balloon.wrong .body {
  animation: wrongPop 0.5s ease-out;
  background: radial-gradient(circle at 30% 30%, #ff4477, #aa0033) !important;
}
@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1.2); }
}
@keyframes wrongPop {
  0% { transform: scale(1); }
  50% { transform: scale(0.7); }
  100% { transform: scale(0.5); opacity: 0.3; }
}

/* Memory game */
#memory-screen { padding-top: 60px; }
#memory-hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 10px 14px; display: flex; justify-content: space-between;
  align-items: center; z-index: 11;
  gap: 6px; flex-wrap: wrap;
  background: rgba(5,0,16,0.7); backdrop-filter: blur(6px);
}
.memory-grid {
  display: grid; gap: 8px;
  margin: 0 auto; width: 100%;
  max-width: 500px;
}
.memory-card {
  aspect-ratio: 1;
  perspective: 800px;
  cursor: pointer;
  position: relative;
}
.memory-card-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.5s; transform-style: preserve-3d;
}
.memory-card.flipped .memory-card-inner { transform: rotateY(180deg); }
.memory-card-front, .memory-card-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 12px; display: flex;
  align-items: center; justify-content: center;
  box-shadow: 0 0 15px rgba(0,255,240,0.4);
}
.memory-card-front {
  background: linear-gradient(135deg, #ff00aa, #00fff0);
  color: #fff; font-size: 28px;
  border: 2px solid #fff;
}
.memory-card-front::after {
  content: '?'; font-size: clamp(24px, 8vw, 40px); font-weight: 900;
  color: rgba(255,255,255,0.9); text-shadow: 0 0 10px #fff;
}
.memory-card-back {
  background: linear-gradient(135deg, #1a0040, #4d0080);
  border: 2px solid #00fff0;
  transform: rotateY(180deg);
  font-size: clamp(28px, 9vw, 48px);
  filter: drop-shadow(0 0 8px currentColor);
}
.memory-card.matched .memory-card-back {
  border-color: #66ff99;
  box-shadow: 0 0 25px #66ff99;
  animation: matchPulse 0.6s ease-out;
}
@keyframes matchPulse {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.1); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* Leaderboard */
.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; justify-content: center; }
.lb-tab {
  background: transparent; color: #b380ff;
  border: 1px solid #b380ff; padding: 8px 16px;
  border-radius: 20px; font-size: 13px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px;
}
.lb-tab.active {
  background: #ff00aa; color: #fff; border-color: #ff00aa;
  box-shadow: 0 0 20px #ff00aa;
}
.leaderboard {
  background: rgba(0,0,0,0.6); border: 2px solid #00fff0;
  border-radius: 16px; padding: 14px 18px; margin: 8px 0;
  box-shadow: 0 0 30px rgba(0,255,240,0.3);
  min-width: 280px; width: 100%;
  max-width: 420px;
}
.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; font-size: 15px;
  border-bottom: 1px dashed rgba(255,255,255,0.15);
}
.lb-row:last-child { border-bottom: none; }
.lb-row .rank { color: #ffd700; font-weight: 900; width: 32px; text-align: left; font-size: 16px; }
.lb-row .name { flex: 1; text-align: left; padding-left: 8px; color: #00fff0; }
.lb-row .score { color: #fff; font-weight: 900; }
.lb-row.you { background: rgba(255,0,170,0.25); border-radius: 8px; }
.lb-empty { opacity: 0.7; padding: 16px; }

/* Game over */
#result-title, #mem-result-title {
  font-size: clamp(26px, 7vw, 42px);
  background: linear-gradient(135deg, #ffd700, #ff00aa);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 12px 0 4px;
  font-weight: 900;
}
.stat-row {
  display: flex; gap: 16px; margin: 6px 0;
  font-size: 16px; flex-wrap: wrap; justify-content: center;
}
.stat-row span { color: #00fff0; }
.stat-row b { color: #fff; }

.mute-btn, .back-btn {
  position: fixed; background: rgba(0,0,0,0.6);
  border: 1px solid #00fff0; color: #00fff0;
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 16px; cursor: pointer; z-index: 8;
}
.mute-btn { top: 12px; right: 12px; }
.back-btn { top: 12px; left: 12px; }

/* Difficulty */
.difficulty-row {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap; margin: 12px 0;
}
.diff-btn {
  background: transparent; border: 2px solid #b380ff;
  color: #b380ff; padding: 12px 22px;
  border-radius: 30px; font-weight: 900;
  font-size: 15px; cursor: pointer;
}
.diff-btn.active { background: #b380ff; color: #050010; box-shadow: 0 0 20px #b380ff; }

#feedback {
  position: fixed; top: 35%; left: 50%; transform: translate(-50%, -50%);
  font-size: clamp(36px, 11vw, 70px); font-weight: 900;
  pointer-events: none; z-index: 25; opacity: 0;
  text-shadow: 0 0 30px currentColor;
}
#feedback.show { animation: pop 0.8s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

.howto-content {
  max-width: 480px; line-height: 1.7; font-size: 15px;
  margin: 12px 0; text-align: left;
  background: rgba(0,0,0,0.4); padding: 18px;
  border-radius: 14px; border: 1px solid rgba(0,255,240,0.3);
}
.howto-content b { color: #00fff0; }


/* Preserved login/profile styles */
.login-card {
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(0,255,240,0.45);
  border-radius: 22px;
  padding: 18px 14px;
  width: min(92vw, 390px);
  box-shadow: 0 0 30px rgba(0,255,240,0.25);
}
.profile-error {
  color: #ff4477;
  font-weight: 900;
  margin: 8px 0;
  text-shadow: 0 0 10px #ff4477;
}
#profile-summary {
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,0,170,0.5);
  border-radius: 20px;
  padding: 8px 18px;
}
