/* Super Sinky - nautical UI */

:root {
  --sea-deep: #06253c;
  --sea-mid: #0d3a5c;
  --sea-light: #17557f;
  --foam: #bfe3f2;
  --parchment: #f2ead6;
  --parchment-dim: #cdc2a6;
  --timber: #6b4526;
  --timber-light: #8a5a33;
  --brass: #d9a441;
  --brass-bright: #f0c46a;
  --danger: #e6394d;
  --good: #64c98a;
  --ink: #0a1a26;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 12px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--parchment);
  background: var(--sea-deep);
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, #14507a 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, #0a3050 0%, transparent 60%),
    var(--sea-deep);
}

/* ---------------- menu background battle ---------------- */

.menu-scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

/* Darken and vignette the battle so the panels stay readable over it. */
.menu-scrim {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(3, 18, 30, .28) 0%, rgba(3, 18, 30, .72) 70%, rgba(2, 12, 22, .88) 100%),
    linear-gradient(180deg, rgba(3, 18, 30, .55) 0%, rgba(3, 18, 30, .35) 40%, rgba(2, 12, 22, .7) 100%);
}

/* Both are hidden once a match is on screen. */
body.in-game .menu-scene,
body.in-game .menu-scrim { display: none; }

/* ---------------- screens ---------------- */

.screen { display: none; position: absolute; inset: 0; z-index: 2; }
.screen.active { display: block; }
.screen:not(.game) { overflow-y: auto; }

.menu-wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.brand { text-align: center; margin-bottom: 26px; }

.brand h1, .lobby-head h1 {
  margin: 0;
  font-size: 54px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--parchment);
  text-shadow: 0 3px 0 #7d4a1f, 0 6px 18px rgba(0, 0, 0, .55);
}

.lobby-head h1 { font-size: 30px; }

.tagline { margin: 6px 0 0; color: var(--parchment-dim); font-size: 14px; letter-spacing: .5px; }

.lobby-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}

/* ---------------- panels ---------------- */

.panel {
  background: linear-gradient(180deg, rgba(10, 38, 62, .94), rgba(6, 27, 46, .95));
  border: 1px solid rgba(217, 164, 65, .32);
  backdrop-filter: blur(3px);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}

.panel h2 {
  margin: 0; font-size: 15px; text-transform: uppercase;
  letter-spacing: 2px; color: var(--brass);
}

.muted { color: var(--parchment-dim); font-weight: normal; letter-spacing: 0; }
.hint { margin: 10px 0 0; font-size: 12px; color: var(--parchment-dim); }
.hint.center { text-align: center; }
.version { text-align: center; font-size: 12px; color: rgba(205, 194, 166, .5); margin-top: 26px; }

label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--parchment-dim); }

/* ---------------- controls ---------------- */

input[type=text], input[type=password], select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid rgba(217, 164, 65, .3);
  background: rgba(3, 20, 34, .75);
  color: var(--parchment);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
}

input:focus, select:focus { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(217, 164, 65, .16); }
input::placeholder { color: rgba(205, 194, 166, .45); }
select option { background: #0b2c46; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.row input { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px 14px;
  align-items: center;
}

.btn {
  border: 1px solid rgba(217, 164, 65, .45);
  background: rgba(217, 164, 65, .12);
  color: var(--parchment);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: .6px;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .08s, border-color .15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: rgba(217, 164, 65, .24); border-color: var(--brass); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.wide { width: 100%; padding: 15px; font-size: 17px; text-transform: uppercase; letter-spacing: 2px; }

/* The create button sits straight under the form grid and needs air. */
#createLobby { margin-top: 20px; }

.btn.primary {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: #2b1a06;
  border-color: #b98a2e;
  font-weight: bold;
}

.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffd88a, #e4b04e); }
.btn.ghost { background: rgba(255, 255, 255, .05); }
.btn.danger { border-color: rgba(230, 57, 77, .6); background: rgba(230, 57, 77, .16); }

/* ---------------- lobby list ---------------- */

.lobby-list { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.lobby-list .empty { color: var(--parchment-dim); font-size: 14px; text-align: center; padding: 18px 0; margin: 0; }

.lobby-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 9px;
}

.lobby-row:hover { border-color: rgba(217, 164, 65, .4); }
.lobby-row .lr-main { flex: 1; min-width: 0; }
.lobby-row .lr-name { font-size: 16px; display: flex; align-items: center; gap: 7px; }
.lobby-row .lr-meta { font-size: 12px; color: var(--parchment-dim); margin-top: 3px; }

.tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 20px;
  border: 1px solid currentColor;
}

