* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: var(--game-width, 100%);
  min-width: 100%;
  min-height: 100%;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(3, 7, 16, 0.2), rgba(2, 5, 11, 0.82)),
    image-set(url("../assets/ui/menu-bg.webp") type("image/webp"), url("../assets/ui/menu-bg.png") type("image/png")) center / cover no-repeat,
    #070b16;
  color: #f3fbff;
  font-family: "Pretendard Variable", Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: pan-x pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(53, 225, 255, 0.2), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(255, 196, 82, 0.14), transparent 24%),
    linear-gradient(90deg, rgba(9, 16, 31, 0.32), transparent 36%, rgba(8, 11, 22, 0.34));
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.44;
}

#game-shell {
  position: relative;
  width: var(--game-width, 100vw);
  height: var(--game-height, 100dvh);
  min-width: 100vw;
  min-height: 100dvh;
  overflow: visible;
}

#game-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

#game-container canvas {
  display: block;
  width: var(--game-width, 100vw);
  height: var(--game-height, 100dvh);
}

.hidden {
  display: none !important;
}

.archerlab-link {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 7px 14px;
  border: 1px solid rgba(148, 230, 255, 0.44);
  border-radius: 999px;
  background: rgba(7, 15, 30, 0.68);
  color: #dff9ff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.archerlab-link::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-top: 2px solid #71f6ff;
  border-right: 2px solid #71f6ff;
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(113, 246, 255, 0.85);
}

.hud {
  position: fixed;
  left: 50%;
  top: max(52px, calc(env(safe-area-inset-top) + 50px));
  z-index: 20;
  display: grid;
  grid-template-columns: 42px repeat(4, minmax(64px, auto));
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 22px));
  padding: 8px;
  border: 1px solid rgba(129, 222, 255, 0.28);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(16, 31, 56, 0.82), rgba(6, 12, 24, 0.7)),
    rgba(6, 12, 24, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.stat {
  min-width: 0;
  height: 42px;
  padding: 6px 12px;
  border: 1px solid rgba(135, 229, 255, 0.14);
  border-radius: 14px;
  background: rgba(4, 11, 24, 0.5);
}

.stat span {
  display: block;
  color: #8da8bd;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

.stat strong {
  display: block;
  margin-top: 4px;
  color: #f6fcff;
  font-size: 1rem;
  line-height: 1;
  text-shadow: 0 0 14px rgba(103, 234, 255, 0.42);
}

.stat-time strong {
  color: #fff3c9;
  text-shadow: 0 0 16px rgba(255, 210, 92, 0.46);
}

.stat-time.is-low {
  border-color: rgba(255, 100, 92, 0.42);
  background: rgba(55, 12, 20, 0.56);
}

.stat-time.is-low strong {
  color: #ff8b7e;
  text-shadow: 0 0 18px rgba(255, 90, 78, 0.72);
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(137, 231, 255, 0.24);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(30, 54, 87, 0.9), rgba(8, 18, 34, 0.86));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.icon-btn::before,
.icon-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.icon-home::before {
  width: 17px;
  height: 14px;
  border: 2px solid #dffaff;
  border-top: 0;
  border-radius: 2px 2px 4px 4px;
}

.icon-home::after {
  width: 15px;
  height: 15px;
  border-left: 2px solid #dffaff;
  border-top: 2px solid #dffaff;
  transform: translate(-50%, -70%) rotate(45deg);
}

.icon-undo::before {
  width: 17px;
  height: 17px;
  border: 2px solid #dffaff;
  border-right-color: transparent;
  border-radius: 50%;
}

.icon-undo::after {
  width: 8px;
  height: 8px;
  border-left: 2px solid #dffaff;
  border-bottom: 2px solid #dffaff;
  transform: translate(-93%, -82%) rotate(34deg);
}

.icon-hint::before {
  width: 16px;
  height: 16px;
  border: 2px solid #ffe29a;
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 214, 104, 0.74);
}

.icon-hint::after {
  width: 10px;
  height: 3px;
  border-radius: 99px;
  background: #ffe29a;
  transform: translate(-50%, 9px);
}

.sound-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 46;
}

