:root {
  --orange: #FF8A3D;
  --orange-bright: #FFA45F;
  --orange-deep: #F2600B;
  --gold: #FFC46B;
  --cyan: #66F2E3;
  --ink: #060714;
  --panel: rgba(10, 13, 32, 0.66);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #F6F7FF;
  --muted: #9BA0C6;
  --muted-dim: #767CA4;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

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

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #04050d;
  color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
}

body {
  touch-action: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button:focus-visible {
  outline: 2px solid var(--orange-bright);
  outline-offset: 3px;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, #12122e 0%, #060714 60%, #04050d 100%);
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(125% 82% at 50% 45%, transparent 52%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0%, transparent 14%, transparent 84%, rgba(0, 0, 0, 0.42) 100%);
}

.damage-flash {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(120% 92% at 50% 50%, transparent 36%, rgba(255, 48, 66, 0.58) 100%);
  transition: opacity 0.28s ease;
}

.damage-flash.hit {
  opacity: 1;
  transition: opacity 0.045s ease;
}

.is-hidden {
  display: none !important;
}

/* ---------------- game HUD ---------------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 0 14px;
  pointer-events: none;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: calc(var(--sat) + 10px);
}

.score-card {
  min-width: 116px;
  padding: 7px 13px 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(21, 25, 54, 0.78), rgba(8, 10, 25, 0.62));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  backdrop-filter: blur(12px) saturate(1.25);
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1;
}

.score-value {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
  text-shadow: 0 0 16px rgba(255, 138, 61, 0.4);
  font-variant-numeric: tabular-nums;
}

.wave-wrap {
  display: flex;
  flex: 1;
  justify-content: center;
  padding-top: 5px;
}

.wave-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 160, 92, 0.3);
  border-radius: 999px;
  background: rgba(38, 20, 13, 0.6);
  color: #FFD3B0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.wave-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange-bright);
  box-shadow: 0 0 9px rgba(255, 138, 61, 0.95);
  animation: blink 1.5s ease-in-out infinite;
}

.util {
  display: flex;
  gap: 6px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(21, 25, 54, 0.78), rgba(8, 10, 25, 0.62));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn .mp-icon {
  width: 19px;
  height: 19px;
  color: #E9EBFF;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 138, 61, 0.2);
}

.icon-btn .sound-off {
  display: none;
}

.icon-btn.is-muted .sound-on {
  display: none;
}

.icon-btn.is-muted .sound-off {
  display: inline-block;
  color: #FF9278;
}

.hull-card {
  width: 166px;
  margin-top: 8px;
  padding: 8px 11px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(21, 25, 54, 0.74), rgba(8, 10, 25, 0.56));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease;
}

.hull-row {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #B5B9DA;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.hull-row .mp-icon {
  width: 14px;
  height: 14px;
  color: var(--orange-bright);
}

.hull-row b {
  margin-left: auto;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.hull-track {
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.hull-fill {
  width: 100%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FFC46B 0%, #FF8A3D 55%, #FF6B16 100%);
  box-shadow: 0 0 10px rgba(255, 138, 61, 0.6);
  transition: width 0.28s ease, background 0.25s ease;
}

.hull-card.low {
  border-color: rgba(255, 80, 96, 0.42);
}

.hull-card.low .hull-fill {
  background: linear-gradient(90deg, #FF9D69, #FF4D5E);
  box-shadow: 0 0 12px rgba(255, 60, 80, 0.65);
}

.hull-card.low .hull-row .mp-icon {
  color: #FF6A78;
}

.wave-banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 25%;
  z-index: 12;
  pointer-events: none;
  color: #fff;
  font-size: clamp(26px, 8.4vw, 40px);
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-align: center;
  text-shadow: 0 0 30px rgba(255, 138, 61, 0.9), 0 4px 0 rgba(80, 26, 0, 0.45);
  opacity: 0;
}

.wave-banner.show {
  animation: wave-banner 1.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ---------------- start screen ---------------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.start {
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 16px) 20px calc(var(--sab) + 20px);
  background: linear-gradient(
    180deg,
    rgba(4, 5, 15, 0.8) 0%,
    rgba(4, 5, 15, 0.28) 28%,
    rgba(4, 5, 15, 0) 45%,
    rgba(4, 5, 15, 0.14) 64%,
    rgba(4, 5, 15, 0.82) 89%,
    rgba(4, 5, 15, 0.94) 100%
  );
}

.start-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pilot {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 5px 13px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 12, 30, 0.58);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.avatar {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 2px solid rgba(255, 180, 120, 0.72);
  border-radius: 50%;
  background: linear-gradient(135deg, #FF8A3D 0%, #A846C9 58%, #4A3AD0 100%);
  box-shadow: 0 0 18px rgba(255, 138, 61, 0.35);
}

.avatar img {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar img.on {
  display: block;
}

.avatar-fallback {
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.pilot-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.1;
}

.pilot-label {
  color: var(--muted-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.pilot-meta b {
  max-width: 132px;
  overflow: hidden;
  color: #F2F3FF;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.best-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 196, 107, 0.26);
  border-radius: 12px;
  background: rgba(38, 26, 12, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.best-badge .mp-icon {
  width: 13px;
  height: 13px;
  color: var(--gold);
}

.best-label {
  color: #D8C0A2;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.best-badge b {
  color: #FFE1AE;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.logo-wrap {
  margin-top: clamp(20px, 8.5vh, 82px);
  padding: 0 4px;
  text-align: center;
}

.kicker {
  margin: 0 0 12px;
  color: #FFB98A;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.24em;
  line-height: 1.4;
  text-shadow: 0 2px 12px rgba(255, 110, 30, 0.35);
}

.logo {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: 0;
  font-size: clamp(46px, 13.6vw, 64px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1;
}

.logo-text {
  background: linear-gradient(180deg, #FFFFFF 10%, #FFEBDD 48%, #FFA25B 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(94, 31, 3, 0.55)) drop-shadow(0 0 26px rgba(255, 122, 34, 0.4));
}

.logo-num {
  display: inline-block;
  margin-left: 7px;
  margin-top: -2px;
  padding: 0.14em 0.24em 0.16em;
  border: 1px solid rgba(255, 220, 190, 0.42);
  border-radius: 0.24em;
  background: linear-gradient(180deg, #FFA45F 0%, #FF7A22 55%, #F2600B 100%);
  box-shadow: 0 5px 18px rgba(255, 106, 22, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  color: #2A1205;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.4em;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: rotate(4deg);
}

.tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 14px 0 0;
  color: #C9CBE7;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.tagline span {
  color: rgba(255, 138, 61, 0.75);
  font-weight: 900;
}

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
  padding-top: 26px;
}

.primary-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 60px;
  overflow: hidden;
  border: 1px solid rgba(255, 218, 186, 0.45);
  border-radius: 19px;
  background: linear-gradient(180deg, #FFB06F 0%, #FF8A3D 48%, #F26A12 100%);
  box-shadow:
    0 14px 32px rgba(255, 106, 22, 0.34),
    0 4px 0 rgba(112, 38, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.58);
  color: #2A1205;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-btn::after {
  position: absolute;
  top: -60%;
  left: -18%;
  width: 60%;
  height: 210%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  content: "";
  transform: rotate(18deg);
  animation: btn-shine 4.6s ease-in-out infinite;
}

.primary-btn .mp-icon {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  color: #2A1205;
}

.primary-btn span {
  position: relative;
  z-index: 1;
}

.primary-btn:active {
  transform: translateY(3px) scale(0.987);
  box-shadow:
    0 5px 16px rgba(255, 106, 22, 0.26),
    0 1px 0 rgba(112, 38, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  color: #9298BD;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.hint b {
  color: #FFB37A;
  font-weight: 800;
}

.hint-dot {
  width: 3px;
  height: 3px;
  margin: 0 2px;
  border-radius: 50%;
  background: rgba(255, 179, 122, 0.55);
}

/* ---------------- overlays ---------------- */

.overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 22px) 22px calc(var(--sab) + 22px);
  background: rgba(3, 5, 16, 0.58);
  -webkit-backdrop-filter: blur(9px) saturate(1.15);
  backdrop-filter: blur(9px) saturate(1.15);
  animation: overlay-in 0.22s ease both;
}

