@font-face {
  font-family: "DSDigital";
  src: url("../assets/fonts/DS-DIGIB.TTF") format("truetype");
  font-weight: normal;
  font-style: normal;
}

:root {
  --ink: #f7fbff;
  --hud-value: #80efff;
  --blue-edge: rgba(111, 164, 225, 0.68);
  --blue-deep: #071322;
  --blue-mid: #102b4c;
  --app-height: 100vh;
}

* {
  box-sizing: border-box;
}

input,
select {
  user-select: auto;
  -webkit-user-select: auto;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: #030508;
  color: var(--ink);
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.shell {
  min-height: var(--app-height);
  height: var(--app-height);
  display: grid;
  place-items: center;
  padding: 4px;
}

.phone {
  position: relative;
  width: min(530px, calc(100vw - 8px), calc((var(--app-height) - 8px) * 0.504));
  max-height: calc(var(--app-height) - 8px);
  aspect-ratio: 530 / 1051;
  display: grid;
  grid-template-rows: 166fr 773fr 92fr;
  gap: 10px;
  padding: 12px 12px 14px;
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(58, 106, 166, 0.68), rgba(13, 31, 55, 0.98) 12%, rgba(9, 20, 35, 1)),
    #0b1d34;
  border: 4px solid #010306;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.72),
    inset 0 0 0 3px rgba(96, 148, 213, 0.62),
    inset 0 0 28px rgba(55, 122, 205, 0.42);
  overflow: hidden;
}

.phone > * {
  min-width: 0;
}

.top-board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(66px, 0.86fr) minmax(104px, 1.1fr) minmax(66px, 0.86fr);
  align-items: start;
  gap: clamp(4px, 1.4vw, 8px);
  padding: clamp(10px, 3.2vw, 18px) clamp(10px, 3.2vw, 18px) clamp(9px, 2.8vw, 15px);
  background:
    radial-gradient(circle at 51% 32%, rgba(75, 168, 245, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(21, 52, 88, 0.62) 0%, rgba(7, 19, 33, 0.2) 82%);
}

.top-board > * {
  min-width: 0;
}

.mini-panel,
.lives-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.hud-stack {
  display: grid;
  min-height: 100%;
  align-content: space-between;
  gap: clamp(5px, 1.8vw, 9px);
}

.stage-stack .mini-panel {
  padding-left: clamp(6px, 3vw, 17px);
  text-align: left;
}

.mini-panel {
  min-height: 60px;
  padding: 0;
}

.mini-panel span,
.lives-panel span {
  display: block;
  color: #ffffff;
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", monospace;
  font-size: clamp(13px, 3.8vw, 19px);
  font-weight: normal;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.7),
    0 0 7px rgba(88, 236, 255, 0.22);
}

.mini-panel strong {
  display: block;
  margin-top: 5px;
  color: #ffffff;
  font-size: clamp(27px, 8.4vw, 38px);
  line-height: 1;
  text-align: center;
}

#stage-value,
#score-value {
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", monospace;
  font-size: clamp(29px, 8.8vw, 41px);
  color: var(--hud-value);
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 3px 5px rgba(0, 0, 0, 0.78),
    0 0 4px rgba(255, 255, 255, 0.28),
    0 0 15px rgba(88, 236, 255, 0.46);
  letter-spacing: 0;
  background: none;
  border: none;
  box-shadow: none;
}

#score-value {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(27px, 7.6vw, 40px);
  white-space: nowrap;
  text-align: right;
}

.score-panel .mini-panel span,
.score-panel .mini-panel strong {
  text-align: right;
}

.stage-stack .mini-panel span,
.stage-stack .mini-panel strong {
  text-align: left;
}

#rank-value {
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", monospace;
  font-size: clamp(26px, 7.8vw, 36px);
  color: var(--hud-value);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-shadow:
    0 3px 5px rgba(0, 0, 0, 0.78),
    0 0 14px rgba(88, 236, 255, 0.42);
}

.logo-title {
  position: relative;
  margin: 0;
  line-height: 1;
  text-align: center;
  align-self: center;
  cursor: pointer;
  touch-action: manipulation;
}

