:root {
  --ink: #171c26;
  --timber: #3d2512;
  --parchment: #f5ebd6;
  --parchment-hi: #fbf6eb;
  --slate: rgba(15, 23, 42, 0.92);
  --brass: #eab308;
  --buoy: #dc2626;
  --font-display: Georgia, 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --font-ui: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-ui);
  background: #1e3a5f;
  color: var(--ink);
}

#arenaCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}

button, .equipped-preview, .reel-bar-track, .fish-card {
  touch-action: manipulation;
}

.lobby-card, .modal-box, .waiting-card, .result-card {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.hidden {
  display: none !important;
}

/* Bottom-Right Utility Pills — Keeps Top HUD Completely Centered! */
.utility-bar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 35;
  display: flex;
  gap: 8px;
}

.icon-pill {
  background: var(--parchment);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  border-radius: 12px;
  padding: 7px 13px;
  font-weight: 900;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.08s ease, background 0.12s ease;
}

.icon-pill:hover {
  background: var(--parchment-hi);
  transform: translateY(-1px);
}

.icon-pill:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.danger-pill {
  background: #fee2e2;
  color: #991b1b;
}

/* Lobby Floating Dockhouse Signpost */
.lobby-layer {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 16px clamp(18px, 4.5vw, 60px) 62px;
}

.logo-lockup {
  width: min(408px, 94vw);
  text-align: center;
  margin-bottom: 10px;
}

.game-logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.8vw, 52px);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fef3c7;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 6px 0 var(--ink);
  line-height: 1;
}

.logo-subtitle {
  display: inline-block;
  margin-top: 5px;
  background: #991b1b;
  color: #fde047;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.22em;
  padding: 4px 16px;
  border-radius: 6px;
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.lobby-card {
  pointer-events: auto;
  width: min(408px, 94vw);
  max-height: calc(100vh - 155px);
  overflow-y: auto;
  background: var(--parchment);
  border: 4px solid var(--ink);
  outline: 3px solid #78350f;
  outline-offset: -7px;
  box-shadow: 0 10px 0 var(--ink), 0 18px 36px rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* Lobby Tabs */
.lobby-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #dfd0b1;
  padding: 4px;
  border-radius: 11px;
  border: 2.5px solid var(--ink);
}

.tab-btn {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 900;
  color: #573b26;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--parchment-hi);
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-group, .outfit-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group label, .stakes-box label, .outfit-section label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
  color: #573b26;
}

input[type="text"] {
  user-select: text;
  width: 100%;
  padding: 8px 11px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  background: var(--parchment-hi);
  border: 3px solid var(--ink);
  border-radius: 9px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #b45309;
  background: #ffffff;
}

/* Outfitter Style Chips & Swatch Grids */
.style-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.style-chip {
  flex: 1 1 auto;
  background: var(--parchment-hi);
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
}

.style-chip:hover {
  background: #fef3c7;
}

.style-chip.active {
  background: var(--brass);
  box-shadow: 0 2px 0 var(--ink);
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}

.compact-swatches {
  grid-template-columns: repeat(6, 1fr);
}

.swatch {
  height: 24px;
  border-radius: 7px;
  background: var(--c);
  border: 2.5px solid var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.swatch.active {
  transform: scale(1.16) translateY(-2px);
  box-shadow: 0 3px 0 var(--ink);
}

.equipped-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e7dac0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 5px 11px 5px 5px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.equipped-preview:hover {
  background: #dfd0b1;
}

.equipped-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.22;
}

.equipped-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #573b26;
}

.equipped-meta strong {
  font-size: 15px;
  font-weight: 900;
}

.equipped-dmg {
  font-size: 12px;
  font-weight: 800;
  color: #9a3412;
}

.change-chip {
  font-size: 11px;
  font-weight: 900;
  background: var(--parchment-hi);
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 4px 8px;
}

