/* BATTLE ON THE LAKE — a Btown Games production */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy: #0e2238;
  --navy-2: #16324e;
  --cream: #f6efdc;
  --cream-dim: #d9ccae;
  --sun: #f2a24a;
  --champ: #3fa860;
  --green: #3fa860;
  --green-deep: #2e8149;
  --gold: #f2b34c;
  --gold-deep: #c07d1e;
  --red: #d4553a;
  --red-deep: #a03823;
  --panel: #1c4a6e;
  --panel-dark: #143a58;
  --water: #123c5c;
  --water-line: #2a5f8a;
  --wood: #8a5a33;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  background: var(--navy);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* Dusk over the lake: night sky → sunset band → deep water */
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    #0b1c30 0%,
    #16324e 24%,
    #594860 30%,
    #a05a48 36%,
    #e79352 41%,
    #123c5c 42%,
    #0e3049 70%,
    #081c30 100%
  );
}

#mountains {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(41% - 8vh);
  width: 100%;
  height: 8vh;
  opacity: 0.9;
  pointer-events: none;
}

.hidden { display: none !important; }

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

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px calc(env(safe-area-inset-bottom, 0px) + 8px);
  overflow-y: auto; /* short and landscape phones must never trap a button off-screen */
}

#menu { justify-content: center; }

/* On very short viewports (phone landscape), centered screens would clip
   their tops once they overflow — stack from the top and let them scroll. */
@media (max-height: 520px) {
  #menu, #handoff { justify-content: flex-start; }
  .menu-inner { justify-content: flex-start; }
}

.menu-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
}

/* ---------------------------------------------------------------- logo */

#logo {
  text-align: center;
  line-height: 1;
  color: var(--cream);
}

.l-battle {
  display: block;
  font-size: clamp(52px, 16vw, 96px);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.l-battle i {
  font-style: normal;
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
}

.l-battle i:nth-child(2n) { animation-delay: -0.7s; }
.l-battle i:nth-child(3n) { animation-delay: -1.4s; }
.l-battle i:nth-child(4n) { animation-delay: -2s; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.l-lake {
  display: block;
  margin-top: 10px;
  font-size: clamp(18px, 5.4vw, 30px);
  font-weight: 800;
  letter-spacing: 0.42em;
  padding-left: 0.42em; /* recenters the tracked-out text */
  color: var(--sun);
}

#tagline {
  text-align: center;
  color: var(--cream-dim);
  font-size: clamp(14px, 3.8vw, 17px);
  line-height: 1.45;
}

/* ---------------------------------------------------------------- buttons */

.big-btn {
  appearance: none;
  border: 0;
  border-radius: 16px;
  background: var(--sun);
  color: #3a2410;
  font-weight: 900;
  font-size: clamp(16px, 4.6vw, 20px);
  letter-spacing: 0.04em;
  padding: 15px 26px;
  box-shadow: 0 5px 0 #b06c24, 0 10px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s ease;
}

.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b06c24; }
.big-btn:disabled { opacity: 0.45; cursor: default; }

#modes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(86vw, 340px);
}

#modes .big-btn { width: 100%; }
.mode-pass { background: var(--panel); color: var(--cream); box-shadow: 0 5px 0 #0d2c44, 0 10px 18px rgba(0, 0, 0, 0.35); }
.mode-pass:active { box-shadow: 0 2px 0 #0d2c44; }

.mode-sub {
  color: var(--cream-dim);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

#credit {
  color: var(--cream-dim);
  font-size: 12px;
  padding-bottom: 4px;
  text-align: center;
  line-height: 1.5;
}

#credit a, .surface-credit a { color: var(--sun); text-decoration: none; font-weight: 700; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
}

.chip-btn, .mute-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 26, 44, 0.65);
  color: var(--cream);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  cursor: pointer;
}

.mute-btn { font-size: 15px; padding: 6px 10px; }

.who-chip, #tally {
  color: var(--cream);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-align: center;
}

