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

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
  border: 2px solid transparent;
  background-clip: padding-box;
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

:root {
  --bg: #090a0f;
  --surface: rgba(17, 19, 28, 0.75);
  --surface2: rgba(25, 28, 41, 0.85);
  --surface3: rgba(33, 37, 54, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.12);
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-dim: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --red: #ef4444;
  --radius: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.5);
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', Inter, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 45%);
  background-attachment: fixed;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}

body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 48px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: cardEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform: translateY(30px);
  opacity: 0;
  z-index: 10;
}

@keyframes cardEnter {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), #06b6d4, transparent);
  opacity: 0.8;
  animation: shimmer 4s ease-in-out infinite alternate;
}

@keyframes shimmer {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.9;
  }
}

.logo {
  text-align: center;
  margin-bottom: 44px;
}

.logo-symbol {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 14px;
  opacity: 0.9;
}

.logo h1 {
  font-family: 'Noto Serif SC', 'Songti SC', 'Source Han Serif SC', SimSun, serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.logo p {
  font-size: 13px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  font-weight: 500;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input#pw {
  width: 100%;
  background: rgba(30, 34, 45, 0.6);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 42px 12px 16px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 10px;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.1em;
}

input#pw[type=password] {
  letter-spacing: 0.35em;
}

input#pw:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(30, 34, 45, 0.9);
}

input:focus-visible, button:focus-visible, .pw-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pw-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.pw-toggle:hover {
  color: var(--text-primary);
  background: var(--surface2);
}

.btn {
  width: 100%;
  margin-top: 28px;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px var(--accent-dim);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px var(--accent-dim);
}

.numpad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.np-btn {
  background: rgba(38, 43, 56, 0.4);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 16px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.np-btn:hover {
  background: rgba(38, 43, 56, 0.8);
  border-color: var(--accent);
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--accent-dim);
}

.np-btn:active {
  background: rgba(99, 102, 241, 0.2);
  transform: scale(0.95);
}

.np-clear {
  color: var(--red);
}

.np-clear:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

.np-del {
  color: #06b6d4;
}

.np-del:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.2);
}

@media(max-width:480px) {
  body {
    align-items: flex-start;
    padding: 40px 0;
  }

  .numpad {
    display: grid;
  }

  .card {
    padding: 40px 24px;
    margin: 0 16px;
    border-radius: 20px;
  }

  input#pw {
    font-size: 16px;
  }
}

.err {
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  margin-top: 16px;
  text-align: center;
  letter-spacing: 0.03em;
  min-height: 18px;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Browser warning overlay */
.bw-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bw-overlay.show {
  display: flex;
  animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.bw-box {
  background: var(--surface);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 40px 48px;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}

.bw-icon {
  font-size: 42px;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.4));
}

.bw-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--red);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.bw-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 28px;
}

.bw-body strong {
  color: var(--text-primary);
}

.bw-btn {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 12px 32px;
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.bw-btn:hover {
  background: #f87171;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

/* Loading Overlay Keyframes */
@keyframes spinRing { to { transform: rotate(360deg); } }
@keyframes pulseDot {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.8); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}
@keyframes dotFade { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }