* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Fredoka', 'Bubblegum Sans', -apple-system, sans-serif;
  background: linear-gradient(135deg, #ff7675 0%, #fdcb6e 35%, #00cec9 70%, #6c5ce7 100%);
  background-size: 300% 300%;
  animation: dynamicSunset 20s ease infinite;
  min-height: 100vh;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  position: relative;
}

@keyframes dynamicSunset {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Festive Sun & Garland Decorations */
.sun-glow {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, #fff200 0%, #ff9f1a 60%, transparent 80%);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(15px);
  opacity: 0.8;
  z-index: 1;
}

.bunting-garland {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 35px;
  background: repeating-linear-gradient(
    90deg,
    #ff4757 0px, #ff4757 30px,
    #ffa502 30px, #ffa502 60px,
    #2ed573 60px, #2ed573 90px,
    #1e90ff 90px, #1e90ff 120px,
    #9b59b6 120px, #9b59b6 150px
  );
  clip-path: polygon(
    0% 0%, 100% 0%, 100% 60%,
    95% 100%, 90% 60%, 85% 100%, 80% 60%, 75% 100%, 70% 60%, 65% 100%, 60% 60%,
    55% 100%, 50% 60%, 45% 100%, 40% 60%, 35% 100%, 30% 60%, 25% 100%, 20% 60%,
    15% 100%, 10% 60%, 5% 100%, 0% 60%
  );
  opacity: 0.9;
  z-index: 20;
  pointer-events: none;
}

/* Main Container - Big Edge-to-Edge Viewing */
#game-container {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: transparent;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  z-index: 10;
}

:fullscreen #game-container,
#game-container:fullscreen,
#game-container:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
}

/* --- HUD Top Bar --- */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 4px solid #ffbe76;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 15;
  gap: 12px;
  margin: 0 16px;
  margin-top: 24px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  padding: 6px 18px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 2px solid #f1f2f6;
  min-width: 110px;
}

.hud-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #747d8c;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.hud-val {
  font-size: 1.55rem;
  font-weight: 700;
  color: #2f3542;
}

