:root {
  --steel: #6b7078;
  --steel-dark: #3a3f47;
  --steel-light: #a0a6ad;
  --gold: #d4a24c;
  --gold-glow: #ffcf6b;
  --red: #e04a4a;
  --green: #46c060;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }

body {
  background:
    radial-gradient(ellipse at center, #1a1d24 0%, #08090c 75%),
    #08090c;
  overflow: hidden;
  user-select: none;
  color: #fff;
}

.scene {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
}

/* ============================================================
   Корпус сейфа
   ============================================================ */
.safe {
  position: relative;
  width: 400px;
  padding: 44px 36px 32px;
  border-radius: 18px;
  background:
    linear-gradient(148deg, #8a9199 0%, #575c65 42%, #3a3e45 100%);
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,0.18),
    inset 0 -4px 12px rgba(0,0,0,0.55),
    0 24px 60px rgba(0,0,0,0.75),
    0 8px 16px rgba(0,0,0,0.4);
  transition: transform 0.7s cubic-bezier(0.4, 0.0, 0.2, 1),
              opacity 0.7s ease;
}
.safe.shake { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.safe.open {
  transform: perspective(1200px) rotateY(-72deg) translateX(-25%);
  opacity: 0.25;
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}

/* Заклёпки */
.rivet {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, var(--steel-light) 0%,
                    var(--steel) 45%, var(--steel-dark) 100%);
  box-shadow:
    inset 0 -1.5px 2px rgba(0,0,0,0.7),
    inset 0 1.5px 1.5px rgba(255,255,255,0.5),
    0 1px 2px rgba(0,0,0,0.5);
}
.r-tl { top: 12px; left: 12px; }
.r-tr { top: 12px; right: 12px; }
.r-bl { bottom: 12px; left: 12px; }
.r-br { bottom: 12px; right: 12px; }

.brand {
  text-align: center;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 5px;
  margin-bottom: 20px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.7);
  opacity: 0.85;
}

/* ============================================================
   SVG диск
   ============================================================ */
.dial-svg {
  display: block;
  width: 300px;
  height: 300px;
  margin: 0 auto 22px;
  cursor: grab;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,0.7));
}
.dial-svg:active { cursor: grabbing; }

#rotor {
  transform-origin: 0 0;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#rotor.spinning { transition: none; }
#rotor.snap { transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }

.dial-num {
  font-family: Georgia, "Palatino Linotype", serif;
  font-weight: 700;
  font-size: 26px;
  fill: #2a251c;
  paint-order: stroke;
  stroke: rgba(255,255,255,0.35);
  stroke-width: 0.6;
}
.dial-num.hit {
  fill: #7a5820;
}

.dial-tick { stroke: #3d3728; stroke-linecap: round; }
.dial-tick.minor { stroke-width: 1;    opacity: 0.55; }
.dial-tick.major { stroke-width: 2.2;  opacity: 0.9;  }

.marker { pointer-events: none; }
.hub-group { pointer-events: none; }

/* ============================================================
   Индикаторы + строка введённых
   ============================================================ */
.pins {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 4px 0 10px;
}
.pin {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #14171c;
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,0.95),
    inset 0 -1px 1px rgba(255,255,255,0.06);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.pin.on {
  background: radial-gradient(circle at 30% 30%, var(--gold-glow) 0%, var(--gold) 65%);
  box-shadow:
    0 0 10px rgba(255, 207, 107, 0.75),
    inset 0 0 4px rgba(255,255,255,0.55);
}
.pin.ok {
  background: radial-gradient(circle at 30% 30%, #a3ffb9 0%, var(--green) 70%);
  box-shadow: 0 0 12px rgba(70, 192, 96, 0.85);
}
.pin.err {
  background: radial-gradient(circle at 30% 30%, #ffb0b0 0%, var(--red) 70%);
  box-shadow: 0 0 12px rgba(224, 74, 74, 0.85);
}

.entered {
  text-align: center;
  color: var(--gold);
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 24px;
  letter-spacing: 12px;
  margin: 2px 0 16px;
  padding-left: 12px;   /* компенсация letter-spacing */
  text-shadow:
    0 0 8px rgba(255,207,107,0.35),
    0 1px 0 rgba(0,0,0,0.7);
}

/* ============================================================
   Ручка сейфа
   ============================================================ */
.handle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}
.handle {
  position: relative;
  width: 150px; height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.handle-plate {
  position: absolute; inset: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #6a7079 0%, #444a51 60%, #2c3037 100%);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.25),
    inset 0 -2px 4px rgba(0,0,0,0.5),
    0 2px 4px rgba(0,0,0,0.4);
}
.handle-bar {
  position: absolute;
  left: 22px; right: 22px;
  top: 50%; height: 10px;
  margin-top: -5px;
  background: linear-gradient(180deg, #d0d4d9 0%, var(--steel) 50%, var(--steel-dark) 100%);
  border-radius: 2px;
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,0.6),
    inset 0 -1px 2px rgba(0,0,0,0.5);
}
.handle-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 32px; height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 32%, #f5eecc 0%, var(--gold) 55%, #6a4818 100%);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.55),
    inset 0 2px 3px rgba(255,255,255,0.55),
    0 3px 6px rgba(0,0,0,0.6);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.handle:hover:not(:disabled) .handle-knob { transform: scale(1.06); }
.handle.turning .handle-knob { transform: rotate(90deg) scale(1.05); }
.handle:disabled { cursor: not-allowed; opacity: 0.55; }

/* ============================================================
   Подсказка + статус
   ============================================================ */
.hint {
  text-align: center;
  color: rgba(255,255,255,0.55);
  font-size: 11.5px;
  font-style: italic;
}

.status {
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-family: "SF Mono", monospace;
  min-height: 20px;
  text-align: center;
  transition: color 0.2s ease;
}
.status.err { color: var(--red); }
.status.ok  { color: var(--green); }

.scene.opened::before {
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(circle at center, rgba(255,220,140,0.55), transparent 60%);
  animation: flash 0.6s ease-out;
  pointer-events: none;
}
@keyframes flash {
  0%   { opacity: 0; transform: scale(0.5); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.5); }
}
