:root {
  --ink: #1a1238;
  --cream: #fff6e0;
  --red: #ff2e63;
  --yellow: #ffd23f;
  --teal: #18d4c4;
  --blue: #1f3fbf;
  --lime: #8be02d;
  --orange: #ff8a1f;
  --violet: #6a47e0;
  --sky: #29c5f6;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); font: 500 16px/1.35 Rubik, system-ui, sans-serif; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
body.playing canvas#gl { cursor: crosshair; }
body.marking canvas#gl { cursor: cell; }

[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; overflow-y: auto; display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px 40px; background: rgba(26, 18, 56, 0.28); z-index: 20; }
.wrap { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 14px; margin: auto 0; }
.wrap.wide { max-width: 1040px; }

h1 { margin: 0; font: 400 clamp(28px, 6vw, 54px)/1.05 'Rubik Mono One', Rubik, sans-serif; display: flex; flex-wrap: wrap; gap: 4px 2px; justify-content: center; }
h1 .l { display: inline-block; padding: 2px 6px 4px; border: 3px solid var(--ink); box-shadow: 3px 4px 0 var(--ink); }
h1 .sp { width: 14px; }
h2 { margin: 0; font: 400 30px/1.1 'Rubik Mono One', Rubik, sans-serif; color: var(--cream); text-shadow: 3px 3px 0 var(--ink); }
h3 { margin: 0 0 6px; font: 900 18px/1.2 Rubik, sans-serif; }
.tag { margin: 0; font: 700 22px/1.2 Caveat, cursive; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); text-align: center; }
.note { margin: 6px 0 0; font-size: 14px; }
.err { color: var(--cream); background: var(--red); padding: 6px 10px; border: 3px solid var(--ink); font-weight: 700; margin: 0; }
.err:empty { display: none; }

.card { background: var(--cream); border: 3px solid var(--ink); box-shadow: 5px 6px 0 var(--ink); padding: 14px 16px; }
.card:nth-child(odd) { transform: rotate(-0.4deg); }
.card:nth-child(even) { transform: rotate(0.5deg); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.row.small button { font-size: 15px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

button { font: 900 16px/1 Rubik, sans-serif; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); box-shadow: 4px 5px 0 var(--ink); padding: 12px 16px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.02em; transition: transform 0.06s, box-shadow 0.06s; }
button:hover { transform: translate(-1px, -1px); box-shadow: 5px 6px 0 var(--ink); }
button:active { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); }
button:disabled { opacity: 0.5; cursor: default; }
button.big { font-size: 19px; padding: 16px 18px; }
button.red { background: var(--red); color: var(--cream); }
button.teal { background: var(--teal); }
button.yellow { background: var(--yellow); }
button.lime { background: var(--lime); }
button.sel { background: var(--ink); color: var(--yellow); }

