:root {
  --sky: #aedcf2;
  --panel: rgba(255, 255, 255, 0.78);
  --border: rgba(40, 60, 70, 0.14);
  --text: #23323c;
  --muted: #51636e;
  --p1: #e8433f;
  --p2: #ffc22e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

#scene {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

.hud,
.hint,
.support {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(30, 60, 80, 0.16);
}

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  max-width: calc(100vw - 32px);
  padding: 14px 16px;
  border-radius: 16px;
}

.hud h1 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

/* Hexagon, to echo the faceted pieces. */
.dot {
  width: 18px;
  height: 18px;
  flex: none;
  background: var(--muted);
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
}

.dot[data-player="1"] {
  background: var(--p1);
}

.dot[data-player="2"] {
  background: var(--p2);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.controls + .controls,
.online-only .controls {
  margin-top: 8px;
}

/* Which parts of the panel show depends on how you are playing. */
body[data-mode="local"] .online-only,
body[data-mode="online"] .local-only,
body:not([data-role="spectator"]) .spectator-only,
body[data-role="spectator"] .player-only {
  display: none;
}

.role,
.notice {
  margin: -6px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.notice {
  max-width: 300px;
  color: #a3341f;
}

#invite-link {
  width: 100%;
  min-width: 270px;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 10px;
}

button.primary {
  color: #fff;
  background: #2f7a4d;
  border-color: #2f7a4d;
}

button.primary:hover:not(:disabled) {
  background: #27683f;
  border-color: #27683f;
}

.boat-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.weapon {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.rapid {
  color: #c9541a;
}

/* The fork in the road when you open an invite link. */
.chooser {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 40, 55, 0.35);
}

.chooser[hidden] {
  display: none;
}

.chooser .card {
  display: grid;
  gap: 10px;
  width: min(360px, 100%);
  padding: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(20, 40, 55, 0.3);
}

.chooser h2 {
  margin: 0;
  font-size: 19px;
}

.chooser p {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.chooser button {
  padding: 11px 14px;
  font-size: 15px;
}

.chooser button:disabled {
  color: var(--muted);
  background: rgba(40, 60, 70, 0.12);
  border-color: transparent;
  opacity: 1;
}

.gauge {
  display: grid;
  grid-template-columns: 44px 1fr;
  font-size: 12.5px;
}

.meter {
  height: 10px;
  background: rgba(40, 60, 70, 0.15);
  border-radius: 5px;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: #ff7a2f;
}

.meter.hull span {
  background: #2f9d5c;
}

.tally {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.tally strong {
  color: var(--text);
}

.boat-panel button {
  justify-self: start;
}

/* Who sank whom, newest on top. */
.feed {
  position: fixed;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 6px;
  justify-items: end;
  pointer-events: none;
}

.feed p {
  margin: 0;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.feed p.win {
  color: #fff;
  background: #2f7a4d;
  border-color: #2f7a4d;
}

/* Open crosshair: four ticks around a clear middle, no scope mask. */
.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  display: none;
}

body[data-aiming] .crosshair {
  display: block;
}

body[data-aiming] .hud {
  opacity: 0.55;
}

.crosshair i {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.crosshair i:nth-child(1),
.crosshair i:nth-child(2) {
  width: 2px;
  height: 10px;
  left: -1px;
}

.crosshair i:nth-child(1) {
  top: -17px;
}

.crosshair i:nth-child(2) {
  top: 7px;
}

.crosshair i:nth-child(3),
.crosshair i:nth-child(4) {
  width: 10px;
  height: 2px;
  top: -1px;
}

.crosshair i:nth-child(3) {
  left: -17px;
}

.crosshair i:nth-child(4) {
  left: 7px;
}

/* Hit marker: the ticks snap into an X for a moment. */
.crosshair.hit {
  transform: rotate(45deg);
}

.crosshair.hit i {
  background: #ff4d3d;
}

.damage {
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px 30px rgba(232, 67, 63, 0.55);
  opacity: 0;
  transition: opacity 0.5s;
}

.damage.on {
  opacity: 1;
  transition: none;
}

button,
select {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 12px;
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover {
  background: #fff;
  border-color: rgba(40, 60, 70, 0.3);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid #2f7a4d;
  outline-offset: 2px;
}

label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

/* The strip along the bottom: how to play, with the support line under it. */
.footer {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.hint,
.support {
  margin: 0;
  border-radius: 14px;
  line-height: 1.45;
  text-align: center;
  color: var(--muted);
}

/* Controls, laid out as key caps each followed by what the key does. */
.hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 16px;
  padding: 9px 16px;
  font-size: 13px;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--text);
}

kbd {
  min-width: 24px;
  padding: 2px 7px;
  font: 600 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  color: var(--text);
  background: #fff;
  border: 1px solid rgba(40, 60, 70, 0.28);
  border-bottom-width: 2px;
  border-radius: 6px;
}

.hint .note {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
}

/* Closed, this is just the word "Support"; clicking it reveals the address. */
.support {
  padding: 4px 12px;
  font-size: 11.5px;
  overflow-wrap: anywhere;
  pointer-events: auto;
}

.support summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.support summary::-webkit-details-marker {
  display: none;
}

.support summary:hover {
  color: var(--text);
}

.support summary:focus-visible {
  outline: 2px solid #2f7a4d;
  outline-offset: 3px;
  border-radius: 6px;
}

/* One click selects the whole address, ready to copy. */
.support .address {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
  user-select: all;
}
