:root {
  --bg: #dfe9f0; --panel: #f6f1e7; --ink: #1d2b44; --muted: #6a7788;
  --water: #a8c4dd; --water-line: #ffffff88; --accent: #1d2b44; --accent-ink: #fff;
  --ship: #4a5568; --ship-edge: #2d3748; --hit: #e5484d; --miss: #ffffff; --warn: #c2410c;
  --radius: 14px; --cell: min(8.2vw, 44px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: Georgia, "Times New Roman", serif; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; max-width: 1100px; margin: 0 auto; }
#top h1 { font-size: 1.3rem; margin: 0; cursor: pointer; }
#top .who { font-size: .9rem; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 4px #0002; margin-bottom: 14px; }
h2 { margin: 0 0 10px; font-size: 1.15rem; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; min-height: 44px; }
.btn.alt { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input.txt { padding: 10px 12px; border-radius: 10px; border: 1px solid #0003; background: #fff; min-height: 44px; width: 100%; }
.form { max-width: 360px; margin: 30px auto; display: grid; gap: 10px; }
.err { color: var(--warn); min-height: 1.2em; font-size: .9rem; }
.muted { color: var(--muted); }
.list { display: grid; gap: 8px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: #fff8; border-radius: 10px; cursor: pointer; }
.item.mine { background: #fff; box-shadow: inset 4px 0 0 var(--hit); }
.tag { font-size: .8rem; padding: 2px 8px; border-radius: 99px; background: #0001; }
.tag.turn { background: var(--hit); color: #fff; }
.code { font-size: 2.2rem; letter-spacing: .25em; font-weight: bold; text-align: center; margin: 8px 0; user-select: all; }

/* brætter */
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.board-wrap h3 { margin: 0 0 6px; font-size: 1rem; }
.board { position: relative; width: 100%; max-width: 480px; aspect-ratio: 1; background: var(--water); border-radius: 10px; touch-action: none; user-select: none; overflow: hidden; }
.board .grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); }
.cell { border: 1px solid var(--water-line); position: relative; }
.shootable .cell.open { cursor: crosshair; }
.shootable .cell.open:hover { background: #ffffff55; }
.cell.sel { background: #ffffff88; outline: 2px solid var(--accent); outline-offset: -2px; }
.mark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.mark.miss::after { content: ""; width: 24%; height: 24%; border-radius: 50%; background: var(--miss); opacity: .9; }
.mark.hit::after { content: "✕"; color: var(--hit); font-weight: bold; font-size: calc(var(--bw, 400px) * .07); line-height: 1; text-shadow: 0 0 2px #0006; }
.mark.new::after { animation: pop .35s ease-out; }
.cell.hitbg { background: #e5484d33; }
@keyframes pop { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ship { position: absolute; background: var(--ship); border: 2px solid var(--ship-edge); border-radius: 999px; box-shadow: inset 0 0 0 2px #ffffff22; }
.ship.enemy { opacity: .85; }
.ship.sunk { background: #6b2a2a; border-color: #3b1111; }
.place .ship { cursor: grab; z-index: 2; }
.place .ship.drag { cursor: grabbing; z-index: 5; opacity: .85; }
.place .ship.bad { background: var(--warn); border-color: #7c2d12; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.status { text-align: center; padding: 12px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); margin-bottom: 14px; }
.status.wait { background: #0002; color: var(--ink); }
.status small { display: block; opacity: .8; }
.mini { display: none; }

@media (max-width: 760px) {
  .boards { grid-template-columns: 1fr; gap: 10px; }
  .boards .own { order: 2; }
  .boards .own .board { max-width: 190px; }
  .boards .own .legend { display: none; }
  .own-big .board { max-width: 480px !important; }
}
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.board { container-type: inline-size; }
.mark.hit::after { font-size: 7cqw; }
.ship { z-index: 1; pointer-events: none; }
.grid { z-index: 2; }
.place .grid { pointer-events: none; }
.place .ship { pointer-events: auto; z-index: 3; }

/* kompakt layout: brættet skal være synligt uden at scrolle */
#top { padding: 6px 12px; }
#top h1 { font-size: 1.05rem; }
#top .who { font-size: .8rem; gap: 8px; }
#top .btn.small { min-height: 28px; padding: 2px 8px; }
main { padding: 4px 12px 20px; }
.status { padding: 6px 10px; margin-bottom: 8px; font-size: .95rem; }
.status small { display: inline; font-size: .85rem; }
.lbl { font-size: .8rem; color: var(--muted); margin: 0 0 3px; }
.code { text-transform: uppercase; font-size: 2rem; letter-spacing: .12em; word-break: break-all; }
@media (max-width: 760px) {
  .boards { gap: 6px; }
  .boards .board-wrap:not(.own) .board { margin: 0 auto; max-width: max(260px, min(100%, calc(100dvh - 330px))); }
  .boards .own { display: flex; align-items: center; gap: 10px; }
  .boards .own .lbl { writing-mode: horizontal-tb; flex: 1; font-size: .85rem; }
  .boards .own .board { max-width: 150px; flex: none; }
  .boards .own.own-big { display: block; }
  .boards .own.own-big .board { max-width: 480px; }
  .legend { justify-content: center; margin-top: 2px; }
}

/* topbar uden logo */
#top { justify-content: flex-end; }
.link { background: none; border: 0; padding: 4px 2px; font-weight: bold; color: var(--ink); text-decoration: underline dotted; }
.icon-btn { background: none; border: 0; color: var(--ink); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; padding: 0; }
.icon-btn:hover { background: #0001; }

/* resultat-popup */
.modal-back { position: fixed; inset: 0; background: #0a1424b0; display: grid; place-items: center; padding: 16px; z-index: 30; animation: fade .2s; }
.modal { position: relative; background: var(--panel); border-radius: 18px; padding: 28px 22px 20px; width: min(420px, 100%); text-align: center; box-shadow: 0 12px 40px #0008; animation: rise .3s cubic-bezier(.2,.9,.3,1.2); }
.modal.won { border-top: 8px solid #2f9e44; }
.modal.lost { border-top: 8px solid var(--hit); }
.modal .big { font-size: 3.4rem; line-height: 1; }
.modal h2 { font-size: 1.9rem; margin: 6px 0; }
.modal .stats { display: grid; gap: 6px; margin: 16px 0; text-align: left; }
.modal .stats div { display: flex; justify-content: space-between; background: #fff9; border-radius: 10px; padding: 8px 12px; }
.modal-actions { display: grid; gap: 8px; }
.modal-x { position: absolute; top: 8px; right: 8px; font-size: 1.1rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px) scale(.94); opacity: 0; } }