.panel {
  position: relative;
  width: 100%;
  max-width: 356px;
  overflow: hidden;
  padding: 26px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 27px;
  background:
    radial-gradient(120% 80% at 50% -12%, rgba(255, 138, 61, 0.22), transparent 52%),
    linear-gradient(180deg, rgba(22, 26, 56, 0.95) 0%, rgba(9, 11, 28, 0.97) 100%);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  text-align: center;
  animation: panel-in 0.28s cubic-bezier(0.2, 0.9, 0.25, 1.1) both;
}

.panel::before {
  position: absolute;
  top: -46%;
  left: 50%;
  width: 78%;
  height: 80%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 138, 61, 0.28), transparent 68%);
  content: "";
  pointer-events: none;
  transform: translateX(-50%);
}

.panel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border: 1px solid rgba(255, 148, 82, 0.4);
  border-radius: 21px;
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.25), rgba(255, 138, 61, 0.05));
  box-shadow: 0 8px 24px rgba(255, 100, 20, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.panel-icon .mp-icon {
  width: 30px;
  height: 30px;
  color: #FFA45F;
}

.panel-icon.danger {
  border-color: rgba(255, 90, 110, 0.42);
  background: linear-gradient(180deg, rgba(255, 72, 96, 0.25), rgba(255, 72, 96, 0.05));
  box-shadow: 0 8px 24px rgba(255, 48, 76, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.panel-icon.danger .mp-icon {
  color: #FF7A8A;
}

.panel h2 {
  position: relative;
  margin: 0 0 7px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.panel-sub {
  position: relative;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  line-height: 1.6;
}

.panel .primary-btn {
  height: 54px;
  margin-top: 16px;
  border-radius: 17px;
  font-size: 17px;
}

.panel .primary-btn:first-of-type {
  margin-top: 4px;
}

.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  margin-top: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.055);
  color: #D9DCF4;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: transform 0.12s ease, background 0.15s ease;
}

.ghost-btn:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.1);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 17px 0 4px;
}

