:root {
  --bg: #05030d;
  --text: #eef2ff;
  --muted: #9aa3c7;
  --accent: #38e1ff;
  --accent2: #ff3df2;
  --gold: #ffd23f;
  --card: rgba(12, 10, 28, 0.74);
  --stroke: rgba(255, 255, 255, 0.12);
  --display: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --ui: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-family: var(--ui);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app { position: fixed; inset: 0; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* ---------- Botões ---------- */
.btn {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
  color: #061018;
  background: linear-gradient(135deg, #38e1ff, #7b5cff);
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(56, 225, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s;
  outline: none;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.12); box-shadow: 0 12px 32px rgba(56, 225, 255, 0.45); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7); }
.btn.big { font-size: 22px; padding: 16px 48px; border-radius: 18px; }
.btn.small { font-size: 12px; padding: 8px 14px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--stroke);
  box-shadow: none;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); box-shadow: none; }
.btn.toggle.off { opacity: 0.55; text-decoration: line-through; }
.btn:disabled { cursor: default; opacity: 0.7; transform: none; filter: none; }
.btn.cant { background: rgba(255, 255, 255, 0.08); color: var(--muted); box-shadow: none; }

.icon-btn {
  pointer-events: auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Moeda ---------- */
.coin-ico {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c2, #ffd23f 45%, #c98a00);
  box-shadow: 0 0 10px rgba(255, 210, 63, 0.7);
  vertical-align: middle;
  flex: none;
}
.coin-ico.sm { width: 14px; height: 14px; }

.pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  backdrop-filter: blur(6px);
}
.pill.bump { animation: bump 0.25s ease; }
@keyframes bump { 50% { transform: scale(1.15); } }

/* ---------- HUD ---------- */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 16px max(20px, env(safe-area-inset-left));
  display: flex; justify-content: space-between; align-items: flex-start;
  opacity: 0; transition: opacity 0.3s;
  z-index: 10;
}
#hud.active { opacity: 1; }
.hud-left { display: flex; flex-direction: column; gap: 2px; }
.hud-right { display: flex; align-items: center; gap: 10px; }
#score {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1;
  text-shadow: 0 0 18px rgba(56, 225, 255, 0.6), 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: color 0.3s;
}
#score.x2 { color: var(--gold); text-shadow: 0 0 18px rgba(255, 210, 63, 0.7), 0 2px 0 rgba(0, 0, 0, 0.5); }
#hud-best { font-size: 13px; color: var(--muted); letter-spacing: 0.2em; font-weight: 700; }

#powers { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.pw {
  display: none; align-items: center; gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 150px;
  animation: pwIn 0.3s ease;
}
.pw.on { display: flex; }
.pw svg { width: 20px; height: 20px; fill: currentColor; filter: drop-shadow(0 0 6px currentColor); flex: none; }
.pw svg text { font-family: var(--display); font-weight: 900; font-size: 12px; }
.pw .bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.pw .bar i { display: block; height: 100%; background: currentColor; transform-origin: left; box-shadow: 0 0 8px currentColor; }
.pw .tag { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; flex: 1; }
.pw.ending { animation: blink 0.35s steps(2) infinite; }
@keyframes pwIn { from { opacity: 0; transform: translateX(-10px); } }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- Toasts ---------- */
#toasts {
  position: absolute; left: 0; right: 0; top: 20%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
  z-index: 30;
}
.toast {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(16px, 2.4vw, 24px);
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 0 18px currentColor, 0 2px 0 rgba(0, 0, 0, 0.6);
  animation: toastIn 1.5s ease forwards;
}
.toast.zone { font-size: clamp(24px, 4.5vw, 44px); animation-duration: 2.6s; }
.toast .sub { display: block; font-size: 0.42em; letter-spacing: 0.45em; opacity: 0.85; margin-top: 4px; }
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(12px) scale(0.85); }
  12% { opacity: 1; transform: none; }
  78% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-16px); }
}

/* ---------- Telas ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 20;
}
.screen.active { opacity: 1; pointer-events: auto; }
.screen.passthrough.active { pointer-events: none; }
.screen.dim { background: rgba(3, 2, 10, 0.55); }
.screen.menu { background: radial-gradient(ellipse at center, rgba(3, 2, 10, 0.25) 0%, rgba(3, 2, 10, 0.78) 75%); }

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.3s ease;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.screen.active .card { transform: none; }
.card h2 { font-family: var(--display); font-weight: 900; letter-spacing: 0.15em; font-size: 26px; margin-bottom: 18px; }

.col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.row .btn { flex: 1 1 auto; }
.muted { color: var(--muted); font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 14px; line-height: 1.6; }
kbd {
  font-family: var(--ui); font-weight: 700;
  padding: 1px 7px; border-radius: 6px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* ---------- Menu ---------- */