/* High Score Card */
.highscore-card {
  background: linear-gradient(135deg, #fff9e6 0%, #fff1b8 100%);
  border: 2px solid #ffd32a;
  min-width: 180px;
}

.highscore-card .hud-label {
  color: #b7791f;
}

.highscore-card .hud-val {
  color: #d35400;
  font-size: 1.25rem;
}

/* Timer Card with Warning Pulse */
.timer-card {
  background: #ebf7ff;
  border: 2px solid #70a1ff;
  min-width: 120px;
}

.timer-card .hud-val {
  color: #1e90ff;
  font-size: 1.6rem;
}

.timer-card.danger-pulse {
  background: #ffeaa7;
  border-color: #ff4757;
  animation: timerAlert 0.5s infinite alternate ease-in-out;
}

.timer-card.danger-pulse .hud-val {
  color: #ff4757;
  font-size: 1.75rem;
}

@keyframes timerAlert {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.score-card {
  min-width: 125px;
}

.score-card .hud-val {
  color: #ff4757;
  font-size: 1.6rem;
}

.combo-card {
  min-width: 110px;
}

.combo-card .hud-val {
  color: #8e44ad;
  font-size: 1.55rem;
}

/* Icon Buttons */
.hud-controls {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: #ffffff;
  border: 2px solid #ffbe76;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  transform: scale(1.1);
  background: #fff8e7;
}

/* --- Canvas Wrapper --- */
.canvas-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Attractive sky & festival ground background */
  background: linear-gradient(180deg, #70a1ff 0%, #a4b0be 0%, #74b9ff 35%, #81ecec 70%, #55efc4 100%);
  cursor: none; /* Custom kid-friendly crosshair rendered on canvas */
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Overlays & Modals --- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 25, 48, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  cursor: default;
  overflow-y: auto;
  padding: 14px;
  box-sizing: border-box;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.overlay.hidden {
  display: none;
}

.dialog-card {
  background: #ffffff;
  border-radius: 26px;
  padding: clamp(18px, 3vh, 26px) clamp(20px, 3.5vw, 36px);
  max-width: 520px;
  width: 92%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  transform: scale(0.96);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  border: 4px solid #ffeaa7;
  margin: auto;
  max-height: 94%;
  overflow-y: auto;
  scrollbar-width: thin;
}

@keyframes popIn {
  to { transform: scale(1); }
}

.mela-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ff9ff3, #feca57);
  color: #222f3e;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 16px;
  border-radius: 50px;
  margin-bottom: 6px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  letter-spacing: 0.5px;
}

.game-title {
  font-size: clamp(2.2rem, 5vh, 2.75rem);
  font-weight: 700;
  color: #ff4757;
  text-shadow: 3px 3px 0px #fed330;
  margin-bottom: 3px;
  line-height: 1.15;
}

.subtitle {
  color: #576574;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

/* Highscore Hero Showcase */
.highscore-hero-box {
  background: linear-gradient(135deg, #fff3b0 0%, #ffda79 100%);
  border: 2px solid #f9ca24;
  border-radius: 16px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.2);
}

.trophy-big {
  font-size: 2.2rem;
  animation: wiggleTrophy 2s infinite ease-in-out;
}

@keyframes wiggleTrophy {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.hero-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.hero-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #b7791f;
  letter-spacing: 0.6px;
}

.hero-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: #c0392b;
}

/* Instructions Pills */
.instructions-pill-box {
  background: #f8f9fa;
  border-radius: 16px;
  padding: 10px 16px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  text-align: left;
  border: 2px dashed #c8d6e5;
}

.pill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: #2c3e50;
}

.pill-icon {
  font-size: 1.25rem;
}

/* Action Buttons */
.action-btn {
  font-family: inherit;
  font-size: 1.22rem;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
  letter-spacing: 0.6px;
}

.primary-btn {
  background: linear-gradient(135deg, #10ac84 0%, #1dd1a1 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(16, 172, 132, 0.4);
}

.primary-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 22px rgba(16, 172, 132, 0.5);
}

.primary-btn:active {
  transform: translateY(1px);
}

.secondary-btn {
  background: #f1f2f6;
  color: #576574;
}

.secondary-btn:hover {
  background: #e4e7eb;
}

.fullscreen-btn-style {
  background: #f1f2f6;
  color: #2f3542;
  font-size: 0.98rem;
  padding: 9px 18px;
  margin-top: 8px;
  border: 2px solid #dfe4ea;
  border-radius: 14px;
}

.fullscreen-btn-style:hover {
  background: #e4e7eb;
  border-color: #ced6e0;
}

.pulse-glow {
  animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 8px 22px rgba(16, 172, 132, 0.45);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 12px 30px rgba(16, 172, 132, 0.7);
  }
}

/* --- New High Score Card & Input --- */
.record-card {
  border: 4px solid #ffd32a;
  background: linear-gradient(180deg, #ffffff 0%, #fffbf0 100%);
}

.confetti-cannon {
  font-size: 2.5rem;
  margin-bottom: 4px;
  animation: bounceMedal 1s infinite alternate;
}

.record-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ff9f43;
  margin-bottom: 4px;
  text-shadow: 1px 1px 0px #ee5253;
}

.record-subtitle {
  color: #576574;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.gold-text {
  color: #e67e22;
  font-size: 1.3rem;
}

.name-input-section {
  margin-bottom: 14px;
  text-align: left;
}

.input-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #2f3542;
  margin-bottom: 6px;
}

#player-name-input {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  color: #2ed573;
  border: 2px solid #7bed9f;
  border-radius: 14px;
  outline: none;
  background: #ffffff;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

#player-name-input:focus {
  border-color: #2ed573;
  box-shadow: 0 0 0 3px rgba(46, 213, 115, 0.25);
}