/* Playing For (Stakes) Box */
.stakes-box {
  background: #eadec5;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stakes-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-chip {
  background: var(--parchment-hi);
  border: 2px solid var(--ink);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.preset-chip:hover {
  background: #fef3c7;
}

.preset-chip.active {
  background: var(--brass);
  font-weight: 900;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.split-row, .join-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.join-row {
  grid-template-columns: 115px 1fr;
}

#roomCodeInput {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.16em;
  font-size: 15px;
}

.btn {
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-primary {
  background: var(--brass);
  font-size: 14.5px;
}

.btn-secondary {
  background: #38bdf8;
}

.btn-accent {
  background: #4ade80;
}

.btn-ghost {
  background: var(--parchment-hi);
}

.btn-danger {
  background: var(--buoy);
  color: #ffffff;
}

.btn-small {
  padding: 7px 14px;
  font-size: 12px;
}

.open-rooms-box {
  border-top: 2px dashed rgba(23, 28, 38, 0.25);
  padding-top: 7px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.open-rooms-label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #9a3412;
}

.open-rooms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.room-chip {
  background: #fef3c7;
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.room-chip:hover {
  background: #4ade80;
}

/* 100% CENTERED Top HUD */
.hud-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 20px 20px;
}

.top-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

.fighter-hud {
  background: var(--slate);
  color: #f8fafc;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  border-radius: 14px;
  padding: 8px 13px;
}

.fighter-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  gap: 8px;
}

.fighter-name {
  font-weight: 900;
  font-size: 15px;
  color: #fef3c7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fighter-fish {
  font-size: 11px;
  font-weight: 800;
  color: #171c26;
  background: #fde047;
  padding: 2px 8px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  white-space: nowrap;
}

.hp-track {
  position: relative;
  height: 20px;
  background: #090d16;
  border: 2.5px solid #000000;
  border-radius: 8px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}

.fighter-hud.right .hp-fill {
  margin-left: auto;
}

.hp-fill.low-hp {
  background: linear-gradient(90deg, #b91c1c, #ef4444);
}

.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 2px #000000;
}

.center-pill {
  background: var(--slate);
  color: #ffffff;
  border: 3px solid #eab308;
  box-shadow: 0 4px 0 var(--ink);
  border-radius: 14px;
  padding: 6px 18px;
  text-align: center;
  min-width: 225px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stakes-ribbon {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #fde047;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-banner {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.role-banner.attack-mode {
  color: #fca5a5;
}

.role-banner.defend-mode {
  color: #7dd3fc;
}

.round-timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 900;
  color: #cbd5e1;
}

.timer-ring {
  color: #fde047;
  font-size: 14px;
}

/* Personal Room Waiting & Direct Link Card */
.waiting-card {
  pointer-events: auto;
  align-self: center;
  margin: auto 0;
  width: min(420px, 94vw);
  background: var(--parchment);
  border: 4px solid var(--ink);
  box-shadow: 0 8px 0 var(--ink);
  border-radius: 18px;
  padding: 18px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.waiting-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #573b26;
}

.waiting-stakes {
  font-size: 13px;
  font-weight: 900;
  color: #9a3412;
  background: #fef3c7;
  border: 2px solid var(--ink);
  padding: 4px 12px;
  border-radius: 8px;
}

.invite-link-btn {
  width: 100%;
  font-size: 15px;
  padding: 11px 14px;
}

.invite-url-row {
  width: 100%;
}

#inviteUrlDisplay {
  font-size: 12px;
  text-align: center;
  background: #eadec5;
  color: #3f2e21;
  cursor: pointer;
}

.waiting-or-code {
  font-size: 12px;
  font-weight: 800;
  color: #44403c;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-code-pill {
  background: #fde047;
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
}

