:root {
  --bg-top: #0a1a2e;
  --bg-bot: #1a3a5c;
  --ice: #b8e6ff;
  --ice-bright: #e0f4ff;
  --accent: #6ec6ff;
  --text: #e8f4ff;
  --muted: #8db4d1;
  --card: rgba(20, 50, 80, 0.7);
  --border: rgba(180, 220, 255, 0.2);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(10, 26, 46, 0.3), rgba(26, 58, 92, 0.6)),
    url('icetower_bg.jpg') center/cover no-repeat;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app { position: relative; width: 100vw; height: 100vh; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.screen.visible { display: flex; }

#menu {
  justify-content: space-between;
  padding-top: 40px;
  padding-bottom: 40px;
}

#menu .card,
#menu .btn {
  flex-shrink: 0;
}

#menu-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#menu .title-character {
  width: 140px;
  margin: 8px 0 16px 0;
}

.title {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0;
  text-align: center;
  /* Ice block gradient fill */
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #e0f4ff 30%,
    #a8d8f0 60%,
    #6ec6ff 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* Ice glow and depth */
  filter:
    drop-shadow(0 0 12px rgba(110, 198, 255, 0.9))
    drop-shadow(0 4px 0 rgba(30, 70, 110, 0.7))
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
  /* Subtle frost shimmer */
  animation: iceShimmer 4s ease-in-out infinite;
}

@keyframes iceShimmer {
  0%, 100% {
    filter:
      drop-shadow(0 0 12px rgba(110, 198, 255, 0.9))
      drop-shadow(0 4px 0 rgba(30, 70, 110, 0.7))
      drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
  }
  50% {
    filter:
      drop-shadow(0 0 20px rgba(180, 230, 255, 1))
      drop-shadow(0 4px 0 rgba(30, 70, 110, 0.7))
      drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
  }
}

.title-character {
  width: 70px;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(110, 198, 255, 0.5));
  animation: bobble 2s ease-in-out infinite;
}

@keyframes bobble {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

h2 {
  font-size: 28px;
  color: var(--ice-bright);
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 16px;
}
.row span { color: var(--muted); }
.row strong { color: var(--text); }

.btn {
  width: 100%;
  max-width: 360px;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4a9eff);
  border-color: var(--accent);
  color: #0a1a2e;
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(110, 198, 255, 0.4);
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 16px; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
#hud-floors {
  background: rgba(10, 26, 46, 0.7);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ice-bright);
}
#hud-xp {
  background: rgba(10, 26, 46, 0.7);
  border: 1px solid rgba(255, 200, 80, 0.4);
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #ffcc44;
  transition: transform 0.15s;
}
#hud-xp.combo {
  transform: scale(1.3);
  color: #fff;
  background: rgba(255, 150, 50, 0.9);
}

#lb-list {
  list-style: none;
  width: 100%;
  max-width: 420px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}
#lb-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
#lb-list li .rank { color: var(--muted); margin-right: 10px; min-width: 28px; }
#lb-list li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#lb-list li .xp   { color: var(--accent); font-weight: 700; }

.toast {
  position: absolute;
  bottom: 30px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 26, 46, 0.95);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; }
.mute-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(10, 26, 46, 0.7);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
}
.mute-btn:active { transform: scale(0.95); }