/* Mereröövel — mängulava on oma meresinise paletiga; kaardid (algus, paus, ülesanne)
   järgivad saidi heledat/tumedat teemat (minimal_head seab data-theme). */
:root {
  --mr-card-bg: #fffaf0;
  --mr-card-text: #2b1d0e;
  --mr-card-muted: #6b5640;
  --mr-card-border: #d9c29c;
  --mr-accent: #b5401f;
  --mr-accent-hover: #962f12;
  --mr-accent-text: #ffffff;
  --mr-ghost-text: #5b3a1a;
  --mr-chip-bg: rgba(255, 250, 240, 0.92);
  --mr-chip-text: #2b1d0e;
  --mr-kbd-bg: #f1e4cc;
  --mr-kbd-border: #c8ad80;
  --mr-ok: #1f7a35;
  --mr-bad: #b42318;
  --mr-backdrop: rgba(10, 30, 50, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --mr-card-bg: #182434;
    --mr-card-text: #f3ead8;
    --mr-card-muted: #b9ab93;
    --mr-card-border: #3a4c63;
    --mr-accent: #e0683f;
    --mr-accent-hover: #f07d55;
    --mr-accent-text: #1a0f06;
    --mr-ghost-text: #f0d9b5;
    --mr-chip-bg: rgba(24, 36, 52, 0.9);
    --mr-chip-text: #f3ead8;
    --mr-kbd-bg: #24364b;
    --mr-kbd-border: #4b6382;
    --mr-ok: #6fd68a;
    --mr-bad: #ff8a7a;
    --mr-backdrop: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --mr-card-bg: #182434;
  --mr-card-text: #f3ead8;
  --mr-card-muted: #b9ab93;
  --mr-card-border: #3a4c63;
  --mr-accent: #e0683f;
  --mr-accent-hover: #f07d55;
  --mr-accent-text: #1a0f06;
  --mr-ghost-text: #f0d9b5;
  --mr-chip-bg: rgba(24, 36, 52, 0.9);
  --mr-chip-text: #f3ead8;
  --mr-kbd-bg: #24364b;
  --mr-kbd-border: #4b6382;
  --mr-ok: #6fd68a;
  --mr-bad: #ff8a7a;
  --mr-backdrop: rgba(0, 0, 0, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0f3b5c;
  font-family: 'Fredoka', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
main#sisu { display: block; width: 100%; height: 100%; outline: none; }
#game { width: 100%; height: 100%; }
canvas { display: block; }
[hidden] { display: none !important; }

/* HUD */
#hud {
  position: fixed; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 8px;
  pointer-events: none; z-index: 10;
}
.hud-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--mr-chip-bg); color: var(--mr-chip-text);
  border-radius: 999px; padding: 6px 14px;
  font-size: 20px; font-weight: 600; line-height: 1.2;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  white-space: nowrap;
}
.chip b { font-weight: 700; }
#coins-chip.low { color: #fff; background: #c0392b; }
#holes-chip { color: #fff; background: #1f6fb2; }
#carry-chip { color: #fff; background: #2b2b2b; }
.hud-btn {
  pointer-events: auto; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--mr-chip-bg); color: var(--mr-chip-text);
  font-size: 20px; box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
}
/* pausiikoon on SVG, mitte fondimärk ⏸ — märgi asukoht ringis sõltus seadme fondist */
.hud-btn svg { display: block; fill: currentColor; }
/* täisekraani nupp: sees olles „kokku" ikoon */
#fs-btn .fs-out, #fs-btn[aria-pressed="true"] .fs-in { display: none; }
#fs-btn[aria-pressed="true"] .fs-out { display: inline; }
.hud-btn:focus-visible { outline: 3px solid #f6c445; outline-offset: 2px; }
/* muusika väljas: läbikriipsutatud noot */
#music-btn { position: relative; }
#music-btn.off { opacity: 0.6; }
#music-btn.off::after {
  content: ''; position: absolute; left: 10px; right: 10px; top: 50%; height: 3px;
  background: #c0392b; transform: rotate(-35deg); border-radius: 2px;
}

