/* LOTSE — Seekarte und Brücke, Telefon zuerst. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #05080c;
  color: #cfdcea;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#view, #chart, #hud {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#chart { background: #071018; }
#hud { touch-action: none; }
.gone { display: none !important; }

#ui { position: fixed; inset: 0; pointer-events: none; }
.layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}
.layer.passthru { pointer-events: none; }
.layer.passthru button, .layer.passthru .box { pointer-events: auto; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- Hauptmenue */

#menu {
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% -10%, #123a4c 0%, transparent 55%),
    linear-gradient(#080e14, #05080c);
  touch-action: pan-y;
}
.menuwrap {
  max-width: 760px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 40px;
}
header h1 {
  font-size: clamp(34px, 8vw, 52px);
  letter-spacing: 0.18em;
  font-weight: 800;
  color: #e8f0f8;
}
header .tag { color: #7f93a8; margin: 6px 0 18px; }

.menubar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.counters { color: #9fb2c4; }
.counters b { color: #ffd020; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.lvl {
  text-align: left;
  background: #0e1620;
  border: 1px solid #23303e;
  border-radius: 10px;
  padding: 10px 12px;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "n t s" "b b b";
  gap: 2px 10px;
  align-items: baseline;
}
.lvl:active { background: #182534; }
.lvl.done { border-color: #2e5b3c; }
.lvl .n { grid-area: n; color: #5d7186; font-weight: 700; }
.lvl .t { grid-area: t; font-weight: 700; letter-spacing: 0.04em; font-size: 14px; }
.lvl .s { grid-area: s; color: #ffd020; font-size: 13px; }
.lvl .b {
  grid-area: b;
  color: #74879b;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.endless { margin: 18px 0 8px; text-align: center; }
.endless .fine { margin-top: 8px; }

button.primary {
  background: #12506e;
  border: 1px solid #2f88b4;
  color: #dceafc;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 13px 22px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}
button.primary:active { background: #1a6c93; }
button.ghost {
  background: none;
  border: 1px solid #33404e;
  color: #74879b;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
footer { margin-top: 22px; }
.fine { color: #5d7186; font-size: 12px; line-height: 1.6; }

/* ----------------------------------------------------------------- Spiel */

.tabs {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}
.tab {
  background: rgba(12, 18, 26, 0.82);
  border: 1px solid #2b3949;
  color: #8ea3b8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tab.on { background: rgba(28, 74, 114, 0.9); border-color: #3d80b8; color: #dceafc; }

.corner {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
button.icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(14, 20, 28, 0.82);
  border: 1px solid #3a4654;
  color: #aebecd;
  font-size: 17px;
  cursor: pointer;
}
button.icon:active { background: rgba(40, 52, 66, 0.9); }

.brief {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 92vw);
  background: rgba(10, 15, 22, 0.88);
  border: 1px solid #33404e;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #b8c8d8;
  text-align: center;
  /* Wegtippbar — mit pointer-events:none lief der Handler in main.js ins Leere
     und der Kasten stand neun Sekunden ueber Bug und Liegeplatzfeld. */
  pointer-events: auto;
  cursor: pointer;
}

.brief.toast {
  /* Nie ueber einem Bedienelement: die Schlepperfelder liegen bei rund 60 %
     der Hoehe, das Bedienband darunter. Die Meldung sitzt deshalb oben. */
  top: 150px;
  bottom: auto;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 15px;
  pointer-events: none;
}
.brief.toast.bad { color: #ff6a58; border-color: #7a2b22; background: rgba(38, 12, 10, 0.92); }
.brief.toast.ok { color: #8fd9a8; border-color: #2e5b3c; }

/* ------------------------------------------------------ Auftragskarte ---- */
/* Gleiche Sprache wie das Instrumentenbrett in hud.js: Deckton, Messing fuer
   Sollwerte, Seeblau fuer Istwerte. Waehrend die Karte steht, ruht die
   Simulation und das Brett wird nicht gezeichnet — der Einstieg zeigt erst
   das Schiff, dann den Auftrag, dann die Instrumente. */

#briefing {
  display: flex;
  /* Unten, nicht mittig: ueber der Karte steht das Schiff, und das soll man
     beim Lesen sehen. Mittig deckte die Karte genau das zu, worum es geht. */
  align-items: flex-end;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 42%, rgba(4, 10, 16, 0.30) 0%, rgba(3, 7, 11, 0.86) 78%);
  overflow-y: auto;
  touch-action: pan-y;
}
#briefing .card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: rgba(7, 17, 26, 0.94);
  border: 1px solid #27404f;
  border-radius: 12px;
  padding: 16px 18px 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}
#briefing .kicker {
  color: #5d7486;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
}
#briefing h2 {
  color: #e7edf3;
  font-size: clamp(19px, 5.2vw, 25px);
  font-weight: 800;
  letter-spacing: 0.06em;
  margin: 3px 0 10px;
}
#briefing .rule { height: 1px; background: #27404f; margin: 0 0 11px; }
#briefing p.text {
  color: #b8c8d8;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 4px;
}
#briefing .cond {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 13px 0 4px;
}
#briefing .cell {
  background: #0b1a26;
  border: 1px solid #2d4a5d;
  border-radius: 8px;
  padding: 7px 9px;
}
#briefing .cell .k {
  color: #5d7486;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
#briefing .cell .v {
  color: #5fbfe8;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}
#briefing .cell .u { color: #8aa2b6; font-size: 10px; font-weight: 600; white-space: nowrap; }
#briefing .cell.warn .v { color: #f0b544; }
#briefing .hint {
  color: #5d7486;
  font-size: 11.5px;
  line-height: 1.5;
  margin-top: 11px;
}
#briefing button {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: #12506e;
  border: 1px solid #2f88b4;
  color: #dceafc;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 15px;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
}
#briefing button:active { background: #1a6c93; }

/* Quer ist die Hoehe knapp: Text und Kacheln nebeneinander. */
@media (orientation: landscape) and (max-height: 460px) {
  #briefing .card { width: min(680px, 100%); padding: 12px 14px 14px; }
  #briefing h2 { margin-bottom: 7px; }
  #briefing .cond { grid-template-columns: repeat(6, 1fr); margin: 9px 0 0; }
  #briefing p.text { font-size: 13px; }
  #briefing .hint { display: none; }
  #briefing button { margin-top: 10px; padding: 11px; }
}

/* ------------------------------------------------------------- Auswertung */

#result { display: flex; align-items: flex-start; justify-content: center; }
#result .box {
  margin-top: max(64px, env(safe-area-inset-top));
  background: rgba(8, 13, 20, 0.93);
  border: 1px solid #33404e;
  border-radius: 12px;
  padding: 18px 22px;
  max-width: min(520px, 94vw);
  text-align: center;
}
#result h2 { letter-spacing: 0.08em; font-size: 20px; margin-bottom: 6px; }
#result h2.won { color: #58e08c; }
#result h2.lost { color: #ff5040; }
#result .stars { color: #ffd020; font-size: 24px; letter-spacing: 0.2em; }
#result .big { font-size: 26px; font-weight: 800; color: #e8f0f8; margin: 4px 0; }
#result p { margin: 4px 0; color: #9fb2c4; font-size: 13px; }
.btnrow { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.btnrow button {
  background: #16202c;
  border: 1px solid #3a4a5c;
  color: #cfdcea;
  padding: 11px 16px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}
.btnrow button.primary { background: #12506e; border-color: #2f88b4; }

#fatal { background: #080b10; display: flex; align-items: center; justify-content: center; }
#fatal .box { max-width: 90vw; }
#fatal pre { text-align: left; color: #74879b; font-size: 11px; margin-top: 10px; white-space: pre-wrap; }
