:root {
  --bg: #04101c;
  --panel: rgba(8, 20, 34, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --gold: #fbbf24;
  --text: #e2e8f0;
  --muted: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#minimap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 200px;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  image-rendering: pixelated;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#hud {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#board {
  position: fixed;
  right: 16px;
  top: 16px;
  min-width: 190px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#board h4 {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
#board .row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#board .row.me { color: var(--gold); font-weight: 700; }
#board .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#board .name { flex: 1; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
#board .num { color: var(--muted); min-width: 2.4em; text-align: right; }
#board .arrow { display: inline-block; width: 14px; text-align: center; color: var(--gold); }
#board[hidden] { display: none; }

#status {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(190, 40, 40, 0.85);
  font-size: 13px;
}

#join {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(4, 22, 40, 0.55), rgba(2, 8, 16, 0.92));
  backdrop-filter: blur(3px);
  z-index: 10;
}

#join[hidden], #hud[hidden], #status[hidden] { display: none; }

#join-form {
  width: min(92vw, 380px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 20, 34, 0.9);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

#join-form .kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

#join-form h1 { margin: 6px 0 4px; font-size: 30px; letter-spacing: -0.01em; }
#join-form .lead { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
#join-form label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }

#join-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #020a14;
  color: var(--text);
  font-size: 15px;
}

#join-form button {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--gold);
  color: #1c1204;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}
#join-form button:hover { filter: brightness(1.08); }
#join-form button:active { transform: scale(0.98); }
#join-form .keys { margin: 14px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

kbd {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  font-family: inherit;
  font-size: 11px;
}

/* --- Hafen-Oberfläche ------------------------------------------------------------ */
#shop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 8, 16, 0.55);
  backdrop-filter: blur(2px);
}
#shop[hidden] { display: none; }

#shop .panel {
  width: min(96vw, 980px);
  height: min(94vh, 680px); /* feste Größe: kein Springen beim Tabwechsel */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 20, 34, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 18px 20px 20px;
}
#shop header { flex: none; display: flex; align-items: center; gap: 18px; margin-bottom: 8px; }
#shop header > div:first-child { flex: 1; }
#shop .kicker { color: var(--gold); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; }
#shop h2 { margin: 2px 0 0; font-size: 26px; }
#shop h3 { margin: 9px 0 4px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#shop h3 small, #shop small { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
#shop h3:first-child { margin-top: 0; }
#shop .money { display: grid; text-align: right; font-weight: 800; font-size: 18px; color: var(--gold); }
#shop .money .muted, #shop .muted { color: var(--muted); font-weight: 600; font-size: 12px; }
#shop .cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; }
@media (max-width: 800px) { #shop .cols { grid-template-columns: 1fr; } }

#shop .cards { display: grid; gap: 8px; }
#shop .card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
#shop .card.current { border-color: rgba(251, 191, 36, 0.6); background: rgba(251, 191, 36, 0.07); }
#shop .card img { width: 44px; height: 62px; object-fit: contain; }
#shop .card h4 { margin: 0; font-size: 15px; }
#shop .card .blurb { margin: 2px 0; color: var(--muted); font-size: 12px; }
#shop .card .stats { margin: 0; font-size: 12px; font-variant-numeric: tabular-nums; }

#shop .row { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
#shop .row .grow { flex: 1; display: block; }
#shop .row .grow small { margin-left: 8px; }
#shop .row.bank { flex-wrap: wrap; border: 0; }
#shop .pips { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
#shop .pips i { width: 12px; height: 8px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); }
#shop .pips i.on { background: var(--gold); }

#shop button {
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--gold);
  color: #1c1204;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
}
#shop button:hover:not(:disabled) { filter: brightness(1.1); }
#shop button:active:not(:disabled) { transform: scale(0.97); }
#shop button:disabled { background: rgba(255, 255, 255, 0.1); color: var(--muted); cursor: not-allowed; }
#shop button.ghost { background: rgba(255, 255, 255, 0.1); color: var(--text); }
#shop .tabbody { flex: 1; min-height: 0; overflow: auto; }
#shop .tabs { flex: none; display: flex; gap: 6px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
#shop .tabs .tab { border-radius: 9px 9px 0 0; background: transparent; color: var(--muted); }
#shop .tabs .tab.on { background: rgba(251, 191, 36, 0.15); color: var(--gold); box-shadow: inset 0 -2px 0 var(--gold); }
#shop .tabs .tab:hover:not(:disabled) { color: var(--text); filter: none; }
#shop .tag { padding: 4px 9px; border-radius: 999px; background: rgba(251, 191, 36, 0.18); color: var(--gold); font-size: 12px; font-weight: 700; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.92);
  font-size: 14px;
}
#toast.bad { background: rgba(185, 28, 28, 0.92); }
#toast[hidden] { display: none; }