.boat-warn {
  position: fixed; top: 50%; z-index: 9; pointer-events: none;
  background: rgba(192, 57, 43, 0.92); color: #fff;
  font-size: 22px; font-weight: 700; padding: 8px 12px; border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  animation: mr-pulse 0.9s ease-in-out infinite alternate;
}
#boat-warn-l { left: 10px; }
#boat-warn-r { right: 10px; }
#island-warn { left: 10px; background: rgba(31, 122, 53, 0.92); }
#harbor-warn { right: 10px; background: rgba(29, 78, 137, 0.92); }
/* lipuvaras mastis: väike silt vasakul HUD-kiipide all (▲ lipp + sekundid järgmise mündi kaoni, setFlagWarn).
   Varem lai pulseeriv silt üleval keskel — varjas mängu (kasutaja 2026-10-23); seletus on häälega ja all teates. */
#flag-warn {
  top: 60px; left: 10px; animation-name: mr-blink;
  font-size: 17px; padding: 4px 10px; text-align: center; width: max-content;
  background: rgba(150, 30, 20, 0.92); border: 2px solid #f6c445;
}
#flag-warn > span:first-child { font-size: 18px; }
@keyframes mr-blink { from { opacity: 1; } to { opacity: 0.7; } }
@media (max-height: 480px) { #flag-warn { font-size: 15px; padding: 3px 8px; } #flag-warn > span:first-child { font-size: 15px; } }
/* kitsal ekraanil murdub HUD kahele reale — silt nuppude alla */
@media (max-width: 480px) { #flag-warn { top: 104px; } }
@keyframes mr-pulse-x { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.12); } }
@keyframes mr-pulse { from { transform: translateY(-50%) scale(1); } to { transform: translateY(-50%) scale(1.12); } }

#message {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: rgba(15, 30, 45, 0.85); color: #fff;
  padding: 10px 20px; border-radius: 14px;
  font-size: 20px; font-weight: 600; text-align: center;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 11;
}
#message.show { opacity: 1; }
/* teadaanne pärgamendirullil (kasutaja valik 2026-10-11): helebeež leht, rullid otstes; mängu kunsti osa,
   seega teemast (hele/tume) sõltumatu nagu mänguväli ise */
#banner {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(0.8);
  color: #3b2410; font-size: clamp(24px, 5.4vw, 58px); font-weight: 700; line-height: 1.15; text-align: center;
  padding: 10px 44px 13px; max-width: calc(100vw - 48px); width: max-content;
  background: radial-gradient(ellipse at center, #fbf1d5 0%, #f2dcaa 68%, #e0c086 100%);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.38), inset 0 0 22px rgba(140, 90, 30, 0.35);
  text-shadow: 0 1px 0 rgba(255,255,255,0.55);
  opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 11;
}
#banner::before, #banner::after {
  content: ''; position: absolute; top: -7px; bottom: -7px; width: 22px; border-radius: 11px;
  background: linear-gradient(90deg, #a77a3e, #f3dfae 45%, #a77a3e);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}
#banner::before { left: -11px; }
#banner::after { right: -11px; }
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Ülekatted */
/* püsttsentreerimine .card { margin: auto } kaudu, mitte align-items: center — see lõikas ekraanist
   kõrgema akna ülaosa ära nii, et sinna ei saanud kerida (sadama pood 1024 x 600, 2026-10-11) */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px; overflow-y: auto;
  background: var(--mr-backdrop);
}
#start-screen { background: linear-gradient(180deg, rgba(10,40,70,0.75), rgba(10,40,70,0.9)); }
.card {
  position: relative;
  background: var(--mr-card-bg); color: var(--mr-card-text);
  border: 2px solid var(--mr-card-border);
  border-radius: 20px; padding: 28px 28px 22px;
  width: 100%; max-width: 620px; margin: auto;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.home-link {
  align-self: flex-start;
  color: var(--mr-ghost-text); text-decoration: none; font-weight: 600; font-size: 15px;
}
.home-link:hover, .home-link:focus-visible { text-decoration: underline; }
.title-big { font-size: clamp(28px, 6vw, 44px); line-height: 1.1; font-weight: 700; }
.lead { font-size: 18px; line-height: 1.4; }
.lead.small { font-size: 16px; color: var(--mr-card-muted); }
/* vihjed vasakule joondatud; rippuv taane — teine rida algab teksti, mitte emoji alt */
.tip { font-size: 15px; color: var(--mr-card-muted); align-self: stretch; text-align: left; padding-left: 1.7em; text-indent: -1.7em; margin: 0; }

.levels { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; }
.level-btn {
  flex: 1 1 150px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 12px; border-radius: 14px; cursor: pointer;
  background: transparent; color: var(--mr-card-text);
  border: 2px solid var(--mr-card-border); font: inherit;
}
.level-btn[aria-checked="true"] { border-color: var(--mr-accent); box-shadow: inset 0 0 0 2px var(--mr-accent); }
.level-btn:focus-visible { outline: 3px solid #f6c445; outline-offset: 2px; }
.lv-name { font-size: 19px; font-weight: 700; }
.lv-desc { font-size: 15px; color: var(--mr-card-muted); }
.lv-best { font-size: 14px; color: var(--mr-card-muted); min-height: 1.2em; }

.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--mr-accent); color: var(--mr-accent-text);
  border: 0; border-radius: 14px; padding: 12px 28px;
  font: inherit; font-size: 22px; font-weight: 700; cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(0,0,0,0.25);
  transition: background 0.15s, transform 0.1s;
}
.big-btn:hover { background: var(--mr-accent-hover); }
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.big-btn:focus-visible, .ghost-btn:focus-visible { outline: 3px solid #f6c445; outline-offset: 3px; }
.big-btn kbd, .ghost-btn kbd { font-size: 13px; }
/* lõpuekraani lukk: nupp on tuhm ja täitub ooteribaga (OVER_LOCK_MS app.js-is) */
.big-btn:disabled, .ghost-btn:disabled { cursor: default; }
.big-btn:disabled:hover { background: var(--mr-accent); }
.big-btn.waiting { position: relative; overflow: hidden; opacity: 0.6; }
.big-btn.waiting::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 5px; width: 100%;
  background: #f6c445; transform-origin: left; animation: mr-wait 3s linear forwards;
}
@keyframes mr-wait { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ghost-btn {
  background: transparent; color: var(--mr-ghost-text);
  border: 2px solid var(--mr-card-border); border-radius: 12px;
  padding: 8px 18px; font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--mr-accent); }

