/* Chainz - page layout, HUD and menu styling */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b0614;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Nunito', system-ui, sans-serif;
  color: #fff;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The game area. main.js sizes it to fit the screen and sets font-size so everything scales. */
#stage {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(180, 100, 255, 0.25);
}

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

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(0.8em + env(safe-area-inset-top, 0px)) 0.9em 0;
  pointer-events: none;
}
#hud.hidden { display: none; }

.hud-top { display: flex; align-items: center; gap: 0.5em; }
.hud-left { flex: 1; display: flex; flex-direction: column; line-height: 1.05; }

.hud-name {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: 1em;
  color: #ffd23f;
  text-shadow: 0 0.12em 0 #1a1a1a;
}
.hud-score {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: 2em;
  text-shadow: 0 0.08em 0 #1a1a1a;
}
.hud-score small { font-size: 0.5em; opacity: 0.8; }

.icon-btn {
  pointer-events: auto;
  width: 2.6em; height: 2.6em;
  border-radius: 50%;
  border: 0.18em solid #1a1a1a;
  background: #ffd23f;
  color: #1a1a1a;
  font-size: 1.1em;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0.18em 0 #1a1a1a;
}
.icon-btn:active { transform: translateY(0.12em); box-shadow: 0 0.06em 0 #1a1a1a; }

.bar {
  margin-top: 0.5em;
  height: 0.8em;
  border-radius: 1em;
  background: rgba(0, 0, 0, 0.45);
  border: 0.15em solid #1a1a1a;
  overflow: hidden;
}
#hud-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd23f, #fff3a8, #ffd23f);
  transition: width 0.3s ease-out;
}