input, select { font: 700 18px Rubik, sans-serif; color: var(--ink); background: #fff; border: 3px solid var(--ink); padding: 10px 12px; width: 100%; }
input[type=range] { padding: 0; border: 0; accent-color: var(--red); background: transparent; }
input[type=checkbox] { width: auto; transform: scale(1.4); margin-right: 8px; }
label { display: block; font-weight: 700; }
.profile label input { margin-top: 6px; }
.profile .stats { display: flex; gap: 16px; margin-top: 10px; font-weight: 900; }
.join input { flex: 1.3; font-size: 22px; letter-spacing: 0.2em; text-align: center; }

.code { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.code b { font: 400 34px 'Rubik Mono One', monospace; letter-spacing: 0.08em; color: var(--red); }
.code button { margin-left: auto; font-size: 13px; padding: 10px 12px; }
#members { display: flex; flex-direction: column; gap: 6px; }
#members .m { display: flex; gap: 10px; align-items: center; font-weight: 700; }
#members .m i { font-style: normal; font-size: 12px; background: var(--yellow); border: 2px solid var(--ink); padding: 1px 6px; }
#members .m .r { margin-left: auto; font-size: 14px; opacity: 0.75; }
#hostOpts { display: grid; gap: 10px; }
#hostOpts label { display: grid; gap: 4px; }
#hostOpts label:last-child { display: flex; align-items: center; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.choices.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { background: var(--cream); border: 3px solid var(--ink); box-shadow: 4px 5px 0 var(--ink); padding: 8px 10px 10px; cursor: pointer; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.choice img { width: auto; height: auto; max-width: 100%; max-height: 90px; }
.choice b { font-weight: 900; }
.choice small { font-size: 12.5px; line-height: 1.25; opacity: 0.85; }
.choice.sel { background: var(--yellow); outline: 4px solid var(--red); outline-offset: -1px; }
.preview { display: flex; align-items: center; justify-content: center; background: #1a5fd6; }
.preview img { width: 100%; max-width: 340px; }

#atlasList { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
#atlasList .card img { width: 100%; height: auto; }
#atlasList .card p { margin: 4px 0 0; font-size: 13.5px; }
#atlasList .card .el { font-weight: 900; color: var(--red); }

#resList { display: flex; flex-direction: column; gap: 10px; }
.res { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center; }
.res .ic { font-size: 26px; }
.res .who b { font-size: 18px; }
.res .who div { font-size: 14px; }
.res .d { font: 900 18px Rubik; min-width: 70px; text-align: right; }
.res .d.plus { color: #0c8a3a; }
.res .d.minus { color: var(--red); }
.res.me { background: var(--yellow); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.lbl { position: absolute; transform: translate(-50%, -100%); font: 900 13px Rubik; padding: 2px 7px; border: 2px solid var(--ink); background: var(--yellow); white-space: nowrap; box-shadow: 2px 2px 0 var(--ink); }
.lbl.boat { background: var(--cream); }
.lbl.me { background: var(--lime); }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.scrap { background: var(--cream); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 6px 12px; }
#top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: flex-start; }
#phase { font: 900 15px Rubik; text-transform: uppercase; background: var(--yellow); transform: rotate(-1.5deg); }
#timer { font: 400 26px 'Rubik Mono One', monospace; }
#timer.warn { background: var(--red); color: var(--cream); }
#fishers { display: flex; flex-direction: column; gap: 6px; }
#fishers .f { font: 900 13px Rubik; border: 3px solid var(--ink); padding: 4px 8px; box-shadow: 3px 3px 0 var(--ink); color: var(--ink); }
#panel { position: absolute; left: 12px; bottom: 12px; min-width: 240px; max-width: 320px; font-size: 14px; }
#panel h4 { margin: 0 0 6px; font: 900 16px Rubik; text-transform: uppercase; }
#panel .lures { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
#panel .lures div { padding: 2px 6px; border: 2px solid transparent; }
#panel .lures div.on { border-color: var(--ink); background: var(--yellow); font-weight: 900; }
#panel .bar { height: 12px; border: 2px solid var(--ink); background: #fff; margin: 4px 0; }
#panel .bar i { display: block; height: 100%; background: var(--teal); }
#panel .bar.low i { background: var(--red); }
#panel .kv { display: flex; justify-content: space-between; gap: 12px; }
#panel .errs b { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--ink); margin-right: 4px; text-align: center; line-height: 18px; font-weight: 900; }
#panel .errs b.x { background: var(--red); color: var(--cream); }
#panel .warn { background: var(--red); color: var(--cream); padding: 4px 6px; margin-top: 6px; font-weight: 900; }
#panel .ok { background: var(--lime); padding: 4px 6px; margin-top: 6px; font-weight: 900; }
#keys { position: absolute; right: 12px; bottom: 12px; font-size: 12.5px; max-width: 300px; }
#keys table { border-collapse: collapse; }
#keys td { padding: 1px 6px 1px 0; vertical-align: top; }
#keys td:first-child { font-weight: 900; white-space: nowrap; }
#keys .g td { padding-top: 5px; font-weight: 900; text-transform: uppercase; font-size: 11px; opacity: 0.6; }
#feed { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-width: 340px; }
#feed div { background: var(--cream); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 5px 10px; font-weight: 700; font-size: 14px; animation: pop 0.25s ease-out; }
#feed div.hot { background: var(--red); color: var(--cream); }
#feed div.good { background: var(--lime); }
@keyframes pop { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
#banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) rotate(-2deg); font: 400 clamp(26px, 5vw, 50px)/1.1 'Rubik Mono One', sans-serif; text-align: center; background: var(--yellow); border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); padding: 14px 24px; animation: pop 0.3s ease-out; max-width: 90vw; }
#banner.hot { background: var(--red); color: var(--cream); }
#banner small { display: block; font: 700 18px Rubik; margin-top: 6px; }
#power { position: absolute; width: 140px; height: 16px; border: 3px solid var(--ink); background: var(--cream); transform: translate(-50%, 0); }
#power i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime), var(--yellow), var(--red)); }
#markmode { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: var(--red); color: var(--cream); border: 3px solid var(--ink); padding: 6px 12px; font-weight: 900; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: var(--cream); padding: 8px 14px; font-weight: 700; border: 3px solid var(--cream); }

@media (max-width: 700px) {
  #keys { display: none; }
  #panel { min-width: 0; max-width: 58vw; font-size: 12.5px; }
  #top { top: 8px; }
  #timer { font-size: 20px; }
}

#pause .wrap { max-width: 420px; }
#pause #pHelpBox table { font-size: 14px; }
#pause #pHelpBox td { padding: 2px 8px 2px 0; }
#pause #pHelpBox .g td { font-weight: 900; opacity: 0.6; text-transform: uppercase; font-size: 11px; padding-top: 6px; }