/* --- Hilfe ------------------------------------------------------------------------ */
#help-btn {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 7;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
#help-btn:hover { background: rgba(255, 255, 255, 0.12); }

#help {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 8, 16, 0.6);
  backdrop-filter: blur(2px);
}
#help[hidden] { display: none; }
#help .panel {
  width: min(96vw, 860px);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 20, 34, 0.97);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 18px 22px 22px;
}
#help header { display: flex; align-items: center; gap: 18px; margin-bottom: 8px; }
#help header > div:first-child { flex: 1; }
#help .kicker { color: var(--gold); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; }
#help h2 { margin: 2px 0 0; font-size: 24px; }
#help h3 { margin: 14px 0 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#help .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: 14px; line-height: 1.5; }
@media (max-width: 760px) { #help .cols { grid-template-columns: 1fr; } }
#help ul { margin: 0; padding-left: 18px; }
#help li { margin-bottom: 4px; }
#help table { border-collapse: collapse; width: 100%; }
#help td { padding: 4px 8px 4px 0; vertical-align: top; }
#help td:first-child { white-space: nowrap; }
#help .small { font-size: 12px; color: var(--muted); }
#help a { color: var(--gold); }
#help .vol { display: flex; align-items: center; gap: 12px; }
#help .vol input { flex: 1; }
#help button.ghost {
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
#join-form .credits { margin: 10px 0 0; text-align: center; color: #64748b; font-size: 11px; }

/* --- Nationen ------------------------------------------------------------------------ */
#nation {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 28, 0.88);
}
#nation[hidden] { display: none; }
#nation .panel {
  width: min(560px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
#nation h2 { margin: 0 0 6px; }
#nation-list { display: grid; gap: 8px; margin-top: 14px; }
#nation-list button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
#nation-list button:hover { background: rgba(255, 255, 255, 0.12); }
#nation-list img { width: 32px; height: 22px; image-rendering: pixelated; }
#nation-list .bonus { margin-left: auto; color: var(--muted); font-size: 13px; }

#territory {
  position: fixed;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 700;
  pointer-events: none;
}
#territory[hidden] { display: none; }

/* --- Ruf im Hafen ---------------------------------------------------------------------- */
.reps { display: grid; gap: 4px; margin-top: 8px; font-size: 13px; }
.reps .rep { display: flex; align-items: center; gap: 8px; }
.reps img { width: 18px; height: 12px; image-rendering: pixelated; }
.reps small { color: var(--muted); }
.hostile { padding: 16px 20px 24px; }
.hostile h3 { color: #fca5a5; margin-top: 0; }

/* --- Quest-Log ------------------------------------------------------------------------ */
#quest-log {
  position: fixed;
  left: 16px;
  top: 60px;
  width: 230px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}
#quest-log[hidden] { display: none; }
#quest-log h4 { margin: 0 0 2px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
#quest-log .q { padding: 4px 0; border-top: 1px solid var(--line); }
#quest-log .q:first-of-type { border-top: 0; }
#quest-log .q b { display: block; }
#quest-log .meta { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#quest-log .arrow { display: inline-block; width: 14px; text-align: center; color: var(--gold); }
.card h4, h4 { margin-top: 12px; }

/* --- Neu anfangen ---------------------------------------------------------------------- */
#restart-link {
  margin-top: 10px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
#restart-link:hover { color: var(--text); }
#join-form #restart-link { width: auto; padding: 0; border: 0; background: none; display: block; margin: 10px auto 0; font-weight: 400; }
#restart-link[hidden] { display: none; }
#restart {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 28, 0.88);
}
#restart[hidden] { display: none; }
#restart .panel {
  width: min(520px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
#restart h2 { margin: 0 0 8px; }
#restart ul { margin: 8px 0 12px; padding-left: 20px; line-height: 1.6; }
#restart .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
#restart button {
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}
#restart button.danger { background: #dc2626; color: #fff; }
#restart button:hover { filter: brightness(1.1); }

/* --- ESC-Menü -------------------------------------------------------------------------- */
#pause {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 28, 0.7);
  backdrop-filter: blur(2px);
}
#pause[hidden] { display: none; }
#pause .panel {
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
#pause h2 { margin: 0; }
#pause .note { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
#pause button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#pause button:hover { background: rgba(255, 255, 255, 0.14); }
#pause #pause-resume { background: var(--gold); border-color: transparent; color: #1c1204; font-weight: 700; }
#pause #pause-leave { color: #fca5a5; }
#pause .vol { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
#pause .vol input { flex: 1; }
