:root {
  --bg: #0e1116;
  --panel: rgba(255, 255, 255, 0.06);
  --text: #e8ecf2;
  --accent: #5ae0b3;
  --muted: #a8b3c4;
  --border: rgba(255, 255, 255, 0.08);
  --danger: #ff6b6b;
  --warn: #f7c948;
  --max-width: 960px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 12px) 12px env(safe-area-inset-bottom, 12px);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(90, 224, 179, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.06), transparent 40%),
    var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: saturate(130%);
  margin-bottom: 14px;
}

header h1 {
  margin: 0;
  font-size: 18px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

main {
  max-width: var(--max-width);
  margin: 0 auto 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

input, select, textarea, button {
  font: inherit;
  color: inherit;
}

input, select, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  min-height: 48px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

button {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(90, 224, 179, 0.25), rgba(90, 224, 179, 0.1));
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}

button.secondary {
  background: rgba(255, 255, 255, 0.05);
}

button.danger {
  border-color: rgba(255, 107, 107, 0.4);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 107, 107, 0.05));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list .item {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  align-items: center;
}

.list .item .grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flex {
  display: flex;
  gap: 8px;
  align-items: center;
}

.flex.between {
  justify-content: space-between;
}

.card-stage {
  position: relative;
  min-height: 260px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: center;
  user-select: none;
}

.card-text {
  font-size: 32px;
  line-height: 1.2;
  word-break: break-word;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.choice {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  min-height: 48px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.choice.disabled {
  opacity: 0.5;
}

.choice.selected {
  border-color: var(--accent);
  background: rgba(90, 224, 179, 0.1);
  transform: translateY(1px);
}

.choice.correct {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(90, 224, 179, 0.2), rgba(90, 224, 179, 0.08));
  box-shadow: 0 0 0 2px rgba(90, 224, 179, 0.35), 0 4px 18px rgba(90, 224, 179, 0.18);
}

.choice.wrong {
  border-color: rgba(255, 107, 107, 0.5);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.18), rgba(255, 107, 107, 0.06));
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.35), 0 4px 18px rgba(255, 107, 107, 0.15);
}

.action-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.recommended {
  box-shadow: 0 0 0 2px var(--accent);
}

.pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

.pill.info {
  border-color: rgba(90, 224, 179, 0.5);
  background: linear-gradient(135deg, rgba(90, 224, 179, 0.16), rgba(90, 224, 179, 0.04));
}

.pill.warn {
  border-color: rgba(247, 201, 72, 0.6);
  background: linear-gradient(135deg, rgba(247, 201, 72, 0.16), rgba(247, 201, 72, 0.04));
}

.pill.danger {
  border-color: rgba(255, 107, 107, 0.6);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.16), rgba(255, 107, 107, 0.04));
}

.progress {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress .fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(90, 224, 179, 0.35), rgba(90, 224, 179, 0.8));
  transition: width 0.15s ease;
}

.muted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -6px);
}

.modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  background: rgba(16, 19, 25, 0.98);
  color: var(--text);
  width: min(720px, 96vw);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.modal .modal-body {
  padding: 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button {
  flex: 1;
  min-height: 46px;
}

.hidden {
  display: none !important;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.drop-zone {
  margin: 12px 0;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.drop-zone.active {
  border-color: var(--accent);
  background: rgba(90, 224, 179, 0.08);
}

small {
  color: var(--muted);
}

@media (min-width: 960px) {
  header h1 {
    font-size: 20px;
  }
  .card-text {
    font-size: 36px;
  }
}