#tally .t-green { color: var(--green); }
#tally .t-gold { color: var(--gold); }

/* ---------------------------------------------------------------- boards */

.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  grid-template-columns: repeat(10, 1fr);
}

.cells > div, .cells > button {
  appearance: none;
  padding: 0;
  border: 1px solid rgba(140, 190, 230, 0.22);
  background: rgba(18, 60, 92, 0.55);
  color: var(--cream);
  position: relative;
}

.cells > button { cursor: pointer; }

/* shot markers, drawn straight on the cells */
.cells > .miss::after {
  content: '';
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: rgba(246, 239, 220, 0.55);
}

.cells > .hit { background: rgba(212, 85, 58, 0.5); }
.cells > .hit::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(11px, 3.4vw, 18px);
  color: #ff8d70;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.cells > .sunk { background: rgba(90, 22, 10, 0.75); }
.cells > .sunk::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(11px, 3.4vw, 18px);
  color: #d9836c;
}

/* placement preview */
.cells > .ok { background: rgba(63, 168, 96, 0.55); }
.cells > .bad { background: rgba(212, 85, 58, 0.6); }

.ships { position: absolute; inset: 0; pointer-events: none; }

/* ---------------------------------------------------------------- vessels */

.ship {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.35);
  font-weight: 900;
  overflow: hidden;
  pointer-events: auto;
  touch-action: none;
}

.ship .s-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(20px, 6vw, 34px);
  flex: 0 1 auto;
}

