:root {
  --color-bg: #f6f9fc;
  --color-surface: #ffffff;
  --color-primary: #4c6ef5;
  --color-primary-dark: #3b5bdb;
  --color-success: #2f9e44;
  --color-success-bg: #ebfbee;
  --color-warning: #f08c00;
  --color-warning-bg: #fff4e0;
  --color-text: #23272f;
  --color-text-muted: #6b7280;
  --color-border: #e3e8ef;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --touch-min: 56px;
  --shadow-card: 0 4px 16px rgba(30, 41, 59, 0.08);
  font-size: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Segoe UI", Verdana, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

a { color: var(--color-primary); }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.container--wide {
  max-width: 900px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 16px;
}

h1 { font-size: 1.6rem; margin: 0 0 12px; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
p { line-height: 1.5; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  width: 100%;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--color-primary-dark); }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 2px solid var(--color-border);
}

.btn--success { background: var(--color-success); }
.btn--wide { width: auto; padding-left: 40px; padding-right: 40px; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 140px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }

input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 14px;
  font-size: 1.05rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus, select:focus, button:focus {
  outline: 3px solid #a5b4fc;
  outline-offset: 1px;
}

.field-error {
  color: #c2410c;
  font-size: 0.9rem;
  margin-top: 4px;
}

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.98rem;
}
.alert--info { background: #e7f0ff; color: #1d4ed8; }
.alert--success { background: var(--color-success-bg); color: var(--color-success); }
.alert--warning { background: var(--color-warning-bg); color: #a15c00; }

.avatar-grid, .profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.profile-tile {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 12px;
  text-align: center;
  border: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  display: block;
}
.profile-tile:hover, .profile-tile:focus { border-color: var(--color-primary); }
.profile-tile .avatar-emoji { font-size: 3rem; display: block; margin-bottom: 8px; }
.profile-tile .profile-name { font-weight: 700; }

.avatar-pick {
  font-size: 2.4rem;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 3px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  min-height: var(--touch-min);
}
.avatar-pick[aria-pressed="true"] { border-color: var(--color-primary); background: #eef1ff; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 12px;
}

.menu-tile {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 12px;
  text-align: center;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.05rem;
}
.menu-tile .icon { font-size: 2.4rem; display: block; margin-bottom: 8px; }

.task-display {
  text-align: center;
  font-size: 2.6rem;
  font-weight: 800;
  margin: 28px 0 8px;
  letter-spacing: 1px;
}

.task-answer-box {
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  min-height: 60px;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 3px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.keypad button {
  min-height: 64px;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
}
.keypad button:active { background: #eef1ff; }
.keypad .key-clear { color: #a15c00; }
.keypad .key-check { grid-column: span 3; background: var(--color-success); color: #fff; border: none; min-height: 64px; font-size: 1.3rem; }

.feedback-banner {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 14px;
}
.feedback-banner--correct { background: var(--color-success-bg); color: var(--color-success); }
.feedback-banner--retry { background: var(--color-warning-bg); color: #a15c00; }

.progress-bar {
  background: var(--color-border);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}
.progress-bar__fill { background: var(--color-primary); height: 100%; border-radius: 999px; }

.series-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 2; }
.switch .track {
  position: absolute; inset: 0; background: var(--color-border); border-radius: 999px; transition: background 0.15s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%;
  transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked ~ .track { background: var(--color-primary); }
.switch input:checked ~ .thumb { transform: translateX(22px); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; }
.stat-tile { background: var(--color-surface); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-card); }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--color-primary); }
.stat-tile .stat-label { color: var(--color-text-muted); font-size: 0.85rem; }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 20px 0; }
.pin-dots .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--color-primary); }
.pin-dots .dot.filled { background: var(--color-primary); }

@media (min-width: 640px) {
  :root { font-size: 17px; }
}
