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

:root {
  --btn-cast: #ff6b35;
  --btn-reel: #06d6a0;
  --text: #1a3a4a;
  --white: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--text);
  background: #0f5f8f;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.hud-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.5rem + var(--safe-top)) calc(0.65rem + var(--safe-right)) 0.5rem calc(0.65rem + var(--safe-left));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.15) 70%, transparent 100%);
  pointer-events: none;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.title-block h1 {
  font-size: clamp(1.1rem, 3.5vw, 1.75rem);
  font-weight: 700;
  color: var(--white);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  display: none;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.music-toggle {
  pointer-events: auto;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f5f8f;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  line-height: 1;
  min-width: 2.1rem;
}

.music-toggle:active {
  transform: scale(0.96);
}

.music-toggle.muted {
  opacity: 0.65;
}

.char-toggle {
  pointer-events: auto;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f5f8f;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.char-toggle:active {
  transform: scale(0.96);
}

.stats {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.stat {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 0.3rem 0.6rem;
  text-align: center;
  min-width: 58px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a7a8a;
  font-weight: 600;
}

.stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f5f8f;
  line-height: 1.1;
}

.bite-alert {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fee440;
  color: #1a3a4a;
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 700;
  padding: 0.45rem 1.75rem;
  border-radius: 999px;
  border: 4px solid #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  animation: bitePop 0.35s ease infinite alternate;
  pointer-events: none;
  z-index: 4;
}

.bite-alert.hidden {
  display: none;
}

@keyframes bitePop {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.1); }
}

.bottom-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem calc(0.65rem + var(--safe-right)) calc(0.5rem + var(--safe-bottom)) calc(0.65rem + var(--safe-left));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.2) 60%, transparent 100%);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.btn {
  font-family: inherit;
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 700;
  padding: 0.7rem 1.8rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--white);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25), 0 6px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  min-width: 130px;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.btn.hidden {
  display: none;
}

.btn-cast {
  background: var(--btn-cast);
}

.btn-reel {
  background: var(--btn-reel);
  animation: reelPulse 0.45s ease infinite alternate;
}

@keyframes reelPulse {
  from { filter: brightness(1); transform: scale(1); }
  to { filter: brightness(1.12); transform: scale(1.04); }
}

.message {
  text-align: center;
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  font-weight: 600;
  color: var(--white);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  max-width: 92vw;
  line-height: 1.2;
}

.bucket {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 0.4rem 0.75rem;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  max-width: min(480px, 94vw);
  width: 100%;
}

.bucket h2 {
  font-size: 0.7rem;
  margin-bottom: 0.25rem;
  color: #0f5f8f;
}

.bucket-list {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}

.bucket-list li {
  background: #e8f6ff;
  border: 2px solid #b8dff5;
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.bucket-list li.empty {
  background: transparent;
  border: 2px dashed #b8dff5;
  color: #5a7a8a;
  font-weight: 500;
}

.bucket-list li.rare {
  background: #fff3cd;
  border-color: #ffd60a;
}

.bucket-list li.mega {
  background: #caf0f8;
  border-color: #0077b6;
  color: #023e8a;
  font-weight: 700;
}

@media (max-height: 620px) {
  .bucket {
    display: none;
  }

  .btn {
    padding: 0.55rem 1.4rem;
    min-width: 110px;
  }
}

@media (max-width: 380px) {
  .stat {
    min-width: 50px;
    padding: 0.25rem 0.45rem;
  }

  .stat-value {
    font-size: 1rem;
  }
}