/* Monster Bay, a harbour at dusk: slate city, teal water, warm monster colours. Fixed palette. */
:root {
  --bg: #e6ecee;
  --surface: #f9fbfb;
  --surface2: #dde5e8;
  --line: rgba(28, 48, 60, .13);
  --ink: #1f2d36;
  --muted: #667783;
  --accent: #e0532f;           /* you */
  --water: #2c6f8c;
  --water2: #1f556d;
  --city: #53606b;
  --gold: #f2b51c;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #f2b51c;
  --tut-accent-ink: #1f2d36;
  --tut-bubble: #f9fbfb;
  --tut-ink: #1f2d36;
  --tut-muted: #667783;
  --tut-dim: rgba(10, 26, 36, .58);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; touch-action: manipulation; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; flex: none; }

.app { position: relative; max-width: 720px; margin: 0 auto; padding: 0 12px 16px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- top bar + menu ---------- */
.topbar { display: flex; align-items: center; gap: 4px; height: 48px; }
.back, .iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 22px; background: none; border: 0; cursor: pointer; padding: 0; }
.back:hover, .iconbtn:hover, .iconbtn[aria-expanded="true"] { color: var(--ink); background: var(--surface2); }
.brand { flex: 1; text-align: center; font: 900 21px/1 "Arial Black", "Helvetica Neue", Impact, system-ui, sans-serif; letter-spacing: .03em; color: var(--water2); }
.menu { position: absolute; right: 12px; top: 44px; z-index: 45; min-width: 190px; padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 36px rgba(28, 48, 60, .25); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.menu button { min-height: 46px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: var(--surface2); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; font-weight: 700; transition: background .15s, transform .1s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not(:disabled) { background: #cfd9dd; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #c64522; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.btn .ico { width: 16px; height: 16px; }

/* ---------- status ---------- */
.status { min-height: 36px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 4px 4px; font-size: 15px; color: var(--muted); text-align: center; }
.status.mine { color: var(--ink); font-weight: 650; }
.status .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- the harbour ---------- */
.scene { position: relative; width: 100%; height: 340px; border-radius: 20px; overflow: hidden; background: linear-gradient(#f5d7b8 0%, #e9b99a 26%, #9fb7c2 27%, #9fb7c2 100%); box-shadow: 0 8px 22px rgba(28, 48, 60, .18); }
.skyline { position: absolute; left: 0; right: 0; top: 0; height: 30%; background:
  linear-gradient(var(--city), var(--city)) 4% 100% / 9% 58% no-repeat,
  linear-gradient(var(--city), var(--city)) 14% 100% / 6% 80% no-repeat,
  linear-gradient(var(--city), var(--city)) 21% 100% / 11% 45% no-repeat,
  linear-gradient(var(--city), var(--city)) 33% 100% / 5% 95% no-repeat,
  linear-gradient(var(--city), var(--city)) 39% 100% / 9% 62% no-repeat,
  linear-gradient(var(--city), var(--city)) 55% 100% / 7% 72% no-repeat,
  linear-gradient(var(--city), var(--city)) 63% 100% / 12% 50% no-repeat,
  linear-gradient(var(--city), var(--city)) 76% 100% / 5% 88% no-repeat,
  linear-gradient(var(--city), var(--city)) 83% 100% / 8% 60% no-repeat,
  linear-gradient(var(--city), var(--city)) 93% 100% / 9% 76% no-repeat; opacity: .85; }
.bay { position: absolute; left: 22%; right: 22%; top: 31%; bottom: 20%; border-radius: 48% 52% 44% 56% / 50% 46% 54% 50%; background: radial-gradient(ellipse at 50% 40%, var(--water) 0%, var(--water2) 100%); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .25), 0 0 0 6px #b9a88a; }
.baylabel { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font: 800 11px/1 system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .6); }
.bay.empty .baylabel { bottom: 44%; font-size: 13px; }

.token { position: absolute; transform: translate(-50%, -50%); width: 88px; border: 0; padding: 4px 3px 5px; border-radius: 16px; background: rgba(249, 251, 251, .94); box-shadow: 0 3px 8px rgba(28, 48, 60, .22); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; transition: left .5s ease, top .5s ease, box-shadow .2s, opacity .3s; }
.token svg.art { width: 44px; height: 44px; }
.token .nm { font-size: 11.5px; font-weight: 800; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.token .stats { display: flex; gap: 4px; font-size: 12px; font-weight: 800; color: var(--ink); }
.token .stats span { display: inline-flex; align-items: center; gap: 1px; }
.token .stats svg { width: 12px; height: 12px; }
.token.cur { box-shadow: 0 0 0 3px var(--pc), 0 3px 10px rgba(28, 48, 60, .3); }
.token.me .nm { color: var(--accent); }
.token.inbay { width: 104px; background: rgba(255, 255, 255, .96); box-shadow: 0 0 0 3px var(--gold), 0 6px 16px rgba(0, 0, 0, .35); }
.token.inbay svg.art { width: 56px; height: 56px; }
.token.inbay.cur { box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px var(--pc), 0 6px 16px rgba(0, 0, 0, .35); }
.token.out { opacity: .35; filter: grayscale(1); }
.token.hit { animation: shake .45s ease-out; }
@keyframes shake { 0%, 100% { transform: translate(-50%, -50%); } 20% { transform: translate(-54%, -50%); } 40% { transform: translate(-46%, -50%); } 60% { transform: translate(-52%, -50%); } 80% { transform: translate(-48%, -50%); } }
.token .pow { position: absolute; top: -6px; left: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #5b3a8e; color: #fff; font-size: 11px; font-weight: 800; line-height: 20px; }
.float { position: absolute; top: -12px; right: -10px; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; pointer-events: none; z-index: 3; }
.float b { font-size: 12px; font-weight: 900; padding: 1px 6px; border-radius: 9px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); animation: rise 2.2s ease-out forwards; white-space: nowrap; }
.float b.bad { background: #e0405a; color: #fff; }
.float b.good { background: #2f9e5a; color: #fff; }
.float b.vp { background: var(--gold); color: #3a2a00; }
.float b.en { background: #2fa0d8; color: #fff; }
@keyframes rise { 0% { transform: translateY(6px); opacity: 0; } 12% { transform: none; opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }

/* ---------- tray ---------- */
.tray { margin-top: 10px; background: var(--surface); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.tray.turn { box-shadow: inset 0 0 0 2px rgba(224, 83, 47, .35); }
.dice { display: flex; gap: 6px; justify-content: center; min-height: 58px; align-items: flex-end; }
.die { width: 48px; height: 48px; flex: 0 1 48px; min-width: 0; border-radius: 11px; border: 0; background: #fff; box-shadow: inset 0 0 0 2px #c7d2d7, 0 2px 0 #b7c3c9; display: grid; place-items: center; cursor: default; padding: 0; transition: transform .15s, box-shadow .15s; font: 900 25px/1 "Arial Black", system-ui, sans-serif; color: var(--ink); }
.die svg { width: 34px; height: 34px; }
.die.blank { background: #eef2f4; box-shadow: inset 0 0 0 2px dashed #c7d2d7; }
.die.can { cursor: pointer; }
.die.kept { transform: translateY(-8px); box-shadow: inset 0 0 0 3px var(--gold), 0 6px 10px rgba(0, 0, 0, .15); background: #fffaf0; }
.die.fresh { animation: tumble .4s ease-out; }
@keyframes tumble { 0% { transform: rotate(-25deg) scale(.8); opacity: .3; } 100% { transform: none; opacity: 1; } }
.die.kept.fresh { animation: none; }
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 44px; align-items: center; }
.controls .hint { font-size: 13px; color: var(--muted); }
.controls .btn { min-width: 110px; }
.market { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pcard { position: relative; border: 0; border-radius: 12px; padding: 6px 7px 7px; background: #f1ebf8; text-align: left; cursor: pointer; min-height: 82px; display: flex; flex-direction: column; gap: 2px; box-shadow: inset 0 0 0 1.5px #d6c7ea; transition: box-shadow .2s, opacity .2s, transform .15s; }
.pcard.keep { background: #e9f3ee; box-shadow: inset 0 0 0 1.5px #bcd9c8; }
.pcard .cn { font-size: 12.5px; font-weight: 800; line-height: 1.15; padding-right: 26px; }
.pcard .ct { font-size: 11px; line-height: 1.25; color: #4c5b65; }
.pcard .cost { position: absolute; right: 5px; top: 5px; display: inline-flex; align-items: center; gap: 1px; font-weight: 900; font-size: 13px; background: #fff; border-radius: 9px; padding: 1px 5px 1px 2px; }
.pcard .cost svg { width: 13px; height: 13px; }
.pcard .kind { font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #7a5aa8; }
.pcard.keep .kind { color: #2f7a52; }
.pcard.can { box-shadow: inset 0 0 0 2.5px var(--accent); }
.pcard.can:hover { transform: translateY(-2px); }
.pcard.dim { opacity: .55; }
.pcard.empty { visibility: hidden; }
.mine-row { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--muted); align-items: center; }
.mine-row .chip { background: #e9f3ee; color: #2f5a42; border-radius: 8px; padding: 2px 7px; font-weight: 700; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 34, 44, .38); }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease-out; box-shadow: 0 -10px 40px rgba(20, 34, 44, .2); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font: 900 18px/1.2 "Arial Black", system-ui, sans-serif; margin-bottom: 6px; color: var(--water2); display: flex; align-items: center; gap: 8px; }
.sheet h3 svg { width: 40px; height: 40px; }
.sheet p { margin: 6px 0; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1 1 0; }
.sheet .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 5px; }
.sheet .kindtag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 8px; background: #efe7f8; color: #6a4a98; }
.sheet .kindtag.keep { background: #e2f1e8; color: #2f7a52; }
.log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child, .log li.mine { color: var(--ink); }
.setup-sheet .field { margin: 12px 0; }
.setup-sheet .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1 1 0; min-width: 0; min-height: 46px; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; font-weight: 700; }
.seg button.on { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.results { width: 100%; border-collapse: collapse; font-size: 14px; }
.results th, .results td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results th:first-child, .results td:first-child { text-align: left; }
.results td:first-child { display: flex; align-items: center; gap: 6px; }
.results td svg.art { width: 26px; height: 26px; }
.results th { color: var(--muted); font-size: 12px; font-weight: 600; }
.results tr.me td { font-weight: 800; color: var(--accent); }
.results tr.out td { color: var(--muted); }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(20, 34, 44, .45); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(20, 34, 44, .3); }
.over-modal { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.modal-head h2 { font: 900 20px/1.2 "Arial Black", system-ui, sans-serif; color: var(--water2); }
.modal-body { padding: 0 18px 14px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.modal-foot .btn { flex: 1 1 110px; }
.rules h3 { font-size: 15px; margin: 16px 0 4px; color: var(--water2); }
.rules p, .rules li { font-size: 14px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules li { margin: 4px 0; }
.result-banner { display: flex; align-items: center; gap: 10px; font: 900 24px/1.2 "Arial Black", system-ui, sans-serif; margin: 0 0 10px; }
.result-banner svg { width: 56px; height: 56px; }
.result-banner.win { color: var(--accent); }

@media (min-width: 700px) {
  .scene { height: 400px; }
  .token { width: 100px; }
  .token.inbay { width: 118px; }
  .die { width: 54px; height: 54px; flex-basis: 54px; }
}
@media (max-width: 370px) {
  .token { width: 78px; }
  .token .stats { gap: 2px; font-size: 11px; }
  .pcard .ct { display: none; }
  .pcard { min-height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Online play (online.js): a presence line under the status, the online rows in the menu. */
.turn-row { display: flex; flex-direction: column; align-items: center; }
.turn-row .net { margin: -2px 0 6px; color: var(--muted); }
/* The menu has no divider above How to play, so the online rows are plain menu items. */
/* Result card online: Rematch, Leave and View harbour stacked. The footer's 8px flex gap is the space
   above #over-leave (a margin on top of it would double it). */
#over-rematch, #over-leave { flex-basis: 100%; }