.logo-title img {
  width: 100%;
  max-width: 166px;
  display: block;
  margin: 0 auto;
}

.score-panel {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  align-content: space-between;
  gap: clamp(5px, 1.8vw, 9px);
  justify-items: stretch;
  padding-right: clamp(6px, 3vw, 17px);
}

.score-panel .mini-panel {
  min-height: 62px;
  padding: 0;
}

.score-panel .mini-panel {
  min-height: 0;
}

.lives-panel {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 0;
  text-align: right;
  justify-self: stretch;
}

.lives-panel span {
  text-align: right;
}

.lives-panel strong {
  display: grid;
  grid-template-columns: repeat(3, clamp(15px, 4.6vw, 22px));
  justify-content: end;
  align-items: center;
  gap: clamp(2px, 1vw, 4px) clamp(3px, 1.2vw, 5px);
  margin-top: 7px;
  direction: rtl;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
}

.lives-panel strong img {
  width: clamp(15px, 4.6vw, 22px);
  height: clamp(15px, 4.6vw, 22px);
}

#game {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 506 / 760;
  align-self: center;
  justify-self: stretch;
  min-height: 0;
  min-width: 0;
  border: 0;
  border-radius: 28px;
  background: #071321;
  box-shadow:
    inset 0 0 0 5px rgba(63, 116, 181, 0.72),
    inset 0 0 0 10px rgba(8, 18, 31, 0.88),
    inset 0 0 48px rgba(35, 99, 175, 0.25),
    0 8px 16px rgba(0, 0, 0, 0.54);
  touch-action: none;
}

@media (pointer: coarse), (max-width: 640px) {
  #game {
    width: 92%;
    justify-self: center;
  }
}

.item-bar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  justify-content: center;
  align-items: center;
  gap: clamp(1px, 0.8vw, 3px);
  min-width: 0;
}

.item {
  position: relative;
  min-width: 0;
  min-height: clamp(50px, 12.8vw, 68px);
  border: 2px solid rgba(107, 160, 222, 0.5);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(47, 83, 134, 0.96), rgba(8, 19, 35, 0.98)),
    #0d2039;
  color: var(--ink);
  font: inherit;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 8px 13px rgba(0, 0, 0, 0.46);
}

.item.pause {
  cursor: pointer;
  background: none;
  border: none;
  box-shadow: none;
}

.item.pause img {
  width: clamp(42px, 11vw, 54px);
  height: clamp(42px, 11vw, 54px);
  display: block;
}

.item.power {
  background: none;
  border: none;
  box-shadow: none;
  flex-direction: column;
  gap: 3px;
}

.item.power.empty .item-icon {
  filter: grayscale(1) brightness(0.48) contrast(0.85);
  opacity: 0.58;
}

.item.power.empty strong {
  background: linear-gradient(180deg, #7b8793, #3b4652);
  border-color: rgba(175, 187, 199, 0.42);
  color: rgba(235, 241, 247, 0.66);
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.34);
}

.item.power strong {
  position: static;
  right: auto;
  bottom: auto;
  align-self: flex-end;
  margin-right: 2px;
}

.item-icon {
  width: clamp(31px, 8.4vw, 42px);
  height: clamp(31px, 8.4vw, 42px);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #06101d;
  font-size: 26px;
  font-weight: 1000;
  text-shadow: none;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.55),
    inset 0 -4px 8px rgba(0, 0, 0, 0.22),
    0 5px 8px rgba(0, 0, 0, 0.42);
}

.item-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.item-icon.swap,
.item-icon.shield {
  border-radius: 12px;
}

.item strong {
  position: absolute;
  right: 4px;
  bottom: -7px;
  min-width: clamp(20px, 5.2vw, 25px);
  height: clamp(19px, 4.8vw, 23px);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #40d4ff, #0c82c8);
  border: 1px solid rgba(150, 231, 255, 0.75);
  color: #ffffff;
  font-size: clamp(13px, 3.5vw, 16px);
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.58);
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.42);
}

