:root{
  --bg:#040714;
  --bg2:#091227;
  --panel:rgba(8,14,30,.78);
  --panel-soft:rgba(8,14,30,.34);
  --panel-lite:rgba(8,14,30,.22);
  --text:#edf4ff;
  --muted:#a8b9da;
  --cyan:#56dbff;
  --blue:#8caeff;
  --violet:#b08dff;
  --gold:#ffc857;
  --green:#49dc8f;
  --danger:#ff5a7a;
  --shadow:0 24px 60px rgba(0,0,0,.42);
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
}

html,body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(86,219,255,.10), transparent 24%),
    radial-gradient(circle at 80% 12%, rgba(176,141,255,.12), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(255,90,122,.08), transparent 34%),
    linear-gradient(180deg,var(--bg2),var(--bg));
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

body{
  min-height:100dvh;
  overflow:hidden;
}

#app{
  position:relative;
  width:100%;
  height:100dvh;
  overflow:hidden;
  touch-action:none;
  overscroll-behavior:none;
}

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

#app.ui-open canvas{
  touch-action:auto;
}

#app.menu-mode .gameplay-ui,
#app.menu-mode .mobile-controls{
  opacity:0;
  pointer-events:none;
}

#app.play-mode .gameplay-ui{
  opacity:1;
  pointer-events:none;
}

#app.menu-mode .home-overlay{
  opacity:1;
  pointer-events:auto;
}

#app.play-mode .home-overlay{
  opacity:0;
  pointer-events:none;
}

button{
  font:inherit;
}

svg{
  display:block;
  width:22px;
  height:22px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

/* GAMEPLAY UI */
.gameplay-ui{
  position:absolute;
  inset:0;
  z-index:14;
  transition:opacity .24s ease;
  pointer-events:none;
}

.icon-btn,
.mobile-controls,
.mobile-controls .control-btn{
  pointer-events:auto;
}

.hud,
.hud-left,
.hud-right,
.boss-bar-wrap,
.power-dock{
  pointer-events:none;
}

.hud{
  position:absolute;
  top:14px;
  left:14px;
  right:14px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  z-index:16;
}

.hud-left,
.hud-right{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:flex-start;
}

.hud-pill{
  min-width:92px;
  padding:10px 12px;
  border-radius:18px;
  background:var(--panel);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
}

.hud-pill.compact{
  min-width:84px;
}

.hud-label{
  display:block;
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:var(--muted);
  margin-bottom:6px;
}

.hud-pill strong{
  display:block;
  font-size:18px;
  line-height:1;
  font-weight:900;
}

.icon-btn{
  width:50px;
  height:50px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background:var(--panel);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
}

.hud .icon-btn,
.mobile-controls .control-btn,
.home-overlay button,
.overlay button,
.garage button{
  pointer-events:auto;
}

.hud,
.boss-bar-wrap,
.power-dock{
  pointer-events:none;
}

.boss-bar-wrap{
  position:absolute;
  top:92px;
  left:50%;
  transform:translateX(-50%);
  width:min(720px,calc(100vw - 28px));
  padding:12px 14px;
  border-radius:22px;
  background:rgba(22,13,28,.88);
  border:1px solid rgba(255,255,255,.08);
  backdrop-filter:blur(16px);
  box-shadow:var(--shadow);
  z-index:15;
}

.boss-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-bottom:9px;
  font-size:12px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:#ffd7e0;
}

.boss-bar{
  height:16px;
  border-radius:999px;
  overflow:hidden;
  background:rgba(255,255,255,.09);
}

.boss-fill{
  height:100%;
  width:100%;
  background:linear-gradient(90deg,#ff5a7a,#ff9d54,#ffc857);
  transition:width .14s linear;
}

.power-dock{
  position:absolute;
  left:14px;
  bottom:108px;
  min-width:170px;
  max-width:min(62vw,360px);
  padding:10px 12px;
  border-radius:18px;
  background:rgba(8,14,30,.72);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:var(--shadow);
  backdrop-filter:blur(12px);
  z-index:15;
}

.power-title{
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:var(--muted);
  margin-bottom:8px;
}

.power-strip{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  min-height:22px;
  align-items:center;
}

.power-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:5px 8px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.08);
  font-size:12px;
  font-weight:900;
}

.power-badge .time{
  color:var(--muted);
}

.empty-power{
  font-size:12px;
  color:var(--muted);
}

/* HOME */
.home-overlay{
  position:absolute;
  inset:0;
  z-index:20;
  transition:opacity .24s ease;
}