/* --- Results Screen --- */
.medal-icon {
  font-size: 3rem;
  margin-bottom: 2px;
}

#result-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #2f3542;
  margin-bottom: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.stat-box {
  background: #f8f9fa;
  border-radius: 14px;
  padding: 8px;
  border: 2px solid #edf2f7;
}

.stat-box.score-highlight {
  background: #fff8e7;
  border-color: #feca57;
}

.stat-number {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: #0984e3;
}

.score-highlight .stat-number {
  color: #d63031;
}

.stat-desc {
  font-size: 0.74rem;
  font-weight: 600;
  color: #8395a7;
  text-transform: uppercase;
}

.record-reminder {
  background: #f1f2f6;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  color: #2f3542;
}

.result-actions {
  display: flex;
  gap: 12px;
}

/* --- Pause Modal Styling --- */
.pause-card {
  border: 4px solid #70a1ff;
  background: linear-gradient(180deg, #ffffff 0%, #f0f7ff 100%);
  max-width: 480px;
}

.pause-icon {
  font-size: 2.8rem;
  margin-bottom: 4px;
  animation: gentlePulse 2s infinite ease-in-out;
}

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

.pause-title {
  font-size: 1.85rem;
  font-weight: 700;
  color: #1e90ff;
  margin-bottom: 4px;
}

.pause-desc {
  color: #576574;
  font-size: 1.02rem;
  margin-bottom: 14px;
}

.pause-status-chip {
  display: flex;
  justify-content: center;
  gap: 12px;
  background: #e8f4fd;
  padding: 8px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: #2f3542;
  border: 1px solid #d4e8fa;
}

.pause-chip-item strong {
  color: #1e90ff;
}

.pause-actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Exit Modal Styling --- */
.exit-card {
  border: 4px solid #ff7675;
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
  max-width: 460px;
}

.exit-icon {
  font-size: 2.8rem;
  margin-bottom: 4px;
}

.exit-title {
  font-size: 1.85rem;
  font-weight: 700;
  color: #d63031;
  margin-bottom: 4px;
}

.exit-desc {
  color: #576574;
  font-size: 1.02rem;
  margin-bottom: 16px;
}

.exit-actions-list {
  display: flex;
  gap: 12px;
}

.exit-note-text {
  margin-top: 14px;
  font-size: 0.88rem;
  color: #636e72;
  background: #f1f2f6;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px dashed #b2bec3;
}

/* Danger & Exit Buttons */
.danger-btn {
  background: linear-gradient(135deg, #d63031 0%, #ff4757 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(214, 48, 49, 0.4);
}

.danger-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 22px rgba(214, 48, 49, 0.55);
}

.danger-soft-btn {
  background: #ffebee;
  color: #d63031;
  border: 2px solid #ffcdd2;
  font-weight: 700;
}

.danger-soft-btn:hover {
  background: #ffcdd2;
  border-color: #ef9a9a;
}

.menu-sub-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.exit-sub-btn {
  background: #ffebee;
  color: #d63031;
  font-size: 0.98rem;
  padding: 9px 18px;
  border: 2px solid #ffcdd2;
  border-radius: 14px;
}

.exit-sub-btn:hover {
  background: #ffcdd2;
  border-color: #ef9a9a;
}

.exit-icon-btn:hover {
  border-color: #ff7675;
  background: #ffebee;
}

.pause-btn:hover {
  border-color: #70a1ff;
  background: #ebf7ff;
}

/* --- 3 Difficulty Levels Styling --- */
.level-card {
  background: #f1f8ff;
  border: 2px solid #54a0ff;
  min-width: 95px;
}

.level-card .hud-val {
  font-size: 1.15rem;
  color: #10ac84;
}

.level-select-container {
  margin: 8px 0 10px 0;
  text-align: left;
}

.level-select-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  color: #8395a7;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.level-toggle-group {
  display: flex;
  gap: 6px;
  background: #f1f2f6;
  padding: 4px;
  border-radius: 14px;
}

