/* ====== Layout / Base ====== */
:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111;
  --muted: #666;
  --border: #e6e8ef;

  --danger: #c0392b;
  --primary: #2c6bed;

  --key-bg: #f2f3f6;
  --key-border: #d8dbe6;

  --key-used: #cfe3ff;      /* blau */
  --key-next: #bff3c8;      /* grün */
  --key-wrong: #ffd0d0;     /* optional */

  --good: #1f8b2e;
  --bad: #c0392b;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* App shell */
.app{
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ====== Header ====== */
.header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.header__left{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-box{
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-box__name, .user-box__avg{
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.label{ color: var(--muted); font-size: 12px; }
.value{ font-weight: 700; }

.timer-box{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.timer-box__label{ color: var(--muted); font-size: 12px; }
.timer-box__value{ font-weight: 800; font-size: 20px; }

/* ====== Main ====== */
.main{
  flex: 1;
  display: flex;
  justify-content: center;  /* horizontal zentriert */
  padding: 18px 16px;
}

.screen{
  width: min(980px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Panels */
.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

/* Buttons */
.btn{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover{ filter: brightness(0.98); }
.btn--primary{
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn--danger{
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hidden */
.hidden{ display: none !important; }

/* ====== Level list ====== */
.level-list{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.level-card{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
}
.level-card:hover{ filter: brightness(0.98); }

.level-card__top{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.level-card__id{ font-weight: 800; }
.level-card__best{ color: var(--muted); font-size: 13px; }

.apm{
  font-weight: 800;
}
.apm--bad{ color: var(--bad); }
.apm--ok{ color: var(--text); }
.apm--good{ color: var(--good); }

.level-card__text{
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
}

/* ====== Trainer ====== */
.trainer-top{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.target-line{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 20px;
  line-height: 1.6;
  word-break: break-word;
}

.target-line .done{ color: var(--muted); }
.target-line .next{
  display: inline-block;
  padding: 0 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.target-line .rest{ color: var(--muted); }

.typed-line{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 18px;
  line-height: 1.6;
  word-break: break-word;
}
.typed-line .ok{ color: var(--text); }
.typed-line .bad{ color: var(--bad); font-weight: 700; }

.countdown{
  text-align: center;
  font-size: 44px;
  font-weight: 900;
  padding: 12px;
}

/* ====== Keyboard ====== */
.keyboard{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keyboard-row{
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.key{
  min-width: 34px;
  height: 42px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-weight: 700;
  font-size: 13px;
}

.key--w{ min-width: 48px; }
.key--ww{ min-width: 68px; }
.key--space{ min-width: 260px; }

.key--used{ background: var(--key-used); }
.key--next{ background: var(--key-next); }

/* ====== Modal ====== */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px;
}
.modal__title{ font-weight: 900; font-size: 18px; }
.modal__text{ margin-top: 8px; color: var(--muted); line-height: 1.4; }
.modal__actions{ margin-top: 12px; display: flex; justify-content: flex-end; gap: 10px; }

/* ====== Result screen ====== */
.result-big{
  font-size: 26px;
  font-weight: 900;
}
.result-sub{
  color: var(--muted);
}