.home-shade{
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.10), rgba(0,0,0,.30) 50%, rgba(0,0,0,.52) 100%),
    linear-gradient(180deg, rgba(3,7,18,.10) 0%, rgba(3,7,18,.22) 44%, rgba(3,7,18,.62) 100%);
}

.home-stage{
  position:relative;
  width:100%;
  height:100%;
  padding:22px;
  overflow:hidden;
}

.home-title-wrap{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-58%);
  width:min(860px,92vw);
  text-align:center;
  z-index:3;
}

.home-kicker{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:0 14px;
  border-radius:999px;
  background:rgba(8,14,30,.30);
  border:1px solid rgba(255,255,255,.10);
  backdrop-filter:blur(12px);
  font-size:12px;
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:.16em;
  color:#e2ebff;
}

.game-title{
  margin:16px 0 10px;
  font-size:clamp(52px,9vw,108px);
  line-height:.9;
  letter-spacing:-.08em;
  text-transform:uppercase;
  text-shadow:0 12px 34px rgba(0,0,0,.34);
}

.game-title span{
  background:linear-gradient(90deg,#ffffff,#8edbff,#c9b7ff,#ffb7d0);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}

.home-sub{
  margin:0 auto;
  max-width:760px;
  color:#dde8ff;
  font-size:16px;
  line-height:1.65;
  text-shadow:0 6px 18px rgba(0,0,0,.34);
}

.home-corner-card{
  position:absolute;
  min-width:160px;
  max-width:min(230px,42vw);
  padding:14px 16px;
  border-radius:20px;
  background:var(--panel-soft);
  border:1px solid rgba(255,255,255,.10);
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
  z-index:3;
}

.home-corner-card span{
  display:block;
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:#c0d1ee;
  margin-bottom:8px;
}

.home-corner-card strong{
  display:block;
  font-size:28px;
  line-height:1.08;
  font-weight:1000;
  color:#fff;
}

.card-top-left{ top:22px; left:22px; }
.card-top-right{ top:22px; right:22px; }
.card-mid-left{ top:50%; left:22px; transform:translateY(-138%); }
.card-mid-right{ top:50%; right:22px; transform:translateY(-138%); }
.card-bottom-left{ bottom:126px; left:22px; }
.card-bottom-right{ bottom:126px; right:22px; }

.menu-side-btn{
  position:absolute;
  bottom:126px;
  width:min(250px,28vw);
  min-height:82px;
  padding:14px 16px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.10);
  background:var(--panel-lite);
  color:#fff;
  box-shadow:var(--shadow);
  backdrop-filter:blur(12px);
  text-align:left;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:6px;
  z-index:3;
}

.menu-side-btn span{
  font-size:20px;
  font-weight:1000;
  line-height:1.05;
}

.menu-side-btn small{
  color:#c7d4ed;
  font-size:13px;
  line-height:1.45;
}

.menu-left{
  left:50%;
  transform:translateX(calc(-100% - 18px));
}

.menu-right{
  left:50%;
  transform:translateX(18px);
}

.tap-start-wrap{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  z-index:4;
  display:flex;
  justify-content:center;
  padding:12px 18px max(16px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(4,7,20,0) 0%, rgba(4,7,20,.34) 24%, rgba(4,7,20,.78) 64%, rgba(4,7,20,.96) 100%);
  backdrop-filter:blur(10px);
}

.tap-start-btn{
  min-width:min(460px,94vw);
  min-height:72px;
  padding:0 28px;
  border:0;
  border-radius:999px;
  background:linear-gradient(135deg,#84edff,#8caeff 58%,#c6afff);
  color:#061220;
  font-size:22px;
  font-weight:1000;
  letter-spacing:.08em;
  text-transform:uppercase;
  cursor:pointer;
  box-shadow:
    0 24px 50px rgba(86,219,255,.24),
    0 0 0 6px rgba(255,255,255,.06);
  animation:tapPulse 1.7s ease-in-out infinite;
}

@keyframes tapPulse{
  0%,100%{
    transform:translateY(0) scale(1);
    box-shadow:
      0 24px 50px rgba(86,219,255,.22),
      0 0 0 6px rgba(255,255,255,.05);
  }
  50%{
    transform:translateY(-3px) scale(1.018);
    box-shadow:
      0 30px 70px rgba(86,219,255,.34),
      0 0 0 10px rgba(255,255,255,.07);
  }
}

/* OVERLAYS */
.overlay,
.garage{
  position:absolute;
  inset:0;
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:linear-gradient(180deg,rgba(5,8,22,.26),rgba(5,8,22,.78));
  backdrop-filter:blur(8px);
}

.panel{
  width:min(1080px,100%);
  padding:28px;
  border-radius:28px;
  background:linear-gradient(180deg,rgba(255,255,255,.06),rgba(255,255,255,.02)),rgba(8,12,24,.94);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 30px 70px rgba(0,0,0,.5);
}

.small-panel{
  width:min(560px,100%);
  text-align:center;
}

.brand-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:0 14px;
  border-radius:999px;
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.08);
  font-size:12px;
  font-weight:900;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:#dce8ff;
}