.level-pill-btn {
  flex: 1;
  padding: 7px 6px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: #576574;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.level-pill-btn:hover {
  background: rgba(255, 255, 255, 0.6);
}

.level-pill-btn.active[data-level="beginner"] {
  background: #10ac84;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(16, 172, 132, 0.35);
}

.level-pill-btn.active[data-level="intermediate"] {
  background: #f39c12;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.35);
}

.level-pill-btn.active[data-level="expert"] {
  background: #ee5253;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(238, 82, 83, 0.35);
}

.level-desc-info {
  font-size: 0.78rem;
  color: #576574;
  margin-top: 4px;
  font-weight: 600;
  text-align: center;
}

.result-level-chip {
  display: inline-block;
  background: #eef2f7;
  color: #2f3542;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 50px;
  margin-top: 4px;
  border: 1px solid #dcdde1;
}

.level-tag-highlight {
  color: #e67e22;
  font-weight: 700;
}

/* Height Responsive Adaptations */
@media (max-height: 700px) {
  #game-container {
    height: 98vh;
    max-height: 98vh;
  }
  .hud-bar {
    padding: 6px 12px;
    gap: 6px;
  }
  .hud-item {
    min-width: 75px;
    padding: 3px 8px;
  }
  .hud-val {
    font-size: 1.1rem;
  }
  .dialog-card {
    padding: 12px 18px;
  }
  .game-title {
    font-size: 1.85rem;
  }
  .subtitle {
    margin-bottom: 6px;
    font-size: 0.88rem;
  }
  .highscore-hero-box {
    margin-bottom: 6px;
    padding: 6px 10px;
  }
  .instructions-pill-box {
    margin-bottom: 8px;
    padding: 6px 8px;
    gap: 4px 8px;
  }
  .action-btn {
    padding: 9px 18px;
    font-size: 0.98rem;
  }
  .level-select-container {
    margin: 4px 0 8px 0;
  }
  .level-pill-btn {
    padding: 5px 4px;
    font-size: 0.78rem;
  }
}

@media (max-height: 540px) {
  .instructions-pill-box {
    display: none; /* Hide redundant instructions on ultra-compact screens */
  }
  .game-title {
    font-size: 1.6rem;
  }
}

/* Width Responsive Adaptations */
@media (max-width: 650px) {
  #game-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  .hud-bar {
    padding: 6px 8px;
    gap: 4px;
  }
  .hud-item {
    min-width: 60px;
    padding: 3px 6px;
  }
  .hud-label {
    font-size: 0.62rem;
  }
  .hud-val {
    font-size: 0.95rem;
  }
  .highscore-card {
    min-width: 80px;
  }
  .highscore-card .hud-val {
    font-size: 0.9rem;
  }
  .instructions-pill-box {
    grid-template-columns: 1fr;
  }
}

/* --- Creator Attribution Credit Badge --- */
.creator-credit {
  position: absolute;
  right: 20px;
  bottom: 14px;
  z-index: 30;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid #ffd32a;
  border-radius: 50px;
  padding: 6px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
  font-family: 'Fredoka', 'Bubblegum Sans', 'Segoe UI', -apple-system, sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  color: #576574;
  letter-spacing: 0.35px;
  line-height: 1.2;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.creator-credit .creator-name {
  color: #2f3542;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-left: 4px;
}

@media (max-height: 700px) {
  .creator-credit {
    bottom: 10px;
    right: 16px;
    padding: 5px 12px;
    font-size: 0.78rem;
  }
}

@media (max-height: 540px) {
  .creator-credit {
    bottom: 6px;
    right: 10px;
    padding: 4px 10px;
    font-size: 0.72rem;
  }
}

@media (max-width: 650px) {
  .creator-credit {
    bottom: 8px;
    right: 12px;
    padding: 4px 10px;
    font-size: 0.72rem;
  }
}


