:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: color-mix(in oklab, #0f172a 85%, transparent);
  --panel-border: color-mix(in oklab, #cbd5e1 25%, transparent);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --accent-2: #818cf8;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: min(680px, 100% - 1.2rem);
  margin: max(0.8rem, env(safe-area-inset-top)) auto max(0.8rem, env(safe-area-inset-bottom));
  padding: clamp(0.9rem, 3vw, 1.4rem);
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 48px rgba(2, 6, 23, 0.45);
}

h1,
h2,
p {
  margin: 0;
}

header {
  display: grid;
  gap: 0.5rem;
}

.back {
  justify-self: start;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}

header p {
  color: var(--muted);
  line-height: 1.4;
}

.status-card {
  margin-top: 1rem;
  border: 1px solid color-mix(in oklab, var(--muted) 34%, transparent);
  border-radius: 14px;
  padding: 0.8rem;
  background: color-mix(in oklab, #0b1220 86%, transparent);
  display: grid;
  gap: 0.7rem;
}

.current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.guess {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  min-width: 8ch;
  text-align: right;
}

.keypad {
  margin-top: 1rem;
  display: grid;
  gap: 0.7rem;
}

.digits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

button {
  border: 1px solid color-mix(in oklab, var(--muted) 40%, transparent);
  background: color-mix(in oklab, #111827 85%, transparent);
  color: var(--text);
  border-radius: 12px;
  min-height: 50px;
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
}

.history-head {
  margin-top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history {
  margin: 0.75rem 0 0;
  padding-left: 1.35rem;
  display: grid;
  gap: 0.45rem;
}

.history li {
  color: #cbd5e1;
}

.history li strong {
  color: #fff;
}

@media (min-width: 720px) {
  .app {
    margin-top: 1.6rem;
  }

  button {
    min-height: 54px;
  }
}