.small-panel h2{
  margin:14px 0 10px;
  font-size:40px;
  line-height:1;
}

.small-panel p{
  margin:0;
  color:var(--muted);
  font-size:15px;
  line-height:1.7;
}

.cta-row{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
  margin-top:18px;
}

.primary-btn,
.secondary-btn{
  min-height:54px;
  padding:0 20px;
  border-radius:16px;
  border:0;
  cursor:pointer;
  font-size:15px;
  font-weight:900;
}

.primary-btn{
  background:linear-gradient(135deg,#84edff,#8caeff);
  color:#061321;
  box-shadow:0 16px 32px rgba(86,219,255,.26);
}

.secondary-btn{
  background:rgba(255,255,255,.08);
  color:#fff;
  border:1px solid rgba(255,255,255,.08);
}

.gameover-panel{
  background:
    linear-gradient(180deg,rgba(255,90,122,.08),rgba(255,255,255,.02)),
    rgba(8,12,24,.94);
}

/* GARAGE */
.garage-shell{
  max-height:min(92vh,900px);
  overflow:auto;
}

.garage-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  margin-bottom:18px;
}

.garage-top h2{
  margin:8px 0;
  font-size:34px;
}

.garage-top p{
  margin:0;
  color:var(--muted);
  max-width:560px;
  line-height:1.6;
}

.garage-summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
  margin-bottom:18px;
}

.summary-card{
  padding:16px;
  border-radius:18px;
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.06);
}

.summary-card span{
  display:block;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.12em;
  color:var(--muted);
  margin-bottom:8px;
}

.summary-card strong{
  font-size:24px;
  line-height:1.1;
}

.plane-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}

.plane-tile{
  padding:16px;
  border-radius:22px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.07);
  transition:transform .18s ease,border-color .18s ease,background .18s ease;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.plane-tile:hover{
  transform:translateY(-2px);
}

.plane-tile.owned{
  border-color:rgba(73,220,143,.25);
}

.plane-tile.equipped{
  border-color:rgba(86,219,255,.55);
  background:rgba(86,219,255,.08);
  box-shadow:0 0 0 1px rgba(86,219,255,.12) inset;
}