/* Boatside Fish-Catching Reel Meter */
.catch-card {
  pointer-events: auto;
  align-self: center;
  margin-bottom: 18px;
  background: var(--parchment);
  border: 4px solid var(--ink);
  box-shadow: 0 8px 0 var(--ink), 0 14px 28px rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  padding: 14px 20px;
  width: min(440px, 94vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.catch-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.catch-kicker {
  font-size: 13px;
  font-weight: 900;
  color: #991b1b;
}

.catch-species {
  font-size: 12px;
  font-weight: 800;
  color: #573b26;
}

.reel-bar-track {
  position: relative;
  width: 100%;
  height: 30px;
  border-radius: 10px;
  border: 3px solid var(--ink);
  background: linear-gradient(90deg, #64748b 0%, #38bdf8 26%, #4ade80 42%, #fde047 50%, #4ade80 58%, #38bdf8 74%, #64748b 100%);
  overflow: hidden;
  cursor: pointer;
}

.reel-zone-sweet {
  position: absolute;
  left: 41%;
  width: 18%;
  top: 0;
  bottom: 0;
  border-left: 2.5px dashed var(--ink);
  border-right: 2.5px dashed var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.08em;
}

.reel-needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 8px;
  margin-left: -4px;
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  left: 50%;
}

.reel-btn {
  width: 100%;
  font-size: 16px;
}

.catch-status {
  font-size: 13px;
  font-weight: 900;
  color: #15803d;
}

/* Minimal Hover Instruction Pill at Bottom */
.choose-hint {
  align-self: center;
  background: rgba(15, 23, 42, 0.85);
  color: #fef3c7;
  border: 2.5px solid #eab308;
  border-radius: 999px;
  padding: 7px 20px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* Match Finished Card */
.result-card {
  pointer-events: auto;
  align-self: center;
  margin: auto 0;
  background: var(--parchment);
  border: 4px solid var(--ink);
  outline: 3px solid #78350f;
  outline-offset: -7px;
  box-shadow: 0 10px 0 var(--ink), 0 18px 36px rgba(0, 0, 0, 0.5);
  border-radius: 20px;
  padding: 22px 26px;
  text-align: center;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.result-kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #9a3412;
}

.result-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 900;
  color: #eab308;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 4px 0 var(--ink);
}

.stakes-won-banner {
  background: var(--ink);
  color: #fde047;
  font-size: 13px;
  font-weight: 900;
  padding: 6px 14px;
  border-radius: 8px;
  border: 2px solid #eab308;
  max-width: 100%;
}

.result-sub {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #44403c;
}

.unlock-callout {
  width: 100%;
  background: linear-gradient(135deg, #fef9c3, #fde047);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.unlock-badge {
  background: var(--ink);
  color: #fde047;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 6px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--parchment);
  border: 4px solid var(--ink);
  box-shadow: 0 10px 0 var(--ink);
  border-radius: 20px;
  width: min(690px, 96vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
}

.modal-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #573b26;
}

.close-btn {
  background: var(--parchment-hi);
  border: 3px solid var(--ink);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.fish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.fish-card {
  background: var(--parchment-hi);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.12s ease;
}

.fish-card:hover:not(.locked) {
  transform: translateY(-2px);
  background: #ffffff;
}

.fish-card.equipped {
  background: #dcfce7;
  box-shadow: 0 4px 0 var(--ink);
}

.fish-card.locked {
  opacity: 0.7;
  cursor: not-allowed;
  background: #e5ded0;
}

.fish-card strong {
  font-size: 14px;
  font-weight: 900;
}

.fish-dmg-pill {
  font-size: 11px;
  font-weight: 900;
  background: #fde047;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 2px 8px;
}

.fish-status-tag {
  font-size: 11px;
  font-weight: 800;
  color: #44403c;
  margin-top: 2px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--parchment-hi);
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  font-weight: 800;
}

.lb-rank {
  width: 28px;
  font-weight: 900;
  color: #9a3412;
}

.lb-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lb-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}

.toast {
  position: fixed;
  bottom: calc(70px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 92vw;
  text-align: center;
  word-break: break-word;
  background: var(--ink);
  color: #fde047;
  font-weight: 800;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 2px solid #eab308;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.35);
}

/* Prevent iOS Safari auto-zoom, remove sticky mobile :hover, & boost touch press feel */
@media (hover: none) {
  .btn:hover,
  .icon-pill:hover,
  .fish-card:hover:not(.locked) {
    transform: none;
    filter: none;
  }

  .style-chip:active:not(.active),
  .preset-chip:active:not(.active),
  .room-chip:active {
    transform: scale(0.96);
    background: #fde68a;
  }

  .swatch:active {
    transform: scale(0.92);
  }

  .fish-card:active:not(.locked) {
    transform: scale(0.97);
  }
}

@media (pointer: coarse), (max-width: 860px) {
  input[type="text"],
  #roomCodeInput,
  #inviteUrlDisplay {
    font-size: 16px;
  }

  .style-chip {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .preset-chip {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 11.5px;
  }

  .close-btn {
    width: 42px;
    height: 42px;
  }
}

/* ==========================================================================
   MOBILE PORTRAIT (Phones & Narrow Tablets in Portrait)
   ========================================================================== */
@media (max-width: 820px) and (orientation: portrait) {
  /* In Lobby: keep Utility Pills in Top-Right so Bottom Card gets 100% width */
  body:not(.in-room) .utility-bar {
    top: calc(10px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    bottom: auto;
    gap: 6px;
  }

  /* In Match: dock Utility Pills cleanly at Bottom-Center below HUD action area */
  body.in-room .utility-bar {
    bottom: calc(8px + var(--safe-bottom));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    gap: 6px;
  }

  .icon-pill {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 10px;
  }

  .lobby-layer {
    align-items: center;
    justify-content: flex-end;
    padding: calc(48px + var(--safe-top)) 10px calc(12px + var(--safe-bottom));
  }

  .logo-lockup {
    width: min(400px, 94vw);
    margin-bottom: 8px;
  }

  .game-logo {
    font-size: clamp(28px, 8.5vw, 40px);
  }

  .logo-subtitle {
    font-size: 11px;
    padding: 3px 12px;
  }

  .lobby-card {
    width: min(420px, 95vw);
    max-height: calc(100dvh - 132px - var(--safe-top) - var(--safe-bottom));
    padding: 12px 14px;
    gap: 9px;
  }

  /* When Outfitter Tab is open on Portrait, leave top ~45% open for live Boat & Skipper preview! */
  body.outfit-open .logo-lockup {
    display: none;
  }

  body.outfit-open .lobby-card {
    max-height: 55dvh;
  }

  /* Generous 5-column × 2-row thumb-friendly color swatches instead of tiny 10-col slivers */
  .color-swatches {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .compact-swatches {
    grid-template-columns: repeat(6, 1fr);
  }

  .swatch {
    height: 31px;
  }

  /* Centered Compact Portrait Match HUD */
  .hud-layer {
    padding: calc(8px + var(--safe-top)) 10px calc(54px + var(--safe-bottom));
  }

  .top-hud {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
  }

  .center-pill {
    grid-column: 1 / -1;
    order: -1;
    width: 100%;
    min-width: 0;
    padding: 5px 12px;
    border-radius: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 2px 8px;
  }

  .stakes-ribbon {
    width: 100%;
    max-width: 100%;
    text-align: center;
    font-size: 9.5px;
  }

  .role-banner {
    font-size: 13px;
  }

  .round-timer-row {
    font-size: 11.5px;
    gap: 6px;
  }

  .fighter-hud {
    padding: 6px 8px;
    border-radius: 11px;
  }

  .fighter-meta {
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    margin-bottom: 4px;
  }

  .fighter-hud.right .fighter-meta {
    align-items: flex-end;
  }

  .fighter-name {
    font-size: 13px;
  }

  .fighter-fish {
    font-size: 10px;
    padding: 1px 6px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    align-self: flex-start;
  }

  .fighter-hud.right .fighter-fish {
    align-self: flex-end;
  }

  .hp-track {
    height: 17px;
  }

  .choose-hint {
    padding: 6px 14px;
    font-size: 12px;
    max-width: 94vw;
    text-align: center;
  }

  .catch-card {
    padding: 12px 14px;
    margin-bottom: 4px;
    gap: 8px;
  }

  .catch-header {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .reel-bar-track {
    height: 34px;
  }

  .waiting-card,
  .result-card {
    padding: 16px 16px;
    max-height: calc(100dvh - 185px - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
  }

  .result-title {
    font-size: 30px;
  }

  .fish-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .modal-box {
    padding: 14px;
    max-height: 88dvh;
  }
}

/* ==========================================================================
   MOBILE LANDSCAPE (Short Height Viewports, e.g. 667×375, 844×390, 915×412)
   ========================================================================== */
@media (max-height: 540px) and (orientation: landscape) {
  /* In Lobby: tuck Utility Pills bottom-left under the logo, away from Right Card */
  body:not(.in-room) .utility-bar {
    bottom: calc(10px + var(--safe-bottom));
    left: calc(14px + var(--safe-left));
    right: auto;
    gap: 6px;
  }

  body.in-room .utility-bar {
    bottom: calc(8px + var(--safe-bottom));
    right: calc(12px + var(--safe-right));
    gap: 6px;
  }

  .icon-pill {
    padding: 5px 9px;
    font-size: 11.5px;
    border-radius: 9px;
    box-shadow: 0 3px 0 var(--ink);
  }

  /* Side-by-side 2-column Lobby: Harbor + Logo on Left, Full-Height Card on Right! */
  .lobby-layer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: calc(8px + var(--safe-top)) calc(14px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(14px + var(--safe-left));
  }

  .logo-lockup {
    width: auto;
    max-width: 40vw;
    margin-bottom: 0;
    align-self: flex-start;
    margin-top: 6px;
    transition: opacity 0.18s ease;
  }

  /* Clear left harbor view completely when customizing Skipper & Boat in Landscape! */
  body.outfit-open .logo-lockup {
    opacity: 0;
    pointer-events: none;
  }

  .game-logo {
    font-size: clamp(24px, 3.8vw, 36px);
  }

  .logo-subtitle {
    font-size: 10.5px;
    padding: 2px 11px;
  }

  .lobby-card {
    width: min(410px, 54vw);
    max-height: calc(100dvh - 16px - var(--safe-top) - var(--safe-bottom));
    padding: 10px 13px;
    gap: 7px;
    border-radius: 14px;
  }

  .tab-btn {
    padding: 5px 6px;
    font-size: 11px;
  }

  .equipped-preview {
    padding: 3px 9px 3px 3px;
  }

  #lobbyFishThumb {
    width: 84px;
    height: 40px;
  }

  .stakes-box {
    padding: 6px 8px;
    gap: 4px;
  }

  .btn {
    padding: 7px 11px;
    font-size: 12.5px;
  }

  .color-swatches {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }

  .swatch {
    height: 26px;
  }

  /* Sleek Single-Row Centered Landscape HUD (~46px tall so Fishermen fill the pier!) */
  .hud-layer {
    padding: calc(6px + var(--safe-top)) calc(12px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
  }

  .top-hud {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    max-width: 820px;
  }

  .fighter-hud {
    padding: 4px 9px;
    border-radius: 10px;
    box-shadow: 0 3px 0 var(--ink);
  }

  .fighter-meta {
    margin-bottom: 3px;
    gap: 5px;
  }

  .fighter-name {
    font-size: 12px;
  }

  .fighter-fish {
    font-size: 9.5px;
    padding: 1px 5px;
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hp-track {
    height: 14px;
  }

  .hp-text {
    font-size: 10px;
  }

  .center-pill {
    min-width: 165px;
    padding: 3px 12px;
    border-radius: 10px;
    gap: 1px;
  }

  .stakes-ribbon {
    font-size: 8.5px;
    max-width: 190px;
  }

  .role-banner {
    font-size: 12px;
  }

  .round-timer-row {
    font-size: 10.5px;
  }

  .timer-ring {
    font-size: 12px;
  }

  .catch-card {
    width: min(400px, 66vw);
    padding: 7px 14px;
    gap: 5px;
    margin-bottom: 2px;
    border-radius: 13px;
  }

  .reel-bar-track {
    height: 24px;
  }

  .reel-btn {
    padding: 6px 12px;
    font-size: 13.5px;
  }

  .choose-hint {
    padding: 4px 14px;
    font-size: 11.5px;
  }

  .waiting-card,
  .result-card {
    width: min(430px, 78vw);
    max-height: calc(100dvh - 64px - var(--safe-top) - var(--safe-bottom));
    overflow-y: auto;
    padding: 10px 16px;
    gap: 6px;
  }

  .result-title {
    font-size: 25px;
  }

  .unlock-callout {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    padding: 6px 10px;
    gap: 6px;
  }

  #unlockFishCanvas {
    width: 96px;
    height: 44px;
  }

  .modal-box {
    max-height: 90dvh;
    padding: 12px 15px;
  }

  .fish-grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 8px;
  }
}