.vessel-icon {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.vessel-icon .icon-accent { fill: var(--sun); }
.v-ferry .icon-accent { fill: #5f87a4; }
.v-schooner .icon-accent { fill: var(--cream-dim); }
.v-cutter .icon-accent { fill: var(--red); }
.v-sailboat .icon-accent { fill: var(--cream); }
.v-kayak .icon-accent { fill: var(--cream); }

.ship .s-label {
  font-size: clamp(7px, 2vw, 10px);
  letter-spacing: 0.08em;
}

.ship.vertical .s-label { display: none; } /* no room to read sideways */
.ship.vertical { flex-direction: column; }
.ship.vertical .s-icon { transform: rotate(90deg); }

.v-ferry { background: linear-gradient(180deg, #f8f2e0, #d9ccae); color: #24445f; }
.v-schooner { background: linear-gradient(180deg, #a06b3e, #6b4226); color: #f6efdc; }
.v-cutter { background: linear-gradient(135deg, #eef0ee 55%, #e8642e 55%, #e8642e 68%, #eef0ee 68%); color: #24445f; }
.v-sailboat { background: linear-gradient(180deg, #8fc3e4, #5f97bd); color: #10314a; }
.v-kayak { background: linear-gradient(180deg, #f2b34c, #cf8a25); color: #4a2f08; }

.ship.selected { outline: 3px solid var(--sun); outline-offset: 1px; }
.dragging { opacity: 0.35; }
.ship.sunk-ship { filter: grayscale(0.9) brightness(0.55); }

/* the drag ghost floats above everything */
#ghost {
  position: absolute;
  z-index: 40;
  opacity: 0.85;
  pointer-events: none;
}

/* ---------------------------------------------------------------- placement */

#placeTitle {
  color: var(--cream);
  font-weight: 900;
  letter-spacing: 0.14em;
  font-size: clamp(15px, 4.4vw, 19px);
  margin: 8px 0 6px;
}

#placeBoard {
  position: relative;
  width: min(92vw, 48vh, 430px);
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: visible;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

#placeBoard .cells { border-radius: 10px; overflow: hidden; }

#placeBoard.shake { animation: shake 0.3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

#fleetTray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 10px;
  min-height: 40px;
  width: 100%;
  max-width: 460px;
}

.tray-chip {
  appearance: none;
  border: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.tray-icon {
  display: block;
  width: 28px;
}

.tray-chip .t-cells { display: flex; gap: 2px; }
.tray-chip .t-cells i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.28);
}

.tray-done {
  color: var(--cream-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  align-self: center;
}

#placeHint {
  color: var(--cream-dim);
  font-size: 12.5px;
  text-align: center;
  margin-top: 8px;
  min-height: 2.4em;
  max-width: 320px;
  line-height: 1.35;
}

#placeTools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.tool-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--cream);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  box-shadow: 0 4px 0 #0d2c44;
  cursor: pointer;
}

.tool-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #0d2c44; }
.tool-btn:disabled { opacity: 0.45; cursor: default; }

#readyBtn { padding: 12px 18px; font-size: 15px; }

/* ---------------------------------------------------------------- handoff */

#handoff {
  justify-content: center;
  gap: 18px;
  z-index: 60; /* always covers the boards */
  background: linear-gradient(180deg, #0b1c30, #0e2238 60%, #081c30);
}

#handoffArt {
  font-size: 74px;
  animation: bob 2.6s ease-in-out infinite;
}

#handoffTitle {
  color: var(--cream);
  font-weight: 900;
  font-size: clamp(20px, 6vw, 28px);
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.3;
  max-width: 320px;
}

#handoffTitle .green { color: var(--green); }
#handoffTitle .gold { color: var(--gold); }

#handoffSub {
  color: var(--cream-dim);
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- battle */

#turnbar { margin: 6px 0 4px; min-height: 30px; }

#turnChip:empty { display: none; }

#turnChip {
  display: inline-block;
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 900;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  color: #10314a;
  background: var(--cream);
}

#turnChip.green { background: var(--green); color: #06220f; }
#turnChip.gold { background: var(--gold); color: #4a2f08; }
#turnChip.thinking { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#actionCue {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: min(92vw, 400px);
  margin: 0 0 6px;
  padding: 6px 8px 6px 11px;
  border: 1px solid rgba(242, 162, 74, 0.55);
  border-radius: 999px;
  background: rgba(10, 26, 44, 0.82);
  color: var(--cream);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

#dismissActionCue {
  appearance: none;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50%;
  background: rgba(246, 239, 220, 0.14);
  color: var(--cream);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.board-label {
  color: var(--cream-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin-bottom: 4px;
  text-align: center;
}

#enemyBlock { display: flex; flex-direction: column; align-items: center; }

#targetWrap {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-rows: 14px 1fr;
  width: min(90vw, 42vh, 400px);
}

#colLabels, #rowLabels {
  display: grid;
  color: var(--cream-dim);
  font-size: 9px;
  font-weight: 700;
}

#colLabels { grid-template-columns: repeat(10, 1fr); }
#rowLabels { grid-template-rows: repeat(10, 1fr); }
#colLabels span, #rowLabels span { display: grid; place-items: center; }

#targetBoard {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

#targetBoard .cells > button:not(.miss):not(.hit):not(.sunk):active { background: rgba(242, 162, 74, 0.4); }

#targetBoard .cells > .selected-target {
  z-index: 2;
  background: rgba(242, 162, 74, 0.34);
  box-shadow: inset 0 0 0 3px var(--sun);
}

#targetBoard .cells > .selected-target::before {
  content: '';
  position: absolute;
  inset: 27%;
  border: 2px solid var(--cream);
  border-radius: 50%;
}

#targetFx { position: absolute; inset: 0; pointer-events: none; }

.fx {
  position: absolute;
  width: 10%;
  height: 10%;
  display: grid;
  place-items: center;
  font-size: clamp(14px, 4.6vw, 24px);
  animation: fxpop 0.55s ease forwards;
}

@keyframes fxpop {
  0% { transform: scale(0.3); opacity: 0; }
  35% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.impact-particle {
  position: absolute;
  z-index: 8;
  left: 0;
  top: 0;
  width: var(--particle-size, 7px);
  height: var(--particle-size, 7px);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: particleBurst var(--particle-time, 580ms) cubic-bezier(0.15, 0.7, 0.2, 1) forwards;
  animation-delay: var(--particle-delay, 0ms);
}

.impact-particle.water {
  background: #b7e4ff;
  box-shadow: 0 0 5px rgba(183, 228, 255, 0.9);
}

.impact-particle.fire {
  border-radius: 45% 55% 55% 45%;
  background: #ffca58;
  box-shadow: 0 0 7px #ed5c2d;
}

.impact-particle.smoke {
  background: #66717d;
  box-shadow: 0 0 6px rgba(10, 26, 44, 0.7);
}

@keyframes particleBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  18% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--particle-x)), calc(-50% + var(--particle-y))) scale(0.75);
  }
}