.sound-toggle.is-muted {
  border-color: rgba(255, 139, 126, 0.34);
  background:
    linear-gradient(180deg, rgba(58, 29, 36, 0.9), rgba(16, 13, 22, 0.88));
}

.icon-sound::before {
  width: 19px;
  height: 17px;
  background: #dffaff;
  clip-path: polygon(0 34%, 32% 34%, 72% 9%, 72% 91%, 32% 66%, 0 66%);
  filter: drop-shadow(0 0 10px rgba(111, 238, 255, 0.5));
}

.icon-sound::after {
  width: 13px;
  height: 20px;
  border: 2px solid #dffaff;
  border-left: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 0 999px 999px 0;
  transform: translate(-12%, -50%);
  filter: drop-shadow(0 0 10px rgba(111, 238, 255, 0.45));
}

.icon-sound.is-muted::after {
  width: 22px;
  height: 3px;
  border: 0;
  border-radius: 999px;
  background: #ff8b7e;
  transform: translate(-50%, -50%) rotate(-42deg);
  box-shadow: 0 0 12px rgba(255, 117, 101, 0.7);
}

.icon-retry::before {
  width: 17px;
  height: 17px;
  border: 2px solid #dffaff;
  border-left-color: transparent;
  border-radius: 50%;
}

.icon-retry::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid #dffaff;
  border-top: 2px solid #dffaff;
  transform: translate(15%, -86%) rotate(25deg);
}

.icon-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  min-width: max-content;
  padding: 5px 8px;
  border: 1px solid rgba(137, 231, 255, 0.24);
  border-radius: 8px;
  background: rgba(5, 12, 24, 0.92);
  color: #e8fbff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.icon-btn:hover .icon-tooltip,
.icon-btn:focus-visible .icon-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.menu-screen {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 15;
  width: var(--game-width, 100vw);
  min-width: 100vw;
  height: var(--game-height, 100dvh);
  min-height: 100dvh;
  display: grid;
  align-items: stretch;
  padding: max(80px, calc(env(safe-area-inset-top) + 76px)) 28px max(26px, env(safe-area-inset-bottom));
  background:
    linear-gradient(90deg, rgba(2, 6, 14, 0.9) 0%, rgba(2, 6, 14, 0.58) 42%, rgba(2, 6, 14, 0.2) 100%),
    radial-gradient(circle at 18% 34%, rgba(78, 235, 255, 0.22), transparent 24%),
    linear-gradient(180deg, rgba(2, 5, 12, 0.18), rgba(2, 5, 12, 0.78));
  overflow: hidden;
}

.menu-art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 9, 19, 0.04), rgba(4, 9, 19, 0.56)),
    image-set(url("../assets/ui/menu-bg.webp") type("image/webp"), url("../assets/ui/menu-bg.png") type("image/png")) center / cover no-repeat;
  transform: scale(1.02);
  filter: saturate(1.12) contrast(1.04);
}

.menu-content {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  min-height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  align-items: end;
  gap: 28px;
}

.menu-title-block {
  align-self: center;
  max-width: 620px;
  padding-bottom: 40px;
}

.menu-title-block .brand-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 12px;
  border: 1px solid rgba(126, 239, 255, 0.28);
  border-radius: 999px;
  background: rgba(4, 12, 24, 0.62);
  letter-spacing: 0.18em;
  box-shadow: 0 0 24px rgba(86, 236, 255, 0.12);
}

.menu-title-block h1 {
  margin-top: 18px;
  font-size: clamp(4.2rem, 11vw, 8.6rem);
  line-height: 0.82;
  letter-spacing: 0;
  text-transform: uppercase;
}

.menu-title-block h1 span {
  display: block;
}

.menu-title-block h1 span:first-child {
  color: #f6fdff;
  text-shadow:
    0 0 24px rgba(109, 241, 255, 0.52),
    0 24px 70px rgba(0, 0, 0, 0.48);
}

.menu-title-block h1 span:last-child {
  color: #ffd76a;
  text-shadow:
    0 0 20px rgba(255, 211, 92, 0.44),
    0 22px 64px rgba(0, 0, 0, 0.48);
}

