/* ============================================================
   Battle Stations — Modern Responsive Base Stylesheet
   Reusable template CSS for all pages.
   ============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #0c0a07;
  color: #d8c8a8;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #ffcc44;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: #ffd700;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Layout Container --- */
.bs-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.bs-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* --- Header / Navbar --- */
.bs-header {
  background: linear-gradient(180deg, #3a2810 0%, #2a1a08 100%);
  border-bottom: 1px solid #5a3a1a;
  position: sticky;
  top: 0;
  z-index: 100;
}

.bs-header .bs-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.bs-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffcc44;
  white-space: nowrap;
}

.bs-logo img {
  height: 32px;
  width: auto;
}

/* Desktop nav */
.bs-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.bs-nav a,
.bs-nav button {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #c8a868;
  background: transparent;
  border: none;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
  white-space: nowrap;
}

.bs-nav a:hover,
.bs-nav button:hover {
  background: rgba(184, 136, 58, 0.15);
  color: #ffcc44;
}

.bs-nav a.active,
.bs-nav button.active {
  background: rgba(184, 136, 58, 0.2);
  color: #ffcc44;
}

/* Mobile hamburger */
.bs-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: #c8a868;
}

.bs-menu-toggle svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Mobile nav drawer */
.bs-nav-mobile {
  display: none;
  flex-direction: column;
  background: #2a1a08;
  border-bottom: 1px solid #5a3a1a;
  padding: 8px 16px 16px;
}

.bs-nav-mobile a,
.bs-nav-mobile button {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c8a868;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition:
    background 0.2s,
    color 0.2s;
}

.bs-nav-mobile a:hover,
.bs-nav-mobile button:hover {
  background: rgba(184, 136, 58, 0.15);
  color: #ffcc44;
}

.bs-nav-mobile.open {
  display: flex;
}

@media (max-width: 768px) {
  .bs-nav {
    display: none;
  }
  .bs-menu-toggle {
    display: block;
  }
}

/* --- Main Content --- */
.bs-main {
  flex: 1;
  padding: 24px 0;
}

/* --- Game Canvas Section --- */
.bs-game-section {
  background: #1e1208;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #5a3a1a;
  margin-bottom: 24px;
}

/* --- Start Panel (replaces Phaser canvas) --- */
.bs-start-panel {
  position: relative;
  background:
    linear-gradient(
      135deg,
      rgba(30, 18, 8, 0.92) 0%,
      rgba(42, 26, 8, 0.88) 100%
    ),
    url("../phaser/assets/start_loader/bg.jpg") center/cover no-repeat;
  padding: 20px 24px 24px;
}

.bs-portal-tag {
  text-align: right;
  font-size: 0.75rem;
  color: #c8a868;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  margin-bottom: 8px;
}

.bs-start-content {
  display: flex;
  gap: 24px;
  align-items: stretch;
}

/* Left column: logo + news */
.bs-start-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.bs-start-logo {
  margin-bottom: 16px;
}

.bs-start-logo img {
  max-width: 260px;
  height: auto;
}

/* News feed */
.bs-news-feed {
  flex: 1;
}

.bs-news-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffcc44;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.bs-news-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bs-news-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 0.82rem;
  line-height: 1.4;
}

.bs-news-date {
  flex-shrink: 0;
  color: #c8a868;
  min-width: 90px;
}

.bs-news-link {
  color: #d8c8a8;
  transition: color 0.2s;
}

.bs-news-link:hover {
  color: #ffcc44;
}

.bs-news-empty {
  color: #8a6a3a;
  font-size: 0.85rem;
}

.bs-news-loading {
  color: #8a6a3a;
  font-size: 0.85rem;
  font-style: italic;
}

