:root {
  --bg: #0b1220;
  --card: #101a30;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --border: rgba(148, 163, 184, 0.18);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);

  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: radial-gradient(1200px 700px at 30% 0%, #142047 0%, var(--bg) 55%);
  color: var(--text);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
/* Matrix Mode */
.matrix-box {
  position: relative;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
  border-radius: 16px;
  padding: 12px;
  height: 260px;
  overflow: hidden;
}

.matrix-stream {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  color: rgba(34, 197, 94, 0.55);
  font-size: 18px;
  line-height: 1.2;
  user-select: none;
}

.matrix-line {
  white-space: pre;
  transform: translateY(0);
  animation: matrixUp 2.2s linear forwards;
}

@keyframes matrixUp {
  from { transform: translateY(40px); opacity: 0.0; }
  10% { opacity: 1; }
  to { transform: translateY(-260px); opacity: 0.0; }
}

.matrix-dim {
  color: rgba(34, 197, 94, 0.35);
}

.matrix-hot {
  color: rgba(34, 197, 94, 0.95);
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.35);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

h1 { margin: 0 0 6px 0; font-size: 28px; }
.sub { margin: 0; color: var(--muted); }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hidden { display: none; }

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mode {
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.mode:hover {
  transform: translateY(-2px);
  border-color: rgba(148, 163, 184, 0.35);
}

.mode.selected {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.mode-title { font-size: 18px; margin-bottom: 6px; }
.mode-desc { color: var(--muted); line-height: 1.35; }

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 22px;
}

select, input[type="checkbox"] {
  accent-color: var(--ok);
}

select {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.btn:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
}

.btn-ghost {
  background: transparent;
}

.row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint { color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 110px;
}

.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 18px; margin-top: 2px; }

.arena {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  border-radius: 16px;
  padding: 16px;
}

.text {
  font-size: 22px;
  line-height: 1.75;
  user-select: none;
  word-break: break-word;
}

.char {
  padding: 0 0.5px;
}

.char.correct { color: var(--ok); }
.char.wrong {
  color: var(--bad);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
.char.current {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(229, 231, 235, 0.7);
}
.char.pending { color: rgba(229,231,235,0.55); }

.statusline {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.status {
  color: var(--muted);
}

.status.good { color: rgba(34,197,94,0.9); }
.status.bad { color: rgba(239,68,68,0.9); }
.status.warn { color: rgba(245,158,11,0.95); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.result {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  border-radius: 14px;
  padding: 12px;
}

.result-label { color: var(--muted); font-size: 12px; }
.result-value { font-size: 22px; margin-top: 6px; }

.footer {
  margin-top: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .mode-grid { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .row { flex-direction: column; align-items: stretch; }
  .topbar { flex-direction: column; align-items: stretch; }
  .stats { justify-content: flex-start; }
}