#targetBoard.impact-nudge,
#ownBoard.impact-nudge {
  animation: boardNudge 230ms ease-out;
}

@keyframes boardNudge {
  0%, 100% { transform: translate(0, 0); }
  28% { transform: translate(-4px, 2px) rotate(-0.35deg); }
  58% { transform: translate(4px, -2px) rotate(0.35deg); }
  80% { transform: translate(-2px, 1px); }
}

.fleet-roster {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  width: min(90vw, 400px);
  margin-top: 5px;
}

.fleet-row {
  position: relative;
  min-width: 0;
  padding: 4px 2px;
  overflow: hidden;
  border: 1px solid rgba(246, 239, 220, 0.16);
  border-radius: 6px;
  background: rgba(10, 26, 44, 0.58);
  color: var(--cream-dim);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1.15;
  text-align: center;
}

.fleet-name,
.fleet-condition {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-condition {
  margin-top: 2px;
  color: #9bc9e6;
  letter-spacing: 0.02em;
}

.own-roster .fleet-condition { color: var(--sun); }

.fleet-row.sunk {
  color: #ae847a;
  background: rgba(90, 22, 10, 0.58);
}

.fleet-row.sunk .fleet-condition { color: #e58a73; }

.fleet-row.sunk::after {
  content: '';
  position: absolute;
  left: 5%;
  top: 50%;
  width: 90%;
  height: 2px;
  border-radius: 2px;
  background: #ff6b49;
  transform: rotate(-5deg);
  transform-origin: left center;
}

.fleet-row.sunk.just-sunk::after {
  animation: rosterCrossOut 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rosterCrossOut {
  from { transform: rotate(-5deg) scaleX(0); }
  to { transform: rotate(-5deg) scaleX(1); }
}

#targetActions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 7px;
}

#targetSelection {
  display: grid;
  place-items: center;
  min-width: 126px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(246, 239, 220, 0.25);
  border-radius: 999px;
  background: rgba(10, 26, 44, 0.7);
  color: var(--cream-dim);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

#fireBtn {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 16px;
}

#statusLine {
  color: var(--cream);
  font-weight: 800;
  font-size: clamp(13px, 3.8vw, 16px);
  letter-spacing: 0.03em;
  text-align: center;
  min-height: 2.5em;
  margin: 6px 0 2px;
  max-width: 340px;
  line-height: 1.3;
}

#ownBlock { display: flex; flex-direction: column; align-items: center; }

#ownBoard {
  position: relative;
  width: min(46vw, 22vh, 210px);
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4);
}

#ownBoard .cells > div { border-width: 0.5px; }
#ownBoard .ship { border-width: 1px; box-shadow: none; }
#ownBoard .s-icon { width: clamp(12px, 3.2vw, 18px); }
#ownBoard .s-label { display: none; }

#ownShots { position: absolute; inset: 0; pointer-events: none; }
#ownFx { position: absolute; inset: 0; pointer-events: none; }

#ownShots .m-miss, #ownShots .m-hit {
  position: absolute;
  width: 10%;
  height: 10%;
  display: grid;
  place-items: center;
}

#ownShots .m-miss::after {
  content: '';
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(246, 239, 220, 0.6);
}

#ownShots .m-hit::after {
  content: '✕';
  font-weight: 900;
  font-size: clamp(9px, 2.6vw, 13px);
  color: #ff5a33;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