.menu-lane {
  display: grid;
  grid-template-columns: 1.2fr 0.65fr 1.2fr;
  gap: 10px;
  width: min(420px, 88vw);
  height: 10px;
  margin-top: 28px;
}

.menu-lane span {
  border-radius: 999px;
  background: linear-gradient(90deg, #63f2ff, #fff0a8 58%, #ff9c45);
  box-shadow: 0 0 22px rgba(118, 238, 255, 0.38);
}

.menu-lane span:nth-child(2) {
  opacity: 0.54;
}

.menu-control-bar {
  align-self: end;
  width: min(430px, 100%);
  display: grid;
  gap: 10px;
}

.menu-control-bar .record-row {
  margin: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.menu-control-bar .record-row div {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.menu-control-bar .record-row span {
  color: #91d8e8;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-shadow: 0 0 14px rgba(18, 32, 48, 0.9);
}

.menu-control-bar .record-row strong {
  color: #fff7cf;
  font-size: 1.5rem;
  text-shadow:
    0 0 18px rgba(255, 211, 92, 0.5),
    0 8px 20px rgba(0, 0, 0, 0.5);
}

.menu-control-bar .menu-actions--menu {
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
}

.menu-control-bar .primary-btn,
.menu-control-bar .secondary-btn {
  min-height: 58px;
  border-radius: 12px;
}

.menu-control-bar .secondary-btn {
  background:
    linear-gradient(180deg, rgba(20, 45, 72, 0.84), rgba(5, 14, 28, 0.86));
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(470px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid rgba(141, 231, 255, 0.24);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(13, 25, 48, 0.78), rgba(4, 9, 19, 0.82)),
    rgba(4, 9, 19, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.clear-panel {
  width: min(480px, calc(100vw - 32px));
  padding: 26px 26px 24px;
  border-color: rgba(112, 238, 255, 0.36);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(7, 18, 32, 0.7), rgba(3, 7, 14, 0.9)),
    image-set(url("../assets/ui/asphalt-tile.webp") type("image/webp"), url("../assets/ui/asphalt-tile.png") type("image/png")) center / 150px repeat,
    #07101d;
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.54),
    0 0 34px rgba(88, 226, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  isolation: isolate;
  overflow-x: hidden;
  overflow-y: auto;
}

.clear-panel > * {
  position: relative;
  z-index: 1;
}

.clear-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 0;
  border: 1px solid rgba(124, 239, 255, 0.16);
  border-radius: 15px;
  background:
    linear-gradient(90deg, transparent 0 44%, rgba(255, 211, 92, 0.28) 44% 48%, transparent 48% 52%, rgba(255, 211, 92, 0.28) 52% 56%, transparent 56%),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 211, 92, 0.16) 18px 34px, transparent 34px 52px);
  opacity: 0.7;
  pointer-events: none;
}

.clear-panel::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 0;
  width: 132px;
  height: 16px;
  border-radius: 999px;
  background: repeating-linear-gradient(135deg, #ffd35c 0 16px, #17202c 16px 30px);
  box-shadow: 0 0 24px rgba(255, 205, 78, 0.2);
  transform: rotate(-12deg);
  pointer-events: none;
}

.clear-gate {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  height: 36px;
  margin-bottom: 16px;
}

.clear-gate span {
  position: relative;
  border: 1px solid rgba(130, 239, 255, 0.28);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(24, 55, 82, 0.86), rgba(5, 13, 25, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.clear-gate span::before {
  content: "";
  position: absolute;
  inset: 8px 14px;
  border-radius: 999px;
  background: #5ef2ff;
  box-shadow: 0 0 20px rgba(94, 242, 255, 0.76);
}

.clear-gate span:nth-child(2)::before {
  background: #ffe17a;
  box-shadow: 0 0 20px rgba(255, 225, 122, 0.76);
}

.clear-gate span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -16px;
  width: 2px;
  height: 16px;
  border-radius: 99px;
  background: rgba(129, 230, 255, 0.28);
  transform: translateX(-50%);
}

.clear-panel .brand-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 1px solid rgba(124, 239, 255, 0.24);
  border-radius: 999px;
  background: rgba(5, 13, 25, 0.72);
  letter-spacing: 0.14em;
}

.clear-panel h2 {
  color: #f7fdff;
  font-size: clamp(2rem, 8vw, 3.35rem);
  text-shadow:
    0 0 18px rgba(103, 237, 255, 0.5),
    0 0 42px rgba(255, 205, 78, 0.16);
}

.clear-panel .clear-stats {
  gap: 8px;
  margin: 20px 0 18px;
}

.clear-panel .clear-stats div {
  position: relative;
  min-height: 82px;
  border-color: rgba(135, 229, 255, 0.2);
  border-radius: 13px;
  background:
    linear-gradient(180deg, rgba(13, 31, 53, 0.88), rgba(4, 11, 22, 0.82));
  overflow: hidden;
}

.clear-panel .clear-stats div::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #67eaff, #ffd25c);
  opacity: 0.82;
}