/* klahvijuhend: vasakule joondatud veerg (üks klahv/tegevus real) */
.keys {
  list-style: none; display: flex; flex-direction: column; align-items: flex-start; align-self: stretch;
  gap: 6px; font-size: 15px; color: var(--mr-card-muted); text-align: left; margin: 0; padding: 0;
}
/* ühe mängija juhend kahes veerus (lühikesed read) — algekraan mahub nii sülearvuti ekraanile */
#keys-solo, #keys-touch { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 16px; }
kbd {
  display: inline-block; min-width: 1.7em; padding: 1px 6px; margin-right: 2px;
  background: var(--mr-kbd-bg); color: var(--mr-card-text);
  border: 1px solid var(--mr-kbd-border); border-bottom-width: 3px; border-radius: 6px;
  font-family: inherit; font-weight: 600; font-size: 14px; text-align: center;
}
#loading { font-size: 15px; color: var(--mr-card-muted); min-height: 1.2em; }

.record { color: var(--mr-accent); font-weight: 700; }

/* kahe mängija klahvijuhend: numbrimärk (sama number kui algekraani „1./2. mängija" valikutel) */
.who { display: inline-block; min-width: 1.6em; padding: 0 5px; border-radius: 6px; color: #1a1a1a; font-weight: 700; text-align: center; }
.who1 { background: #f6c445; }
.who2 { background: #7ed957; }

/* oma laev */
.custom {
  width: 100%; border: 2px solid var(--mr-card-border); border-radius: 14px; padding: 8px 14px;
}
/* <details> ei ole kõigis brauserites flex-konteiner — vahed marginaaliga */
.custom > * + * { margin-top: 8px; }
.custom[open] { padding-bottom: 12px; }
.custom-title {
  font-weight: 700; font-size: 17px; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px;
}
.custom-title::-webkit-details-marker { display: none; }
.custom-title::after { content: '▸'; font-size: 14px; color: var(--mr-card-muted); transition: transform 0.2s; }
.custom[open] > .custom-title::after { transform: rotate(90deg); }
.custom-title:focus-visible { outline: 3px solid #f6c445; outline-offset: 3px; border-radius: 8px; }
.custom:not([open]):hover { border-color: var(--mr-accent); }
/* lipu, kübara ja nime eelvaade (joonistab app.js drawShipPreview) */
.ship-preview { display: block; width: 240px; max-width: 100%; height: auto; aspect-ratio: 240 / 124; margin: 0 auto; border-radius: 12px; }
.custom-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 15px; }
#ship-name {
  flex: 1 1 180px; min-width: 0; max-width: 260px; font: inherit; font-size: 16px; padding: 6px 10px; border-radius: 10px;
  border: 2px solid var(--mr-card-border); background: var(--mr-kbd-bg); color: var(--mr-card-text);
  -webkit-user-select: text; user-select: text; text-transform: uppercase;
}
#ship-name::placeholder { text-transform: none; }
#ship-name:focus, .admin-num:focus { outline: none; border-color: var(--mr-accent); }
/* admini testistart (näha ainult adminile) */
.admin-num {
  width: 90px; font: inherit; font-size: 16px; padding: 6px 10px; border-radius: 10px;
  border: 2px solid var(--mr-card-border); background: var(--mr-kbd-bg); color: var(--mr-card-text);
  -webkit-user-select: text; user-select: text;
}
.admin-box .lead.small { margin: 0; text-align: left; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 3px solid var(--mr-card-bg); box-shadow: 0 0 0 2px var(--mr-card-border);
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--mr-accent); }
.swatch:focus-visible { outline: 3px solid #f6c445; outline-offset: 3px; }
/* kahekesi: teise mängija kübara/papagoi värv on valimatu (läbikriipsutatud) */
.swatch { position: relative; }
.swatch:disabled { cursor: not-allowed; opacity: 0.35; }
.swatch:disabled::after {
  content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 3px; margin-left: -1.5px;
  background: var(--mr-card-text); transform: rotate(45deg); border-radius: 2px;
}
.custom-row[hidden] { display: none; }
/* tegelase valik: pea pisipilt (app.js figPaint) */
.swatch.figure { width: 44px; height: 44px; border-radius: 12px; background: var(--mr-kbd-bg); overflow: hidden; }
.swatch.figure canvas { display: block; width: 38px; height: 38px; margin: 0 auto; }

/* lõpuekraan: proovi uuesti saarelt (viimane saar + kontrollpunktid) */
.retry-box { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.retry-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.start-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#start-btn:not(:only-child) { background: transparent; color: var(--mr-ghost-text); border: 2px solid var(--mr-card-border); box-shadow: none; font-size: 18px; }
#continue-btn[hidden] + #start-btn { background: var(--mr-accent); color: var(--mr-accent-text); }

/* Kõik kaardid ühe suurusega (kasutaja soov 2026-10-11): ruudustik, read võrdse kõrgusega
   (grid-auto-rows: 1fr), kaardil ikoon + nimi üleval, kirjeldus kuni 3 rida, hind alati all */
.shop-card { max-width: 980px; gap: 10px; }
.shop-head { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 20px; }
.shop-coins {
  font-size: 24px; font-weight: 700; padding: 2px 14px; border-radius: 999px;
  background: var(--mr-kbd-bg); border: 1px solid var(--mr-kbd-border);
}
.shop-items {
  display: grid; gap: 8px; width: 100%;
  grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: 1fr;
}
/* 10 kaupa: laial 5 x 2 (ka telefon rõhtasendis — kaks rida mahub ekraanile), kitsamal 3 või 2 veergu */
@media (max-width: 639px) { .shop-items { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .shop-items { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shop-item {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr auto;
  grid-template-areas: 'ico name' 'desc desc' 'price price';
  gap: 4px 8px; align-items: center; text-align: left; min-width: 0;
  padding: 8px 12px; border-radius: 14px; cursor: pointer;
  background: transparent; color: var(--mr-card-text);
  border: 2px solid var(--mr-card-border); font: inherit;
}
.shop-item:not([aria-disabled="true"]):hover { border-color: var(--mr-accent); }
.shop-item:focus-visible { outline: 3px solid #f6c445; outline-offset: 2px; }
.shop-item[aria-disabled="true"] { cursor: default; opacity: 0.55; }
.shop-item.maxed { opacity: 0.5; border-style: dashed; }
.shop-item.maxed:hover { border-color: var(--mr-card-border); }
.si-icon { grid-area: ico; font-size: 26px; line-height: 1; justify-self: center; }
.si-name { grid-area: name; font-weight: 700; font-size: 17px; line-height: 1.15; min-width: 0; }
.si-desc {
  grid-area: desc; align-self: start; font-size: 14px; line-height: 1.3; color: var(--mr-card-muted);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
/* Hind ja tase eristuvad: mündid paksult, tase väikese tuhmi sildina */
.si-price { grid-area: price; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.si-cost { font-weight: 700; font-size: 16px; }
.si-lvl {
  font-size: 13px; font-weight: 600; color: var(--mr-card-muted);
  padding: 1px 8px; border-radius: 999px;
  background: var(--mr-kbd-bg); border: 1px solid var(--mr-kbd-border);
}
/* madal ekraan (sülearvuti brauseriaken): kompaktsem, juhtrida peidus (reegel tuleb ka ostu katsel teatena) */
@media (max-height: 760px) {
  .shop-card { padding-top: 14px; padding-bottom: 14px; gap: 8px; }
  .shop-card .title-big { font-size: 30px; }
  .shop-lead { display: none; }
  .shop-coins { font-size: 20px; }
  .shop-item { padding: 6px 10px; gap: 2px 8px; }
  .si-icon { font-size: 22px; }
  .si-name { font-size: 15px; }
  .si-desc { font-size: 12.5px; line-height: 1.25; }
  .si-cost { font-size: 15px; }
  .si-lvl { font-size: 12px; padding: 0 7px; }
  .shop-card .big-btn { font-size: 19px; padding: 8px 22px; }
}
/* telefon rõhtasendis (~360–430 px kõrge): kirjeldus kahele reale, et 5 x 2 + nupp mahuks ekraanile */
@media (max-height: 480px) {
  .shop-card { padding: 10px 14px; gap: 6px; }
  .shop-card .title-big { font-size: 22px; }
  .shop-coins { font-size: 17px; padding: 0 10px; }
  .shop-items { gap: 6px; }
  .shop-item { padding: 4px 8px; border-radius: 10px; }
  .si-icon { font-size: 18px; }
  .si-name { font-size: 14px; }
  .si-desc { font-size: 12px; line-height: 1.2; -webkit-line-clamp: 2; line-clamp: 2; }
  .si-cost { font-size: 14px; }
  .shop-card .big-btn { font-size: 17px; padding: 6px 18px; }
}

/* Aardekaart (saarel): vihje vasakul, kaart paremal; kitsal ekraanil üksteise all. Kaart on pärgament
   nagu #banner — mängu kunst, seega teemast sõltumatu (tume tekst heledal liival ka tumedas teemas). */
.tmap-card { max-width: 780px; gap: 10px; }
.tmap-body { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 22px; width: 100%; }
.tmap-side { flex: 1 1 230px; min-width: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.tmap-side .lead { font-weight: 600; }
.tmap-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 19px; font-weight: 700; }
.tmap-help { padding-left: 1.5em; text-indent: -1.5em; }
.tmap-digs { font-size: 15px; color: var(--mr-card-muted); margin: 0; }
.tmap-msg { font-size: 18px; font-weight: 700; min-height: 1.3em; margin: 0; color: var(--mr-accent); }
#tmap-skip, .tmap-say { align-self: flex-start; }
.tmap-mapbox {
  --cell: clamp(38px, 8.5vmin, 56px);
  display: grid; grid-template-columns: auto auto auto; grid-template-areas: '. n .' 'w g e' '. s .';
  align-items: center; justify-items: center; gap: 4px;
  padding: 10px; border-radius: 14px;
  background: radial-gradient(ellipse at center, #fbf1d5 0%, #f2dcaa 70%, #e0c086 100%);
  box-shadow: inset 0 0 18px rgba(140, 90, 30, 0.35);
  color: #3b2410;
}
.tm-dir { font-size: 14px; font-weight: 700; color: #6b4a1e; }
.tm-n { grid-area: n; } .tm-s { grid-area: s; } .tm-e { grid-area: e; } .tm-w { grid-area: w; }
.tm-w, .tm-e { writing-mode: vertical-rl; }
.tm-w { transform: rotate(180deg); }
/* esimene rida (A–E) on madal tähtede rida, ülejäänud ruudu kõrgused */
.tmap-grid { grid-area: g; display: grid; grid-template-columns: 20px repeat(5, var(--cell)); grid-template-rows: 22px repeat(5, var(--cell)); gap: 3px; }
.tm-head { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #6b4a1e; }
.tm-cell {
  width: var(--cell); height: var(--cell); padding: 0; cursor: pointer;
  font: inherit; font-size: calc(var(--cell) * 0.5); line-height: 1;
  background: #e8c98a; color: #3b2410;
  border: 2px solid #c79a55; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.tm-cell:hover { background: #f1d9a6; }
.tm-cell.cur { border-color: var(--mr-accent); box-shadow: 0 0 0 3px #f6c445; }
.tm-cell.dug { background: #c9a466; cursor: default; }
.tm-cell:focus-visible { outline: 3px solid #f6c445; outline-offset: 1px; }
@media (max-height: 480px) {
  .tmap-card { padding: 10px 14px; gap: 6px; }
  .tmap-card .title-big { font-size: 22px; }
  .tmap-mapbox { --cell: clamp(28px, 8.6vh, 40px); padding: 4px 6px; gap: 2px; }
  .tmap-grid { grid-template-rows: 18px repeat(5, var(--cell)); gap: 2px; }
  .tm-dir { font-size: 12px; }
  .tmap-side .lead { font-size: 16px; }
  .tmap-steps { font-size: 16px; }
  .tmap-help { display: none; }
  .tmap-card .ghost-btn { font-size: 15px; padding: 4px 14px; }
}

@media (max-width: 600px) {
  .card { padding: 20px 16px 18px; }
  .chip { font-size: 16px; padding: 5px 10px; }
  .big-btn { font-size: 19px; padding: 10px 20px; }
}
/* Puutejuhtimine (tahvel/telefon): nähtav ainult puuterežiimis mängu ajal (body.mr-touch.mr-playing).
   Nupud on poolläbipaistvad, et laeva nurgad (laoruumi kahurid) jääksid näha; ülekatted (z 20) on peal. */
#touch-pad { display: none; --tp: clamp(52px, 11vmin, 76px); }
body.mr-touch.mr-playing #touch-pad {
  display: flex; justify-content: space-between; align-items: flex-end;
  position: fixed; z-index: 12; pointer-events: none;
  left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
}
.tp-move, .tp-acts { display: grid; gap: 8px; pointer-events: none; }
.tp-move { grid-template-columns: repeat(3, var(--tp)); grid-template-areas: ". up ." "left down right"; }
.tp-acts { grid-template-columns: var(--tp) calc(var(--tp) * 1.25); align-items: end; }
.tp-btn {
  pointer-events: auto; touch-action: none; -webkit-touch-callout: none;
  width: var(--tp); height: var(--tp); border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(15, 30, 45, 0.38); color: #fff;
  font-size: calc(var(--tp) * 0.42); line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
.tp-btn.on { background: rgba(246, 196, 69, 0.75); border-color: #fff; transform: scale(0.94); }
.tp-up { grid-area: up; } .tp-left { grid-area: left; } .tp-down { grid-area: down; } .tp-right { grid-area: right; }
.tp-attack { width: calc(var(--tp) * 1.25); height: calc(var(--tp) * 1.25); }
body.mr-touch #game { touch-action: none; }
/* puuterežiimis teated üles (all on nupud) */
body.mr-touch.mr-playing #message { bottom: auto; top: calc(64px + var(--mr-flag-h, 0px)); }   /* lipuvarga sildi alla (setFlagWarn) */
/* püstiasend: kaamera mahutab maailma KÕRGUSE, kitsas ekraan näitaks vaid tükikest laevast */
#rotate-note { display: none; }
@media (orientation: portrait) {
  body.mr-touch.mr-playing #rotate-note {
    display: flex; position: fixed; inset: 0; z-index: 30;
    align-items: center; justify-content: center; padding: 16px;
    background: #0f3b5c;   /* läbipaistmatu: alla jääv pausikaart ei tohi läbi paista */
  }
}

@media (prefers-reduced-motion: reduce) {
  .boat-warn { animation: none; transform: translateY(-50%); }
  #flag-warn { opacity: 1; transform: none; }
  #banner, #message { transition: none; }
  .big-btn.waiting::after { animation: none; transform: scaleX(1); opacity: 0.5; }
}