.item.status strong {
  font-size: 16px;
}

.hint {
  display: none;
}

.screen-overlay {
  position: absolute;
  inset: 12px;
  z-index: 10;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 18px;
  padding: 34px 28px;
  border-radius: 27px;
  background:
    radial-gradient(circle at 50% 43%, rgba(42, 147, 255, 0.2), transparent 42%),
    #000000;
  color: #ffffff;
  text-align: center;
  touch-action: manipulation;
}

.intro-screen::before,
.gameover-screen::before,
.ranking-screen::before {
  content: "";
  position: absolute;
  inset: -12px;
  z-index: -1;
  background: #000000;
}

.gameover-screen {
  align-content: center;
  gap: 18px;
}

.stageclear-screen {
  align-content: center;
  gap: 54px;
  background:
    radial-gradient(circle at 50% 45%, rgba(42, 147, 255, 0.2), transparent 45%),
    rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(6px);
}

.ranking-screen {
  gap: 16px;
  padding: 20px 18px;
}

.screen-overlay.hidden {
  display: none;
}

.cheat-status {
  position: absolute;
  right: 36px;
  bottom: 134px;
  z-index: 8;
  display: grid;
  gap: 3px;
  padding: 8px 10px 7px;
  border: 1px solid rgba(128, 239, 255, 0.28);
  border-radius: 9px;
  background: rgba(2, 9, 18, 0.68);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 16px rgba(88, 236, 255, 0.1);
  pointer-events: none;
}

.cheat-status.hidden {
  display: none;
}

.cheat-status div {
  color: rgba(145, 156, 169, 0.62);
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", monospace;
  font-size: 15px;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

.cheat-status div.active {
  color: #ffffff;
  text-shadow:
    0 0 8px rgba(88, 236, 255, 0.56),
    0 2px 3px rgba(0, 0, 0, 0.78);
}

.debug-overlay {
  position: absolute;
  inset: 12px;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 27px;
  background:
    radial-gradient(circle at 50% 44%, rgba(42, 147, 255, 0.24), transparent 45%),
    rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(5px);
}

.debug-overlay.hidden {
  display: none;
}

.debug-panel {
  width: min(390px, 94%);
  display: grid;
  gap: 17px;
  padding: 24px 22px 21px;
  border: 2px solid rgba(128, 239, 255, 0.72);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(24, 58, 96, 0.96), rgba(4, 13, 25, 0.98)),
    #061427;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    inset 0 -18px 28px rgba(0, 0, 0, 0.38),
    0 18px 36px rgba(0, 0, 0, 0.62),
    0 0 24px rgba(88, 236, 255, 0.2);
}

.debug-title,
.debug-field span,
.debug-actions button,
.debug-field select,
.debug-field input {
  font-family: "DSDigital", Bahnschrift, "Cascadia Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.debug-title {
  color: #ffffff;
  font-size: 32px;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 12px rgba(88, 236, 255, 0.44),
    0 3px 5px rgba(0, 0, 0, 0.72);
}

.debug-field {
  display: grid;
  gap: 7px;
  color: #ffffff;
  text-align: left;
}

.debug-field.hidden {
  display: none;
}

.debug-field span {
  font-size: 18px;
  text-shadow: 0 0 9px rgba(88, 236, 255, 0.24);
}

.debug-field select,
.debug-field input {
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(128, 239, 255, 0.68);
  border-radius: 10px;
  padding: 7px 10px 5px;
  background: rgba(3, 12, 23, 0.94);
  color: var(--hud-value);
  font-size: 26px;
  outline: none;
  box-shadow:
    inset 0 2px 9px rgba(0, 0, 0, 0.62),
    0 0 14px rgba(88, 236, 255, 0.18);
}

.debug-field select:focus,
.debug-field input:focus {
  border-color: rgba(255, 255, 255, 0.84);
  box-shadow:
    inset 0 2px 9px rgba(0, 0, 0, 0.62),
    0 0 18px rgba(88, 236, 255, 0.36);
}

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

