* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a0b2e;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: #fff;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(10px, env(safe-area-inset-top)) 14px 0 14px;
  pointer-events: none;
  z-index: 5;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#hearts {
  display: flex;
  gap: 4px;
  font-size: 22px;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

#score {
  font-size: 20px;
  font-weight: 700;
  background: rgba(0,0,0,.35);
  padding: 4px 12px;
  border-radius: 20px;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

#progress-wrap {
  margin-top: 8px;
  height: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,.35);
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff5b7f, #ffb13d, #ffe85b, #5bff8f, #5bc9ff, #b15bff);
  transition: width .15s linear;
}

#phase-name {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,.6);
  opacity: .9;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 25, .72);
  backdrop-filter: blur(3px);
  z-index: 20;
  padding: 20px;
}

.screen.hidden {
  display: none;
}

.panel {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(160deg, #3b1d6b, #241347);
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 22px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

.panel h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 14px;
  opacity: .85;
  margin-bottom: 18px;
  line-height: 1.4;
}

#menu-buttons, .menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  font-size: 16px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  transition: transform .1s ease, background .2s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, #ff5b9e, #7b2ff7);
  box-shadow: 0 6px 16px rgba(123,47,247,.45);
}

.howto-list {
  list-style: none;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  margin: 10px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#phase-select {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.phase-chip {
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.2);
}

.phase-chip.locked {
  opacity: .4;
  cursor: not-allowed;
}

.phase-chip.active {
  background: linear-gradient(135deg, #ff5b9e, #7b2ff7);
}

#btn-pause {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 14px;
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