#passBtn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 30;
}

#passBtn:active { transform: translateX(-50%) translateY(3px); }

/* --------------------------------------------------------- battle impacts */

#impactCallout,
#sunkBanner,
#streakChip {
  position: fixed;
  z-index: 50;
  left: 50%;
  pointer-events: none;
  text-align: center;
}

#impactCallout {
  top: 42%;
  min-width: min(78vw, 300px);
  padding: 11px 18px;
  border: 2px solid #ffb08c;
  border-radius: 14px;
  background: rgba(90, 22, 10, 0.94);
  color: #fff7e7;
  font-size: clamp(24px, 8vw, 38px);
  font-weight: 1000;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 0 #721b0c;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.46);
  transform: translate(-50%, -50%);
  animation: hitCallout 680ms ease-out both;
}

@keyframes hitCallout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.09); }
  34%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(0.96); }
}

#sunkBanner {
  top: 36%;
  width: 100%;
  padding: 16px max(16px, env(safe-area-inset-left, 0px));
  border-top: 3px solid #ffb348;
  border-bottom: 3px solid #ffb348;
  background: linear-gradient(90deg, rgba(61, 13, 8, 0.96), rgba(140, 43, 19, 0.98), rgba(61, 13, 8, 0.96));
  color: var(--cream);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
  animation: sunkBanner 1450ms ease-in-out both;
}

#sunkBanner strong,
#sunkBanner span { display: block; }

#sunkBanner strong {
  font-size: clamp(21px, 6.8vw, 34px);
  font-weight: 1000;
  letter-spacing: 0.045em;
}

#sunkBanner span {
  margin-top: 4px;
  color: #ffd39a;
  font-size: clamp(12px, 3.5vw, 15px);
  font-weight: 800;
}

@keyframes sunkBanner {
  0% { opacity: 0; transform: translate(-50%, -64%) scaleY(0.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scaleY(1.04); }
  22%, 74% { opacity: 1; transform: translate(-50%, -50%) scaleY(1); }
  100% { opacity: 0; transform: translate(-50%, -46%) scaleY(0.95); }
}

#streakChip {
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  padding: 7px 13px;
  border: 2px solid var(--sun);
  border-radius: 999px;
  background: rgba(10, 26, 44, 0.94);
  color: var(--cream);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.07em;
  transform: translateX(-50%);
  animation: streakPop 900ms ease-out both;
}

@keyframes streakPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.78); }
  18%, 80% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.96); }
}

/* ---------------------------------------------------------------- endgame */

#resultbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(10, 26, 44, 0.92);
  border-radius: 18px;
  padding: 14px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#resultText {
  color: var(--cream);
  font-weight: 900;
  font-size: clamp(16px, 4.8vw, 21px);
  letter-spacing: 0.05em;
  text-align: center;
}

#resultText.green-win { color: var(--green); }
#resultText.gold-win { color: var(--gold); }
#resultText.red-loss { color: var(--red); }

/* ---------------------------------------------------- monthly leaderboard */

#lb {
  width: min(78vw, 300px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--water-line);
}

.lb-tabs { display: flex; gap: 6px; justify-content: center; }

.lb-chip {
  border: 1px solid var(--water-line);
  background: var(--panel-dark);
  color: var(--cream-dim);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.lb-chip.sel { background: var(--panel); color: var(--cream); border-color: var(--sun); }

.lb-status {
  text-align: center;
  color: var(--cream-dim);
  font-size: 12px;
  min-height: 15px;
}

#lbList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 32vh;
  overflow-y: auto;
}

#lbList li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--cream);
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 8px;
}

#lbList li.me { background: rgba(63, 168, 96, 0.22); outline: 1px solid var(--green-deep); }
#lbList .rank { flex: none; width: 24px; text-align: center; }
#lbList .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
#lbList .sc { color: var(--gold); font-weight: 800; font-size: 12px; white-space: nowrap; }