.menu-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center; max-width: 640px; width: 100%;
}
.logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(48px, 10vw, 104px);
  letter-spacing: 0.04em;
  line-height: 0.95;
  color: #fff;
  text-shadow: 0 0 24px rgba(56, 225, 255, 0.55);
  animation: logoGlow 3s ease-in-out infinite;
}
.logo span {
  margin-left: 0.18em;
  background: linear-gradient(90deg, #38e1ff, #ff3df2);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 18px rgba(255, 61, 242, 0.5));
}
@keyframes logoGlow { 50% { text-shadow: 0 0 40px rgba(56, 225, 255, 0.85); } }
.tagline { font-size: clamp(16px, 2.2vw, 20px); color: #cfd6ff; font-weight: 600; letter-spacing: 0.05em; margin-top: -6px; }
#btn-play { margin-top: 6px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 8px 40px rgba(56, 225, 255, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.4); } }
.menu .row { max-width: 560px; }
.stats-line { display: flex; gap: 12px; align-items: center; font-size: 16px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); }
.stats-line b { color: var(--text); font-family: var(--display); letter-spacing: 0.04em; }
.stats-line .sep { opacity: 0.5; }

.legend { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.legend .lg {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px; font-weight: 600; color: #d8ddff;
}
.legend svg { width: 22px; height: 22px; fill: currentColor; filter: drop-shadow(0 0 6px currentColor); }
.legend svg text { font-family: var(--display); font-weight: 900; font-size: 12px; }
.legend .lg b { display: block; font-size: 13px; letter-spacing: 0.06em; }
.legend .lg small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; line-height: 1.1; }
.legend .lg .tx { text-align: left; color: var(--text); }

/* ---------- Pronto ---------- */
.ready { text-align: center; transform: translateY(18vh); }
.ready-title {
  font-family: var(--display); font-weight: 900;
  font-size: clamp(22px, 4vw, 38px);
  letter-spacing: 0.18em;
  text-shadow: 0 0 20px rgba(56, 225, 255, 0.8);
  animation: breathe 1.4s ease-in-out infinite;
}
.ready-sub { margin-top: 8px; color: var(--muted); font-weight: 700; letter-spacing: 0.3em; font-size: 14px; text-transform: uppercase; }
@keyframes breathe { 50% { opacity: 0.45; transform: scale(0.97); } }

/* ---------- Fim de jogo ---------- */
.over-title { font-family: var(--display); font-weight: 900; letter-spacing: 0.25em; font-size: 16px; color: var(--muted); }
.over-score {
  font-family: var(--display); font-weight: 900;
  font-size: clamp(52px, 10vw, 76px);
  line-height: 1.05;
  margin: 6px 0 16px;
  background: linear-gradient(180deg, #ffffff, #8fefff);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(56, 225, 255, 0.5));
}
.badge {
  display: none;
  margin: 10px auto 0;
  width: max-content;
  font-family: var(--display); font-weight: 900; font-size: 13px; letter-spacing: 0.2em;
  color: #1a1200;
  background: linear-gradient(90deg, #ffd23f, #ff9f1c);
  padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 0 24px rgba(255, 210, 63, 0.6);
  animation: badge 0.9s ease-in-out infinite alternate;
}
.badge.show { display: block; }
@keyframes badge { to { transform: scale(1.07); box-shadow: 0 0 36px rgba(255, 210, 63, 0.9); } }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.grid > div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px;
}
.grid span { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.15em; text-transform: uppercase; font-weight: 700; }
.grid b { font-family: var(--display); font-size: 20px; }
.wallet-line { color: var(--muted); font-weight: 700; margin-bottom: 18px; letter-spacing: 0.05em; }
.wallet-line b { color: var(--gold); font-family: var(--display); }

/* ---------- Hangar ---------- */
.card.hangar { max-width: 860px; }
.hangar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hangar-head h2 { margin: 0; }
.skins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.skin {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 10px 10px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color 0.2s, transform 0.2s;
}
.skin:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.25); }
.skin.equipped { border-color: var(--accent); box-shadow: 0 0 22px rgba(56, 225, 255, 0.25); }
.skin.locked canvas { filter: brightness(0.45) saturate(0.4); }
.skin canvas { width: 100%; aspect-ratio: 16 / 9; }
.skin canvas.orbit { cursor: grab; touch-action: none; }
.skin canvas.orbit.dragging { cursor: grabbing; }
.drag-hint { font-size: 13px; margin-top: 4px; color: var(--accent); }
.skin-name { font-family: var(--display); font-weight: 700; letter-spacing: 0.1em; font-size: 14px; }
.skin .btn { width: 100%; }
.skin.nope { animation: nope 0.35s ease; }
@keyframes nope { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Idioma ---------- */
.lang-switch {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex; gap: 8px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(6px);
  z-index: 35;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.lang-switch.show { opacity: 1; pointer-events: auto; }
.flag {
  width: 42px; height: 30px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  background: none;
  opacity: 0.45;
  filter: saturate(0.6);
  transition: opacity 0.2s, transform 0.15s, border-color 0.2s, filter 0.2s;
  outline: none;
}
.flag svg { width: 100%; height: 100%; display: block; }
.flag:hover { opacity: 0.85; transform: translateY(-1px); }
.flag.active { opacity: 1; filter: none; border-color: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, 0.35); }
.flag:focus-visible { border-color: var(--accent); }

/* ---------- Diversos ---------- */
#fade {
  position: absolute; inset: 0;
  background: #000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}
#fade.on { opacity: 1; }

#rotate-hint {
  display: none;
  position: absolute; left: 50%; bottom: 18px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 14px;
  z-index: 40;
  pointer-events: none;
  white-space: nowrap;
}
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint { display: block; }
}

