:root {
  --orange: #FF8A3D;
  --orange-light: #FFC07A;
  --orange-deep: #FF5F16;
  --deep: #04202F;
  --ink: #F4FBFF;
  --muted: #9CCBD6;
  --glass: rgba(4, 27, 41, 0.58);
  --stroke: rgba(255, 255, 255, 0.14);
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #03141F;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #052638;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0) 42%, rgba(1, 10, 17, 0.38) 100%),
    linear-gradient(180deg, rgba(1, 12, 20, 0.22) 0%, rgba(1, 12, 20, 0) 16%, rgba(1, 12, 20, 0) 80%, rgba(1, 9, 15, 0.32) 100%);
}

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 55, 35, 0.04) 16%, rgba(255, 40, 25, 0.56) 100%);
}

.damage-flash.on {
  animation: damagePulse 0.5s ease-out both;
}

@keyframes damagePulse {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* ============ HUD ============ */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  pointer-events: none;
  transition: opacity 0.34s ease, transform 0.34s ease;
}

body.menu-mode .hud {
  opacity: 0;
  transform: translateY(-8px);
}

body.menu-mode .hint {
  opacity: 0;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.glass {
  background: linear-gradient(158deg, rgba(8, 45, 64, 0.78) 0%, rgba(3, 21, 33, 0.66) 100%);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 28px rgba(0, 7, 12, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 62vw;
  padding: 7px 13px 7px 7px;
  border-radius: 19px;
}

.avatar-wrap {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 2px;
  border-radius: 16px;
  background: linear-gradient(150deg, #FFB46E 0%, #FF8A3D 46%, rgba(255, 255, 255, 0.18) 100%);
  box-shadow: 0 5px 16px rgba(255, 138, 61, 0.32);
}

.shark-avatar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #06283A;
}

.level-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #082A3C;
  background: linear-gradient(180deg, #FFB46E, #FF7A27);
  color: #341503;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.player-meta {
  min-width: 0;
  padding-right: 2px;
}

.player-name {
  max-width: 33vw;
  overflow: hidden;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stage {
  margin-top: 2px;
  color: var(--orange-light);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.stat-stack {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.score-card {
  min-width: 92px;
  padding: 7px 12px 8px;
  border-radius: 17px;
  text-align: right;
}

.score-label {
  display: block;
  color: #9FD9E2;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.score-value {
  display: block;
  margin-top: 1px;
  color: #FFFFFF;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
}

.lives {
  display: flex;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 13px;
}

.lives .mp-icon {
  width: 15px;
  height: 15px;
  color: #FF6B6B;
  filter: drop-shadow(0 1px 4px rgba(255, 70, 60, 0.5));
  transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.lives .mp-icon.off {
  color: rgba(255, 255, 255, 0.16);
  filter: none;
  transform: scale(0.86);
}

.evo-panel {
  margin-top: 8px;
  padding: 8px 12px 10px;
  border-radius: 15px;
}

.evo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #A8DCE5;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.evo-num {
  color: #DDF6FA;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.evo-track {
  height: 7px;
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  background: rgba(0, 9, 16, 0.52);
}

.evo-fill {
  position: relative;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FFD29E 0%, #FF8A3D 58%, #FF611C 100%);
  box-shadow: 0 0 12px rgba(255, 138, 61, 0.66);
  transition: width 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.evo-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 18%, rgba(255, 255, 255, 0.62) 48%, transparent 78%);
  background-size: 220% 100%;
  animation: evoShimmer 2.2s linear infinite;
}

@keyframes evoShimmer {
  0% { background-position: 140% 0; }
  100% { background-position: -120% 0; }
}

.combo-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 148px);
  right: 18px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 224, 190, 0.5);
  border-radius: 99px;
  background: linear-gradient(135deg, #FFB46E 0%, #FF8A3D 48%, #FF5F16 100%);
  color: #3A1702;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  opacity: 0;
  transform: translateY(-6px) scale(0.72);
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.2, 1.5, 0.4, 1);
  box-shadow: 0 8px 22px rgba(255, 100, 20, 0.42);
}

.combo-pill.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.combo-pill.bump {
  animation: comboBump 0.32s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.combo-x {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

@keyframes comboBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ============ Hint ============ */

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  background: rgba(3, 22, 35, 0.62);
  color: #D7F3F8;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 7, 12, 0.32);
  transform: translateX(-50%);
  transition: opacity 0.65s ease, transform 0.65s ease;
  pointer-events: none;
}

.hint .mp-icon {
  width: 18px;
  height: 18px;
  color: var(--orange);
}

.hint.fade {
  opacity: 0;
  transform: translate(-50%, 8px);
}

/* ============ Evolution banner ============ */

.evo-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 20px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.72);
  pointer-events: none;
  text-align: center;
}