/* Right column: ship + player */
.bs-start-right {
  flex: 0 0 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bs-start-hero {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  min-height: 250px;
  margin-bottom: 8px;
  padding-top: 8px;
  overflow: visible;
}

.bs-avatar-body-canvas {
  width: 120px;
  height: 180px;
  flex: 0 0 auto;
  overflow: hidden;
  pointer-events: none;
}

.bs-start-avatar {
  width: 200px;
  height: 300px;
  margin-left: -52px;
  margin-bottom: -4px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  overflow: visible;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
}

.bs-avatar-body-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.bs-avatar-body-canvas.bs-avatar-body-transparent,
.bs-avatar-body-canvas.bs-avatar-body-transparent canvas {
  background: transparent !important;
}

.bs-avatar-body-canvas.bs-avatar-body-outfit {
  background: transparent !important;
}

.bs-avatar-body-canvas.bs-avatar-body-dom {
  background: transparent !important;
}

.bs-avatar-body-dom-stage {
  position: relative;
  overflow: hidden;
  background: transparent !important;
}

.bs-avatar-body-dom-inner {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.bs-avatar-body-dom-inner img {
  display: block;
  image-rendering: auto;
}

/* Ship porthole */
.bs-ship-porthole {
  width: 240px;
  height: 240px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 40% 30%,
    #3a4a6a 0%,
    #1a1a2e 70%,
    #0c0c18 100%
  );
  border: 6px solid #5a3a1a;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.6),
    0 0 0 3px #8a6a3a,
    0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 0;
}

.bs-ship-frame {
  width: 190px;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bs-ship-sprite-clip {
  width: 180px;
  height: 180px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bs-ship-sprite-clip.bs-ship-sprite-stage {
  animation: shipBob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.bs-ship-sprite-viewport {
  background-repeat: no-repeat;
  background-position: 0 0;
  flex-shrink: 0;
}

.bs-ship-sprite-clip.bs-ship-sprite-stage.bs-ship-sprite-flip {
  animation: shipBobFlip 2.4s ease-in-out infinite;
  transform-origin: center center;
}

.bs-ship-sprite-clip .bs-ship-img.bs-ship-sprite-frame {
  display: block;
  max-width: none;
  max-height: none;
}

.bs-ship-img {
  max-width: 108%;
  max-height: 108%;
  object-fit: contain;
  animation: shipBob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.bs-ship-img.bs-ship-sprite-frame {
  object-fit: none;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.bs-ship-sprite-clip .bs-ship-img.bs-ship-sprite-frame.bs-ship-sprite-flip {
  animation: shipBobFlip 2.4s ease-in-out infinite;
  transform-origin: center center;
}

@keyframes shipBobFlip {
  0%,
  100% {
    transform: scaleX(-1) translateY(0);
  }
  50% {
    transform: scaleX(-1) translateY(-8px);
  }
}

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

/* Player details */
.bs-player-details {
  text-align: center;
}

.bs-player-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffcc44;
  margin-bottom: 4px;
}

.bs-player-stat {
  font-size: 0.85rem;
  color: #d8c8a8;
  line-height: 1.5;
}

/* Responsive: stack on narrow screens */
@media (max-width: 640px) {
  .bs-start-content {
    flex-direction: column;
    align-items: center;
  }
  .bs-start-right {
    flex: none;
    width: 100%;
  }
  .bs-ship-porthole {
    width: 200px;
    height: 200px;
  }
  .bs-ship-frame {
    width: 158px;
    height: 158px;
  }
  .bs-start-hero {
    min-height: 210px;
    margin-bottom: 4px;
  }
  .bs-start-avatar {
    width: 150px;
    height: 225px;
    margin-left: -36px;
    margin-bottom: 0;
  }
  .bs-avatar-body-canvas:not(.bs-start-avatar) {
    width: 90px;
    height: 135px;
  }
  .bs-start-logo img {
    max-width: 200px;
    margin: 0 auto;
  }
  .bs-start-left {
    align-items: center;
    text-align: center;
  }
  .bs-news-list li {
    flex-direction: column;
    gap: 2px;
  }
  .bs-news-date {
    min-width: auto;
  }
  .bs-portal-tag {
    text-align: center;
  }
}

/* --- Promo Banner --- */
.bs-promo {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #3a2810 0%, #2a1a08 100%);
  border-top: 1px solid #5a3a1a;
}

.bs-promo-img {
  flex: 1;
  min-width: 0;
}

.bs-promo-img a {
  display: block;
}

.bs-promo-img img {
  width: 100%;
  border-radius: 6px;
}

/* --- Play Button --- */
.bs-play-btn {
  flex-shrink: 0;
}

.bs-play-btn a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 36px;
  background: linear-gradient(135deg, #5a8832 0%, #3a6620 100%);
  border: 1px solid #7ab844;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition:
    background 0.2s,
    transform 0.15s,
    box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(90, 136, 50, 0.4);
}

.bs-play-btn a:hover {
  background: linear-gradient(135deg, #6a9a3e 0%, #5a8832 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(90, 136, 50, 0.55);
  color: #fff;
}

.bs-play-btn a:active {
  transform: translateY(0);
}

@media (max-width: 600px) {
  .bs-promo {
    flex-direction: column;
    text-align: center;
  }
  .bs-play-btn a {
    width: 100%;
    padding: 16px 24px;
  }
}

/* --- Card Panels (reusable) --- */
.bs-card {
  background: #2a1a08;
  border: 1px solid #5a3a1a;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.bs-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffcc44;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #5a3a1a;
}

/* --- Footer --- */
.bs-footer {
  background: #1e1208;
  border-top: 1px solid #5a3a1a;
  padding: 24px 0;
  margin-top: auto;
}

.bs-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.bs-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  list-style: none;
}

.bs-footer-links a {
  font-size: 0.8rem;
  color: #c8a868;
  transition: color 0.2s;
}
.bs-footer-links a:hover {
  color: #ffcc44;
}

.bs-footer-meta {
  font-size: 0.75rem;
  color: #8a6a3a;
}

.bs-footer-time {
  font-size: 0.8rem;
  color: #c8a868;
}

@media (max-width: 600px) {
  .bs-footer-inner {
    flex-direction: column;
    text-align: center;
  }
  .bs-footer-links {
    justify-content: center;
  }
}

/* --- Social embed --- */
.bs-social {
  margin-top: 16px;
  max-width: 100%;
  overflow: hidden;
}

/* --- Utility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-center {
  text-align: center;
}
.mt-sm {
  margin-top: 8px;
}
.mt-md {
  margin-top: 16px;
}
.mt-lg {
  margin-top: 24px;
}
.mb-sm {
  margin-bottom: 8px;
}
.mb-md {
  margin-bottom: 16px;
}
.mb-lg {
  margin-bottom: 24px;
}

/* --- Overlay / Popup --- */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.88);
  z-index: 999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 168, 104, 0.45) rgba(0, 0, 0, 0.35);
}

#overlay::-webkit-scrollbar {
  width: 10px;
}

#overlay::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
}

