:root {
  --sea: #bfe4f3;
  --land: #f6efb0;
  --deep: #10394f;
  --rail: #164a63;
  --page: #e8f2f7;
  --ink: #17303f;
  --line: #b7cfdb;
  --teal: #137c91;
  --danger: #b3261e;
  --bar-h: 52px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: var(--bar-h) 1fr auto;
  height: 100dvh;
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}
button { font: inherit; }
:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }

.titlebar { display: flex; align-items: center; gap: .75rem; padding: 0 1rem; background: var(--deep); color: var(--land); }
.titlebar h1 { margin: 0; font: 700 1.4rem/1 "Palatino Linotype", "Book Antiqua", Georgia, serif; letter-spacing: .02em; }
.whoami { margin-left: auto; font-size: .95rem; display: inline-flex; gap: .4rem; align-items: center; color: #fff; }
.conn { background: var(--danger); color: #fff; border-radius: 99px; padding: .1rem .6rem; font-size: .8rem; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); flex: none; }
.sound-btn { background: transparent; border: 0; color: #fff; font-size: 1.25rem; cursor: pointer; padding: .2rem .4rem; border-radius: 8px; }
.sound-btn:hover { background: rgba(255,255,255,.16); }
.sound-btn[aria-pressed=false] { opacity: .55; }
.burger { display: none; background: transparent; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer; padding: .2rem .4rem; }

.layout { display: flex; min-height: 0; }
.menu { width: 58px; flex: none; background: var(--rail); display: flex; flex-direction: column; gap: .35rem; padding: .6rem .45rem; }
.menu-btn { position: relative; display: flex; align-items: center; gap: .75rem; width: 44px; height: 44px; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 1.35rem; cursor: pointer; }
.menu-btn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.menu-btn:disabled { opacity: .35; cursor: not-allowed; }
.menu-btn .lbl { display: none; font-size: .95rem; }
.menu-btn::after { content: attr(data-tip); position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); background: #000; color: #fff; font-size: .8rem; padding: .25rem .55rem; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60; }
.menu-btn:hover::after, .menu-btn:focus-visible::after { opacity: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel { margin: 1.5rem auto; width: min(560px, calc(100% - 2rem)); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.5rem 1.5rem; }
.panel h2 { margin-top: 0; font-family: "Palatino Linotype", Georgia, serif; }
.field { display: grid; gap: .3rem; margin-bottom: 1rem; font-weight: 600; }
input[type=text], input[type=number] { font: inherit; padding: .45rem .6rem; border: 1px solid #8fb0c0; border-radius: 6px; background: #fff; color: var(--ink); }
.colors { border: 0; padding: 0; margin: 0 0 1rem; }
.colors legend { font-weight: 600; padding: 0; margin-bottom: .35rem; }
.color-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4rem; }
.swatch { position: relative; display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch .dot { width: 22px; height: 22px; border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.swatch:has(input:checked) { border-color: var(--deep); background: #eef6fa; font-weight: 600; }
.swatch:has(input:focus-visible) { outline: 3px solid #f2a900; }
.swatch:has(input:disabled) { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.hint { color: #4a6575; font-size: .9rem; }
.error { color: var(--danger); margin: 0; padding: 0 1.25rem; min-height: 1.2em; }
.player-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; }
.player-list li { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; }
.player-list .dot { width: 20px; height: 20px; border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }

.btn { padding: .45rem .9rem; border: 1px solid #7fa4b5; border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover:not(:disabled) { background: #eaf4f9; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed=true] { background: var(--deep); color: #fff; border-color: var(--deep); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0f6677; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1e18; }

.board { display: flex; flex-direction: row; flex: 1; min-height: 0; }
.sidebar { width: 270px; flex: none; overflow-y: auto; background: #fff; border-right: 1px solid var(--line); }
.toolbar { display: flex; flex-direction: column; align-items: stretch; gap: .75rem; padding: .75rem; }
.turn-info { font-size: .9rem; color: #36586b; display: grid; gap: .15rem; }
.status-row { display: flex; align-items: center; gap: .5rem; }
.status-line { font-weight: 600; flex: 1; min-width: 0; }
.help-btn { width: 2rem; height: 2rem; padding: 0; border-radius: 50%; font-weight: 700; flex: none; }
.chips { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; }
.actions { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .1rem .6rem .1rem .3rem; border-radius: 99px; border: 2px solid transparent; background: var(--page); font-size: .9rem; }
.chip .dot { width: 16px; height: 16px; border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.chip.turn { border-color: var(--deep); font-weight: 600; }
.chip.out { opacity: .5; text-decoration: line-through; }
.log { background: #f6fafc; border-top: 1px solid var(--line); padding: .35rem .75rem; font-size: .88rem; }
.log summary { cursor: pointer; color: #36586b; }
.log ol { margin: .3rem 0 .4rem; padding-left: 1.2rem; max-height: 14rem; overflow: auto; }
.scroller { flex: 1; min-height: 0; overflow: auto; background: var(--sea); overscroll-behavior: contain; scrollbar-width: auto; scrollbar-color: #4b7a91 #d3e8f1; }
.map-content { position: relative; }
/* Das Canvas zeigt nur den sichtbaren Ausschnitt (klebt oben links im Scrollbereich); map-content liefert die Scrollgröße */
#map { position: sticky; left: 0; top: 0; display: block; cursor: crosshair; }

.info-page { max-width: 760px; width: 100%; margin: 1.5rem auto; padding: 0 1.25rem; }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--teal); font-weight: 600; }

.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1.5rem; padding: .6rem 1rem; background: #000; color: #c8d0d5; font-size: .85rem; }
.footer nav { display: flex; gap: 1.25rem; }
.footer a { color: #fff; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(920px, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); color: var(--ink); box-shadow: 0 12px 40px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(5, 25, 35, .55); }
#dlg-confirm { width: min(440px, calc(100vw - 1rem)); }
#dlg-settings { width: min(1400px, calc(100vw - 1rem)); }
.dlg-head { padding: .9rem 1.25rem 0; }
.dlg-head h2 { margin: 0; font-family: "Palatino Linotype", Georgia, serif; }
.dlg-body { padding: .75rem 1.25rem; max-height: 62dvh; overflow: auto; }
.dlg-foot .spacer { margin-right: auto; }
.hint.info { padding: 0 1.25rem; margin: .25rem 0; }
.zoombox { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.zoombox .btn { padding: .25rem .6rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.25rem 1rem; margin: 0; }
.dlg-body h3 { margin: 1rem 0 .4rem; }
.set-grid { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.set-grid label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
.set-grid input { width: 7.5rem; }
.table-wrap { overflow-x: auto; }
.type-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.type-table th { text-align: left; font-weight: 600; padding: .2rem .35rem; vertical-align: bottom; line-height: 1.2; }
.type-table td { padding: .2rem .25rem; }
.type-table input[type=text] { width: 10.5rem; }
.type-table input[type=number] { width: 4.6rem; }
.img-cell { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.img-cell .btn { padding: .2rem .5rem; font-size: .8rem; }
.type-img { width: 32px; height: 32px; object-fit: contain; background: #cfe7f3; border: 1px solid var(--line); border-radius: 6px; }

.toast { position: fixed; left: 50%; bottom: 3.5rem; transform: translate(-50%, 20px); max-width: min(90vw, 520px); background: #10212b; color: #fff; padding: .6rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .burger { display: block; }
  .menu { position: fixed; top: var(--bar-h); left: 0; bottom: 0; width: 230px; transform: translateX(-100%); transition: transform .2s; z-index: 70; padding: .75rem; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .menu-open .menu { transform: none; }
  .menu-btn { width: 100%; justify-content: flex-start; padding: 0 .75rem; }
  .menu-btn .lbl { display: inline; }
  .menu-btn::after { display: none; }
  .titlebar h1 { font-size: 1.15rem; }
  .board { flex-direction: column; }
  .sidebar { width: auto; max-height: 45%; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .menu, .toast { transition: none; }
}