.evo-banner.show {
  animation: evoPop 1.9s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

.evo-kicker {
  color: #FFD9B7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.46em;
  text-indent: 0.46em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.evo-name {
  margin: 2px 0 0;
  color: #FFFFFF;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  line-height: 1.16;
  text-shadow: 0 0 26px rgba(255, 138, 61, 0.95), 0 6px 22px rgba(0, 0, 0, 0.56);
}

.evo-sub {
  margin-top: 5px;
  color: rgba(229, 251, 255, 0.9);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

@keyframes evoPop {
  0% { opacity: 0; transform: translate(-50%, -46%) scale(0.68); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  30% { transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; transform: translate(-50%, -52%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(0.96); }
}

/* ============ Overlays ============ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: radial-gradient(ellipse at 50% 44%, rgba(3, 22, 35, 0.1) 0%, rgba(1, 12, 20, 0.62) 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  width: min(100%, 360px);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  padding: 26px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px;
  background: linear-gradient(166deg, rgba(11, 50, 69, 0.93) 0%, rgba(4, 24, 37, 0.95) 58%, rgba(3, 20, 32, 0.97) 100%);
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 0 1px rgba(255, 138, 61, 0.05);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: cardIn 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
  scrollbar-width: none;
}

.start-card::-webkit-scrollbar {
  display: none;
}

@keyframes cardIn {
  0% { opacity: 0; transform: translateY(18px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.hero-wrap {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 15px;
}

.hero-ring {
  position: absolute;
  inset: -10px;
  border-radius: 36px;
  background: conic-gradient(from 0deg, rgba(255, 138, 61, 0) 0%, rgba(255, 138, 61, 0.7) 22%, rgba(255, 209, 155, 0.1) 48%, rgba(255, 138, 61, 0.7) 76%, rgba(255, 138, 61, 0) 100%);
  filter: blur(7px);
  animation: ringSpin 7s linear infinite;
}

.hero-shark {
  position: relative;
  display: block;
  width: 104px;
  height: 104px;
  border: 2px solid rgba(255, 172, 101, 0.92);
  border-radius: 30px;
  overflow: hidden;
  background: #06283A;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.38), 0 0 0 7px rgba(255, 138, 61, 0.1), 0 0 30px rgba(255, 138, 61, 0.18);
  animation: heroFloat 3.8s ease-in-out infinite;
}

.hero-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FFD6B2;
  box-shadow: 0 0 10px rgba(255, 183, 117, 0.95);
  animation: sparkFloat 3.2s ease-in-out infinite;
}

.hero-spark.s1 { top: -8px; left: 16px; animation-delay: 0s; }
.hero-spark.s2 { right: -10px; top: 34px; width: 4px; height: 4px; animation-delay: 0.9s; }
.hero-spark.s3 { bottom: -7px; right: 16px; width: 3px; height: 3px; animation-delay: 1.6s; }

@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

@keyframes sparkFloat {
  0%, 100% { transform: translateY(0); opacity: 0.25; }
  50% { transform: translateY(-11px); opacity: 0.95; }
}

.hero-name {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 88%;
  margin: -3px auto 11px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.065);
  color: #E2F5F9;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.hero-name span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4BE3C8;
  box-shadow: 0 0 8px rgba(75, 227, 200, 0.85);
}

.eyebrow {
  color: #FFC08A;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-align: center;
}

.start-card h1 {
  margin: 6px 0 0;
  color: #EAFBFF;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .start-card h1 {
    background: linear-gradient(180deg, #FFFFFF 18%, #CFF7FB 58%, #86DCE6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.lead {
  margin: 9px 0 0;
  color: #AFD8E0;
  font-size: 12.5px;
  line-height: 1.66;
  letter-spacing: 0.03em;
  text-align: center;
}

.rule-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 16px 0 17px;
}

.rule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.055);
  color: #C8E9EF;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

.rule .mp-icon {
  width: 14px;
  height: 14px;
  color: #FFA55C;
}

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 54px;
  border: 1px solid rgba(255, 222, 190, 0.42);
  border-radius: 17px;
  background: linear-gradient(180deg, #FFA95F 0%, #FF8A3D 46%, #FF671D 100%);
  color: #361603;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  box-shadow: 0 12px 26px rgba(255, 103, 29, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  touch-action: manipulation;
}

.primary-btn .mp-icon {
  width: 22px;
  height: 22px;
  color: #371703;
}

.primary-btn:active {
  transform: scale(0.972);
  box-shadow: 0 6px 14px rgba(255, 103, 29, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(0.97);
}

.primary-btn:focus-visible {
  outline: 2px solid #FFE0C2;
  outline-offset: 3px;
}

.best-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 13px;
  color: #9DCBD5;
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

.best-line .mp-icon {
  width: 15px;
  height: 15px;
  color: #FFC07A;
}

.best-line b {
  color: #FFD8B5;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.micro {
  margin: 10px 0 0;
  color: rgba(163, 207, 216, 0.72);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-align: center;
}

/* ============ Game over card ============ */

.over-card {
  text-align: center;
}

.over-mark {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border: 2px solid rgba(255, 170, 98, 0.7);
  border-radius: 24px;
  overflow: hidden;
  background: #06283A;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36), 0 0 0 6px rgba(255, 138, 61, 0.08);
  filter: saturate(0.45);
}

.over-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.over-card h2 {
  margin: 7px 0 0;
  color: #FFFFFF;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 18px 0 15px;
}

.result-cell {
  padding: 10px 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.result-cell span {
  display: block;
  color: #95C7D2;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.result-cell b {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-best {
  margin: -4px 0 12px;
  color: #FFC07A;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  animation: bestGlow 1.2s ease-in-out infinite;
}

@keyframes bestGlow {
  0%, 100% { text-shadow: 0 0 6px rgba(255, 138, 61, 0.3); }
  50% { text-shadow: 0 0 16px rgba(255, 138, 61, 0.9); }
}

/* ============ Small screens ============ */

@media (max-height: 700px) {
  .start-card {
    padding: 18px 20px 16px;
    border-radius: 24px;
  }

  .hero-wrap,
  .hero-shark {
    width: 82px;
    height: 82px;
  }

  .hero-wrap {
    margin-bottom: 10px;
  }

  .hero-shark {
    border-radius: 25px;
    overflow: hidden;
  }

  .start-card h1 {
    font-size: 27px;
  }

  .lead {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.5;
  }

  .rule-row {
    margin: 11px 0 12px;
  }

  .primary-btn {
    height: 48px;
    font-size: 15px;
  }

  .best-line {
    margin-top: 9px;
  }

  .micro {
    margin-top: 7px;
  }

  .result-grid {
    margin: 12px 0 11px;
  }

  .over-mark {
    width: 58px;
    height: 58px;
    border-radius: 19px;
    margin-bottom: 8px;
  }
}

@media (max-height: 560px) {
  .hero-wrap,
  .hero-shark {
    width: 64px;
    height: 64px;
  }

  .hero-wrap {
    margin-bottom: 8px;
  }

  .hero-shark {
    border-radius: 20px;
    overflow: hidden;
  }

  .hero-ring {
    inset: -7px;
    border-radius: 24px;
  }

  .lead,
  .micro {
    display: none;
  }

  .rule-row {
    margin: 9px 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-ring,
  .hero-shark,
  .hero-spark,
  .evo-fill::after,
  .new-best {
    animation: none;
  }
}
