@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf");
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: Fredoka, system-ui, sans-serif;
  color: #fff;
  background: #0b1133;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
  background: #0b1133 url("../assets/images/space.jpg") center/cover no-repeat;
  overflow: auto;
}
.screen.active {
  display: block;
}
.top,
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4%;
  max-width: 1400px;
  margin: auto;
}
header h2 {
  font-size: 26px;
  text-align: center;
  margin: 0;
}
.pill,
.hud-pill {
  background: #1a2158e8;
  border: 2px solid #879fef;
  border-radius: 22px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #f5e4a4;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.13em;
  color: #a6d3ff;
  font-weight: 700;
}
.btn,
.tiny,
.level {
  border: 3px solid #ffffffaf;
  border-radius: 17px;
  font-weight: 700;
  box-shadow:
    0 6px 0 #172555,
    inset 0 4px 0 #ffffff6b,
    0 8px 18px #070b2d7a;
  transition:
    transform 0.1s,
    filter 0.1s;
}
.btn:active,
.tiny:active,
.level:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #172555,
    inset 0 3px 0 #ffffff6b;
}
.btn:hover,
.tiny:hover {
  filter: brightness(1.1);
}
.btn {
  min-height: 54px;
  font-size: 18px;
  padding: 11px 16px;
  color: #fff;
  text-shadow: 0 2px 1px #34316775;
}
.btn span {
  float: right;
}
.tiny {
  min-width: 48px;
  min-height: 46px;
  padding: 7px 12px;
  background: linear-gradient(#e4edff, #a8c1ee);
  color: #314271;
  border-color: #7e9bdf;
  font-size: 16px;
}
.orange {
  background: linear-gradient(#ffce76, #f28e47);
  color: #563122;
  text-shadow: none;
}
.purple {
  background: linear-gradient(#dba5ff, #a774e6);
}
.blue {
  background: linear-gradient(#8bdaf5, #4da5d5);
  color: #24476f;
  text-shadow: none;
}
.green {
  background: linear-gradient(#a9e994, #6cc778);
  color: #275640;
  text-shadow: none;
}
.pink {
  background: linear-gradient(#ffaac9, #e976a4);
  color: #652e54;
  text-shadow: none;
}
.compact {
  min-height: 45px;
  font-size: 15px;
}
.home {
  width: min(1080px, 92%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 35px;
  margin: 3vh auto;
}
.home-box {
  width: 510px;
  background: #171d53ee;
  border: 3px solid #8399e8;
  border-radius: 27px;
  padding: 27px;
  box-shadow: 0 8px 0 #0a123c99;
}
.home h1 {
  font-size: clamp(52px, 6vw, 78px);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin: 14px 0 5px;
  text-shadow: 0 5px 0 #322363;
}
.home h1 em {
  font-style: normal;
  color: #ffc86e;
}
.home h2 {
  font-size: 19px;
  letter-spacing: 0.35em;
  color: #8ee3f8;
  margin: 10px 0;
}
.home p,
.panel p {
  font-size: 18px;
  line-height: 1.4;
  color: #dce8ff;
}
.home small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.11em;
  color: #bfcdf7;
  text-align: center;
  margin-top: 16px;
}
.hero-image {
  width: min(40vw, 420px);
  aspect-ratio: 1;
  border: 6px solid #b9d7ff;
  border-radius: 32px;
  overflow: hidden;
  box-shadow:
    0 9px 0 #262c71,
    0 15px 40px #0008;
  transform: rotate(-2deg);
}
.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 13px;
}
.secondary .btn {
  font-size: 15px;
  padding: 8px 4px;
}
.panel,
.load-box {
  background: #1b245bee;
  border: 3px solid #8fa9ee;
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 7px 0 #090e34aa,
    0 10px 35px #02051a99;
}
.load-box {
  position: absolute;
  width: min(350px, 90%);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.load-box img {
  width: 100px;
  height: 130px;
  object-fit: contain;
}
.load-box h1 {
  font-size: 37px;
  margin: 8px;
}
.loadbar {
  height: 18px;
  border-radius: 20px;
  background: #101840;
  border: 2px solid #94b5ec;
  overflow: hidden;
}
.loadbar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #62d9f4, #a5e98b, #ffd86d);
}
.load-box strong {
  display: block;
  margin-top: 8px;
}
.map,
.info,
.settings {
  width: min(840px, 94%);
  margin: 12px auto;
  text-align: center;
}
.panel h2 {
  margin: 6px;
  font-size: 30px;
}
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 17px;
  margin: 10px;
}
.pager b {
  min-width: 150px;
}
#levelGrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.level {
  min-height: 74px;
  background: linear-gradient(#9cdff3, #5cadd8);
  color: #284875;
}
.level b {
  display: block;
  font-size: 24px;
}
.level span {
  font-size: 12px;
}
.level:disabled {
  background: #747e9d;
  color: #c4cbda;
  opacity: 0.7;
}
.map p {
  font-size: 14px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0;
}
.cards article {
  text-align: left;
  background: #121a4ae8;
  border: 2px solid #7796d6;
  border-radius: 15px;
  padding: 12px;
}
.cards article > b {
  font-size: 26px;
  color: #ffd881;
}
.cards h3 {
  margin: 5px 0;
}
.cards p {
  font-size: 14px;
  margin: 0;
}
.settings {
  max-width: 450px;
}
.settings > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #141d4d;
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}
.screen#game {
  overflow: hidden;
  background: #060e30 url("../assets/images/space.jpg") center/cover;
}
.game-head {
  height: 62px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 5px;
  background: #101943ed;
  border-bottom: 3px solid #647fc6;
}
.game-head .tiny {
  min-height: 44px;
}
.race-name {
  text-align: center;
  min-width: 190px;
}
.race-name small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #a9c7ff;
}
.race-name strong {
  font-size: 20px;
}
.hud-pill {
  font-size: 14px;
  min-width: 90px;
  text-align: center;
}
.race-area {
  position: absolute;
  inset: 62px 0 0;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.race-progress {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 70%);
  background: #151e50e8;
  border: 2px solid #859cdd;
  border-radius: 14px;
  padding: 8px 12px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #d4e5ff;
}
.progress-track,
.fuelbar {
  height: 12px;
  border-radius: 12px;
  background: #0c153d;
  border: 1px solid #7ba4d6;
  overflow: hidden;
  margin-top: 5px;
}
.progress-track i,
.fuelbar i {
  height: 100%;
  width: 0;
  display: block;
  background: linear-gradient(90deg, #80d5ee, #8ff2bf, #f9e278);
  border-radius: 12px;
}
.message {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #172454e8;
  border: 2px solid #8eaae5;
  color: #eaf4ff;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  max-width: 95%;
}
.race-bottom {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 100%);
  padding: 10px 15px calc(12px + env(safe-area-inset-bottom));
  background: #111a48ef;
  border: 2px solid #7b98dc;
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
}
.fuel {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #cce4ff;
}
.fuelbar {
  flex: 1;
  margin: 0;
}
.fuelbar i {
  background: linear-gradient(90deg, #b685fa, #ff9b73, #ffe37b);
}
.fuel b {
  color: #ffdb84;
  min-width: 67px;
  text-align: right;
}
.steer {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.steer .btn {
  min-height: 50px;
}
.steer #left,
.steer #right {
  font-size: 30px;
  line-height: 1;
  padding: 5px;
}
.impact {
  display: block;
  text-align: center;
  color: #ffd39d;
  font-size: 12px;
  height: 14px;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #05081dbf;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
}
.hidden {
  display: none;
}
.modal {
  text-align: center;
  width: min(430px, 100%);
}
.modal img {
  width: 75px;
  height: 110px;
  object-fit: contain;
}
.modal h2 {
  font-size: 30px;
}
.modal #modalButtons {
  display: grid;
  gap: 10px;
}
.modal .btn {
  width: 100%;
}
#modalStars {
  margin: 8px 0 14px;
  font-size: 32px;
  color: #ffdb6b;
}
.btn:disabled {
  opacity: 0.5;
  filter: grayscale(0.3);
}
@media (max-width: 700px) and (orientation: portrait) {
  .top,
  header {
    padding: 9px 12px;
  }
  header h2 {
    font-size: 20px;
  }
  .top .pill {
    font-size: 10px;
  }
  .home {
    flex-direction: column;
    gap: 10px;
    margin: 0 auto;
  }
  .hero-image {
    width: min(47vw, 180px);
    height: 155px;
    transform: rotate(-1deg);
  }
  .home-box {
    width: min(450px, 100%);
    padding: 17px;
  }
  .home h1 {
    font-size: clamp(40px, 11vw, 55px);
    margin: 8px 0;
  }
  .home h2 {
    font-size: 13px;
  }
  .home p {
    font-size: 15px;
    margin: 9px 0;
  }
  .primary .btn {
    font-size: 15px;
  }
  .secondary .btn {
    font-size: 14px;
  }
  .home small {
    font-size: 10px;
  }
  .map,
  .info,
  .settings {
    padding: 15px;
    margin: 8px auto;
  }
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0;
  }
  .cards p {
    font-size: 13px;
  }
  #levelGrid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .level {
    min-height: 60px;
  }
  .game-head {
    height: 56px;
    gap: 6px;
  }
  .game-head .tiny {
    min-width: 42px;
    min-height: 43px;
  }
  .race-name {
    min-width: 120px;
  }
  .race-name small {
    font-size: 9px;
  }
  .race-name strong {
    font-size: 17px;
  }
  .hud-pill {
    font-size: 12px;
    min-width: 70px;
    padding: 7px;
  }
  .race-area {
    inset: 56px 0 0;
  }
  .race-progress {
    top: 8px;
    width: calc(100% - 24px);
    padding: 6px 10px;
  }
  .progress-label {
    font-size: 11px;
  }
  .message {
    top: 58px;
    font-size: 12px;
    padding: 6px 10px;
  }
  .race-bottom {
    padding: 8px 12px calc(9px + env(safe-area-inset-bottom));
  }
  .steer .btn {
    min-height: 47px;
  }
  .impact {
    font-size: 11px;
  }
}
@media (max-width: 350px) {
  .race-name {
    min-width: 100px;
  }
  .race-name strong {
    font-size: 15px;
  }
  .message {
    white-space: normal;
    width: 90%;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-head {
    height: 48px;
  }
  .game-head .tiny {
    min-height: 37px;
  }
  .race-name strong {
    font-size: 16px;
  }
  .race-name small {
    font-size: 9px;
  }
  .race-area {
    inset: 48px 0 0;
  }
  .race-progress {
    width: 290px;
    left: 12px;
    transform: none;
    top: 6px;
  }
  .message {
    top: 6px;
    left: auto;
    right: 12px;
    transform: none;
    font-size: 11px;
  }
  .race-bottom {
    left: auto;
    right: 10px;
    bottom: 0;
    transform: none;
    width: 280px;
    padding: 6px;
  }
  .steer .btn {
    min-height: 40px;
  }
  .steer {
    margin-top: 4px;
  }
  .impact {
    height: 12px;
  }
}

.yellow {
  background: linear-gradient(#ffe58e, #f4b650);
  color: #65421e;
  text-shadow: none;
}
.garage-button {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  font-size: 16px;
}
.garage {
  width: min(700px, 94%);
  margin: 12px auto;
  text-align: center;
}
.ships {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}
.ship {
  background: linear-gradient(#404c8c, #232d69);
  border: 3px solid #a3b5ef;
  border-radius: 18px;
  color: #fff;
  padding: 12px;
  box-shadow: 0 5px 0 #101842;
  font-weight: 700;
  min-width: 0;
}
.ship img {
  width: 100%;
  height: 170px;
  object-fit: contain;
  display: block;
}
.ship b {
  font-size: 16px;
}
.ship.selected {
  border-color: #ffe078;
  background: linear-gradient(#6c65af, #3a407a);
  box-shadow:
    0 5px 0 #58468a,
    0 0 0 3px #fff6b1;
}
.ship:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
@media (max-width: 700px) and (orientation: portrait) {
  .garage-button {
    margin-top: 8px;
    min-height: 45px;
    font-size: 14px;
  }
  .garage {
    padding: 15px;
    margin: 8px auto;
  }
  .ships {
    gap: 8px;
    margin: 12px 0;
  }
  .ship {
    padding: 6px;
  }
  .ship img {
    height: 110px;
  }
  .ship b {
    font-size: 13px;
  }
}

/* Racing polish */
.countdown {
  position: absolute;
  left: 50%;
  top: 37%;
  transform: translate(-50%, -50%);
  font-size: clamp(80px, 15vw, 150px);
  line-height: 1;
  font-weight: 800;
  color: #ffe17a;
  text-shadow:
    0 5px 0 #b65f28,
    0 9px 0 #3f2564,
    0 0 30px #9edcff;
  pointer-events: none;
}
.countdown.hidden {
  display: none;
}
.hud-pill {
  background: linear-gradient(#344b99, #212861);
  box-shadow:
    inset 0 3px 0 #ffffff35,
    0 3px 0 #0b1037;
}
.race-progress {
  box-shadow:
    inset 0 2px 0 #ffffff27,
    0 5px 15px #050a2c80;
}
.race-bottom {
  box-shadow:
    inset 0 3px 0 #ffffff25,
    0 -6px 20px #050a2b70;
}
.steer .btn {
  border-radius: 15px;
}
.steer #boost:not(:disabled) {
  box-shadow:
    0 6px 0 #9d4f25,
    inset 0 4px 0 #ffffff85,
    0 0 19px #ffbf6780;
}

/* ---------- Polish: icons, feedback, motion ---------- */
.ic {
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
  vertical-align: -0.17em;
  flex: none;
}
.tiny .ic {
  width: 1.2em;
  height: 1.2em;
}
.btn span .ic {
  width: 1em;
  height: 1em;
}
.level span .ic {
  width: 1.5em;
  height: 1.5em;
  margin: 0 1px;
  color: #ffc93a;
}
.level:disabled span .ic {
  width: 1.2em;
  height: 1.2em;
  color: #c4cbda;
}
.pill .ic {
  color: #ffd75a;
}
#modalStars {
  margin: 8px 0 14px;
  display: flex;
  justify-content: center;
  gap: 6px;
  color: #ffd75a;
  font-size: 34px;
  min-height: 0;
}
#modalStars .ic {
  width: 1em;
  height: 1em;
  animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
#modalStars .ic:nth-child(2) {
  animation-delay: 0.15s;
}
#modalStars .ic:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes pop {
  from {
    transform: scale(0) rotate(-40deg);
  }
  to {
    transform: scale(1) rotate(0);
  }
}
.screen.active {
  animation: screen-in 0.28s ease-out;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.overlay:not(.hidden) .modal {
  animation: modal-pop 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.hero-image img {
  transition: transform 0.35s;
}
.hero-image:hover img {
  transform: scale(1.03) rotate(-0.6deg);
}
.level:not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.12);
}
.ship {
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.ship:hover {
  transform: translateY(-4px);
}
.ship.selected img {
  animation: hover-ship 1.8s ease-in-out infinite;
}
@keyframes hover-ship {
  50% {
    transform: translateY(-6px);
  }
}
#boost:not(:disabled) {
  animation: boost-ready 1.2s ease-in-out infinite;
}
@keyframes boost-ready {
  50% {
    filter: brightness(1.2);
    box-shadow:
      0 6px 0 #172555,
      inset 0 4px 0 #ffffff6b,
      0 0 22px #ffb64aaa;
  }
}
.btn:disabled {
  filter: saturate(0.5) brightness(0.85);
  cursor: default;
}
.load-box img {
  animation: hover-ship 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Fit every menu on one screen (short screens and phones) ---------- */
@media (max-height: 520px) {
  .top,
  header {
    padding: 6px 3%;
  }
  header h2 {
    font-size: 17px;
  }
  .home {
    gap: 18px;
    margin: 0 auto;
    min-height: calc(100% - 64px);
  }
  .hero-image {
    width: min(34vh, 40vw);
    border-width: 4px;
    border-radius: 22px;
  }
  .home-box {
    width: min(480px, 58vw);
    padding: 12px 16px;
    border-radius: 20px;
  }
  .home h1 {
    font-size: clamp(30px, 11vh, 44px);
  }
  .home h2 {
    font-size: 13px;
    margin: 2px 0;
  }
  .home p {
    display: none;
  }
  .home small {
    display: none;
  }
  .home .btn {
    min-height: 38px;
    padding: 6px 8px;
    font-size: 14px;
  }
  .garage-button {
    margin-top: 8px;
    min-height: 38px;
  }
  .secondary {
    margin-top: 8px;
    gap: 8px;
  }
  .panel {
    padding: 10px 14px;
    border-radius: 18px;
  }
  .map,
  .info,
  .settings,
  .garage {
    margin: 4px auto;
  }
  .panel h2 {
    font-size: 20px;
    margin: 2px;
  }
  .panel p {
    margin: 3px 0;
    font-size: 12px;
  }
  .cards {
    margin: 8px 0;
    gap: 8px;
  }
  .cards article {
    padding: 6px 8px;
  }
  .cards article > b {
    font-size: 18px;
  }
  .cards h3 {
    margin: 1px 0;
    font-size: 14px;
  }
  .cards p {
    font-size: 11px;
    line-height: 1.2;
  }
  .level {
    min-height: 44px;
  }
  .level b {
    font-size: 18px;
  }
  .level span .ic {
    width: 1.2em;
    height: 1.2em;
  }
  .ships {
    margin: 8px 0;
    gap: 8px;
  }
  .ship {
    padding: 6px;
  }
  .ship img {
    height: min(26vh, 110px);
  }
  .ship b {
    font-size: 13px;
  }
  .settings .btn {
    min-height: 40px;
  }
}
@media (max-width: 380px) and (orientation: portrait) {
  .home-box {
    padding: 16px 14px;
  }
  .home h1 {
    font-size: 46px;
  }
  .home p {
    margin: 4px 0 8px;
    font-size: 13px;
  }
  .home .hero-image {
    width: min(40vw, 17vh);
    height: min(40vw, 17vh);
    aspect-ratio: auto;
    border-width: 4px;
  }
  .home small {
    display: none;
  }
  .home p {
    display: none;
  }
  .home h1 {
    font-size: 40px;
  }
  .home .btn {
    min-height: 42px;
  }
  .home {
    margin: 1vh auto;
    gap: 14px;
  }
  .cards {
    grid-template-columns: repeat(2, 1fr);
    margin: 10px 0;
  }
  .cards article {
    padding: 6px 8px;
  }
  .cards article > b {
    font-size: 20px;
  }
  .cards p {
    font-size: 11px;
    line-height: 1.25;
  }
  .panel {
    padding: 10px 12px;
  }
  .panel h2 {
    font-size: 24px;
  }
  .level {
    min-height: 54px;
  }
}
@media (max-height: 360px) {
  header h2 {
    font-size: 15px;
  }
  .panel {
    padding: 6px 10px;
  }
  .panel h2 {
    font-size: 17px;
  }
  .cards {
    margin: 4px 0;
  }
  .cards article {
    padding: 4px 6px;
  }
  .cards p {
    font-size: 10px;
  }
  .btn,
  .tiny {
    min-height: 34px;
  }
  .level {
    min-height: 36px;
  }
  .ship img {
    height: 22vh;
  }
  .home-box {
    padding: 8px 14px;
  }
}
/* End of style.css */
