.cabinet {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 14px) 14px calc(var(--safe-bottom) + 14px);
}

.cabinet[hidden] {
  display: none !important;
}

.cabinet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 10, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in 0.3s ease both;
}

:root[data-lite='true'] .cabinet__backdrop {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: rgba(2, 3, 10, 0.94);
}

.cabinet.is-closing .cabinet__backdrop {
  animation: fade-out 0.35s ease both;
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

.cabinet__box {
  --neon: #5de9ff;
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  height: min(720px, 100%);
  border-radius: 26px;
  overflow: hidden;
  background: #060816;
  border: 2px solid var(--neon);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 46px -8px var(--neon), 0 40px 100px -30px rgba(0, 0, 0, 0.9);
}

.cabinet__box::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.cabinet.is-opening .cabinet__box {
  animation: crt-on 0.56s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.cabinet.is-opening .cabinet__box::after {
  animation: crt-flash 0.6s ease-out both;
}

.cabinet.is-closing .cabinet__box {
  animation: crt-off 0.36s cubic-bezier(0.6, 0, 0.8, 0.4) both;
}

@keyframes crt-on {
  0% {
    transform: scale(0.08, 0.004);
  }

  45% {
    transform: scale(1, 0.008);
  }

  100% {
    transform: none;
  }
}

@keyframes crt-flash {
  0%,
  40% {
    opacity: 0.85;
  }

  100% {
    opacity: 0;
  }
}

@keyframes crt-off {
  0% {
    transform: none;
    opacity: 1;
  }

  55% {
    transform: scale(1, 0.008);
    opacity: 1;
  }

  100% {
    transform: scale(0, 0.004);
    opacity: 0;
  }
}

.cabinet__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cabinet__title {
  margin-right: auto;
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #fff;
}

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

.cabinet__stat {
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.06);
}

.cabinet__stat b {
  margin-left: 4px;
  font-weight: 900;
  color: #fff;
}

.cabinet__stat.is-bump b {
  display: inline-block;
  animation: stat-bump 0.3s var(--ease-pop);
}

@keyframes stat-bump {
  40% {
    scale: 1.3;
    color: var(--neon);
  }
}

.cabinet__extra:empty {
  display: none;
}

.cabinet__bar .icon-btn {
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.cabinet__bar .icon-btn:hover {
  color: #fff;
}

.cabinet__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #05060d;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.cabinet__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.cabinet__screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background: radial-gradient(70% 70% at 50% 45%, rgba(5, 6, 13, 0.55), rgba(5, 6, 13, 0.9));
  animation: fade-in 0.25s ease both;
}

.cabinet__screen[hidden] {
  display: none !important;
}

.cab-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 440px;
  text-align: center;
  color: #fff;
  animation: rise-in 0.45s var(--ease-out) both;
}

.cab-card h3 {
  font-family: var(--font-neon);
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 400;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 8px var(--neon), 0 0 26px var(--neon);
}

.cab-card p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.78);
}

.cab-card .keys {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.5);
}

.targets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 7px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.07);
}

.target.is-got {
  color: #05060d;
  background: var(--neon);
}

.big-score {
  font-size: clamp(44px, 9vw, 72px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px var(--neon);
}

.new-best {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  animation: blink 0.45s steps(2, jump-none) 6;
}

.medal-won {
  display: grid;
  justify-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  animation: medal-in 0.8s var(--ease-pop) 0.15s both;
}

@keyframes medal-in {
  from {
    opacity: 0;
    scale: 0.3;
    rotate: -30deg;
  }
}

.medal-big {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 26px -4px var(--m);
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--m) 55%, var(--m2) 100%);
}

.medal-big::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.55);
}

.medal-big--bronze {
  --m: #d9884a;
  --m2: #8a4a14;
}

.medal-big--silver {
  --m: #c9d3e6;
  --m2: #6f7c96;
}

.medal-big--gold {
  --m: #ffcf33;
  --m2: #b8860b;
}

.cab-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.neon-btn {
  padding: 13px 26px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #05060d;
  background: var(--neon);
  box-shadow: 0 0 26px -6px var(--neon);
  transition: translate 0.2s var(--ease-out), filter 0.2s ease;
}

.neon-btn:hover {
  translate: 0 -2px;
  filter: brightness(1.1);
}

.neon-btn:active {
  translate: 0 2px;
}

.neon-btn--ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.cab-loading {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

@media (max-width: 640px), (max-height: 520px) {
  .cabinet {
    padding: 0;
  }

  .cabinet__box {
    width: 100%;
    height: 100%;
    border-width: 0;
    border-radius: 0;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }

  .cabinet__bar {
    padding: 8px 8px 8px 14px;
  }

  .cabinet__title {
    font-size: 15px;
  }

  .cabinet__stat {
    padding: 4px 8px;
    font-size: 11.5px;
  }
}

@media (max-width: 420px) {
  .cabinet__stat--best {
    display: none;
  }
}