.plane-badge{
  display:inline-flex;
  min-width:72px;
  height:28px;
  padding:0 12px;
  border-radius:999px;
  align-items:center;
  justify-content:center;
  font-weight:900;
  font-size:12px;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.plane-preview{
  height:128px;
  border-radius:20px;
  background:radial-gradient(circle at 50% 20%, rgba(255,255,255,.08), rgba(255,255,255,.03));
  border:1px solid rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  overflow:hidden;
}

.plane-preview::before{
  content:"";
  position:absolute;
  inset:auto -10% 10px -10%;
  height:38px;
  background:radial-gradient(circle, rgba(86,219,255,.14), transparent 60%);
  filter:blur(8px);
}

.plane-preview svg{
  width:110px;
  height:110px;
  filter:drop-shadow(0 8px 20px rgba(0,0,0,.35));
}

.plane-name{
  font-size:20px;
  font-weight:900;
}

.plane-tier{
  font-size:12px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:var(--muted);
}

.plane-stats{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}

.plane-stat{
  padding:10px 12px;
  border-radius:14px;
  background:rgba(255,255,255,.05);
  font-size:13px;
  color:var(--muted);
}

.plane-stat strong{
  display:block;
  color:#fff;
  font-size:15px;
  margin-top:4px;
}

.tile-actions{
  display:flex;
  gap:10px;
  margin-top:auto;
}

.tile-actions button{
  flex:1;
  padding:12px 14px;
  border-radius:14px;
  border:0;
  font-weight:900;
  cursor:pointer;
}

.tile-buy{
  background:linear-gradient(135deg,#ffd76b,#ffb44f);
  color:#2d1e05;
}

.tile-equip{
  background:linear-gradient(135deg,#84edff,#8caeff);
  color:#061321;
}

.tile-owned{
  background:rgba(255,255,255,.08);
  color:#fff;
  border:1px solid rgba(255,255,255,.08);
}

/* COMMON */
.toast{
  position:absolute;
  left:50%;
  bottom:120px;
  transform:translateX(-50%);
  padding:12px 16px;
  border-radius:16px;
  background:rgba(7,12,24,.9);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:var(--shadow);
  font-size:14px;
  font-weight:900;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease,transform .2s ease;
  z-index:40;
}

.toast.show{
  opacity:1;
  transform:translateX(-50%) translateY(-6px);
}

.mobile-controls{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  padding:14px;
  display:none;
  justify-content:flex-end;
  z-index:18;
  pointer-events:none;
}

.control-btn{
  width:84px;
  height:84px;
  border-radius:50%;
  pointer-events:auto;
  color:#fff;
  box-shadow:var(--shadow);
  border:1px solid rgba(255,255,255,.10);
  display:flex;
  align-items:center;
  justify-content:center;
  background:radial-gradient(circle at 30% 30%, rgba(255,255,255,.22), rgba(255,200,87,.42));
  touch-action:manipulation;
}

.hidden{
  display:none !important;
}

@media (max-width: 1180px){
  .plane-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .home-corner-card{
    max-width:min(220px,42vw);
  }

  .menu-side-btn{
    width:min(220px,29vw);
  }
}

@media (max-width: 860px){
  .mobile-controls{
    display:flex;
    padding:12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) 12px;
  }

  .boss-bar-wrap{
    top:82px;
    width:min(720px,calc(100vw - 20px));
  }

  .power-dock{
    left:10px;
    bottom:104px;
    max-width:min(66vw,260px);
    padding:9px 11px;
  }

  .hud{
    left:10px;
    right:10px;
    top:10px;
    gap:8px;
  }

  .hud-left{
    gap:7px;
    max-width:calc(100% - 106px);
  }

  .hud-right{
    gap:8px;
    margin-left:auto;
  }

  .hud-pill{
    min-width:68px;
    padding:8px 9px;
    border-radius:15px;
  }

  .hud-pill strong{
    font-size:15px;
  }

  .hud-label{
    font-size:9px;
    margin-bottom:5px;
  }

  .icon-btn{
    width:46px;
    height:46px;
    border-radius:14px;
  }

  .home-stage{
    padding:12px;
    overflow:hidden;
  }

  .home-title-wrap{
    position:absolute;
    left:50%;
    top:44px;
    transform:translateX(-50%);
    width:min(92vw,520px);
    text-align:center;
    padding:0 10px;
  }

  .game-title{
    font-size:clamp(34px,12vw,60px);
    line-height:.94;
    margin:8px 0 8px;
  }

  .home-sub{
    font-size:12px;
    line-height:1.45;
    max-width:100%;
    margin-inline:auto;
  }

  .home-corner-card{
    max-width:none;
    min-width:0;
    width:auto;
    padding:10px 12px;
    border-radius:16px;
    background:rgba(8,14,30,.36);
    backdrop-filter:blur(14px);
  }

  .home-corner-card span{
    font-size:10px;
  }

  .home-corner-card strong{
    font-size:18px;
  }

  .card-top-left{ top:12px; left:12px; }
  .card-top-right{ top:12px; right:12px; }
  .card-mid-left{ top:auto; left:12px; bottom:158px; }
  .card-mid-right{ top:auto; right:12px; bottom:158px; }
  .card-bottom-left{ bottom:96px; left:12px; }
  .card-bottom-right{ bottom:96px; right:12px; }

  .menu-side-btn{
    width:min(200px,44vw);
    min-height:70px;
    border-radius:18px;
    padding:12px 14px;
  }

  .menu-left{
    left:12px;
    bottom:12px;
  }

  .menu-right{
    right:12px;
    bottom:12px;
  }

  .menu-side-btn span{
    font-size:16px;
  }

  .menu-side-btn small{
    font-size:11px;
  }

  .tap-start-wrap{
    left:50%;
    right:auto;
    bottom:22px;
    transform:translateX(-50%);
    width:min(58vw,260px);
  }

  .tap-start-btn{
    min-width:100%;
    min-height:58px;
    font-size:17px;
    letter-spacing:.06em;
  }

  .overlay,
  .garage{
    padding:12px;
  }

  .panel{
    padding:20px;
  }

  .garage-top{
    flex-direction:column;
  }
}

  .garage-summary,
  .plane-grid{
    grid-template-columns:1fr;
  }

  .small-panel h2{
    font-size:32px;
  }

  .small-panel p{
    font-size:14px;
  }

  .cta-row{
    flex-direction:column;
    align-items:stretch;
  }

  .primary-btn,
  .secondary-btn{
    width:100%;
  }
}