* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #020309;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  color: #e8f0ff;
}
#wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
#game { display: block; width: 100%; height: 100%; }
#ui { position: absolute; inset: 0; font-size: calc(var(--s, 1) * 16px); overflow: hidden; }
#ui.screen-game { pointer-events: none; }
#ui.screen-game .modal, #ui.screen-game .toast { pointer-events: auto; }

.scr {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: .9em;
  padding: 1.1em 1.2em 1.6em;
  overflow-y: auto; overflow-x: hidden;
  touch-action: pan-y;
  scrollbar-width: none;
}
.scr::-webkit-scrollbar { display: none; }
.top { display: flex; align-items: center; justify-content: space-between; gap: .5em; }
.row { display: flex; align-items: center; gap: .6em; flex-wrap: wrap; justify-content: center; }
.row.center { justify-content: center; }
h2 { font-size: 1.8em; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
h3 { font-size: 1.15em; font-weight: 800; letter-spacing: .05em; margin-bottom: .4em; }
.dim { color: #9fb0d8; font-size: .9em; }
small { font-size: .7em; opacity: .8; font-weight: 600; letter-spacing: .02em; }

.chip {
  background: rgba(20, 30, 60, .75);
  border: 1px solid rgba(120, 170, 255, .3);
  border-radius: 2em; padding: .35em .8em;
  font-weight: 800; font-size: .9em;
  display: flex; align-items: center; gap: .35em; white-space: nowrap;
}
.chip small { margin-left: .2em; }
.coin-i {
  width: 1em; height: 1em; border-radius: 50%; display: inline-block; vertical-align: -.12em; margin-right: .2em;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc531 50%, #b07800);
  box-shadow: 0 0 .4em #ffc53188;
}

.btn {
  font: inherit; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #e8f6ff; cursor: pointer;
  background: linear-gradient(180deg, rgba(60, 140, 255, .35), rgba(30, 60, 140, .35));
  border: 2px solid #4fb4ff; border-radius: .7em;
  padding: .75em 1.1em; font-size: 1em;
  box-shadow: 0 0 1em rgba(79, 180, 255, .3), inset 0 0 1em rgba(79, 180, 255, .12);
  transition: transform .08s, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: .1em .3em; flex-wrap: wrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .45; filter: grayscale(.8); cursor: default; }
.btn.big { font-size: 1.25em; padding: .7em 1em; }
.btn.small { font-size: .78em; padding: .5em .8em; }
.btn.gold { border-color: #ffc531; background: linear-gradient(180deg, rgba(255, 197, 49, .35), rgba(140, 90, 10, .35)); box-shadow: 0 0 1em rgba(255, 197, 49, .3), inset 0 0 1em rgba(255, 197, 49, .12); }
.btn.pink { border-color: #ff4dd8; background: linear-gradient(180deg, rgba(255, 77, 216, .3), rgba(120, 20, 100, .35)); box-shadow: 0 0 1em rgba(255, 77, 216, .3), inset 0 0 1em rgba(255, 77, 216, .12); }
.btn.green { border-color: #3dff9a; background: linear-gradient(180deg, rgba(61, 255, 154, .28), rgba(10, 100, 60, .35)); box-shadow: 0 0 1em rgba(61, 255, 154, .25), inset 0 0 1em rgba(61, 255, 154, .1); }
.btn.gold .coin-i, .btn .coin-i { margin-right: .3em; }
.btn > small { display: block; width: 100%; }

/* Main menu */
.menu { justify-content: space-between; }
.logo { text-align: center; margin-top: 1em; }
.logo h1 {
  font-size: 3.6em; line-height: .95; font-weight: 900; letter-spacing: .1em;
  color: #bfe6ff; text-shadow: 0 0 .3em #44aaff, 0 0 .8em #44aaff88;
}
.logo h1 span { color: #ff6bd8; text-shadow: 0 0 .3em #ff4dd8, 0 0 .8em #ff4dd888; }
.logo p { margin-top: .6em; color: #9fb0d8; letter-spacing: .3em; text-transform: uppercase; font-size: .8em; font-weight: 700; }
.menu-ship { display: flex; flex-direction: column; align-items: center; }
.ship-label { font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #9fb0d8; font-size: .85em; }
.menu-btns { display: flex; flex-direction: column; gap: .7em; }
.menu-btns .row .btn { flex: 1; }

/* Campaign */
.sector { border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 1em; padding: .8em; background: color-mix(in srgb, var(--c) 7%, rgba(5, 8, 20, .6)); }
.sector h3 { color: var(--c); font-size: 1em; text-transform: uppercase; }
.lvl-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5em; }
.lvl {
  font: inherit; color: #fff; cursor: pointer;
  aspect-ratio: 1; border-radius: .7em;
  border: 2px solid var(--c); background: rgba(10, 16, 36, .8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15em;
  box-shadow: 0 0 .6em color-mix(in srgb, var(--c) 40%, transparent);
}
.lvl b { font-size: 1.4em; font-weight: 900; }
.lvl.major { border-style: double; border-width: 4px; }
.lvl.locked { border-color: #333a55; box-shadow: none; opacity: .55; cursor: default; }
.lvl .stars { font-size: .7em; }
.star { color: #39405a; }
.star.on { color: #ffd23f; text-shadow: 0 0 .4em #ffd23f; }
.rules { display: flex; flex-direction: column; gap: .5em; margin: .8em 0; text-align: left; }
.rules > div { display: flex; align-items: center; gap: .6em; font-size: .9em; }
.rules .star { font-size: 1.1em; }
.ship-pick { margin: .6em 0 1em; justify-content: flex-start; text-align: left; }

/* Hangar */
.carousel { display: flex; align-items: center; justify-content: space-between; }
.arrow { font-size: 2em; padding: .1em .5em; }
.ship-view { filter: drop-shadow(0 0 1.2em color-mix(in srgb, var(--c) 50%, transparent)); }
.dots { display: flex; justify-content: center; gap: .45em; margin-top: -.6em; }
.dots i { width: .6em; height: .6em; border-radius: 50%; background: #2a3150; cursor: pointer; }
.dots i.own { background: #56618c; }
.dots i.on { background: var(--c); box-shadow: 0 0 .5em var(--c); }
.ship-head { text-align: center; }
.ship-head h2 { text-shadow: 0 0 .4em currentColor; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .4em 1em; }
.stat span { font-size: .75em; font-weight: 700; text-transform: uppercase; color: #9fb0d8; letter-spacing: .08em; }
.bar { height: .45em; background: rgba(255, 255, 255, .1); border-radius: 1em; overflow: hidden; margin-top: .2em; }
.bar i { display: block; height: 100%; border-radius: 1em; }
.abilities { display: flex; flex-direction: column; gap: .5em; }
.abilities > div { background: rgba(10, 16, 36, .7); border-left: 3px solid var(--c); padding: .5em .7em; border-radius: .4em; font-size: .88em; line-height: 1.35; }
.abilities b { display: block; color: var(--c); font-size: .8em; text-transform: uppercase; letter-spacing: .1em; }
.upgrades { display: flex; flex-direction: column; gap: .5em; }
.upg { display: flex; align-items: center; justify-content: space-between; gap: .6em; background: rgba(10, 16, 36, .7); border-radius: .6em; padding: .55em .7em; border: 1px solid rgba(120, 170, 255, .15); }
.upg b { font-size: .95em; }
.upg small { display: block; color: #9fb0d8; }
.upg .btn { min-width: 6.5em; }
.pips { display: flex; gap: .25em; margin-top: .3em; }
.pips i { width: 1.4em; height: .4em; border-radius: .2em; background: rgba(255, 255, 255, .12); }
.pips i.on { background: var(--c); box-shadow: 0 0 .4em var(--c); }

/* Results */
.results { justify-content: center; text-align: center; }
.results h2.win { color: #7dffb8; text-shadow: 0 0 .5em #3dff9a; }
.results h2.lose { color: #ff7d95; text-shadow: 0 0 .5em #ff4d6d; }
.big-stars { font-size: 3.2em; letter-spacing: .15em; }
.big-stars .star.on { animation: pop .5s both; }
.big-stars .star:nth-child(2) { animation-delay: .25s; }
.big-stars .star:nth-child(3) { animation-delay: .5s; }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.3); } to { transform: scale(1); } }
.res-rows { background: rgba(10, 16, 36, .75); border-radius: .8em; padding: .8em 1em; display: flex; flex-direction: column; gap: .45em; border: 1px solid rgba(120, 170, 255, .2); }
.res-rows > div { display: flex; justify-content: space-between; font-size: .95em; }
.res-rows span { color: #9fb0d8; }
.res-rows em { color: #ffd23f; font-style: normal; font-size: .75em; margin-left: .4em; }
.res-rows .total { border-top: 1px solid rgba(255, 255, 255, .15); padding-top: .5em; font-size: 1.15em; }
.res-rows .total b { color: #ffe066; }

/* Modals */
.modal { position: absolute; inset: 0; background: rgba(2, 4, 12, .72); display: flex; align-items: center; justify-content: center; padding: 1.2em; z-index: 10; backdrop-filter: blur(3px); }
.panel { width: 100%; max-height: 100%; overflow-y: auto; background: linear-gradient(180deg, #121a38, #0a0f24); border: 2px solid rgba(79, 180, 255, .5); border-radius: 1em; padding: 1.2em; text-align: center; box-shadow: 0 0 2em rgba(79, 180, 255, .25); }
.panel p { margin: .5em 0; line-height: 1.4; }
.panel .row { margin-top: .8em; }
.panel .row .btn { flex: 1; }
.big-timer { font-size: 1.3em; font-weight: 800; color: #ffe066; }
.small-print { font-size: .75em; margin-top: 1em !important; }
.ad { position: relative; padding: 1em 0; }
.ad-tag { position: absolute; top: 0; left: 0; background: #ffc531; color: #000; font-weight: 900; font-size: .75em; padding: .15em .5em; border-radius: .3em; }
.ad-count { font-size: 4em; font-weight: 900; color: #ffe066; margin: .2em 0; text-shadow: 0 0 .4em #ffc531; }

.toast { position: absolute; left: 50%; top: 12%; transform: translateX(-50%); background: rgba(10, 16, 36, .95); border: 2px solid #3dff9a; padding: .6em 1.2em; border-radius: 2em; font-weight: 800; z-index: 20; animation: toast 1.8s both; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -1em); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
