:root{
  --bg:#04050a;
  --panel:rgba(9,14,28,.86);
  --cyan:#31f4ff;
  --magenta:#ff4ad8;
  --lime:#9eff5a;
  --yellow:#ffe15d;
  --red:#ff5f6c;
  --text:#eef6ff;
  --muted:#97aac5;
  --border:1px solid rgba(125,170,255,.18);
  --shadow:0 0 18px rgba(49,244,255,.28), 0 0 34px rgba(255,74,216,.14);
}

*{box-sizing:border-box}
html,body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:radial-gradient(circle at center,#101a3a 0%, #05060d 50%, #020208 100%);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

#app{
  position:relative;
  width:100%;
  height:100%;
}

canvas#game{
  display:block;
  width:100%;
  height:100%;
}

#ui{
  position:absolute;
  inset:0;
  pointer-events:none;
}

.panel{
  position:absolute;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  text-align:center;
  padding:24px;
  background:linear-gradient(180deg,rgba(4,5,10,.78),rgba(4,5,10,.92));
  pointer-events:auto;
}

.panel.visible{display:flex}

.titleWrap{
  text-align:center;
  margin-bottom:10px;
}

h1,h2{
  margin:0;
  text-transform:uppercase;
  letter-spacing:.16em;
  text-shadow:var(--shadow);
}

h1{
  font-size:clamp(2.4rem,6vw,5.2rem);
  color:var(--text);
}

h2{
  font-size:clamp(1.9rem,4vw,3rem);
  color:var(--yellow);
}

.subtitle{
  margin:10px 0 22px;
  color:var(--muted);
  letter-spacing:.08em;
}

.menuCard,.infoCard{
  width:min(640px,92vw);
  border:var(--border);
  border-radius:18px;
  padding:16px;
  background:var(--panel);
  box-shadow:var(--shadow);
  backdrop-filter:blur(8px);
}

.menuCard{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.menuBtn{
  cursor:pointer;
  border:var(--border);
  border-radius:14px;
  padding:14px 16px;
  background:linear-gradient(180deg,rgba(32,42,74,.96),rgba(13,16,32,.96));
  color:var(--text);
  font-weight:700;
  letter-spacing:.06em;
  box-shadow:var(--shadow);
  transition:transform .15s ease, border-color .15s ease, background .15s ease;
}

.menuBtn:hover{
  transform:translateY(-2px);
  border-color:rgba(49,244,255,.55);
}
.difficultyBtn.active,
.controlBtn.active{
  border-color:rgba(49,244,255,.75);
  background:linear-gradient(180deg,rgba(49,244,255,.18),rgba(13,16,32,.96));
  box-shadow:0 0 12px rgba(49,244,255,.35);
}
.infoCard{
  margin-top:16px;
  color:var(--muted);
  line-height:1.55;
}

.infoCard strong{color:var(--cyan)}

.footerHint{
  margin-top:16px;
  color:var(--muted);
}

#hud{
  position:absolute;
  left:0;
  top:0;
  width:100%;
  padding:12px;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  pointer-events:none;
  text-shadow:0 0 8px rgba(0,0,0,.8);
}

.hudBlock{
  min-width:240px;
  border:var(--border);
  border-radius:14px;
  padding:10px 12px;
  background:linear-gradient(180deg,rgba(9,14,28,.58),rgba(9,14,28,.18));
  box-shadow:var(--shadow);
  backdrop-filter:blur(8px);
}

.playerHud{
  display:none;
  min-width:300px;
  margin-bottom:10px;
}

.playerHud.visible{display:block}

.hudName{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  font-weight:700;
  margin-bottom:6px;
}

.bar{
  height:12px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(255,255,255,.08);
  margin:5px 0;
  border:1px solid rgba(255,255,255,.12);
}

.fill{
  width:50%;
  height:100%;
  background:linear-gradient(90deg,var(--cyan),var(--lime));
}

.energy .fill{
  background:linear-gradient(90deg,var(--magenta),var(--yellow));
}

.ammo .fill{
  background:linear-gradient(90deg,#65b8ff,#ffffff);
}

.small{
  font-size:.82rem;
  color:var(--muted);
  line-height:1.35;
}

.abilityRow{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:8px;
  margin-top:8px;
}

.ability{
  position:relative;
  height:52px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.05);
  overflow:hidden;
}

.ability .icon{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  letter-spacing:.05em;
  font-size:.95rem;
  color:#fff;
  text-shadow:0 0 10px rgba(0,0,0,.8);
}

.ability .cool{
  position:absolute;
  left:0;
  bottom:0;
  width:100%;
  height:100%;
  transform-origin:bottom;
  background:rgba(0,0,0,.6);
  pointer-events:none;
}

.ability.ready{
  border-color:rgba(49,244,255,.75);
  box-shadow:0 0 10px rgba(49,244,255,.28);
}

.ability.ready .cool{
  opacity:0;
}

.ability.cooling .icon{
  opacity:.7;
}

.abilityLabel{
  position:absolute;
  left:6px;
  top:5px;
  font-size:.68rem;
  color:rgba(255,255,255,.72);
}

#toast{
  position:absolute;
  left:50%;
  bottom:26px;
  transform:translateX(-50%);
  padding:10px 16px;
  border-radius:999px;
  border:var(--border);
  background:rgba(0,0,0,.48);
  color:var(--text);
  font-weight:700;
  letter-spacing:.08em;
  opacity:0;
  transition:opacity .2s ease, transform .2s ease;
  box-shadow:var(--shadow);
}

#toast.show{
  opacity:1;
  transform:translateX(-50%) translateY(-8px);
}
.controlsDialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  padding: 0;
  color: #ffffff;
  background: rgba(8, 12, 30, 0.98);
  border: 1px solid rgba(49, 244, 255, 0.65);
  border-radius: 14px;
  box-shadow:
    0 0 30px rgba(49, 244, 255, 0.25),
    0 20px 70px rgba(0, 0, 0, 0.65);
}

.controlsDialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(4px);
}

.controlsDialogHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.controlsDialogHeader h2 {
  margin: 0;
}

.closeBtn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.closeBtn:hover {
  background: rgba(255, 80, 110, 0.35);
}

.controlsTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 20px 0;
}

.dialogTab.active {
  border-color: #31f4ff;
  background: rgba(49, 244, 255, 0.22);
  box-shadow: 0 0 12px rgba(49, 244, 255, 0.3);
}

.dialogControls {
  padding: 18px 20px 22px;
  line-height: 1.7;
}

.dialogControls h3 {
  margin-top: 0;
  color: #31f4ff;
}

.controlsDivider {
  height: 1px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.14);
}

@media (max-width: 600px) {
  .controlsDialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .dialogControls {
    font-size: 13px;
  }
}
