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

html, body {
  height: 100%;
  background: #101f33;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: #dfe6ee;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  background: transparent;   /* must stay clear — the #gl 3D canvas sits beneath it */
  touch-action: none;
}

/* fullscreen toggle — sits under the Battle Lanes layer (z-index 6) */
.fs-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 42px;
  height: 42px;
  font-size: 20px;
  line-height: 1;
  color: #dfe6ee;
  background: rgba(14, 22, 34, .65);
  border: 1px solid #2b3948;
  border-radius: 8px;
  cursor: pointer;
  pointer-events: auto;
}
.fs-btn:hover { background: rgba(45, 64, 88, .85); }
@media (pointer: coarse) { .fs-btn { display: none; } }   /* mobile fills the viewport already */

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.hidden { display: none !important; }

.screen {
  flex-direction: column;
  gap: 14px;
  background: rgba(6, 10, 16, .82);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  padding: 20px;
  text-align: center;
  overflow-y: auto;
}

.game-title {
  font-size: clamp(42px, 9vw, 84px);
  letter-spacing: .14em;
  color: #f5c542;
  text-shadow: 0 0 24px rgba(245, 197, 66, .35), 0 4px 0 #7a5c00;
}
.subtitle { letter-spacing: .3em; color: #8fa3b8; font-size: clamp(11px, 2vw, 15px); }
.screen-title { font-size: clamp(26px, 5vw, 44px); letter-spacing: .1em; }
.screen-title.danger { color: #e05040; }
.screen-title.gold { color: #f5c542; }
.stats { color: #a9bacb; font-size: 16px; line-height: 1.7; }
.hint { color: #66788c; font-size: 13px; line-height: 1.7; }
.gold-text { color: #f5c542; }

/* ---------- difficulty picker ---------- */
#diff-row, #craft-tabs { display: flex; gap: 8px; }
#craft-tabs { margin: 2px 0 4px; }
.tab-btn {
  pointer-events: auto;
  font: 700 13px/1 "Segoe UI", Arial, sans-serif;
  letter-spacing: .14em;
  color: #8fa3b8;
  background: #18222e;
  border: 1px solid #2b3948;
  border-radius: 8px;
  padding: 9px 26px;
  cursor: pointer;
}
.tab-btn.active { color: #0a0e14; background: #8fd0ff; border-color: #8fd0ff; }
.diff-btn {
  pointer-events: auto;
  font: 700 12px/1 "Segoe UI", Arial, sans-serif;
  letter-spacing: .1em;
  color: #8fa3b8;
  background: #18222e;
  border: 1px solid #2b3948;
  border-radius: 8px;
  padding: 9px 18px;
  cursor: pointer;
}
.diff-btn.active { color: #0a0e14; background: #f5c542; border-color: #f5c542; }

/* ---------- lobby (shared by sign-in + duel) ---------- */
.lobby-row { display: flex; gap: 8px; align-items: center; }
#duel-code {
  width: 110px;
  font: 800 20px/1 "Consolas", monospace;
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  color: #f5c542;
  background: #101820;
  border: 1px solid #2b3948;
  border-radius: 8px;
  padding: 10px 8px 10px 16px;
}
.lobby-btn {
  pointer-events: auto;
  font: 700 14px/1 "Segoe UI", Arial, sans-serif;
  color: #0a0e14;
  background: linear-gradient(#8fd0ff, #5aa9d6);
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  cursor: pointer;
}
#duel-status { min-height: 44px; color: #a9bacb; font-size: 14px; line-height: 1.6; }

/* ---------- sign-in ---------- */
#sso-box { min-height: 46px; display: flex; align-items: center; justify-content: center; }
#sso-who {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 30, 42, .75);
  border: 1px solid #2b3948;
  border-radius: 24px;
  padding: 6px 8px 6px 6px;
}
#sso-who img { width: 32px; height: 32px; border-radius: 50%; }
.sso-text { text-align: left; line-height: 1.25; }
.sso-name { font-weight: 700; font-size: 13px; }
.sso-sub { font-size: 11px; color: #77899c; }
.small-btn { padding: 7px 12px; font-size: 11px; }
.sso-note { color: #66788c; font-size: 12px; }

/* ---------- registration ---------- */
#privacy-card {
  width: min(460px, 92vw);
  background: rgba(20, 30, 42, .85);
  border: 1px solid #2b3948;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
  font-size: 13.5px;
  color: #a9bacb;
  line-height: 1.65;
}
#privacy-card b { color: #f5c542; letter-spacing: .15em; font-size: 12px; }
#privacy-card a { color: #8fd0ff; }
#consent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(143, 208, 255, .07);
  border: 1px solid #2b3948;
  border-radius: 8px;
  cursor: pointer;
  color: #dfe6ee;
}
#consent-row input { width: 18px; height: 18px; accent-color: #f5c542; cursor: pointer; }
#register-status { min-height: 22px; color: #a9bacb; font-size: 13px; }
.link-btn {
  background: none;
  border: none;
  color: #77899c;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: #e05040; }

/* ---------- pilot settings ---------- */
#settings-card, #danger-card {
  width: min(460px, 92vw);
  background: rgba(20, 30, 42, .85);
  border: 1px solid #2b3948;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
}
.set-head { display: flex; align-items: center; gap: 14px; }
#set-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid #f5c542; object-fit: cover;
}
#set-name { color: #dfe6ee; font-weight: 700; font-size: 16px; }
.set-dim { color: #66788c; font-size: 12.5px; }
.set-rows { margin-top: 14px; }
.set-row {
  display: flex; justify-content: space-between;
  padding: 7px 2px; font-size: 13.5px;
  border-bottom: 1px dashed #22303f;
}
.set-row:last-child { border-bottom: none; }
.set-row span { color: #8ba0b5; }
.set-row b { color: #dfe6ee; font-variant-numeric: tabular-nums; }
.set-link { display: inline-block; margin-top: 12px; color: #8fd0ff; font-size: 13px; }
#danger-card { border-color: #5c2f28; }
#danger-card b { color: #e05040; letter-spacing: .15em; font-size: 12px; }
#danger-card p { color: #8ba0b5; font-size: 12.5px; margin: 6px 0 10px; }
.danger-btn {
  width: 100%; padding: 10px;
  background: none; border: 1px solid #e05040; border-radius: 8px;
  color: #e05040; font-weight: 700; letter-spacing: .1em; font-size: 12px;
  cursor: pointer;
}
.danger-btn:hover { background: #e05040; color: #fff; }

/* ---------- battle lanes ---------- */
.moba-row { margin: 8px 0; }
.moba-row > b {
  display: block; color: #f5c542; font-size: 11px; letter-spacing: .2em;
  margin-bottom: 6px;
}
#moba-sizes, #moba-countries { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#moba-crafts { max-height: 42vh; overflow-y: auto; justify-content: center; }
#moba-crafts .card { width: 132px; }
#moba-crafts .card.sel { border-color: #f5c542; box-shadow: 0 0 12px rgba(245,197,66,.4); }
#btn-moba-start:disabled { opacity: .4; cursor: default; }
.country-btn {
  display: flex; align-items: center; gap: 7px;
  background: rgba(20,30,42,.85); border: 1px solid #2b3948; border-radius: 8px;
  color: #dfe6ee; padding: 6px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.country-btn.active { border-color: #f5c542; color: #f5c542; }

#moba-hud { pointer-events: none; }
#moba-hud > * { pointer-events: auto; }
#moba-top {
  position: absolute; top: 6px; left: 6px; right: 6px;
  display: flex; gap: 6px; align-items: center; justify-content: center;
}
.moba-chip {
  background: rgba(10,18,28,.8); border: 1px solid #2b3948; border-radius: 6px;
  color: #dfe6ee; font-size: 13px; padding: 4px 10px;
}
#moba-hp-wrap { width: 110px; height: 16px; padding: 0; overflow: hidden; position: relative; }
#moba-hp { height: 10px; background: linear-gradient(#5ad06a,#2f9e44); width: 100%; }
#moba-xp { height: 4px; background: #8fd0ff; width: 0%; }
#shop-range { color: #e0a050; font-size: 11.5px; margin-bottom: 8px; min-height: 14px; }
#moba-map {
  position: absolute; top: 40px; right: 6px;
  border: 1px solid #2b3948; border-radius: 6px;
  background: rgba(10,18,28,.8);
}
#moba-items { position: absolute; bottom: 8px; left: 6px; display: flex; gap: 6px; }
#moba-abil {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.ab {
  position: relative; width: 62px; height: 46px; overflow: hidden;
  background: rgba(10,18,28,.85); border: 1px solid #2b3948; border-radius: 7px;
  color: #dfe6ee; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  cursor: pointer; padding: 4px 2px;
}
.ab .k {
  position: absolute; top: 2px; left: 4px;
  font-family: Consolas, monospace; font-size: 11px; color: #f5c542;
}
.ab .nm { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; }
.ab .ic { display: block; width: 26px; height: 26px; margin: 3px auto 0; color: #dfe6ee; }
.ab .cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: rgba(0,0,0,.72);
}
.ab .cdt {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: Consolas, monospace; font-size: 16px; color: #f5c542;
}
.ab.armed { border-color: #f5c542; box-shadow: inset 0 0 0 1px #f5c542; }
.ab:disabled { opacity: .45; }
#moba-cast-hint {
  position: absolute; bottom: 62px; left: 50%; transform: translateX(-50%);
  color: #f5c542; font-size: 12px; font-weight: 800; letter-spacing: .15em;
  text-shadow: 0 1px 4px #000; pointer-events: none;
}
#moba-tk b:first-child { color: #39c1ff; }
#moba-tk b:last-child { color: #e05040; }
.item-chip {
  background: rgba(10,18,28,.85); border: 1px solid #8fd0ff; border-radius: 6px;
  color: #8fd0ff; font-size: 11px; font-weight: 700; padding: 8px 10px;
  cursor: pointer;
}
.item-chip.cd { border-color: #2b3948; color: #66788c; }
#moba-shop {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%);
  width: min(340px, 88vw); max-height: 62vh; overflow-y: auto;
  background: rgba(12,20,32,.96); border: 1px solid #f5c542; border-radius: 10px;
  padding: 12px;
}
#moba-shop h3 { color: #f5c542; margin: 0 0 8px; letter-spacing: .2em; font-size: 13px; }
.shop-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px; border-bottom: 1px dashed #22303f; color: #a9bacb; font-size: 12.5px;
}
.shop-item button {
  background: #2f7fc0; border: none; border-radius: 6px; color: #fff;
  font-weight: 700; padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
.shop-item button:disabled { background: #2b3948; color: #66788c; cursor: default; }
.shop-item .si-name { color: #dfe6ee; font-weight: 700; font-size: 12px; }
#moba-respawn {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%,-50%);
  color: #e05040; font-size: 20px; font-weight: 800; letter-spacing: .12em;
  text-shadow: 0 2px 8px #000; text-align: center;
}
#moba-end {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(6,10,16,.88);
}
#moba-result.win { color: #5ad06a; }
#moba-result.lose { color: #e05040; }
#moba-result { font-size: 30px; letter-spacing: .18em; margin: 0; }

/* ---------- duel ---------- */
#duel-crafts { max-height: 34vh; overflow-y: auto; justify-content: center; }
#duel-crafts .card { width: 120px; }
#duel-crafts .card.sel { border-color: #f5c542; box-shadow: 0 0 12px rgba(245,197,66,.4); }
#duel-record { color: #f5c542; min-height: 18px; }
#duel-hp-wrap { width: 120px; height: 14px; padding: 0; overflow: hidden; position: relative; }
#duel-hp { height: 100%; background: linear-gradient(#5ad06a,#2f9e44); width: 100%; }
#duel-lives, #duel-opp-lives { letter-spacing: .15em; font-size: 15px; }
#duel-map {
  position: absolute; top: 40px; right: 6px;
  border: 1px solid #2b3948; border-radius: 6px;
  background: rgba(10,18,28,.8);
}
#duel-item {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  border-color: #f5c542; color: #f5c542; font-weight: 700;
}
#duel-respawn {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%,-50%);
  color: #e05040; font-size: 20px; font-weight: 800; letter-spacing: .12em;
  text-shadow: 0 2px 8px #000;
}
#duel-end {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(6,10,16,.88);
}
#duel-result { font-size: 30px; letter-spacing: .18em; margin: 0; }
#duel-result.win { color: #5ad06a; } #duel-result.lose { color: #e05040; }
#global-table {
  width: min(420px, 90vw);
  background: rgba(20, 30, 42, .75);
  border: 1px solid #2b3948;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #a9bacb;
}
#global-table:empty { display: none; }
#global-table b { color: #8fd0ff; letter-spacing: .2em; font-size: 11px; }
#duel-status b { color: #f5c542; font-size: 22px; letter-spacing: .3em; }

/* ---------- high-score table ---------- */
#score-table {
  width: min(420px, 90vw);
  background: rgba(20, 30, 42, .75);
  border: 1px solid #2b3948;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #a9bacb;
  letter-spacing: .04em;
}
#score-table b { color: #f5c542; letter-spacing: .2em; font-size: 11px; }
.score-row { display: grid; grid-template-columns: 22px 60px 1fr 60px; gap: 6px; padding: 3px 0; text-align: left; }
.score-row span:nth-child(2) { color: #fff; font-weight: 700; }

/* ---------- buttons ---------- */
.big-btn {
  pointer-events: auto;
  font: 700 18px/1 "Segoe UI", Arial, sans-serif;
  letter-spacing: .08em;
  color: #0a0e14;
  background: linear-gradient(#ffd95e, #f0b32a);
  border: none;
  border-radius: 10px;
  padding: 16px 42px;
  cursor: pointer;
  box-shadow: 0 4px 0 #8a6400, 0 8px 18px rgba(0, 0, 0, .5);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6400; }
.big-btn.small { padding: 11px 26px; font-size: 14px; background: linear-gradient(#9fb2c4, #6e8296); box-shadow: 0 3px 0 #3d4a58; color: #0d141c; }
.big-btn.disabled { background: #3a4653; color: #77899c; box-shadow: none; cursor: not-allowed; }

/* ---------- HUD ---------- */
#hud {
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 6px;
}
.hud-chip {
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
#hud-score { margin-left: auto; min-width: 74px; text-align: right; color: #f5c542; }
#hud-weapon { pointer-events: auto; cursor: pointer; color: #8fd0ff; min-width: 86px; text-align: center; }
#hud-weapon:hover { border-color: #8fd0ff; }
#hud-hp-wrap {
  flex: 1;
  height: 16px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  overflow: hidden;
}
#hud-hp {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d33, #7ee081 60%);
  transition: width .15s;
}
.hud-btn {
  pointer-events: auto;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  color: #dfe6ee;
  font-size: 15px;
  padding: 4px 9px;
  cursor: pointer;
}
#hud-progress-wrap {
  height: 4px;
  margin: 0 12px;
  background: rgba(255, 255, 255, .12);
  border-radius: 2px;
}
#hud-progress { height: 100%; width: 0; background: #f5c542; border-radius: 2px; }

/* ---------- level toast ---------- */
#level-toast {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  animation: toastIn .4s ease-out;
}
#toast-num { font-size: clamp(14px, 3vw, 20px); letter-spacing: .4em; color: #f5c542; }
#toast-name { font-size: clamp(28px, 7vw, 54px); font-weight: 800; letter-spacing: .08em; text-shadow: 0 3px 12px rgba(0,0,0,.7); }
#toast-obj { font-size: clamp(12px, 2.4vw, 16px); color: #a9bacb; margin-top: 6px; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ---------- selection screen ---------- */
#plane-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(680px, 94vw);
  max-height: 62vh;
  overflow-y: auto;
  padding: 4px;
}
.country-block h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  letter-spacing: .18em;
  color: #9db1c6;
  margin: 6px 2px;
}
.country-block h3 canvas { border-radius: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.card {
  background: linear-gradient(180deg, #18222e, #101820);
  border: 1px solid #2b3948;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
  text-align: left;
}
.card:hover, .card:active { transform: translateY(-3px); border-color: #f5c542; }
.card .model { font-weight: 800; font-size: 15px; margin-top: 8px; }
.card .role { font-size: 11px; color: #8fa3b8; margin: 2px 0 8px; min-height: 26px; }
.card canvas { display: block; margin: 0 auto; }
.speedbar { height: 6px; background: #222d38; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.speedbar div { height: 100%; background: #f5c542; }
.card .spec { display: flex; justify-content: space-between; font-size: 11px; color: #77899c; margin-top: 5px; }