.stat {
  padding: 10px 12px 11px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.stat span {
  display: block;
  color: #8F95BA;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.stat b {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat:first-child b {
  color: #FFC08A;
}

.new-best {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 10px 0 0;
  color: #FFD799;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-shadow: 0 0 16px rgba(255, 170, 80, 0.5);
}

.new-best .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--gold);
}

/* ---------------- animations ---------------- */

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.78); }
}

@keyframes wave-banner {
  0% { opacity: 0; transform: translateY(18px) scale(0.86); }
  16% { opacity: 1; transform: translateY(0) scale(1); }
  68% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-20px) scale(1.04); }
}

@keyframes btn-shine {
  0%, 62% { transform: translateX(-160%) rotate(18deg); }
  82%, 100% { transform: translateX(330%) rotate(18deg); }
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.965); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- compact phones ---------------- */

@media (max-width: 355px) {
  .hud {
    padding: 0 11px;
  }

  .score-card {
    min-width: 98px;
    padding: 6px 10px 7px;
  }

  .score-value {
    font-size: 19px;
  }

  .wave-pill {
    gap: 4px;
    padding: 6px 8px;
    font-size: 9px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .icon-btn .mp-icon {
    width: 17px;
    height: 17px;
  }

  .hull-card {
    width: 146px;
  }

  .best-label {
    display: none;
  }

  .pilot-meta b {
    max-width: 96px;
  }

  .start {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tagline {
    font-size: 11px;
    letter-spacing: 0.07em;
  }
}

@media (max-height: 670px) {
  .logo-wrap {
    margin-top: 16px;
  }

  .logo {
    font-size: 44px;
  }

  .tagline {
    margin-top: 10px;
  }

  .start-actions {
    padding-top: 14px;
  }

  .primary-btn {
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wave-dot,
  .primary-btn::after {
    animation: none;
  }
}
