/* TECDOOR Tor-Stopp – Grundlayout */
:root {
  --blue: #003A7D;
  --blue2: #0a4fa3;
  --navy: #071a38;
  --orange: #FF9900;
  --orange2: #F9AD09;
  --ink: #13233f;
  --card: rgba(255, 255, 255, 0.985);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b2a55;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); -webkit-user-select: none; user-select: none;
  touch-action: manipulation; overscroll-behavior: none;
}
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

/* Bildschirme */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(12px + var(--sat)) calc(16px + var(--sar)) calc(12px + var(--sab)) calc(16px + var(--sal));
  overflow-y: auto; z-index: 10; background: rgba(4, 18, 42, 0.28);
  animation: fadeIn .25s ease;
}
#scr-start { background: linear-gradient(180deg, rgba(4,18,42,0) 0%, rgba(4,18,42,.15) 60%, rgba(4,18,42,.45) 100%); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.card {
  width: 100%; max-width: 460px; margin: auto; background: var(--card); border-radius: 22px;
  padding: 18px 18px 20px; box-shadow: 0 18px 50px rgba(0, 20, 60, .45); animation: pop .28s ease;
  display: flex; flex-direction: column; gap: 10px; border-top: 6px solid var(--orange);
}
.card-wide { max-width: 760px; }
.card-small { max-width: 340px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h2 { flex: 1; }
h1, h2 { margin: 0; color: var(--blue); }
h2 { font-size: 26px; }
.title { font-size: clamp(34px, 9vw, 48px); text-align: center; font-weight: 900; letter-spacing: -.5px; line-height: 1; }
.title span { color: var(--orange); }
.subtitle { margin: 0; text-align: center; font-size: 16px; color: #3b4d6b; }
.hint { margin: 0; color: #4a5a76; font-size: 15px; }
.small { font-size: 13px; color: #5a6880; margin: 0; }
p { margin: 0; line-height: 1.45; font-size: 16px; }

.logo-plate { background: #fff; border-radius: 14px; padding: 8px 12px; display: flex; justify-content: center; box-shadow: inset 0 0 0 1px #e3e8f0; }
.logo-plate img { width: 100%; max-width: 330px; height: auto; display: block; }
.logo-small img { max-width: 210px; }
/* 20-Jahre-Emblem und Hoermann Kompetenzcenter unter dem TECDOOR-Logo */
.logo-plate { flex-wrap: wrap; }
.logo-plate .marken { width: 100%; display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 6px; }
.logo-plate .marken img { width: auto; max-width: none; }
.logo-plate .marken .emblem { height: 58px; }
.logo-plate .marken .hkc { height: 40px; }
@media (max-height: 700px) and (orientation: landscape) { .logo-plate .marken .emblem { height: 44px; } .logo-plate .marken .hkc { height: 30px; } }

/* Buttons */
.btn {
  appearance: none; border: 0; border-radius: 16px; min-height: 56px; padding: 10px 16px;
  font: inherit; font-size: 19px; font-weight: 700; color: var(--blue); background: #e9eff8;
  cursor: pointer; transition: transform .08s ease, filter .15s ease; text-decoration: none;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  box-shadow: 0 3px 0 rgba(0, 40, 100, .18);
}
.btn:active { transform: translateY(2px) scale(.98); box-shadow: 0 1px 0 rgba(0,40,100,.18); }
.btn:hover { filter: brightness(1.04); }
.btn small { display: block; font-size: 13px; font-weight: 600; opacity: .85; }
.btn-main { background: linear-gradient(180deg, #ffb02e, var(--orange)); color: #fff; font-size: 23px; min-height: 64px; text-shadow: 0 1px 2px rgba(120,60,0,.4); box-shadow: 0 4px 0 #c46f00; }
.btn-pause { background: linear-gradient(180deg, #1a64c2, var(--blue)); color: #fff; flex-direction: column; gap: 0; box-shadow: 0 4px 0 #00244f; }
.btn-daily { background: #fff7e8; color: #8a4b00; border: 2px dashed var(--orange); font-size: 16px; flex-direction: column; gap: 0; min-height: 58px; }
.btn-daily.done { background: #e8f8ec; color: #1d6b36; border-color: #3cb371; }
.btn-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-small { flex-direction: column; gap: 2px; font-size: 24px; min-height: 66px; padding: 6px 4px; }
.btn-small span { font-size: 13px; }
.btn-ok { min-height: 48px; background: var(--blue); color: #fff; }
.btn-danger { background: #fde8e8; color: #a32020; font-size: 15px; min-height: 46px; }
.btn-link { margin-top: 4px; }
.back { appearance: none; border: 0; width: 46px; height: 46px; border-radius: 50%; background: #e9eff8; color: var(--blue); font-size: 34px; line-height: 1; cursor: pointer; padding: 0 0 4px; }
.chip { appearance: none; border: 0; border-radius: 999px; background: #e9eff8; color: var(--blue); font: inherit; font-weight: 700; padding: 8px 14px; cursor: pointer; min-height: 44px; }

.settings-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.seg { display: inline-flex; background: #e9eff8; border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { appearance: none; border: 0; background: transparent; border-radius: 999px; font: inherit; font-weight: 700; color: #4a5a76; padding: 8px 12px; cursor: pointer; min-height: 38px; font-size: 15px; }
.seg button.on { background: var(--blue); color: #fff; }
.seg-big { align-self: center; }
.seg-big button { font-size: 17px; padding: 10px 18px; }

.rank { background: #f1f5fb; border-radius: 14px; padding: 8px 12px; font-size: 14px; color: #3b4d6b; }
.rank b { color: var(--blue); }
.bar { height: 10px; background: #dbe4f1; border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange2), var(--orange)); border-radius: 99px; transition: width .8s ease; }

/* Spielliste */
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.game-card {
  appearance: none; border: 0; text-align: left; font: inherit; cursor: pointer; border-radius: 18px;
  padding: 12px; background: #f3f6fb; display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px;
  align-items: center; box-shadow: 0 3px 0 rgba(0,40,100,.14); color: var(--ink); min-height: 96px;
}
.game-card:active { transform: translateY(2px); }
.game-card .gicon { grid-row: span 3; width: 64px; height: 64px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 36px; background: var(--blue); }
.game-card.main { background: linear-gradient(135deg, #fff4df, #ffe2b0); grid-column: 1 / -1; }
.game-card.main .gicon { background: var(--orange); }
.game-card b { font-size: 19px; color: var(--blue); }
.game-card .gdesc { font-size: 14px; color: #4a5a76; line-height: 1.3; }
.game-card .gbest { font-size: 13px; color: #6a7894; }
.gstars { color: var(--orange); letter-spacing: 2px; }
.gstars .off { color: #c9d3e2; }

/* Anleitung */
.tut-cv { width: 100%; height: 190px; border-radius: 16px; background: #0d3366; display: block; }
.tut-steps { margin: 0; padding-left: 26px; font-size: 17px; line-height: 1.45; }
.tut-steps li { margin: 3px 0; }
.tut-ctrl { font-size: 14px; color: #4a5a76; background: #f1f5fb; border-radius: 12px; padding: 8px 12px; }

/* HUD */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--sat)) calc(10px + var(--sar)) 8px calc(10px + var(--sal)); pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-btn { appearance: none; border: 0; width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.92); color: var(--blue); font-size: 16px; font-weight: 900; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.25); letter-spacing: -2px; }
.hud-title { flex: 1; color: #fff; font-weight: 800; font-size: 18px; text-shadow: 0 2px 4px rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-info { display: flex; gap: 6px; }
.hud-chip { background: rgba(255,255,255,.92); border-radius: 14px; padding: 0 12px; height: 48px; display: flex; align-items: center; font-weight: 800; font-size: 19px; color: var(--blue); box-shadow: 0 3px 10px rgba(0,0,0,.25); white-space: nowrap; }
.hud-chip:empty { display: none; }
.hud-score { background: var(--orange); color: #fff; min-width: 70px; justify-content: center; font-size: 22px; }

/* Ende */
#endTitle { text-align: center; font-size: 30px; }
.end-game { text-align: center; color: #4a5a76; font-weight: 600; }
.end-score { text-align: center; font-size: 58px; font-weight: 900; color: var(--orange); line-height: 1; }
.stars { text-align: center; font-size: 40px; letter-spacing: 6px; line-height: 1; }
.stars span { display: inline-block; color: #d3dbe8; transform: scale(.6); transition: transform .35s cubic-bezier(.3,1.8,.5,1), color .2s; }
.stars span.on { color: var(--orange); transform: scale(1); }
.end-best { text-align: center; font-size: 16px; color: #3b4d6b; }
.end-daily { text-align: center; font-size: 15px; font-weight: 700; color: #1d6b36; }
.end-daily:empty, .end-badges:empty { display: none; }
.end-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.end-badges div { background: #fff4df; border: 1px solid #ffd28a; border-radius: 12px; padding: 6px 10px; font-size: 14px; font-weight: 700; color: #8a4b00; }
.xpbar { font-size: 14px; color: #3b4d6b; }
.name-entry label { font-weight: 700; color: var(--blue); font-size: 15px; }
.name-row { display: flex; gap: 8px; margin-top: 6px; }
.name-row input { flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 12px; border: 2px solid #c9d6ea; -webkit-user-select: text; user-select: text; }

/* Garage */
.design-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.design {
  appearance: none; border: 3px solid transparent; border-radius: 16px; background: #f3f6fb; padding: 8px; cursor: pointer;
  font: inherit; text-align: left; display: flex; flex-direction: column; gap: 6px; color: var(--ink);
}
.design canvas { width: 100%; height: auto; aspect-ratio: 1.3; border-radius: 10px; display: block; background: #ddd; }
.design b { font-size: 14px; color: var(--blue); line-height: 1.2; }
.design span { font-size: 12px; color: #5a6880; line-height: 1.25; }
.design.sel { border-color: var(--orange); background: #fff4df; }
.design.locked { opacity: .55; cursor: default; }
.design.locked b::before { content: "\1F512  "; }

/* Erfolge */
.badge-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.badge { display: flex; gap: 10px; align-items: center; background: #f3f6fb; border-radius: 14px; padding: 10px; }
.badge .bi { font-size: 30px; width: 44px; text-align: center; filter: grayscale(1); opacity: .45; }
.badge.on .bi { filter: none; opacity: 1; }
.badge b { display: block; font-size: 15px; color: var(--blue); }
.badge span { font-size: 13px; color: #5a6880; }
.badge.on { background: #fff4df; }

/* Rangliste */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { appearance: none; border: 0; border-radius: 999px; background: #e9eff8; font: inherit; font-weight: 700; color: var(--blue); padding: 8px 12px; cursor: pointer; font-size: 14px; }
.tabs button.on { background: var(--blue); color: #fff; }
.board-list { margin: 0; padding: 0; list-style: none; counter-reset: r; }
.board-list li { counter-increment: r; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; font-size: 17px; }
.board-list li:nth-child(odd) { background: #f3f6fb; }
.board-list li::before { content: counter(r) "."; width: 28px; font-weight: 800; color: var(--orange); }
.board-list li .n { flex: 1; font-weight: 700; }
.board-list li .d { font-size: 12px; color: #6a7894; }
.board-list li .s { font-weight: 900; color: var(--blue); }
.board-list li.me { outline: 2px solid var(--orange); }
.board-list .empty::before { content: ""; width: 0; }

/* Über */
.partner { display: flex; gap: 12px; align-items: center; background: #eef3fa; border-radius: 14px; padding: 10px; }
.partner img { width: 92px; height: auto; border-radius: 6px; flex: none; }
.partner p { font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%); z-index: 50;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: 90vw; text-align: center; animation: pop .25s ease;
}

@media (max-height: 700px) and (orientation: landscape) {
  .card-start { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .card-start .logo-plate, .card-start .title, .card-start .subtitle, .card-start .rank { grid-column: 1; }
  .card-start > .btn, .card-start .btn-row, .card-start .settings-row { grid-column: 2; }
  .card-start .logo-plate { grid-row: 1; } .card-start .title { grid-row: 2; } .card-start .subtitle { grid-row: 3; } .card-start .rank { grid-row: 4; }
  .card-start .btn-main { grid-row: 1; } .card-start .btn-pause { grid-row: 2; } .card-start .btn-daily { grid-row: 3; }
  .card-start .btn-row { grid-row: 4; } .card-start .settings-row { grid-row: 5; grid-column: 1 / -1; }
  .tut-cv { height: 130px; }
  .card { padding: 14px; gap: 8px; }
}
@media (max-width: 380px) {
  .btn-small span { font-size: 11px; }
  .seg button { padding: 8px 9px; font-size: 14px; }
}
