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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a1030;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* crisp overlay: actors + HUD render here, above the soft-focus world */
#fx {
  position: fixed;
  inset: 0;
  display: block;
  pointer-events: none;
  z-index: 2;
}

.hidden { display: none !important; }

/* ---------- overlay screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #fff;
  text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(38, 20, 70, .55), rgba(16, 8, 34, .82));
  backdrop-filter: blur(3px);
  z-index: 10;
  overflow-y: auto;
}

.game-title {
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  background: linear-gradient(180deg, #ffd75e, #ff5c39);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(60, 20, 60, .6));
}
.game-sub {
  font-size: 14px;
  color: #b9c8e8;
  max-width: 460px;
  line-height: 1.5;
}
.controls-hint {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 13px;
  color: #dfe8ff;
}
.controls-hint span {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  padding: 8px 14px;
}
.key { color: #ffd75e; font-weight: 800; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.btn-big {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 16px 52px;
  border-radius: 999px;
  color: #2a1206;
  background: linear-gradient(180deg, #ffd75e, #ff8b3d);
  box-shadow: 0 6px 0 #a33d1e, 0 10px 24px rgba(0, 0, 0, .4);
  transition: transform .08s, box-shadow .08s;
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 #a33d1e; }

.btn-ghost {
  font-size: 14px;
  font-weight: 700;
  padding: 11px 26px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .25);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .18); }

/* ---------- level select ---------- */
#levels {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}
.level-card {
  position: relative;
  width: 158px;
  min-height: 150px;
  border-radius: 14px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
  border: 1px solid rgba(255, 255, 255, .22);
  transition: transform .1s, border-color .1s;
}
.level-card:not(.locked):hover { transform: translateY(-3px); border-color: #ffd75e; }
.level-card.locked { opacity: .45; cursor: default; }
.lv-num {
  font-size: 22px;
  font-weight: 900;
  color: #ffd75e;
}
.lv-name { font-size: 14px; font-weight: 800; }
.lv-sub { font-size: 10.5px; color: #b9c8e8; line-height: 1.35; flex: 1; }
.lv-stars { font-size: 15px; color: #ffd75e; letter-spacing: 2px; }
.lv-best { font-size: 10px; color: #7df0d8; font-weight: 700; }

/* ---------- uniform selector ---------- */
.uni-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.uni-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #b9c8e8;
}
#uniform-name { color: #ffd75e; }
#uniforms {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.uni-chip {
  width: 32px;
  height: 40px;
  border-radius: 9px;
  border: 2px solid rgba(255, 255, 255, .28);
  cursor: pointer;
  padding: 0;
  transition: transform .1s, border-color .1s;
}
.uni-chip:hover { transform: translateY(-2px); }
.uni-chip.active {
  border-color: #ffd75e;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 215, 94, .5);
}

/* ---------- results ---------- */
.res-card {
  background: rgba(20, 12, 40, .75);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 20px;
  padding: 28px 34px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  min-width: 300px;
}
#res-title { font-size: 26px; font-weight: 900; color: #ffd75e; }
#res-stars { font-size: 44px; letter-spacing: 6px; }
.star { color: rgba(255, 255, 255, .18); display: inline-block; }
.star.lit {
  color: #ffd75e;
  animation: starPop .45s cubic-bezier(.2, 2.4, .4, 1) both;
  text-shadow: 0 0 18px rgba(255, 215, 94, .7);
}
@keyframes starPop {
  from { transform: scale(0) rotate(-40deg); }
  to { transform: scale(1) rotate(0); }
}
.res-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 22px;
  font-size: 14px;
  text-align: left;
}
.res-grid dt { color: #b9c8e8; }
.res-grid dd { font-weight: 800; text-align: right; }
.res-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- HUD chrome ---------- */
#scr-hud {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
#scr-hud button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 17px;
  background: rgba(15, 10, 30, .45);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .2);
}

/* ---------- touch buttons ---------- */
#touch-ui {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 5;
  pointer-events: none;
}
#btn-swing {
  pointer-events: auto;
  width: min(34vw, 140px);
  height: 72px;
  border-radius: 22px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(255, 92, 57, .55);
  opacity: .85;
}
@media (hover: hover) and (pointer: fine) {
  #touch-ui { opacity: .45; }
}
