:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --line: rgba(255, 255, 255, 0.12);
  --primary: #7c3aed;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(900px 600px at 20% 10%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(700px 500px at 80% 0%, rgba(34, 197, 94, 0.16), transparent 55%),
    radial-gradient(800px 600px at 50% 100%, rgba(245, 158, 11, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  touch-action: manipulation;
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  touch-action: manipulation;
}

.topbar {
  padding: 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand__title {
  font-weight: 750;
  letter-spacing: 0.2px;
  font-size: 20px;
}

.brand__subtitle {
  color: var(--muted);
  font-size: 14px;
}

.content {
  padding: 10px 14px 18px;
  display: flex;
  justify-content: center;
}

.card {
  width: min(720px, 100%);
  background: linear-gradient(180deg, var(--card), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 16px;
}

.hidden { display: none; }

.form {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.field {
  display: grid;
  gap: 6px;
}

.sectionTitle {
  font-size: 13px;
  color: var(--muted);
  font-weight: 750;
  margin-top: 4px;
}

.switchList {
  margin-top: 6px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
}

.switchRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.switchRow__label {
  font-weight: 700;
}

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  display: inline-block;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--line);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 24px;
  height: 24px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 160ms ease;
}

.switch input:checked + .switch__track {
  background: rgba(34, 197, 94, 0.35);
  border-color: rgba(34, 197, 94, 0.5);
}

.switch input:checked + .switch__track::after {
  transform: translate(20px, -50%);
}

.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

.inlineError {
  margin-top: 8px;
  color: rgba(239, 68, 68, 0.9);
  font-size: 13px;
  font-weight: 650;
}

label {
  font-size: 13px;
  color: var(--muted);
}

input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
}

input:focus {
  border-color: rgba(124, 58, 237, 0.65);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

.btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 650;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.95), rgba(124, 58, 237, 0.75));
  border-color: rgba(124, 58, 237, 0.45);
}

.status {
  display: grid;
  gap: 12px;
}

.status__row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.status__row--top {
  align-items: flex-start;
}

.status__left {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.status__right {
  display: flex;
  justify-content: flex-end;
  flex: 1;
}

.pill {
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.pill--muted {
  color: var(--muted);
  font-weight: 650;
}

.timer {
  display: grid;
  gap: 4px;
}

.timer__label {
  font-size: 12px;
  color: var(--muted);
}

.timer__value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.question {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.solveCenter {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 6px;
}

.solveCenter__label {
  font-size: 12px;
  color: var(--muted);
}

.solveCenter__value {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.3px;
}

.question__expr {
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 900;
  text-align: center;
}

.answer {
  width: min(360px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  padding: 14px 16px;
  text-align: center;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.answer--ok {
  border-color: rgba(34, 197, 94, 0.7);
  box-shadow:
    0 0 0 4px rgba(34, 197, 94, 0.18),
    0 14px 40px rgba(34, 197, 94, 0.12);
}

.answer--bad {
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow:
    0 0 0 4px rgba(239, 68, 68, 0.18),
    0 14px 40px rgba(239, 68, 68, 0.12);
}

.answer__value {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
  min-height: 34px;
}

.numpad {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.key {
  padding: 16px 12px;
  font-size: 22px;
  font-weight: 800;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.key:active { transform: translateY(1px); }

.key--danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
}

.key--muted {
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.key--ghost {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.key--wide {
  grid-column: span 3;
}

.result {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.result__title {
  font-weight: 850;
  font-size: 18px;
  color: var(--muted);
}

.result__score {
  font-size: 56px;
  font-weight: 950;
  letter-spacing: 0.3px;
}

.result__meta {
  color: var(--muted);
}

.result__badge {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 850;
}

.footer {
  padding: 14px;
  display: flex;
  justify-content: center;
}

.footer__text {
  width: min(720px, 100%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}
