/* Star Cadets — styles. No external fonts or images: nothing is fetched from anywhere else. */
:root {
  --ink: #0a0f33;
  --deep: #121a52;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-b: rgba(255, 255, 255, 0.16);
  --text: #f5f7ff;
  --muted: #b9c2f0;
  --sun: #ffc233;
  --sun-d: #d69200;
  --teal: #2ec4b6;
  --teal-d: #138f84;
  --coral: #ff6b6b;
  --coral-d: #c93a3a;
  --violet: #8a6cff;
  --violet-d: #5a3fd0;
  --good: #3ddc84;
  --font: "Avenir Next Rounded", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(2px 2px at 12% 18%, #fff, transparent 60%),
    radial-gradient(1.5px 1.5px at 28% 62%, #fff, transparent 60%),
    radial-gradient(2px 2px at 44% 12%, #ffe9a8, transparent 60%),
    radial-gradient(1.5px 1.5px at 63% 38%, #fff, transparent 60%),
    radial-gradient(2.5px 2.5px at 78% 72%, #cfe6ff, transparent 60%),
    radial-gradient(1.5px 1.5px at 90% 20%, #fff, transparent 60%),
    radial-gradient(1.5px 1.5px at 7% 88%, #fff, transparent 60%),
    radial-gradient(2px 2px at 54% 90%, #fff, transparent 60%),
    radial-gradient(1200px 700px at 85% -10%, #3b2a8f 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 110%, #0f5a73 0%, transparent 55%),
    linear-gradient(180deg, #0b1040 0%, #0a0f33 100%);
  background-attachment: fixed;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.1; letter-spacing: .01em; }
h1 { font-size: clamp(30px, 5vw, 50px); }
h2 { font-size: clamp(22px, 3vw, 32px); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
.lead { font-size: 1.15rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: #9fd4ff; }
:focus-visible { outline: 4px solid #fff; outline-offset: 3px; border-radius: 10px; }

#app { min-height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.35rem; letter-spacing: .02em; text-decoration: none; color: var(--text); background: none; border: 0; cursor: pointer; font-family: inherit; }
.logo svg { width: 38px; height: 38px; }
.logo small { display: block; font-size: .65rem; font-weight: 700; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.top .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 8px 20px 40px; flex: 1; }
.page.narrow { max-width: 640px; }
.banner { background: linear-gradient(90deg, #5a3fd0, #2a7fb8); color: #fff; padding: 8px 16px; text-align: center; font-weight: 700; font-size: .95rem; }
.banner a { color: #fff; }

/* buttons */
.btn { font-family: inherit; font-weight: 800; font-size: 1.05rem; border: 0; border-radius: 999px; padding: 13px 26px; cursor: pointer; color: var(--ink); background: var(--sun); box-shadow: 0 5px 0 var(--sun-d), 0 10px 18px rgba(0, 0, 0, .3); transition: transform .08s, box-shadow .08s, filter .15s; min-height: 48px; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--sun-d); }
.btn.teal { background: var(--teal); box-shadow: 0 5px 0 var(--teal-d), 0 10px 18px rgba(0, 0, 0, .3); }
.btn.violet { background: var(--violet); color: #fff; box-shadow: 0 5px 0 var(--violet-d), 0 10px 18px rgba(0, 0, 0, .3); }
.btn.danger { background: var(--coral); color: #fff; box-shadow: 0 5px 0 var(--coral-d), 0 10px 18px rgba(0, 0, 0, .3); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: none; border: 2px solid var(--panel-b); }
.btn.ghost:active { transform: none; }
.btn.big { font-size: 1.4rem; padding: 18px 40px; }
.btn.small { font-size: .9rem; padding: 8px 16px; min-height: 38px; box-shadow: 0 3px 0 var(--sun-d); }
.btn.teal.small { box-shadow: 0 3px 0 var(--teal-d); }
.btn.danger.small { box-shadow: 0 3px 0 var(--coral-d); }
.btn.ghost.small { box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.icon-btn { background: var(--panel); border: 2px solid var(--panel-b); color: var(--text); border-radius: 50%; width: 46px; height: 46px; font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-family: inherit; }
.icon-btn svg { width: 26px; height: 26px; }
.link-btn { background: none; border: 0; color: #9fd4ff; text-decoration: underline; cursor: pointer; font: inherit; padding: 6px; }

.card { background: var(--panel); border: 1px solid var(--panel-b); border-radius: 24px; padding: 20px; }
.card + .card { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 16px; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 2px solid var(--panel-b); padding: 6px 14px; border-radius: 999px; font-weight: 800; }
.pill svg { width: 22px; height: 22px; }
.pill.rank { background: linear-gradient(135deg, #4b34c4, #2a7fb8); border-color: #fff3; }

/* sign in */
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.name-tile { font-family: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--panel-b); border-radius: 22px; padding: 18px 10px; cursor: pointer; font-size: 1.3rem; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 120px; transition: transform .1s, background .15s; }
.name-tile:hover { transform: translateY(-3px); background: rgba(255, 255, 255, .14); }
.name-tile .dot { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 900; color: var(--ink); }
.code-input { font-family: inherit; font-size: 2.4rem; font-weight: 900; letter-spacing: .3em; text-align: center; text-transform: uppercase; width: 100%; max-width: 380px; padding: 14px; border-radius: 20px; border: 3px solid var(--panel-b); background: rgba(0, 0, 0, .3); color: var(--text); }
.text-input { font-family: inherit; font-size: 1.1rem; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--panel-b); background: rgba(0, 0, 0, .28); color: var(--text); width: 100%; }
textarea.text-input { min-height: 160px; resize: vertical; }
select.text-input { width: auto; }
.slots { display: flex; gap: 12px; justify-content: center; margin: 14px 0; }
.slot { width: 74px; height: 74px; border-radius: 22px; border: 3px dashed var(--panel-b); display: grid; place-items: center; background: rgba(0, 0, 0, .22); }
.slot svg { width: 56px; height: 56px; }
.slot.filled { border-style: solid; border-color: #fff6; }
.pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 480px; margin: 0 auto; }
.pic { background: var(--panel); border: 2px solid var(--panel-b); border-radius: 20px; padding: 8px; cursor: pointer; aspect-ratio: 1; display: grid; place-items: center; font-family: inherit; }
.pic:hover { background: rgba(255, 255, 255, .16); }
.pic:active { transform: scale(.94); }
.pic svg { width: 100%; max-width: 78px; height: auto; }
.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-12px); } 40% { transform: translateX(12px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(8px); } }
.err { color: #ffb4b4; font-weight: 800; min-height: 1.4em; text-align: center; }

/* command deck */
.deck-head { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.deck-head .avatar { width: 150px; border-radius: 26px; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); flex: none; }
.deck-head h1 { margin-bottom: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-family: inherit; background: var(--panel); border: 2px solid var(--panel-b); color: var(--text); padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 1rem; }
button.chip { cursor: pointer; min-height: 40px; }
.chip.on { background: var(--teal); color: var(--ink); border-color: var(--teal); }
.missions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 20px 0; }
.mission { font-family: inherit; color: var(--text); text-align: left; cursor: pointer; border: 3px solid transparent; border-radius: 30px; padding: 22px; display: flex; flex-direction: column; gap: 8px; min-height: 250px; box-shadow: 0 14px 30px rgba(0, 0, 0, .35); transition: transform .12s; position: relative; overflow: hidden; }
.mission:hover { transform: translateY(-5px) rotate(-.4deg); }
.mission svg { width: 92px; height: 92px; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); }
.mission h2 { margin: 0; font-size: 1.7rem; }
.mission p { margin: 0; color: #fffd; font-size: 1.05rem; }
.mission .tag { margin-top: auto; align-self: flex-start; background: #0006; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .9rem; }
.mission.m-launch { background: linear-gradient(150deg, #ff7a3d, #c2321f); }
.mission.m-flight { background: linear-gradient(150deg, #4f7bff, #2a2fa0); }
.mission.m-check { background: linear-gradient(150deg, #19b5a5, #0b6e86); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.tile-btn { font-family: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--panel-b); border-radius: 22px; padding: 16px; display: flex; gap: 12px; align-items: center; font-size: 1.15rem; font-weight: 800; cursor: pointer; min-height: 76px; text-align: left; }
.tile-btn svg { width: 46px; height: 46px; flex: none; }
.tile-btn:hover { background: rgba(255, 255, 255, .15); }

/* gameplay */
.play { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 16px 16px; gap: clamp(6px, 1.6vh, 14px); width: 100%; max-width: 760px; margin: 0 auto; }
.hud { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 900; font-size: 1.2rem; }
.timerbar { width: 100%; height: 16px; background: rgba(0, 0, 0, .35); border-radius: 999px; overflow: hidden; border: 2px solid var(--panel-b); }
.timerbar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--sun)); border-radius: 999px; transform-origin: left; }
.timerbar.low > i { background: linear-gradient(90deg, var(--coral), var(--sun)); }
.qbox { text-align: center; min-height: clamp(110px, 24vh, 190px); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.q { font-size: clamp(46px, min(13vw, 12vh), 120px); font-weight: 900; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.ans { font-size: clamp(38px, min(10vw, 9vh), 84px); font-weight: 900; min-width: 3.2ch; min-height: 1.3em; margin-top: 10px; border-bottom: 6px solid var(--sun); display: inline-block; padding: 0 16px; }
.ans.good { color: var(--good); border-color: var(--good); }
.ans.bad { color: var(--coral); border-color: var(--coral); animation: shake .4s; }
.reveal { font-size: 1.6rem; font-weight: 900; color: var(--sun); min-height: 1.6em; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 380px; }
.key { font-family: inherit; font-size: clamp(1.5rem, 3.6vh, 2.1rem); font-weight: 900; color: var(--text); background: var(--panel); border: 2px solid var(--panel-b); border-radius: 20px; height: clamp(52px, 8.4vh, 74px); cursor: pointer; touch-action: manipulation; }
.key:active { background: rgba(255, 255, 255, .28); transform: scale(.96); }
.key.go { background: var(--teal); color: var(--ink); border-color: var(--teal); }
.key.del { font-size: 1.5rem; }
.stardust { display: inline-flex; align-items: center; gap: 6px; }
.stardust svg { width: 26px; height: 26px; }
.countdown { font-size: clamp(90px, 22vw, 200px); font-weight: 900; color: var(--sun); text-shadow: 0 8px 0 #0005; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
.floaty { animation: floaty 3.2s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* results */
.result { text-align: center; }
.result .avatar { width: 170px; border-radius: 28px; margin: 6px auto 10px; display: block; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: var(--panel); border: 2px solid var(--panel-b); border-radius: 22px; padding: 14px; }
.stat b { display: block; font-size: 2.2rem; line-height: 1.1; }
.stat span { color: var(--muted); font-weight: 700; }
.rankup { background: linear-gradient(135deg, #ffcf4d, #ff8a3d); color: var(--ink); border-radius: 24px; padding: 14px 20px; font-weight: 900; font-size: 1.35rem; margin: 12px 0; }
.missed { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* hangar */
.hangar { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.hangar .avatar { width: 100%; border-radius: 28px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { font-family: inherit; font-weight: 800; font-size: 1rem; color: var(--text); background: var(--panel); border: 2px solid var(--panel-b); padding: 9px 18px; border-radius: 999px; cursor: pointer; min-height: 44px; }
.tab.on { background: var(--sun); color: var(--ink); border-color: var(--sun); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.item { background: var(--panel); border: 3px solid var(--panel-b); border-radius: 22px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-weight: 800; }
.item.worn { border-color: var(--good); }
.item .avatar { width: 100px; border-radius: 16px; }
.item .btn { width: 100%; padding: 8px 10px; font-size: .95rem; min-height: 40px; }

/* my stars grid & heat map */
.heat { display: grid; grid-template-columns: 34px repeat(12, minmax(0, 1fr)); gap: 4px; max-width: 640px; }
.heat .hd { text-align: center; font-weight: 900; color: var(--muted); font-size: .95rem; align-self: center; }
.cell { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: .85rem; font-weight: 900; color: var(--ink); background: #394072; border: 0; padding: 0; font-family: inherit; }
button.cell { cursor: pointer; }
.cell.u { background: #394072; color: #8b95cf; }
.cell.b0 { background: #ff6b6b; }
.cell.b1 { background: #ff8e5a; }
.cell.b2 { background: #ffb703; }
.cell.b3 { background: #ffd95e; }
.cell.b4 { background: #8bd450; }
.cell.b5 { background: #2ec4b6; }
.cell.hl { outline: 3px solid #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-weight: 700; font-size: .95rem; }
.legend i { display: inline-block; width: 16px; height: 16px; border-radius: 5px; vertical-align: -3px; margin-right: 6px; }

/* teacher */
.tt { width: 100%; border-collapse: collapse; }
.tt th { text-align: left; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 2px solid var(--panel-b); }
.tt td { padding: 10px; border-bottom: 1px solid var(--panel-b); vertical-align: middle; }
.tt tr:hover td { background: rgba(255, 255, 255, .05); }
.tt .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.bar { height: 10px; border-radius: 999px; background: rgba(0, 0, 0, .35); overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--good)); }
.codebox { font-size: clamp(34px, 6vw, 56px); font-weight: 900; letter-spacing: .25em; background: rgba(0, 0, 0, .35); border: 3px dashed var(--sun); border-radius: 22px; padding: 8px 26px; display: inline-block; color: var(--sun); }
.classtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.classtile { font-family: inherit; color: var(--text); text-align: left; cursor: pointer; background: var(--panel); border: 2px solid var(--panel-b); border-radius: 26px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.classtile:hover { background: rgba(255, 255, 255, .15); transform: translateY(-3px); }
.classtile b { font-size: 1.6rem; }
.hm-wrap { display: grid; grid-template-columns: minmax(0, 640px) 1fr; gap: 24px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 800; }
.cards-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.logincard { background: #fff; color: #111; border: 2px dashed #333; border-radius: 14px; padding: 14px; break-inside: avoid; }
.logincard h3 { margin: 0 0 4px; font-size: 1.3rem; color: #111; }
.logincard .code { font-size: 1.4rem; font-weight: 900; letter-spacing: .2em; }
.logincard .ic { display: flex; gap: 6px; margin-top: 8px; }
.logincard .ic svg { width: 52px; height: 52px; background: #1a2260; border-radius: 12px; padding: 4px; }
.logincard small { color: #444; display: block; margin-top: 6px; }
#print-area { display: none; }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(4, 6, 24, .75); display: grid; place-items: center; z-index: 50; padding: 16px; overflow: auto; }
.modal { background: #151d5c; border: 2px solid var(--panel-b); border-radius: 28px; padding: 22px; width: 100%; max-width: 560px; box-shadow: 0 30px 80px #000a; max-height: 92vh; overflow: auto; }
.modal.wide { max-width: 940px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); background: #1f2a7a; border: 2px solid var(--panel-b); padding: 12px 22px; border-radius: 999px; font-weight: 800; opacity: 0; transition: all .3s; z-index: 80; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #7a1f2b; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 6px solid var(--panel-b); border-top-color: var(--sun); animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 70; animation: fall 2.6s linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

@media (max-width: 860px) {
  .missions { grid-template-columns: 1fr; }
  .mission { min-height: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .hangar { grid-template-columns: 1fr; }
  .hangar .avatar { max-width: 220px; margin: 0 auto; display: block; }
  .hm-wrap { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  body { background: #fff !important; }
  #app, .toast, .modal-back, .banner { display: none !important; }
  #print-area { display: block !important; }
  #print-area .cards-preview { grid-template-columns: repeat(2, 1fr); }
}
.deck-head > div:first-child { flex: none; width: 150px; }
.deck-head .avatar { display: block; max-width: 100%; }
@media (max-width: 480px) { .deck-head > div:first-child, .deck-head .avatar { width: 120px; } }