#overlay::-webkit-scrollbar-thumb {
  background: rgba(200, 168, 104, 0.45);
  border: 2px solid rgba(0, 0, 0, 0.35);
  border-radius: 999px;
}

#overlay::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 204, 68, 0.6);
}

.bs-overlay-popup {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  background: linear-gradient(135deg, rgba(30, 18, 8, 0.98) 0%, rgba(20, 12, 4, 0.98) 100%);
  border: 1px solid #5a3a1a;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
}

.bs-overlay-popup-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(90, 58, 26, 0.55);
  background: linear-gradient(180deg, rgba(42, 26, 8, 0.95) 0%, rgba(30, 18, 8, 0.9) 100%);
  flex-shrink: 0;
}

.bs-overlay-popup-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #6a5030;
  border-radius: 8px;
  background: rgba(20, 12, 4, 0.85);
  color: #ffcc44;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}

.bs-overlay-popup-close:hover {
  background: rgba(58, 40, 16, 0.95);
  border-color: #c8a868;
  color: #ffe066;
  transform: translateY(-1px);
}

.bs-overlay-popup-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 168, 104, 0.55) rgba(20, 12, 4, 0.95);
}

.bs-overlay-popup-body::-webkit-scrollbar {
  width: 8px;
}

.bs-overlay-popup-body::-webkit-scrollbar-track {
  background: rgba(20, 12, 4, 0.95);
}

.bs-overlay-popup-body::-webkit-scrollbar-thumb {
  background: rgba(200, 168, 104, 0.5);
  border: 2px solid rgba(20, 12, 4, 0.95);
  border-radius: 999px;
}

.bs-overlay-popup-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 204, 68, 0.65);
}

.bs-overlay-popup-body iframe {
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  border: none;
  background: #0c0a07;
}

.bs-guide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 28px;
  background: linear-gradient(135deg, #5a8832 0%, #3a6620 100%);
  border: 1px solid #7ab844;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 10px rgba(90, 136, 50, 0.3);
}

.bs-guide-btn:hover {
  background: linear-gradient(135deg, #6a9a3e 0%, #5a8832 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(90, 136, 50, 0.5);
  color: #fff;
}

/* Legacy popup class (backward compat) */
.main_popup {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

.main_popup_controls {
  text-align: center;
  padding: 8px 0;
}

.main_popup iframe {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: none;
  overflow: visible;
}

@media (max-width: 600px) {
  #overlay {
    padding: 8px;
  }

  .bs-overlay-popup {
    max-height: calc(100vh - 16px);
    border-radius: 10px;
  }

  .bs-overlay-popup-body iframe {
    min-height: 0;
    height: auto;
  }
}
