/* Inselreich 1800 – Gestaltung im Stil des 19. Jahrhunderts */
:root {
  --paper: #efe5cf;
  --panel: #fbf6ea;
  --line: #cdb88e;
  --ink: #2b2418;
  --muted: #6f6450;
  --navy: #1f2f47;
  --navy-2: #2c4366;
  --gold: #b8892d;
  --red: #a8322a;
  --green: #3f7a3a;
  --sea: #cfe0e6;
  --coast: #e8dcb8;
  --land: #e4d6ae;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(60, 40, 10, .12), 0 4px 14px rgba(60, 40, 10, .08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper) radial-gradient(ellipse at top, #f6eedb 0%, var(--paper) 60%) fixed;
  min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0 0 .5em; color: var(--navy); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; margin-top: .4em; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  background: var(--navy); color: #f3e9d2;
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 1.25rem; letter-spacing: .02em; }
.brand-mark { color: var(--gold); }
.status { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status > span { padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, .1); }
.status .mine { background: var(--gold); color: #1d1406; font-weight: 600; }
.status .endflag { background: #7a2a1e; }
.status .offline { background: var(--red); }
.status .code-pill { font-family: ui-monospace, monospace; letter-spacing: .1em; }
.top-actions { display: flex; gap: 8px; }
.topbar .btn.ghost { color: #f3e9d2; border-color: rgba(243, 233, 210, .4); }

/* ---------- Bedienelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; transition: background .15s, transform .05s;
}
.btn:hover:not(:disabled) { background: #f3e8cf; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #f7efdc; border-color: var(--navy); }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.mini { border: 1px solid var(--line); background: #fff8e6; border-radius: 4px; padding: 0 5px; cursor: pointer; font-size: .8rem; }
.mini:disabled { opacity: .45; cursor: not-allowed; }
input, select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fffdf6; color: var(--ink);
  max-width: 100%;
}
input:focus, select:focus, .btn:focus-visible, .action:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-weight: 500; }
.hint { color: var(--muted); font-size: .88rem; }
.center { text-align: center; }
.badge { font-size: .8rem; background: #efe2c2; border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; margin: 2px; border-radius: 99px; background: #f4ead2; border: 1px solid var(--line); font-size: .85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.error { color: var(--red); font-weight: 600; }
.ok { color: var(--green); font-weight: 600; }
.warn { color: #8a5a00; background: #fff1cc; padding: 6px 10px; border-radius: 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }

/* ---------- Startbildschirm ---------- */
.lobby { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 16px; }
.lobby-hero { text-align: center; padding: 10px 0 4px; }
.lobby-hero h1 { font-size: 2.4rem; }
.lobby-hero p { max-width: 640px; margin: 0 auto; color: var(--muted); font-size: 1rem; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lobby-grid .wide { grid-column: 1 / -1; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-family: ui-monospace, monospace; }
.code { font-family: ui-monospace, monospace; letter-spacing: .2em; font-size: 1.4rem; color: var(--navy); }
.game-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.game-item { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 6px; }
.game-item > span { flex: 1; }
.local-names { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.password-panel { max-width: 460px; margin: 0 auto; width: 100%; }
.password-panel input { flex: 1; }
.wait-players li { padding: 3px 0; font-size: 1.05rem; }

/* ---------- Spielbildschirm ---------- */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "main side" "bottom side";
  align-items: start;
  gap: 14px; padding: 14px;
  max-width: 1600px; margin: 0 auto;
}
.game.concealed { visibility: hidden; }
.col-main { grid-area: main; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col-side { grid-area: side; align-self: stretch; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col-bottom { grid-area: bottom; min-width: 0; }

.resources { display: flex; flex-wrap: wrap; gap: 6px; }
.res { padding: 3px 10px; border-radius: 99px; background: #f4ead2; border: 1px solid var(--line); }
.res.gold b { color: var(--gold); }

/* Bevölkerung */
.population { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.pop { border: 1px solid var(--line); border-top: 5px solid var(--tc); border-radius: 6px; padding: 6px 8px; background: #fffaf0; text-align: center; }
.pop-head { font-weight: 600; font-size: .85rem; color: var(--tc); }
.pop-avail { font-family: var(--serif); font-size: 1.8rem; line-height: 1.1; }
.pop-sub { font-size: .78rem; color: var(--muted); }

/* Inseln und Felder */
.island-wrap { display: flex; flex-direction: column; gap: 10px; }
.island { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: linear-gradient(180deg, #f6eed8, #efe3c4); }
.island.home { background: linear-gradient(180deg, #f3ead0, #eadcb6); }
.island-name { font-family: var(--serif); font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.grid.sea { margin-top: 6px; padding: 6px; border-radius: 8px; background: var(--sea); }
.space { min-height: 84px; border-radius: 6px; padding: 5px; text-align: center; border: 1px solid rgba(0, 0, 0, .12); position: relative; }
.space.empty { display: flex; align-items: center; justify-content: center; border-style: dashed; background: transparent; }
.space.empty.coast { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(90, 140, 160, .12) 6px 8px); }
.space.empty.sea { border-color: rgba(40, 90, 120, .35); }
.empty-label { color: var(--muted); font-size: .78rem; }
.space.ind { background: #fffaf0; border-top: 5px solid var(--tc); }
.space.ind.coast::after { content: "≈"; position: absolute; top: 2px; right: 5px; color: #5c8ea0; font-size: .8rem; }
.space.yard { background: #e9e3d3; border-top: 5px solid #6b5a3a; }
.space.ship { background: #f2f8fa; border-top: 5px solid #2f6f8f; }
.space.ship.explore { border-top-color: #6f5a2f; }
.ind-icon { font-size: 1.4rem; line-height: 1.2; }
.ind-name { font-weight: 600; font-size: .85rem; }
.ind-sub { font-size: .72rem; color: var(--muted); }
.slots { display: flex; justify-content: center; gap: 4px; margin-top: 4px; }
.slot { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .35); display: inline-block; padding: 0; }
button.slot { cursor: pointer; }
.slot.free { background: #fff; border-style: dashed; }
.newworld { background: linear-gradient(180deg, #eef3e2, #dfe9c9); }
.nw-isl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; }

/* Waren */
.good { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px 1px 4px; margin: 1px; border-radius: 99px; background: #fff; border: 1px solid var(--line); font-size: .8rem; white-space: nowrap; }
.good .gi { font-size: .95rem; }
.good.tier-bauer { border-color: #5a8f3c; }
.good.tier-arbeiter { border-color: #3a6ea5; }
.good.tier-handwerker { border-color: #b23a32; }
.good.tier-ingenieur { border-color: #7a4a9e; }
.good.tier-investor { border-color: #2a8c8c; }
.good.tier-neuewelt { border-color: #9a6b2f; background: #fbf1dc; }
.cost { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.free { color: var(--green); font-size: .85rem; }
.dot { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; color: #fff; font-size: .65rem; font-weight: 700; vertical-align: middle; }

/* Aktionen */
.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fffaf0; cursor: pointer; text-align: left; color: var(--ink);
}
.action:hover:not(:disabled) { background: #f6ebcf; border-color: var(--gold); }
.action:disabled { opacity: .45; cursor: not-allowed; }
.a-title { font-weight: 600; }
.a-sub { font-size: .75rem; color: var(--muted); }
.end-turn { grid-column: 1 / -1; padding: 10px; font-size: 1rem; margin-top: 4px; }

/* Karten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cards.small { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); max-height: 380px; overflow: auto; }
.card {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line); border-top: 6px solid var(--tc); border-radius: 7px;
  background: #fffdf7; padding: 6px 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.card.used { opacity: .6; background: #f3eee2; }
.card.selected { outline: 3px solid var(--gold); }
.cards.pick .card { cursor: pointer; }
.card-head { display: flex; justify-content: space-between; font-size: .72rem; color: var(--tc); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card-pts { color: var(--gold); }
.card-name { font-family: var(--serif); font-weight: 600; font-size: .98rem; }
.card-effect { font-size: .8rem; color: var(--muted); }
.card-foot { margin-top: auto; padding-top: 4px; }
.card-foot .btn { width: 100%; }

/* Expeditionen und Aufträge */
.expeditions { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.xcard { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fffaf0; font-size: .85rem; }
.xfield { display: inline-flex; align-items: center; gap: 4px; }
.objectives { display: flex; flex-direction: column; gap: 6px; }
.objective { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: #fffaf0; }
.objective.effect { background: #f2f6ee; }
.o-name { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.o-type { font-size: .72rem; color: var(--muted); font-weight: 400; }
.o-text { font-size: .85rem; color: var(--muted); margin: 2px 0 4px; }

/* Reiter unten */
.tabs { display: flex; gap: 4px; }
.tab { border: 1px solid var(--line); border-bottom: none; border-radius: 6px 6px 0 0; padding: 6px 14px; background: #eadfc4; cursor: pointer; color: var(--ink); }
.tab.active { background: var(--panel); font-weight: 600; }
.tab-panel { border-top-left-radius: 0; }
#tab-opponents { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.opp { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fffaf0; }
.opp.current { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184, 137, 45, .3); }
.opp-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 1rem; }
.opp-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .85rem; }
.opp-pop { display: flex; gap: 10px; margin: 4px 0; }
.opp-cube { display: inline-flex; align-items: center; gap: 2px; }
.opp-inds { margin: 4px 0; }
.opp details { margin-top: 4px; }
.opp summary { cursor: pointer; color: var(--navy); }
table.supply, table.score, table.tiers { border-collapse: collapse; width: 100%; }
table.supply th, table.supply td, table.score th, table.score td, table.tiers th, table.tiers td { padding: 4px 8px; border-bottom: 1px solid #e3d5b2; text-align: left; vertical-align: middle; }
table.supply tr.empty { opacity: .45; }
table.score tr.winner { background: #fbf0cf; font-weight: 600; }
.supply-misc { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.log { margin: 0; padding-left: 0; list-style: none; max-height: 320px; overflow: auto; }
.log li { padding: 3px 0; border-bottom: 1px dotted #e3d5b2; }
.log-r { display: inline-block; min-width: 32px; color: var(--muted); font-size: .8rem; }

/* ---------- Dialoge ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(25, 20, 10, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 50; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); width: min(560px, 100%); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 14px 16px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); }
.close { padding: 2px 8px; }
.pay-rows { display: flex; flex-direction: column; gap: 6px; }
.pay-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; }
.pay-row select { width: 100%; }
.build { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.build-sec { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fffaf0; display: flex; flex-direction: column; }
.build-sec .btn { margin-top: auto; }
.cost-line { margin: -4px 0 10px; font-size: .85rem; }
.rules ul { padding-left: 18px; }
.rules li { margin-bottom: 4px; }
.handover { text-align: center; font-size: 1.1rem; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--navy); color: #f7efdc; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- Kleine Bildschirme ---------- */
@media (max-width: 1100px) {
  .game { grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "side" "main" "bottom"; }
  .build { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .local-names { grid-template-columns: 1fr 1fr; }
  .population { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; }
  .pay-row { grid-template-columns: 1fr; }
}