@media (max-height: 560px) {
  .menu-inner { gap: 10px; }
  .logo { font-size: clamp(38px, 8vw, 64px); }
  .legend { display: none; }
  .hint { margin-top: 4px; }
  .btn.big { padding: 12px 36px; font-size: 18px; }
  .card { padding: 18px; }
  .over-score { font-size: 46px; margin: 2px 0 10px; }
}
@media (max-width: 520px) {
  .menu .row .btn { font-size: 14px; padding: 10px 12px; }
}

/* ---------- Ranking ---------- */
[hidden] { display: none !important; }
input {
  font-family: var(--ui);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  min-width: 0;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 225, 255, 0.2); }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--ui);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}
.link-btn:hover { text-decoration: underline; }

.rank-box {
  margin: -6px 0 16px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.rank-line { font-weight: 700; font-size: 15px; line-height: 1.3; }
.rank-line.good { color: #7dffb0; }
.rank-line.warn, .rank-msg.warn { color: #ff8fa3; }
.rank-line.dim { color: var(--muted); }
.rank-name { display: flex; gap: 8px; width: 100%; justify-content: center; }
.rank-name input { flex: 1; max-width: 220px; }

.card.ranking { max-width: 560px; }
.ranking-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.ranking-head h2 { margin: 0; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--stroke); }
.tab {
  border: none; cursor: pointer;
  font-family: var(--ui); font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
  color: var(--muted); background: none;
  padding: 6px 14px; border-radius: 9px;
}
.tab.active { color: #061018; background: linear-gradient(135deg, #38e1ff, #7b5cff); }
.rank-me { color: var(--accent); font-weight: 700; font-size: 15px; min-height: 20px; margin-bottom: 6px; }
.rank-list {
  list-style: none;
  max-height: min(46vh, 420px);
  overflow-y: auto;
  margin: 0 0 10px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
}
.rank-list li {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 10px;
  font-weight: 700;
}
.rank-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.rank-list li.me { background: rgba(56, 225, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(56, 225, 255, 0.5); }
.rank-list .pos { font-family: var(--display); color: var(--muted); font-size: 13px; }
.rank-list li:nth-child(1) .pos { color: #ffd23f; }
.rank-list li:nth-child(2) .pos { color: #d7e2f0; }
.rank-list li:nth-child(3) .pos { color: #ff9f5a; }
.rank-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .sc { font-family: var(--display); font-size: 14px; }
.rank-list .ds { color: var(--muted); font-size: 13px; min-width: 70px; text-align: right; }
.rank-list li.rank-empty { display: block; text-align: center; color: var(--muted); padding: 22px 10px; background: none; }
.rank-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; color: var(--muted); font-weight: 700; }
.rank-pager .btn:disabled { opacity: 0.3; }
.rank-myname { color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.rank-msg { min-height: 18px; font-weight: 700; font-size: 14px; color: #7dffb0; margin-bottom: 8px; }
@media (max-width: 520px) {
  .rank-list li { grid-template-columns: 40px 1fr auto; }
  .rank-list .ds { display: none; }
}
