*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #6b7280;
  --key-bg: #1a1a1a;
  --key-bg-press: #2a2a2a;
  --ok: #22c55e;
  --err: #ef4444;
  --dot: #2a2a2a;
  --dot-on: #f5f5f5;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.pad {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6vh;
  padding: max(env(safe-area-inset-top), 24px)
           max(env(safe-area-inset-right), 16px)
           max(env(safe-area-inset-bottom), 24px)
           max(env(safe-area-inset-left), 16px);
}

.dots {
  display: flex;
  gap: 14px;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--dot);
  transition: background 120ms ease, border-color 120ms ease,
              transform 120ms ease;
}

.dot.filled {
  background: var(--dot-on);
  border-color: var(--dot-on);
  transform: scale(1.05);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 96px));
  gap: 14px;
  width: 100%;
  max-width: 360px;
  justify-content: center;
}

.key {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 50%;
  background: var(--key-bg);
  color: var(--fg);
  font-size: 32px;
  font-weight: 400;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: background 80ms ease, transform 80ms ease;
  touch-action: manipulation;
}

.key:active,
.key.pressed {
  background: var(--key-bg-press);
  transform: scale(0.96);
}

.key-aux {
  font-size: 26px;
  color: var(--muted);
  background: transparent;
}

.key-ok {
  color: var(--ok);
  background: transparent;
  font-size: 30px;
}

.key:disabled,
.pad.locked .key {
  opacity: 0.35;
  pointer-events: none;
}

.status {
  min-height: 1.4em;
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  padding: 0 16px;
}

.status.err { color: var(--err); }
.status.ok  { color: var(--ok); }

/* Shake bei Fehlversuch */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.dots.shake { animation: shake 420ms ease; }
.dots.err .dot { border-color: var(--err); background: var(--err); }

/* Erfolgs-Overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--bg);
  z-index: 10;
}

.overlay[hidden] { display: none; }

.overlay.pulse { animation: pulseGreen 800ms ease-out 1; }

@keyframes pulseGreen {
  0%   { background: var(--bg); }
  20%  { background: #064e2b; }
  100% { background: var(--bg); }
}

.overlay-icon {
  font-size: 120px;
  color: var(--ok);
  line-height: 1;
}

.overlay-text {
  font-size: 22px;
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  .dots.shake { animation: none; }
  .overlay.pulse { animation: none; }
  .key { transition: none; }
}