.clear-panel .clear-stats span {
  color: #92bdd0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.clear-panel .clear-stats strong {
  color: #fff7cf;
  font-size: 1.42rem;
}

.clear-panel .rank-submit-row {
  margin: 4px 0 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 211, 92, 0.32);
}

.clear-panel .rank-submit-row input {
  border-radius: 10px;
  background: rgba(2, 8, 16, 0.82);
}

.clear-panel .menu-actions--clear .primary-btn {
  min-height: 56px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, #63f2ff, #ffe07a 58%, #ff9c45);
  color: #07101d;
  box-shadow:
    0 16px 34px rgba(255, 206, 78, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.modal-clear.is-timeout .clear-panel {
  border-color: rgba(255, 117, 101, 0.48);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.56),
    0 0 36px rgba(255, 92, 76, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.modal-clear.is-timeout .clear-gate span::before,
.modal-clear.is-timeout .clear-gate span:nth-child(2)::before {
  background: #ff6658;
  box-shadow: 0 0 22px rgba(255, 102, 88, 0.78);
}

.modal-clear.is-timeout .brand-kicker {
  color: #ffb0a7;
  border-color: rgba(255, 117, 101, 0.32);
}

.modal-clear.is-timeout .clear-panel h2 {
  color: #fff1ef;
  text-shadow:
    0 0 20px rgba(255, 105, 88, 0.6),
    0 0 46px rgba(255, 185, 77, 0.18);
}

.modal-clear.is-timeout .clear-panel .clear-stats div::before {
  background: linear-gradient(90deg, #ff6658, #ffd25c);
}

.modal-clear.is-timeout .clear-panel .menu-actions--clear .primary-btn {
  background:
    linear-gradient(135deg, #ff6b5d, #ffbd59 58%, #fff0a8);
}

.brand-kicker {
  margin-bottom: 10px;
  color: #7eefff;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

h1 {
  color: #f5fdff;
  font-size: clamp(2.4rem, 11vw, 4.8rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow:
    0 0 20px rgba(111, 238, 255, 0.45),
    0 0 48px rgba(151, 116, 255, 0.32);
}

h2 {
  color: #f5fdff;
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.record-row,
.clear-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.record-row div,
.clear-stats div {
  min-height: 74px;
  padding: 14px;
  border: 1px solid rgba(146, 231, 255, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(25, 48, 79, 0.72), rgba(7, 15, 30, 0.66));
}

.record-row span,
.clear-stats span {
  display: block;
  color: #8faec2;
  font-size: 0.76rem;
  font-weight: 800;
}

.record-row strong,
.clear-stats strong {
  display: block;
  margin-top: 8px;
  color: #fff7cf;
  font-size: 1.54rem;
  line-height: 1;
  text-shadow: 0 0 20px rgba(255, 212, 92, 0.46);
}

.clear-stats {
  grid-template-columns: repeat(3, 1fr);
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.menu-actions--menu {
  grid-template-columns: 1.15fr 1fr;
}

.menu-actions--clear {
  grid-template-columns: 1fr;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 46%, rgba(71, 230, 255, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(2, 6, 14, 0.68), rgba(2, 5, 12, 0.9));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.loading-panel {
  position: relative;
  width: min(320px, calc(100vw - 48px));
  min-height: 320px;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 26px;
  border: 1px solid rgba(137, 231, 255, 0.26);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 38%, rgba(76, 233, 255, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(12, 27, 52, 0.84), rgba(4, 9, 19, 0.84));
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.loading-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  border: 1px solid rgba(126, 239, 255, 0.18);
  box-shadow: inset 0 0 34px rgba(86, 218, 255, 0.14);
  pointer-events: none;
}

.loading-emblem {
  width: min(178px, 52vw);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(91, 232, 255, 0.58));
  animation: loadingSpin 2.7s linear infinite, loadingPulse 1.36s ease-in-out infinite;
}

.loading-panel .brand-kicker {
  margin: 16px 0 8px;
}

.loading-panel strong {
  color: #fff7cf;
  font-size: 1.55rem;
  line-height: 1;
  text-shadow: 0 0 18px rgba(255, 217, 98, 0.44);
}

.loading-orbit {
  display: flex;
  gap: 7px;
  margin-top: 18px;
}

.loading-orbit span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #86f4ff;
  box-shadow: 0 0 18px rgba(134, 244, 255, 0.8);
  animation: loadingDot 0.92s ease-in-out infinite;
}

.loading-orbit span:nth-child(2) {
  animation-delay: 0.14s;
}

.loading-orbit span:nth-child(3) {
  animation-delay: 0.28s;
}

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

@keyframes loadingPulse {
  0%,
  100% {
    opacity: 0.9;
    scale: 0.98;
  }

  50% {
    opacity: 1;
    scale: 1.04;
  }
}

@keyframes loadingDot {
  0%,
  100% {
    opacity: 0.36;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-6px);
  }
}

.primary-btn,
.secondary-btn {
  min-height: 54px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-btn {
  background:
    linear-gradient(135deg, #55f0ff, #8b74ff 54%, #ffd05f);
  color: #06101d;
  box-shadow:
    0 16px 38px rgba(70, 217, 255, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.secondary-btn {
  border: 1px solid rgba(147, 231, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(31, 57, 91, 0.86), rgba(8, 17, 34, 0.86));
  color: #e5fbff;
}

.secondary-btn--ghost {
  background: rgba(8, 17, 34, 0.48);
  color: #9ab2c5;
}

.primary-btn:active,
.secondary-btn:active,
.icon-btn:active {
  transform: translateY(1px) scale(0.99);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  align-items: start;
  justify-items: center;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 24px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(3, 7, 15, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-panel {
  max-height: calc(100vh - 36px);
  max-height: calc(100svh - 36px);
  max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-clear {
  align-items: center;
}

.rank-submit-row {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.rank-submit-row input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(139, 229, 255, 0.22);
  border-radius: 15px;
  outline: 0;
  background: rgba(4, 11, 24, 0.72);
  color: #f4fbff;
  font: inherit;
  font-weight: 800;
}

.rank-submit-row input:focus {
  border-color: rgba(126, 239, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(126, 239, 255, 0.12);
}

.rank-submit-buttons {
  display: grid;
  grid-template-columns: 1fr 0.5fr;
  gap: 8px;
}

.rank-submit-buttons .secondary-btn {
  min-height: 44px;
  border-radius: 14px;
}

.rank-submit-row.is-submitting #submit-rank-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rank-submit-row.is-submitting #submit-rank-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid rgba(229, 251, 255, 0.34);
  border-top-color: #ffffff;
  border-radius: 999px;
  filter: drop-shadow(0 0 6px rgba(126, 239, 255, 0.52));
  animation: rankSubmitSpin 0.72s linear infinite;
}

.submit-status {
  min-height: 18px;
  color: #fff3c9;
  font-size: 0.82rem;
  font-weight: 800;
}

.rank-submit-row.is-submitting .submit-status {
  color: #bdf8ff;
  text-shadow: 0 0 10px rgba(126, 239, 255, 0.36);
}

.rank-submit-progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(126, 239, 255, 0.22);
  border-radius: 999px;
  background: rgba(4, 11, 24, 0.72);
  box-shadow: inset 0 0 16px rgba(41, 153, 185, 0.18);
}

.rank-submit-progress span {
  position: absolute;
  inset: -1px auto -1px 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #65f1ff 28%, #ffe07a 72%, transparent);
  filter: drop-shadow(0 0 10px rgba(126, 239, 255, 0.7));
  animation: rankSubmitBar 0.92s ease-in-out infinite;
}

.rank-submit-row.is-submitting input {
  opacity: 0.68;
}

@keyframes rankSubmitSpin {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes rankSubmitBar {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}

.rank-panel {
  width: min(520px, calc(100vw - 32px));
}

.rank-panel > .primary-btn {
  width: 100%;
}

.rank-content {
  display: grid;
  gap: 8px;
  max-height: min(54vh, 460px);
  margin: 20px 0;
  overflow: auto;
  padding-right: 4px;
}

.rank-loading,
.rank-empty,
.rank-error {
  padding: 18px;
  border: 1px solid rgba(139, 229, 255, 0.16);
  border-radius: 16px;
  background: rgba(4, 11, 24, 0.54);
  color: #a8bdcf;
  text-align: center;
  font-weight: 800;
}

.rank-error {
  color: #ffd36a;
}

.rank-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid rgba(139, 229, 255, 0.16);
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(18, 36, 61, 0.78), rgba(6, 14, 28, 0.74));
}

.rank-row.top1 {
  border-color: rgba(255, 211, 106, 0.54);
  background:
    linear-gradient(180deg, rgba(82, 60, 22, 0.55), rgba(18, 30, 46, 0.78));
}

.rank-row.top2 {
  border-color: rgba(197, 224, 242, 0.46);
}

.rank-row.top3 {
  border-color: rgba(255, 151, 104, 0.46);
}

.rank-pos {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(126, 239, 255, 0.1);
  color: #dffaff;
  font-weight: 900;
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  color: #f6fcff;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-meta {
  display: block;
  margin-top: 3px;
  color: #8ca9bd;
  font-size: 0.72rem;
  font-weight: 800;
}

.rank-level {
  color: #fff3c9;
  font-weight: 900;
  text-align: right;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 28;
  transform: translateX(-50%);
  min-width: 170px;
  padding: 11px 16px;
  border: 1px solid rgba(255, 218, 124, 0.32);
  border-radius: 999px;
  background: rgba(9, 17, 32, 0.88);
  color: #fff3c9;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
}

@media (max-width: 620px) {
  .hud {
    top: max(48px, calc(env(safe-area-inset-top) + 46px));
    grid-template-columns: 38px repeat(4, minmax(42px, 1fr));
    gap: 5px;
    padding: 6px;
    border-radius: 17px;
  }

  .stat {
    height: 38px;
    padding: 6px 7px;
    border-radius: 12px;
  }

  .stat span {
    font-size: 0.58rem;
  }

  .stat strong {
    font-size: 0.88rem;
  }

  .stat-wide span {
    font-size: 0.52rem;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .modal-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .menu-screen {
    padding: max(74px, calc(env(safe-area-inset-top) + 70px)) 16px max(18px, env(safe-area-inset-bottom));
    background:
      linear-gradient(180deg, rgba(2, 6, 14, 0.28), rgba(2, 6, 14, 0.86)),
      radial-gradient(circle at 50% 36%, rgba(78, 235, 255, 0.18), transparent 30%);
  }

  .menu-art {
    background:
      linear-gradient(180deg, rgba(4, 9, 19, 0.04), rgba(4, 9, 19, 0.58)),
      image-set(url("../assets/ui/menu-bg.webp") type("image/webp"), url("../assets/ui/menu-bg.png") type("image/png")) center / cover no-repeat;
  }

  .menu-content {
    grid-template-columns: 1fr;
    align-content: end;
    gap: 18px;
    justify-self: start;
    width: calc(100vw - 32px);
    max-width: 420px;
    margin: 0;
  }

  .menu-title-block {
    align-self: end;
    padding-bottom: 0;
  }

  .menu-title-block .brand-kicker {
    min-height: 26px;
    padding: 5px 10px;
    font-size: 0.66rem;
  }

  .menu-title-block h1 {
    margin-top: 12px;
    font-size: clamp(3.1rem, 17vw, 5.2rem);
  }

  .menu-lane {
    width: min(300px, 82vw);
    height: 8px;
    margin-top: 18px;
  }

  .menu-control-bar {
    width: 100%;
    padding: 0;
  }

  .menu-control-bar .record-row {
    gap: 12px;
  }

  .menu-control-bar .record-row div {
    min-height: 0;
    padding: 0;
  }

  .menu-control-bar .record-row strong {
    font-size: 1.36rem;
  }

  .menu-control-bar .menu-actions--menu {
    grid-template-columns: 1fr 1fr;
  }

  .menu-control-bar .menu-actions--menu .primary-btn {
    grid-column: 1 / -1;
  }

  .menu-actions {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  }

  .modal-panel {
    width: min(420px, calc(100vw - 24px));
    max-height: calc(100vh - 20px);
    max-height: calc(100svh - 20px);
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .clear-panel {
    padding: 18px;
  }

  .clear-panel::after {
    right: 12px;
    bottom: 12px;
    width: 108px;
    height: 12px;
  }

  .clear-gate {
    height: 30px;
    gap: 7px;
    margin-bottom: 12px;
  }

  .clear-gate span::before {
    inset: 7px 10px;
  }

  .clear-panel .clear-stats {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 16px 0;
  }

  .clear-panel .clear-stats div {
    min-height: 64px;
    padding: 12px;
  }

  .clear-panel .clear-stats strong {
    margin-top: 6px;
    font-size: 1.28rem;
  }

  .clear-stats {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 16px 0;
  }

  .clear-stats div {
    min-height: 64px;
    padding: 12px;
    border-radius: 15px;
  }

  .clear-stats strong {
    margin-top: 6px;
    font-size: 1.36rem;
  }

  .rank-submit-row {
    gap: 8px;
    margin-bottom: 12px;
  }

  .rank-submit-row input {
    min-height: 44px;
  }

  .menu-actions--clear {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .stat-wide {
    display: block;
  }

  .hud {
    grid-template-columns: 38px repeat(4, minmax(38px, 1fr));
  }

  .stat {
    padding: 6px 5px;
  }

  .stat-wide span {
    font-size: 0.48rem;
  }
}

@media (max-width: 620px) and (max-height: 700px) {
  .modal-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .modal-panel .brand-kicker {
    margin-bottom: 6px;
    font-size: 0.66rem;
  }

  .modal-panel h2 {
    font-size: clamp(1.45rem, 7vw, 2.1rem);
  }

  .clear-panel {
    padding: 14px;
  }

  .clear-gate {
    height: 24px;
    margin-bottom: 8px;
  }

  .clear-gate span::before {
    inset: 6px 9px;
  }

  .clear-gate span::after {
    bottom: -10px;
    height: 10px;
  }

  .clear-panel .clear-stats {
    gap: 7px;
    margin: 12px 0;
  }

  .clear-panel .clear-stats div {
    min-height: 54px;
    padding: 10px 12px;
  }

  .clear-panel .clear-stats span {
    font-size: 0.66rem;
  }

  .clear-panel .clear-stats strong {
    margin-top: 4px;
    font-size: 1.12rem;
  }

  .clear-panel .rank-submit-row {
    gap: 7px;
    margin-bottom: 10px;
    padding-top: 10px;
  }

  .clear-stats {
    gap: 7px;
    margin: 12px 0;
  }

  .clear-stats div {
    min-height: 54px;
    padding: 10px 12px;
  }

  .clear-stats span {
    font-size: 0.7rem;
  }

  .clear-stats strong {
    margin-top: 4px;
    font-size: 1.2rem;
  }

  .rank-submit-row {
    gap: 7px;
    margin-bottom: 10px;
  }

  .rank-submit-row input {
    min-height: 38px;
  }

  .rank-submit-buttons .secondary-btn {
    min-height: 38px;
  }

  .modal-panel .primary-btn,
  .modal-panel .secondary-btn {
    min-height: 46px;
    border-radius: 14px;
  }

  .menu-actions {
    gap: 8px;
  }
}