.tag.dm { color: #7bdff2; }
.tag.tdm { color: #f4a259; }
.tag.live { color: var(--good); }
.tag.lock { color: var(--brass); }

/* ---------------- lobby crew ---------------- */

.team-block { margin-bottom: 14px; }
.team-block:last-child { margin-bottom: 0; }

.team-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.6px;
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}

.team-title .team-bots { margin-left: auto; display: flex; gap: 6px; }

.team-title .team-bots .btn {
  padding: 4px 9px; font-size: 12px; letter-spacing: 0;
}

.bot-controls.hidden { display: none; }

.team-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

.crew-list { display: flex; flex-direction: column; gap: 6px; }

.crew-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  font-size: 15px;
}

.crew-row .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .35); }
.crew-row .who { flex: 1; }
.crew-row .badge { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--parchment-dim); }
.crew-row.empty-slot { opacity: .35; font-style: italic; }

.bot-controls { display: flex; gap: 8px; }

/* ---------------- game ---------------- */

.screen.game { background: #05202f; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: absolute; inset: 0; pointer-events: none; font-size: 13px; }
.hud > * { pointer-events: none; }

.hud-scores {
  position: absolute; top: 14px; left: 14px;
  background: rgba(4, 22, 36, .74);
  border: 1px solid rgba(217, 164, 65, .28);
  border-radius: 10px;
  padding: 9px 11px;
  min-width: 188px;
  backdrop-filter: blur(3px);
}

.score-head {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--brass); margin-bottom: 6px;
  display: flex; justify-content: space-between;
}

.score-row {
  display: flex; align-items: center; gap: 7px;
  padding: 2px 0; font-size: 13px;
}

.score-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.score-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .pts { font-weight: bold; min-width: 22px; text-align: right; }
.score-row.me { color: var(--brass-bright); }
.score-row.dead { opacity: .45; }
.score-row .bt { font-size: 9px; color: var(--parchment-dim); letter-spacing: 1px; }

.team-score-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  margin: 7px 0 4px; padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .09);
}

.team-score-head:first-child { border-top: none; margin-top: 0; padding-top: 0; }

.hud-right { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }

.wind-box {
  position: relative;
  background: rgba(4, 22, 36, .74);
  border: 1px solid rgba(217, 164, 65, .28);
  border-radius: 10px;
  padding: 6px;
}

.wind-meta {
  position: absolute; bottom: 6px; left: 0; right: 0;
  text-align: center; line-height: 1.25;
}

.wind-meta .label { display: block; font-size: 10px; letter-spacing: 3px; color: var(--brass); font-weight: bold; }
.wind-meta .value { font-size: 14px; color: var(--parchment); font-weight: bold; letter-spacing: .3px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.minimap {
  background: rgba(4, 22, 36, .74);
  border: 1px solid rgba(217, 164, 65, .28);
  border-radius: 10px;
}

.hud-bottom { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); }

.status-card {
  background: rgba(4, 22, 36, .78);
  border: 1px solid rgba(217, 164, 65, .3);
  border-radius: 11px;
  padding: 10px 14px;
  width: 340px;
  backdrop-filter: blur(3px);
}

.status-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.status-row.small { font-size: 11px; color: var(--parchment-dim); margin-top: 7px; letter-spacing: .4px; }
.status-row.small b { color: var(--parchment); font-weight: normal; }
.ship-name { font-size: 15px; letter-spacing: .6px; }

.pill {
  background: rgba(217, 164, 65, .2); border: 1px solid rgba(217, 164, 65, .45);
  color: var(--brass-bright); border-radius: 20px; padding: 1px 11px;
  font-size: 12px; font-weight: bold;
}

