* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f7f9ff;
  background: #070b15;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 50% -16%, rgba(47, 78, 170, 0.42), transparent 43%),
    #070b15;
}

button {
  font: inherit;
}

.app {
  width: min(100vw, 560px);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  padding:
    max(8px, env(safe-area-inset-top))
    8px
    max(8px, env(safe-area-inset-bottom));
  gap: 8px;
}

.topbar {
  grid-row: 1;
  min-height: 58px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 22, 42, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  border-radius: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #1677ff, #654cff);
  box-shadow: 0 8px 24px rgba(73, 94, 255, 0.28);
  font-size: 13px;
}

.brand-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard {
  display: grid;
  justify-items: end;
  flex: 0 0 auto;
  line-height: 1.25;
  font-size: 13px;
  color: #edf2ff;
}

.download-progress {
  grid-row: 2;
  padding: 10px 12px 11px;
  border-radius: 15px;
  background: rgba(15, 22, 42, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.download-progress.hidden {
  display: none;
}

.download-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 12px;
  color: #d9e1f8;
}

.download-progress-head b {
  flex: 0 0 auto;
  color: #ffffff;
}

.download-progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.download-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a9cff, #6c4cff);
  transition: width 220ms ease;
}

.download-progress-bar.indeterminate {
  width: 34%;
  animation: download-progress-runner 1.15s ease-in-out infinite;
}

@keyframes download-progress-runner {
  0% { transform: translateX(-115%); }
  100% { transform: translateX(330%); }
}

.game-shell {
  grid-row: 3;
  position: relative;
  overflow: hidden;
  min-height: 0;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  background: #10182e;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 11, 21, 0.22);
  backdrop-filter: blur(3px);
}

.overlay.hidden {
  display: none;
}

.card {
  width: min(90%, 340px);
  padding: 23px 20px 20px;
  text-align: center;
  border-radius: 24px;
  background: rgba(12, 18, 35, 0.91);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

.start-card {
  padding-top: 26px;
}

.card h1,
.card h2 {
  margin: 8px 0 10px;
  font-size: clamp(25px, 6vw, 32px);
}

.card p {
  margin: 7px 0;
  color: #ccd5ef;
  line-height: 1.45;
}

.card small {
  display: block;
  margin-top: 12px;
  color: #8f9ab7;
}

.hero-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-weight: 900;
  font-size: 17px;
  background: linear-gradient(145deg, #1677ff, #654cff);
  box-shadow: 0 12px 30px rgba(73, 94, 255, 0.30);
}

.finish-flag {
  width: 48px;
  height: 34px;
  margin: 0 auto 8px;
  border-radius: 5px;
  background:
    conic-gradient(
      #ffffff 0 25%,
      #4d435c 0 50%,
      #ffffff 0 75%,
      #4d435c 0
    ) 0 0 / 16px 16px;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
}

.result-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 9px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: #cbd4ed;
}

.result-row b {
  color: white;
  font-size: 18px;
}

.card button {
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #1677ff, #654cff);
  box-shadow: 0 10px 28px rgba(65, 86, 255, 0.30);
}

.card button:active {
  transform: translateY(1px);
}

@media (max-height: 620px) {
  .topbar {
    min-height: 52px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .card {
    padding: 18px;
  }

  .card h1,
  .card h2 {
    font-size: 24px;
  }
}
