/*
 * SHOALS - "stara mapa" (art pass 2026-08-27). Dve latky: PERGAMEN (mapa,
 * hlavicka, panel rozkazu) a KUZE (listy pres mapu: replay, historie,
 * legenda). Pismo: IM Fell English (titulky, cisla poli - pismo map 17.
 * stoleti), Alegreya Sans pro UI a cisla. Tereni barvy mapy jsou natvrdo
 * v map.ts (string testy) - tady jen UI.
 */
:root {
  --paper: #e9dcb9;
  --paper-2: #dccb9f;
  --paper-3: #f3e9cd;
  --edge: #a58c5a;
  --ink: #2b1d12;
  --ink-2: #5c4a33;
  --rule: #2b1d1240;
  --leather: #2a1c12;
  --leather-2: #3d2a1a;
  --amber: #d9971a;
  --amber-ink: #7a4d00;
  --bad: #8c2f22;
  --ok: #3a6b3a;
  --font-ui: "Alegreya Sans", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --font-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
}

* { box-sizing: border-box; }
#app { min-height: 100%; }
html, body {
  margin: 0;
  height: 100%;
  background: #1a1109;
  color: var(--ink);
  font: 16px/1.35 var(--font-ui);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
h1 { font: 2.4rem/1.05 var(--font-display); margin: 0 0 .4rem; }
h2 { font: 1.5rem/1.1 var(--font-display); margin: .6rem 0 .2rem; }
h2 small { font: italic 1rem var(--font-display); color: var(--ink-2); margin-left: .4rem; }
h3 { font: 1rem var(--font-sc); letter-spacing: .06em; margin: 14px 0 6px; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
h3 small { font: italic .9rem var(--font-display); letter-spacing: 0; margin-left: .4rem; }
p { margin: .3rem 0; }
.hint { color: var(--ink-2); font-size: .9rem; }
.sub { color: var(--ink-2); font-size: .92rem; margin: 2px 0 8px; }
.error { color: var(--bad); font-weight: 700; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

button, .primary {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--paper-3);
  color: var(--ink);
  font: 600 .95rem/1 var(--font-ui);
  cursor: pointer;
  box-shadow: 2px 2px 0 #2b1d1230;
}
button:hover:not(:disabled) { background: #fbf3dc; }
button:active:not(:disabled) { box-shadow: none; transform: translate(1px, 1px); }
button:disabled { opacity: .4; cursor: default; box-shadow: none; }
button.on { background: var(--ink); color: var(--paper); }
button.primary, a.primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  background: var(--ink); color: var(--paper); border-color: var(--ink);
  font: 700 1.05rem var(--font-ui); letter-spacing: .02em;
  text-decoration: none; box-shadow: none;
}
button.primary:hover:not(:disabled) { background: var(--leather-2); }
button.link { min-height: 32px; min-width: 0; padding: 0 4px; border: 0; background: transparent; box-shadow: none; color: var(--ink-2); text-decoration: underline; font-weight: 400; font-size: .9rem; }
button.mini { min-height: 34px; min-width: 40px; padding: 0 10px; font-size: .85rem; }
button.ib { min-height: 36px; min-width: 36px; padding: 0 8px; background: transparent; box-shadow: none; font-size: 1rem; }
input {
  min-height: 44px; width: 100%; padding: 0 10px;
  border: 1.5px solid var(--ink); border-radius: 2px;
  background: var(--paper-3); color: var(--ink); font: 400 1rem var(--font-ui);
}
label { display: block; margin: .6rem 0; font: 1rem var(--font-sc); letter-spacing: .05em; color: var(--ink-2); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: .3rem 0; }

/* prepinac delky partie */
.seg { display: flex; gap: 6px; margin-top: 4px; }
.seg-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; padding: 6px 4px; text-transform: none; letter-spacing: 0; }
.seg-btn small { font-weight: 400; color: var(--ink-2); font-size: .8rem; }
.seg-btn.on small { color: inherit; opacity: .8; }
/* zvonek: odber zapnuty = jantar */
.ib.bell.on { color: var(--amber-ink); }
.bell-note { position: fixed; top: 52px; left: 0; right: 0; z-index: 9; padding: 6px 12px; background: var(--paper-3); border-bottom: 1.5px solid var(--ink); font-size: .85rem; text-align: center; animation: slidedown-in .25s ease-out both; }
.bell-note[hidden] { display: none; }
@keyframes slidedown-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* --- landing / pristav --------------------------------------------------- */
.landing { position: relative; min-height: 100%; background: var(--night, #1a1109); }
.landing .lang { z-index: 3; }
.demo { position: relative; overflow: hidden; background: #d8c69b; }
.demo-map { display: block; width: 100%; height: 100%; pointer-events: none; }
.hero { position: relative; min-height: 78vh; display: grid; align-items: end; }
.hero .demo { position: absolute; inset: 0; }
.hero .demo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #1a110900 30%, #1a1109cc 100%); }
.hero-text { position: relative; z-index: 2; max-width: 34rem; padding: 24px 22px 28px; color: var(--paper); }
.hero-text h1 { font-size: clamp(3rem, 12vw, 5rem); color: var(--paper); text-shadow: 0 2px 0 #000a; }
.hero-text h1 em { display: block; font-style: italic; font-size: 1.25rem; color: var(--paper); opacity: .9; }
.hero-text .tide .lvl { stroke: var(--paper); } .hero-text .tide .water { fill: var(--paper); fill-opacity: .2; }
.hero-text .lead { font-size: 1.1rem; line-height: 1.45; margin: .6rem 0 1rem; }
.cta { display: inline-flex; padding: 0 26px; background: var(--amber); color: var(--ink); border-color: var(--amber); }
.features { list-style: none; margin: 0; padding: 20px 22px; display: grid; gap: 18px; color: var(--paper); background: var(--leather); }
.features li { border-top: 1px solid #6b5a3a; padding-top: 12px; }
.features h3 { font: 1.35rem var(--font-display); color: var(--paper); border: 0; margin: 0 0 4px; text-transform: none; letter-spacing: 0; }
.features p { margin: 0; opacity: .85; line-height: 1.4; }
.landing .sheet.enter { min-height: 0; margin: 0 auto; }
/* landing: the create form is a floating native dialog opened by the CTA */
dialog.sheet.enter { width: min(26rem, calc(100% - 32px)); padding: 18px 22px 22px; border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 12px 40px #000a; }
dialog.sheet.enter::backdrop { background: #1a1109b8; }
dialog.sheet.enter h2 { display: flex; align-items: center; justify-content: space-between; }
dialog.sheet.enter h2 .close { font: inherit; padding: 2px 6px; }
.landing .sheet.enter h2 { margin-top: 0; color: var(--ink); border-bottom: 1px solid var(--rule); padding-bottom: .25rem; }
.sheet.enter .hint, .sheet.lobby .hint { color: var(--ink-2); opacity: 1; }
.berth .ic { width: 1.3em; height: 1.3em; }
.invite .demo { height: 34vh; }
.invite .demo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #1a110900 40%, #1a1109 100%); }
.invite .sheet.enter { margin-top: -24px; position: relative; }
.lead { line-height: 1.45; }
/* pristav */
.lobby-page .demo { height: 30vh; }
.lobby-page .demo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #1a110900 40%, #1a1109 100%); }
.sheet.lobby { position: relative; margin-top: -24px; min-height: 0; }
.sheet.lobby h1 em { display: block; font-style: italic; font-size: 1.1rem; color: var(--ink-2); }
.setup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; padding: 10px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.setup div { display: flex; flex-direction: column; }
.setup dt { font: 1rem var(--font-sc); letter-spacing: .05em; color: var(--ink-2); }
.setup dd { margin: 0; font-weight: 700; }
.berths { list-style: none; padding: 0; margin: 8px 0; }
.berth { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--rule); color: var(--ink-2); }
.berth.on { color: var(--ink); font-weight: 600; }
.berth .dot { opacity: 1; border: 1.5px dashed var(--ink-2); background: transparent; }
.berth.on .dot { border: 1px solid #0004; }
.berth small { font-weight: 400; color: var(--ink-2); }
.berth span { flex: 1; }
.berth .rm { flex: 0 0 auto; }
.addbot { display: flex; gap: 6px; margin: 8px 0; }
.addbot select { flex: 1; }
.share-row { display: flex; gap: 6px; }
.share-row .copy { flex: 0 0 auto; }
.waiting { display: flex; align-items: center; gap: 10px; font-style: italic; color: var(--ink-2); margin-top: 1rem; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); animation: pulsedot 1.6s ease-in-out infinite; }
@keyframes pulsedot { 50% { opacity: .3; transform: scale(.7); } }
@media (min-width: 52rem) {
  .hero { min-height: 70vh; }
  .features { grid-template-columns: repeat(3, 1fr); padding: 28px max(22px, calc(50% - 30rem)); }
  .features li { border-top: 0; border-left: 1px solid #6b5a3a; padding: 0 0 0 14px; }
}

/* --- listy na pergamenu: Vstup / Lobby / Konec ---------------------------- */
.sheet.enter, .sheet.lobby, .sheet.end {
  position: relative; max-width: 30rem; min-height: 100%; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 22px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--paper);
  background-image: radial-gradient(ellipse at 30% 20%, #0000 55%, #8a6f3a2a), radial-gradient(ellipse at 80% 90%, #0000 50%, #8a6f3a33);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--edge), 0 0 80px #000c;
}
.sheet .primary { width: 100%; margin-top: 1.2rem; }
.lang { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 14px; min-height: 40px; min-width: 40px; font-size: .8rem; }
.enter h1 { font-size: 3rem; }
.enter h1 em { font-style: italic; display: block; font-size: 1.2rem; color: var(--ink-2); margin-top: .1rem; }
.tidemark { display: block; margin: .6rem 0 1rem; }
.players, .scores { list-style: none; padding: 0; margin: .5rem 0; }
.players li, .scores li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.scores li { counter-increment: rank; }
.scores li::before { content: counter(rank, upper-roman); font: 1.1rem var(--font-display); color: var(--ink-2); width: 1.6rem; }
.scores b { margin-left: auto; font: 1.3rem var(--font-display); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; opacity: .3; border: 1px solid #0004; }
.dot.on { opacity: 1; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink); }
.players .dot { opacity: 1; }
.share { font-size: .85rem; }
.winner { font: 1.6rem/1.2 var(--font-display); }

/* --- herni obrazovka ------------------------------------------------------ */
.map { position: fixed; inset: 0; width: 100%; height: 100%; background: #d8c69b; touch-action: none; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 7px) max(env(safe-area-inset-left), 12px) 7px max(env(safe-area-inset-right), 12px);
  background: var(--paper);
  background-image: radial-gradient(#0000 60%, #8a6f3a22);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--edge), 0 6px 20px #0008;
  font-size: .9rem;
}
.topbar .round { font: 1.25rem/1 var(--font-sc); letter-spacing: .04em; white-space: nowrap; }
.topbar .clock { margin-left: auto; color: var(--ink-2); white-space: nowrap; }
.dots { display: flex; gap: 5px; }

/* vodocet: kalendar prilivu jako schodovita cara - "ted" je ryska; tooltip s vypisem kol */
.cal { position: relative; display: inline-flex; cursor: help; }
.tide { display: inline-block; width: 112px; height: 26px; vertical-align: middle; }
.tide .lvl { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.tide .water { fill: #3e5566; fill-opacity: .2; }
.tide .now { stroke: var(--amber); stroke-width: 2; }
.tide .rule { stroke: var(--rule); stroke-width: 1; }
.tide.tidemark { width: 100%; height: 44px; }
.tide.mini { width: 24px; height: 20px; flex: 0 0 auto; }
.cal .tip { display: none; position: absolute; top: calc(100% + 10px); left: 0; z-index: 15; width: 17rem; padding: 10px 12px; background: var(--paper-3); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 #2b1d1240, 0 10px 30px #0008; font-size: .9rem; cursor: auto; }
.cal:hover .tip, .cal:focus-within .tip { display: block; }
.cal .tip > b { font: 1.2rem var(--font-display); }
.cal .tip ol { list-style: none; margin: 6px 0; padding: 0; }
.cal .tip li { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dashed var(--rule); }
.cal .tip li:first-child { font-weight: 700; }
.cal .tip p { margin: 8px 0 0; color: var(--ink-2); font-size: .85rem; }

/* panel: rukojet (vzdy) + list (rozbaleno) */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-height: 62vh; overflow-y: auto;
  background: var(--paper);
  background-image: radial-gradient(ellipse at 70% 100%, #0000 50%, #8a6f3a2a);
  border-top: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--edge), 0 -8px 28px #0009;
}
.handle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; font-size: .9rem; cursor: pointer; user-select: none; }
.panel.open .handle { border-bottom: 1px solid var(--rule); }
.handle .stat b { font-size: 1.05rem; margin-left: 3px; }
.handle .stat.amber b { color: var(--amber-ink); }
.handle .chip.upg { min-height: 34px; min-width: 40px; padding: 0 10px; margin-left: 6px; }
.handle .grip { margin-left: auto; font: 700 .8rem var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.ctx { padding: 8px 12px calc(env(safe-area-inset-bottom) + 12px); }
.ctx h2 { margin: 4px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px; }
.chip i { font-style: normal; font-size: 1.1rem; }
.chip small { font-weight: 400; color: var(--ink-2); }
.chip.on small, .chip.done small { color: inherit; opacity: .8; }
.chip.done { background: var(--paper-2); }
.upgrades .pair { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.upgrades .or { opacity: .6; font-size: .85em; }
.chip.locked { opacity: .45; }
.step { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 0 10px; padding: 8px 10px; background: #d9971a2a; border-left: 3px solid var(--amber); font-weight: 600; }
.step .btns { margin: 0; }
.step .link { margin-left: auto; }
.panel .amount { display: flex; align-items: center; gap: 8px; font: 400 .9rem var(--font-ui); letter-spacing: 0; color: var(--ink); }
.panel .amount input { width: 6rem; }
.sent { font-weight: 700; color: var(--ok); }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.queue li:hover { background: #d9971a22; }
.queue li .n { width: 1.6rem; font: 1rem var(--font-display); color: var(--ink-2); }
.queue li .link { margin-left: auto; }
.panel .primary { width: 100%; margin-top: 12px; }
.recap { border: 1.5px solid var(--ink); border-left-width: 5px; padding: 10px 12px; margin: 8px 0; background: var(--paper-3); }
.recap .warn { color: var(--bad); font-weight: 700; }
.recap ol { margin: 6px 0 10px; padding-left: 20px; }

.offline {
  position: fixed; top: calc(env(safe-area-inset-top) + 4px); left: 50%; transform: translateX(-50%); z-index: 50;
  padding: 6px 12px; border-radius: 2px; background: var(--bad); color: #fff; font-size: .85rem;
}
.offline[hidden] { display: none; }

/* --- mapa: selekce, dosazitelnost, popisky -------------------------------- */
.region { cursor: pointer; }
.own, .rose, .amber, .city, .harbor, .fort, .fleet, .order-arrow { pointer-events: none; }
/* Dosazitelnost = jantarovy obrys; kolo za obzorem slabsi. */
.region.reach { stroke: var(--amber); stroke-width: 2.5px; stroke-opacity: .25; }
.region.reach-1 { stroke-opacity: 1; }
.region.reach-2 { stroke-opacity: .6; }
.region.reach-3 { stroke-opacity: .35; }
/* az ZA .reach: stejna specificita, o vysledku rozhoduje poradi */
.region.selected, .region.reach.selected, .own.selected { stroke: var(--ink); stroke-width: 2.4px; stroke-opacity: 1; stroke-dasharray: 5 3; }
.region.hl { stroke: var(--amber); stroke-width: 3.5px; stroke-opacity: 1; }
/* vojsko za hrazi na zalite melcine - drzi se, ale je to more */
.region.seawall { stroke: var(--ink); stroke-dasharray: 3 3; stroke-width: 1px; stroke-opacity: .7; }
.rid { font: italic 8.5px var(--font-display); fill: var(--ink); fill-opacity: .65; pointer-events: none; user-select: none; }
.rid.sea { fill-opacity: .75; }
.strength { font: 700 12px var(--font-ui); fill: var(--ink); paint-order: stroke; stroke: var(--paper-3); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.cargo { font: 700 7.5px var(--font-ui); fill: var(--ink); }
.rose { opacity: .55; }
.rose text { font: 9px var(--font-sc); fill: var(--ink); }
.fleet.stranded { opacity: .6; }
.fleet.stranded .sail { fill: #bdb094; }

/* --- prekryvy nad mapou (kuze) -------------------------------------------- */
.overlay-host { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.overlay-host > * { pointer-events: auto; touch-action: pan-y; }

.replay-overlay {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--leather); color: var(--paper);
  border-top: 3px solid var(--amber);
  box-shadow: 0 -8px 30px #000b;
}
.replay-counter { font: .75rem var(--font-ui); letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.replay-text { font: 1.25rem/1.3 var(--font-display); white-space: pre-line; margin-bottom: 6px; }
.replay-buttons { display: flex; gap: 10px; justify-content: flex-end; }
.replay-buttons button { min-height: 44px; padding: 0 18px; background: transparent; color: var(--paper); border-color: var(--paper); box-shadow: none; }
.replay-buttons button:hover:not(:disabled) { background: #ffffff14; }
.replay-next { background: var(--amber) !important; border-color: var(--amber) !important; color: var(--ink) !important; font-weight: 700; }

.flash { fill: none; stroke-width: 3px; animation: pulse .7s ease-out forwards; pointer-events: none; }
.flash.battle-naval, .flash.battle-land { stroke: #b3261e; }
.flash.move { stroke: var(--amber); }
.flash.flash-stranded, .flash.flash-destroyed, .flash.flash-drowned { stroke: var(--ink); }
.flash.flash-landed, .flash.flash-displaced { stroke: #3a6b3a; }
.flash.terraform { stroke: #6d4a8a; }
@keyframes pulse { from { r: 4; opacity: 1; } to { r: 24; opacity: 0; } }

/* historie / legenda: list z kuze pres mapu */
.sheet { position: fixed; inset: 0; z-index: 40; overflow: auto; background: var(--leather); color: var(--paper); padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px); }
.sheet h2 { margin: 1.2rem 0 .5rem; color: var(--paper); border-bottom: 1px solid #6b5a3a; padding-bottom: .25rem; }
.sheet h2:first-child { margin-top: 0; }
.sheet .close { min-height: 44px; margin-top: 16px; background: transparent; color: var(--paper); border-color: var(--paper); box-shadow: none; }
.sheet .hint { color: var(--paper); opacity: .75; }
.hist-list, .legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.hist-list button { width: 100%; text-align: left; min-height: 44px; padding: 8px 12px; background: var(--leather-2); color: var(--paper); border-color: #6b5a3a; box-shadow: none; display: flex; align-items: center; gap: 12px; }
.hist-list button:hover:not(:disabled) { background: #4d3722; }
.hist-list .tide .lvl { stroke: var(--paper); } .hist-list .tide .water { fill: var(--paper); fill-opacity: .25; }
.hist-list b { font: 1.15rem var(--font-display); }
.hist-list small { display: block; font-weight: 400; opacity: .75; }
.legend li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.35; }
.legend .ic { flex: 0 0 36px; text-align: center; font-size: 1.2rem; }
.legend .tide .lvl { stroke: var(--paper); } .legend .tide .water { fill: var(--paper); fill-opacity: .25; }
.sw { display: inline-block; width: 30px; height: 20px; border: 1px solid #fff6; vertical-align: middle; }
.sw.deep { background: #dccaa2 repeating-linear-gradient(0deg, #0000 0 4px, #3e556699 4px 5px); }
.sw.sea { background: #d9c79c repeating-linear-gradient(0deg, #0000 0 4px, #3e556666 4px 5px); }
.sw.land { background: #efe3c3; }
.sw.owner { background: #efe3c3; box-shadow: inset 0 0 0 30px #a3352a33; border: 3px solid #a3352a; }
.sw.shoal { background: #e9dcb8 radial-gradient(#7a6640 .8px, #0000 1px) 0 0 / 5px 5px; }
.sw.unseen { background: #dccaa2; }

@media (min-width: 40rem) {
  .panel { left: 16px; right: auto; bottom: 16px; width: 29rem; border: 2px solid var(--ink); max-height: calc(100vh - 100px); }
  .panel.open .ctx { padding-bottom: 12px; }
  .replay-overlay { left: auto; right: 16px; bottom: 16px; width: 28rem; border: 1px solid #6b5a3a; border-top: 3px solid var(--amber); }
  .sheet { max-width: 34rem; left: auto; right: 0; border-left: 1px solid #6b5a3a; }
}
@media (max-width: 30rem) {
  /* lista se musi vejit na 360-390 px i s historii a napovedou - jinak jsou tlacitka vpravo mimo displej (telefon, 2026-08-28) */
  .topbar { gap: 6px; padding-left: max(env(safe-area-inset-left), 8px); padding-right: max(env(safe-area-inset-right), 8px); }
  .topbar .round { font-size: 1rem; }
  .topbar .tide { width: 72px; }
  .topbar .clock { font-size: .8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .ib { min-width: 32px; padding: 0 4px; }
  .topbar .dots { gap: 3px; }
  .handle { gap: 8px; font-size: .85rem; }
}
/* ikony: inkoustova linka, dedi barvu textu */
.ic { width: 1.25em; height: 1.25em; vertical-align: -.25em; flex: 0 0 auto; }
.chip .ic { width: 1.35em; height: 1.35em; }
.ib .ic { width: 1.4em; height: 1.4em; }
.legend .ic svg { width: 1.5em; height: 1.5em; }
.queue .link .ic { width: 1.1em; height: 1.1em; }
/* replay: zeton na trase a stopa */
.token { pointer-events: none; filter: drop-shadow(0 1px 1px #0006); }
.trail { fill: none; stroke: var(--amber); stroke-width: 2; stroke-dasharray: 4 3; pointer-events: none; animation: flow .5s linear infinite; }
.pop { pointer-events: none; animation: popup 1.4s ease-out forwards; }
.pop text { font: 700 13px var(--font-ui); fill: var(--amber-ink); paint-order: stroke; stroke: var(--paper-3); stroke-width: 3px; stroke-linejoin: round; }
@keyframes popup { 0% { opacity: 0; transform: translate(var(--tx, 0), 0) scale(.6); } 15% { opacity: 1; transform: scale(1.15); } 100% { opacity: 0; transform: translateY(-22px); } }
.shake { animation: shake .5s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes shake { 20% { transform: translate(-2px, 1px) rotate(-1deg); } 40% { transform: translate(2px, -1px) rotate(1deg); } 60% { transform: translate(-1.5px, 0); } 80% { transform: translate(1.5px, 0); } }

/* --- pohyb: slouzi mape, nerozptyluje ------------------------------------- */
.fleet .bob { animation: bob 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 80%; }
.fleet.stranded .bob { animation: none; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-1.2px) rotate(2deg); } }
.region.selected, .region.reach.selected, .own.selected { animation: march 1.2s linear infinite; }
@keyframes march { to { stroke-dashoffset: -16; } }
.order-arrow { animation: flow .8s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -12; } }
.region.reach-1 { animation: reachpulse 1.6s ease-in-out infinite; }
@keyframes reachpulse { 50% { stroke-opacity: .55; } }
.flash { stroke-width: 3px; animation: pulse .7s ease-out forwards; }
.tidewash { pointer-events: none; animation: wash 1.3s ease-in-out forwards; }
.tidewash.rising { fill: #3e5566; }
.tidewash.falling { fill: #e6d7b3; }
@keyframes wash { 0% { opacity: 0; transform: translateX(-30%); } 35% { opacity: .35; } 100% { opacity: 0; transform: translateX(30%); } }
.panel.open .ctx { animation: rise .28s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.handle .grip { transition: color .2s; }
.chip { transition: transform .12s, box-shadow .12s, background .12s; }
.chip:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 #2b1d1240; }
.replay-overlay { animation: slideup .35s cubic-bezier(.2,.8,.2,1) both; }
@keyframes slideup { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.replay-text.in { animation: inkin .45s ease-out forwards; }
@keyframes inkin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sheet { animation: fadein .25s ease-out both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.cal .tip { animation: fadein .18s ease-out both; }
.offline:not([hidden]) { animation: slidedown .3s ease-out both; }
@keyframes slidedown { from { transform: translate(-50%, -120%); } to { transform: translate(-50%, 0); } }
/* vstup: vodocet se sam vykresli */
.tidemark .lvl { stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 1.8s ease-out .2s forwards; }
.tidemark .water { opacity: 0; animation: fadein .8s ease-out 1.4s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.enter h1, .enter label, .enter .primary { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
.enter label { animation-delay: .15s; } .enter .primary { animation-delay: .3s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .flash { opacity: .8; }
  .tidemark .lvl { stroke-dashoffset: 0; } .tidemark .water { opacity: 1; }
  .replay-text.in { opacity: 1; }
  button:active:not(:disabled) { transform: none; }
}

/* --- konec hry: list nad finalni mapou ----------------------------------- */
.sheet.end-sheet { max-width: 34rem; }
.end-sheet .reason { opacity: .85; margin: .2rem 0 1rem; }
.end-sheet table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-variant-numeric: tabular-nums; }
.end-sheet th, .end-sheet td { padding: 6px 4px; border-bottom: 1px solid #6b5a3a; text-align: right; }
.end-sheet th:first-child, .end-sheet td:first-child { text-align: left; }
.end-sheet th { font-weight: 400; opacity: .7; font-size: .85rem; }
.end-sheet tr.win td { font-weight: 700; }
.end-sheet td .dot { opacity: 1; margin-right: 6px; vertical-align: middle; }
.end-sheet .actions { display: flex; flex-direction: column; gap: 8px; }
.hist-list .hold { display: flex; gap: 10px; flex-wrap: wrap; font-size: .85rem; opacity: .85; }
.hist-list .hold .dot { opacity: 1; width: 10px; height: 10px; margin-right: 3px; vertical-align: middle; }
.end-sheet .actions .primary { margin-top: 0; background: var(--paper); color: var(--ink); border-color: var(--paper); }
.end-sheet .actions .primary:hover:not(:disabled) { background: #fbf3dc; }
/* uzky displej: tabulka vysledku se nesmi rozjet do sirky (list je inset:0, zadny horizontalni scroll) */
.end-sheet { overflow-x: hidden; }
.end-sheet table { table-layout: fixed; }
.end-sheet th, .end-sheet td { padding: 6px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.end-sheet td:first-child { width: 38%; }
@media (max-width: 30rem) { .end-sheet th, .end-sheet td { font-size: .85rem; } .end-sheet h1 { font-size: 2rem; } }