.bar {
  position: relative; height: 15px; margin-top: 7px;
  background: rgba(0, 0, 0, .45); border-radius: 7px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
}

.bar .fill { height: 100%; width: 100%; transition: width .12s linear; }
.bar.health .fill { background: linear-gradient(90deg, #4fb477, #7fd99d); }
.bar.health.hurt .fill { background: linear-gradient(90deg, #e0a53c, #f2c55f); }
.bar.health.critical .fill { background: linear-gradient(90deg, #c22f42, #e6394d); }
.bar.reload { height: 9px; }
.bar.reload .fill { background: linear-gradient(90deg, #4a7fa8, #7bdff2); }
.bar.reload.ready .fill { background: linear-gradient(90deg, #b98a2e, var(--brass-bright)); }

.bar.boost { height: 9px; }
.bar.boost .fill { background: linear-gradient(90deg, #2f6f5a, #6fd8a8); }
.bar.boost.full .fill { background: linear-gradient(90deg, #35a06f, #8ff0bd); }
.bar.boost.empty .fill { background: linear-gradient(90deg, #5a4a4a, #8a6a6a); }
.bar.boost.firing .fill {
  background: linear-gradient(90deg, #7bdff2, #d8fbff);
  animation: boostPulse .5s ease-in-out infinite;
}

@keyframes boostPulse { 50% { filter: brightness(1.5); } }

.bar span {
  position: absolute; inset: 0; text-align: center;
  font-size: 10px; line-height: 15px; letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.bar.reload span, .bar.boost span { line-height: 9px; font-size: 8px; }

.buffs { display: flex; gap: 6px; margin-top: 8px; min-height: 20px; flex-wrap: wrap; }

.buff {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(123, 223, 242, .14); border: 1px solid rgba(123, 223, 242, .45);
  color: #a8ecf8;
}

.buff.super { background: rgba(230, 57, 77, .16); border-color: rgba(230, 57, 77, .55); color: #ff8fa3; }
.buff.sail { background: rgba(100, 201, 138, .14); border-color: rgba(100, 201, 138, .5); color: #9bde7e; }
.buff.rapid { background: rgba(244, 162, 89, .16); border-color: rgba(244, 162, 89, .55); color: #ffc489; }
.buff.regen { background: rgba(143, 240, 189, .14); border-color: rgba(143, 240, 189, .5); color: #8ff0bd; }

.respawn {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(4, 22, 36, .8);
  border: 1px solid rgba(230, 57, 77, .5);
  border-radius: 12px; padding: 18px 38px;
}

.respawn h2 { margin: 0 0 6px; font-size: 30px; letter-spacing: 3px; color: var(--danger); text-transform: uppercase; }
.respawn p { margin: 0; color: var(--parchment-dim); }

.round-box {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none;
}

.round-timer {
  font-size: 26px; font-weight: bold; letter-spacing: 2px;
  color: var(--parchment);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .9);
  line-height: 1;
}

.round-timer.low { color: #ff8fa3; animation: timerPulse 1s ease-in-out infinite; }
@keyframes timerPulse { 50% { opacity: .55; } }

.round-note {
  font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--brass); margin-top: 3px; min-height: 13px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
}

.round-note.urgent { color: #ff8fa3; }

.zone-warn {
  position: absolute; top: 34%; left: 50%; transform: translateX(-50%);
  text-align: center; padding: 12px 28px; border-radius: 10px;
  background: rgba(120, 12, 26, .78);
  border: 2px solid rgba(255, 110, 130, .85);
  animation: zonePulse .8s ease-in-out infinite;
}

.zone-warn b { display: block; font-size: 19px; letter-spacing: 3px; color: #fff; }
.zone-warn span { font-size: 13px; color: #ffd0d8; }
.zone-warn.hidden { display: none; }

@keyframes zonePulse { 50% { border-color: rgba(255, 190, 200, 1); transform: translateX(-50%) scale(1.03); } }

.wide-card { min-width: min(520px, 92vw); }

.match-winner {
  font-size: 27px; font-weight: bold; letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 2px 0 4px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
}

.match-winner .trophy { opacity: .85; margin-right: 8px; }
.match-winner.draw { color: var(--parchment-dim); }

.standings {
  text-align: left; margin-bottom: 18px;
  max-height: 44vh; overflow-y: auto;
}

/* Column labels above the rows. */
.standing-cols {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 10px 5px;
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  color: rgba(205, 194, 166, .55);
}

.standing-cols .rank, .standing-row .rank { width: 26px; flex: none; }
.standing-cols .dot { width: 10px; flex: none; }
.standing-cols .nm { flex: 1; }
.standing-cols .num, .standing-row .num { width: 42px; text-align: right; flex: none; }

.team-total {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase;
  margin: 12px 0 2px; padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.team-total:first-child { margin-top: 0; }
.team-total .team-dot { width: 11px; height: 11px; border-radius: 50%; }
.team-total .nm { flex: 1; }
.team-total .won {
  font-size: 10px; letter-spacing: 1.4px;
  border: 1px solid currentColor; border-radius: 20px; padding: 1px 8px;
}
.team-total .tot { font-weight: bold; }

.standing-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  margin-bottom: 4px; font-size: 14px;
}

.standing-row.me { background: rgba(217, 164, 65, .18); color: var(--brass-bright); }
.standing-row.winner { background: rgba(217, 164, 65, .1); }
.standing-row .rank { color: var(--parchment-dim); font-size: 12px; }
.standing-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.standing-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing-row .num { font-variant-numeric: tabular-nums; }
.standing-row .num.sunk { font-weight: bold; }
.standing-row .num.dim { color: var(--parchment-dim); font-size: 12px; }

.standing-head {
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--brass); margin: 10px 0 5px;
}

.killfeed {
  position: absolute; top: 62px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: 62vw;
}

.kill-line {
  background: rgba(4, 22, 36, .8);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 7px; padding: 4px 11px; font-size: 12.5px;
  animation: killIn .22s ease-out;
  white-space: nowrap;
}

.kill-line.tk { border-color: rgba(230, 57, 77, .55); }
.kill-line .verb { color: var(--parchment-dim); margin: 0 6px; }

@keyframes killIn { from { opacity: 0; transform: translateY(-7px); } to { opacity: 1; transform: none; } }

.hud-help {
  position: absolute; bottom: 12px; left: 14px;
  font-size: 11px; color: rgba(205, 194, 166, .62);
  background: rgba(4, 22, 36, .5); padding: 7px 11px; border-radius: 8px;
  max-width: 230px; line-height: 1.85;
}

.hud-help b { color: var(--brass); font-weight: normal; }
.hud-help.hidden, .respawn.hidden { display: none; }
.btn.hidden { display: none; }
#endMatch { margin-top: 10px; }

/* ---------------- overlays ---------------- */

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(3, 16, 26, .82); pointer-events: auto; z-index: 40;
}

.overlay.hidden { display: none; }

.overlay-card {
  background: #0b2c46; border: 1px solid rgba(217, 164, 65, .4);
  border-radius: 12px; padding: 28px 36px; text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card h2 { margin: 0 0 8px; letter-spacing: 1px; }
.overlay-card p { margin: 0 0 18px; color: var(--parchment-dim); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(230, 57, 77, .92); color: #fff;
  padding: 11px 20px; border-radius: 9px; font-size: 14px;
  z-index: 50; box-shadow: var(--shadow);
  animation: toastIn .18s ease-out;
}

.toast.hidden { display: none; }
.toast.ok { background: rgba(80, 160, 110, .94); }

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- small screens ---------------- */

@media (max-width: 720px) {
  .brand h1 { font-size: 38px; }
  .form-grid { grid-template-columns: 1fr; gap: 6px; }
  .form-grid label { margin-top: 6px; }
  .hud-scores { min-width: 150px; font-size: 12px; }
  .status-card { width: min(92vw, 340px); }
  .minimap { width: 130px; height: 130px; }
  .hud-help { display: none; }
}