/* ---------- Menus ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  background: rgba(8, 3, 18, 0.55);
}
.overlay.show { display: flex; }
.overlay.title, .overlay.intro { background: linear-gradient(180deg, rgba(8,3,18,0.1), rgba(8,3,18,0.75) 55%); align-items: flex-end; }

.card {
  width: 100%;
  max-width: 24em;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.7em;
  animation: rise 0.3s ease-out;
}
@keyframes rise { from { transform: translateY(1em); opacity: 0; } to { transform: none; opacity: 1; } }

h1, h2 {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  margin: 0;
  font-weight: 400;
  text-shadow: 0 0.1em 0 #1a1a1a;
}
.logo {
  font-size: 4.2em;
  background: linear-gradient(180deg, #fff6c2, #ffd23f 45%, #c98f00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.04em #1a1a1a;
  text-shadow: none;
  filter: drop-shadow(0 0.08em 0 #1a1a1a);
}
h2 { font-size: 2.2em; color: #ffd23f; }
h2.win { color: #3ddc84; }
h2.lose { color: #ff4d6d; }
.rapper-name { font-size: 2.8em; }

.sub { margin: 0; font-size: 1.1em; opacity: 0.9; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.15em; font-size: 0.85em; opacity: 0.8; }
.goal { margin: 0.2em 0 0.4em; font-size: 1.15em; }
.goal b { color: #ffd23f; }

.btn {
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: 1.2em;
  padding: 0.6em 1em;
  border-radius: 0.8em;
  border: 0.15em solid #1a1a1a;
  background: #ffffff;
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 0 0.2em 0 #1a1a1a;
}
.btn.big { background: #ffd23f; font-size: 1.5em; }
.btn.ghost { background: rgba(255, 255, 255, 0.12); color: #fff; }
.btn:active { transform: translateY(0.15em); box-shadow: 0 0.05em 0 #1a1a1a; }

.howto {
  text-align: left;
  margin: 0;
  padding: 0.9em 1em 0.9em 2em;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 0.8em;
  line-height: 1.4;
  font-size: 1em;
}
.howto li { margin-bottom: 0.35em; }
.howto b { color: #ffd23f; }

.bling-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3em 0.8em; font-weight: 800; font-size: 0.95em; }

.level-list { display: flex; flex-direction: column; gap: 0.5em; }
.level-card {
  display: grid;
  grid-template-columns: 2.2em 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  padding: 0.55em 0.8em;
  border-radius: 0.8em;
  border: 0.15em solid #1a1a1a;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 0 0.2em 0 #1a1a1a;
  font-family: inherit;
  font-size: 1em;
}
.level-card:disabled { background: rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.6); cursor: default; }
.lv-num { grid-row: span 2; font-family: 'Bungee', sans-serif; font-size: 1.6em; }
.lv-name { font-family: 'Bungee', sans-serif; font-size: 1.15em; }
.lv-info { font-size: 0.85em; font-weight: 800; opacity: 0.7; }

.stats { display: flex; justify-content: space-around; background: rgba(0,0,0,0.45); border-radius: 0.8em; padding: 0.7em; }
.stats div { display: flex; flex-direction: column; font-size: 0.85em; opacity: 0.9; }
.stats b { font-family: 'Bungee', sans-serif; font-size: 1.6em; color: #ffd23f; }

/* ---------- Now playing toast ---------- */
.now-playing {
  position: absolute;
  left: 50%;
  bottom: 1.2em;
  transform: translate(-50%, 1em);
  padding: 0.45em 1em;
  border-radius: 2em;
  border: 0.15em solid #1a1a1a;
  background: rgba(20, 10, 30, 0.85);
  color: #ffd23f;
  font-weight: 800;
  font-size: 0.95em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
}
.now-playing.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Phones only ---------- */
.overlay.mobile-only { align-items: center; }
.qr { background: #fff; border-radius: 0.8em; border: 0.15em solid #1a1a1a; align-self: center; line-height: 0; padding: 0.3em; min-width: 8em; min-height: 8em; }
.qr svg { width: 12em; height: 12em; }
.url { margin: 0; font-weight: 800; color: #ffd23f; word-break: break-all; }

/* Portrait only: ask to rotate when a phone is turned sideways */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b0614;
  color: #fff;
  font-family: 'Bungee', 'Arial Black', sans-serif;
  font-size: 22px;
  text-align: center;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
#rotate .phone { width: 40px; height: 70px; border: 5px solid #ffd23f; border-radius: 10px; animation: turn 1.6s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  #rotate { display: flex; }
}

.version { margin: 0; font-size: 0.7em; opacity: 0.45; }

/* ---------- Music menu ---------- */
.btn-row { display: flex; gap: 0.6em; }
.btn-row .btn { flex: 1; }
.song-list { display: flex; flex-direction: column; gap: 0.45em; max-height: 50vh; overflow-y: auto; touch-action: pan-y; }
.song {
  display: flex; align-items: center; gap: 0.7em;
  padding: 0.65em 0.9em;
  border-radius: 0.8em;
  border: 0.15em solid #1a1a1a;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-family: inherit; font-size: 1.05em; font-weight: 800;
  text-align: left; cursor: pointer;
}
.song.on { background: #ffd23f; color: #1a1a1a; box-shadow: 0 0.2em 0 #1a1a1a; }
.song-icon { width: 1.3em; text-align: center; }
.song-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-eq { display: flex; gap: 0.12em; align-items: flex-end; height: 1em; }
.song-eq i { width: 0.22em; background: currentColor; animation: eq 0.8s ease-in-out infinite; }
.song-eq i:nth-child(2) { animation-delay: -0.3s; }
.song-eq i:nth-child(3) { animation-delay: -0.55s; }
@keyframes eq { 0%, 100% { height: 0.3em; } 50% { height: 1em; } }
.empty { margin: 0; padding: 1em; background: rgba(0, 0, 0, 0.45); border-radius: 0.8em; line-height: 1.4; }
.empty b { color: #ffd23f; }
.hint { margin: 0; font-size: 0.8em; opacity: 0.6; }
.song-title small { font-weight: 600; opacity: 0.65; margin-left: 0.4em; }

/* ---------- Ko-fi tip button ---------- */
.btn.tip {
  display: block;
  font-size: 1em;
  text-decoration: none;
  background: linear-gradient(180deg, #fff3a8, #ffd23f 60%, #e0a800);
  color: #1a1a1a;
  animation: tipGlow 3s ease-in-out infinite;
}
@keyframes tipGlow {
  0%, 100% { box-shadow: 0 0.2em 0 #1a1a1a; }
  50% { box-shadow: 0 0.2em 0 #1a1a1a, 0 0 1.2em rgba(255, 210, 63, 0.6); }
}