.debug-actions button {
  min-height: 45px;
  border: 2px solid rgba(107, 160, 222, 0.58);
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(47, 83, 134, 0.98), rgba(8, 19, 35, 0.98)),
    #0d2039;
  color: #ffffff;
  font-size: 23px;
  cursor: pointer;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    0 7px 11px rgba(0, 0, 0, 0.42);
}

.debug-actions button[type="submit"] {
  border-color: rgba(128, 239, 255, 0.72);
  color: var(--hud-value);
}

.overlay-logo {
  width: min(78%, 340px);
  max-height: 50vh;
  object-fit: contain;
  filter:
    drop-shadow(0 10px 13px rgba(0, 0, 0, 0.72))
    drop-shadow(0 0 18px rgba(71, 206, 255, 0.28));
}

.overlay-title {
  color: #ff4f68;
  font-family: "DSDigital", Bahnschrift, monospace;
  font-size: 64px;
  line-height: 0.9;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.78),
    0 0 18px rgba(255, 70, 93, 0.56);
}

.overlay-gameover {
  display: none;
  width: min(92%, 390px);
  object-fit: contain;
  filter:
    drop-shadow(0 10px 16px rgba(0, 0, 0, 0.78))
    drop-shadow(0 0 18px rgba(255, 67, 114, 0.3));
}

.gameover-screen .overlay-gameover {
  display: block;
}

.overlay-nextstage {
  display: none;
  width: min(90%, 390px);
  object-fit: contain;
  filter:
    drop-shadow(0 10px 16px rgba(0, 0, 0, 0.78))
    drop-shadow(0 0 18px rgba(255, 67, 194, 0.28));
}

.stageclear-screen .overlay-nextstage {
  display: block;
}

.overlay-topranks {
  display: none;
  width: min(62%, 246px);
  object-fit: contain;
  filter:
    drop-shadow(0 10px 16px rgba(0, 0, 0, 0.78))
    drop-shadow(0 0 18px rgba(255, 67, 194, 0.24));
}

.ranking-screen .overlay-topranks {
  display: block;
}

.overlay-score,
.overlay-prompt,
.name-entry {
  font-family: "DSDigital", Bahnschrift, monospace;
  text-transform: uppercase;
  text-shadow: 0 0 13px rgba(88, 236, 255, 0.35);
}

.overlay-score {
  color: var(--hud-value);
  font-size: 34px;
}

.gameover-screen .overlay-score {
  margin-bottom: 54px;
}

.overlay-prompt {
  color: #ffffff;
  font-size: 32px;
  letter-spacing: 0.08em;
  animation: prompt-blink 1.1s steps(2, start) infinite;
}

.name-entry {
  display: none;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-size: 25px;
}

.name-entry.visible {
  display: flex;
}

.name-entry input {
  width: 180px;
  border: 2px solid rgba(128, 239, 255, 0.7);
  border-radius: 8px;
  padding: 7px 10px 5px;
  background: rgba(4, 16, 31, 0.92);
  color: var(--hud-value);
  font: inherit;
  text-transform: uppercase;
  text-align: center;
  outline: none;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.58),
    0 0 15px rgba(88, 236, 255, 0.22);
}

.rank-list {
  display: none;
  width: min(440px, 98%);
  margin: 0;
  padding: 0;
  font-family: "DSDigital", Bahnschrift, monospace;
  font-size: 27px;
  color: #ffffff;
  text-align: left;
}

.rank-list.visible {
  display: grid;
  gap: 12px;
}

.rank-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(128, 239, 255, 0.7), transparent);
}

.rank-row {
  display: grid;
  grid-template-columns: 58px 112px 1fr 86px;
  gap: 5px;
  align-items: baseline;
}

.rank-header {
  color: #ffffff;
  font-size: 22px;
}

.rank-row span:nth-child(1),
.rank-row span:nth-child(4) {
  text-align: center;
}

.rank-row span:nth-child(3) {
  text-align: right;
}

.rank-list .rank-score {
  color: var(--hud-value);
}

@keyframes prompt-blink {
  0%,
  48% {
    opacity: 1;
  }

  49%,
  100% {
    opacity: 0.28;
  }
}