.lb-form { display: flex; gap: 6px; justify-content: center; }

.lb-form input {
  flex: 1;
  min-width: 0;
  background: var(--navy-2);
  border: 1px solid var(--water-line);
  border-radius: 8px;
  color: var(--cream);
  padding: 6px 10px;
  font-size: 14px;
}

.lb-rename { align-self: center; }

.surface-credit {
  max-width: 300px;
  color: var(--cream-dim);
  font-size: 10.5px;
  line-height: 1.45;
  text-align: center;
}

/* ---------------------------------------------------------------- Champ */

#champ {
  position: fixed;
  right: 4vw;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  z-index: 34;
  width: min(30vw, 130px);
  pointer-events: none;
  animation: champup 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes champup {
  from { transform: translateY(70%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#champSvg { width: 100%; }

#champBubble {
  background: var(--cream);
  color: #10314a;
  border-radius: 12px;
  padding: 7px 10px;
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  margin-bottom: 4px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------------- Harbormaster */

#harbormaster {
  position: fixed;
  left: 4vw;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px);
  z-index: 34;
  width: min(34vw, 150px);
  pointer-events: none;
  animation: harbormasterUp 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes harbormasterUp {
  from { transform: translateY(65%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#harbormasterArt {
  font-size: min(24vw, 104px);
  line-height: 0.9;
  text-align: center;
  filter: drop-shadow(0 7px 9px rgba(0, 0, 0, 0.48));
}

#harbormasterBubble {
  margin-bottom: 5px;
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--cream);
  color: #10314a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------ online play */

.online-label {
  color: var(--cream-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

#onlineRow {
  display: flex;
  gap: 8px;
  width: 100%;
}

#onlineRow .online-btn {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  font-size: 12px;
  border-radius: 13px;
}

#rejoinBtn {
  margin-top: 3px;
  color: var(--sun);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 26, 44, 0.78);
  backdrop-filter: blur(3px);
}

.op-card {
  width: min(92vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  color: var(--cream);
  text-align: center;
  background: linear-gradient(180deg, var(--panel), var(--panel-dark));
  border: 3px solid var(--navy);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.op-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.op-label {
  margin-bottom: -6px;
  color: var(--cream-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: left;
}

.op-card input {
  width: 100%;
  padding: 12px;
  color: var(--cream);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  background: var(--navy);
  border: 2px solid rgba(246, 239, 220, 0.3);
  border-radius: 12px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.op-card input:focus { border-color: var(--sun); }

#opCode {
  font-size: 24px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

.op-error {
  color: #ffb09c;
  font-size: 13px;
  font-weight: 700;
}

.op-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.op-btns .big-btn {
  padding: 12px 22px;
  font-size: 16px;
}

#lobbyCode {
  padding: 6px 0;
  color: var(--gold);
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  text-shadow: 0 3px 0 var(--navy);
  animation: lobbyPulse 1.6s ease-in-out infinite;
}

@keyframes lobbyPulse {
  50% { opacity: 0.75; }
}

#lobbyHint {
  color: var(--cream-dim);
  font-size: 13px;
  line-height: 1.4;
}

#onlineWaitBody {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(88vw, 420px);
  text-align: center;
}

#onlineWaitArt {
  font-size: clamp(68px, 22vw, 104px);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  animation: anchorBob 2.4s ease-in-out infinite;
}

@keyframes anchorBob {
  50% { transform: translateY(7px) rotate(2deg); }
}

#onlineWaitTitle {
  color: var(--cream);
  font-size: clamp(20px, 6vw, 28px);
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

#onlineWaitSub {
  color: var(--cream-dim);
  font-size: 14px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .l-battle i,
  #handoffArt,
  #turnChip.thinking,
  #lobbyCode,
  #onlineWaitArt,
  #champ,
  #harbormaster,
  #impactCallout,
  #sunkBanner,
  #streakChip,
  .fleet-row.sunk.just-sunk::after {
    animation: none;
  }
}
