/* ==============================================================
   PIRATES MINI APP - HIGH-END THEME DESIGN SYSTEM
   Aesthetic: Ancient Pirate Galleon, Carved Rune Stone & Gold
   ============================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Outfit:wght@400;500;600;700;800&family=Cairo:wght@600;700;800&display=swap');

:root {
  --bg-dark: #0d0907;
  --bg-card: rgba(28, 20, 16, 0.88);
  --bg-card-border: rgba(212, 175, 55, 0.35);
  
  /* Ancient Carved Stone Button Colors (Inspired by reference) */
  --stone-face: #ded9cf;
  --stone-top: #f4f0e6;
  --stone-shadow: #8f8779;
  --stone-dark: #5c5549;
  --stone-text: #2c251e;
  
  /* Gold & Gems */
  --gold-primary: #ffd700;
  --gold-light: #fff2a3;
  --gold-dark: #aa820a;
  --ruby-primary: #ff2a2a;
  --ruby-glow: rgba(255, 42, 42, 0.6);

  /* Fonts */
  --font-pirate: 'Cinzel', serif;
  --font-body: 'Outfit', 'Cairo', sans-serif;

  --nav-height: 54px;
  --bottom-bar-height: 55px;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: #f1ebd9;
  min-height: 100vh;
  width: 100vw;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Background Atmosphere Layer (Isolated & Modular for user replacement) */
.bg-atmosphere {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('../assets/backgrounds/custom_bg.png'), url('../assets/backgrounds/custom_bg.jpg'), url('../assets/backgrounds/pirate_bg.svg');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  z-index: -2;
  filter: brightness(0.65) contrast(1.1);
}

.bg-vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
  z-index: -1;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
  padding: 10px 12px 70px 12px;
  position: relative;
}

/* ==============================================================
   CARVED STONE BUTTONS & BADGES (Signature Aesthetic)
   ============================================================== */
.stone-badge {
  background: linear-gradient(180deg, var(--stone-top) 0%, var(--stone-face) 70%, var(--stone-shadow) 100%);
  color: var(--stone-text);
  font-weight: 800;
  border-radius: 12px;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -2px 0 var(--stone-dark),
    0 3px 6px rgba(0, 0, 0, 0.6);
  border: 1px solid #786f62;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  letter-spacing: 0.5px;
}

.stone-btn {
  background: linear-gradient(180deg, var(--stone-top) 0%, var(--stone-face) 60%, var(--stone-shadow) 100%);
  color: var(--stone-text);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.88rem;
  border-radius: 10px;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    inset 0 -3px 0 var(--stone-dark),
    0 4px 8px rgba(0, 0, 0, 0.5);
  border: 1px solid #6b6357;
  cursor: pointer;
  padding: 8px 12px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: all 0.1s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.stone-btn:active {
  transform: translateY(2px);
  box-shadow: 
    inset 0 2px 3px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.6);
}

.stone-btn.active {
  background: linear-gradient(180deg, #c7beaf 0%, #ded9cf 100%);
  border-color: #d4af37;
  box-shadow: 
    0 0 10px rgba(212, 175, 55, 0.5),
    inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ==============================================================
   TOP HEADER SECTION
   ============================================================== */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.balance-card {
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  flex: 1;
}

.balance-label-val {
  display: flex;
  flex-direction: column;
}

.balance-title {
  font-size: 0.7rem;
  color: #665b4f;
  text-transform: capitalize;
  font-weight: 700;
}

.balance-number {
  font-size: 1.15rem;
  font-weight: 900;
  color: #1a140e;
  line-height: 1;
}

.icon-gem {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 4px var(--ruby-glow));
  animation: pulseGem 2.5s infinite ease-in-out;
}

@keyframes pulseGem {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 4px var(--ruby-glow)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 8px #ff4d4d); }
}

/* Profile snippet on right */
.profile-snippet {
  display: flex;
  align-items: center;
  gap: 6px;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold-primary);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  background: #1c140e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  font-size: 1.2rem;
}

/* ==============================================================
   TOP NAVIGATION TABS (Stone Tabs Row)
   ============================================================== */
.top-nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.nav-tab-btn {
  padding: 9px 4px;
  font-size: 0.82rem;
}

/* ==============================================================
   DAILY INCOME METER
   ============================================================== */
.income-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(18, 12, 9, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  margin-bottom: 12px;
  backdrop-filter: blur(4px);
}

.income-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #c9bea9;
}

.income-rate {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 900;
  color: var(--gold-light);
  font-size: 0.95rem;
}

/* ==============================================================
   FLEET VIEW: CHARACTER SHOWCASE & 12 SLOTS GRID
   ============================================================== */
.fleet-arena {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 290px;
}

/* Left Showcase Plinth */
.active-pirate-card {
  background: rgba(222, 217, 207, 0.85);
  border: 2px solid #8f8779;
  border-radius: 14px;
  box-shadow: 
    inset 0 2px 4px rgba(255, 255, 255, 0.8),
    inset 0 -4px 0 #5c5549,
    0 8px 16px rgba(0, 0, 0, 0.6);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.active-pirate-bg-glow {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.35) 0%, transparent 70%);
  pointer-events: none;
}

.active-pirate-figure {
  width: 100%;
  height: 165px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  position: relative;
}

.active-pirate-figure img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
  transition: transform 0.2s ease;
}

.pirate-level-pill {
  position: absolute;
  bottom: 85px;
  background: #ded9cf;
  border: 1px solid #6b6357;
  padding: 2px 14px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 0.95rem;
  color: #2c251e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.live-loot-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.15rem;
  font-weight: 900;
  color: #1a140e;
  margin: 6px 0;
  z-index: 2;
}

.live-loot-counter .icon-gem {
  width: 22px;
  height: 22px;
}

/* COLLECT Button */
.btn-collect {
  width: 100%;
  padding: 10px 0;
  font-size: 1.05rem;
  font-family: var(--font-pirate);
  letter-spacing: 1px;
  background: linear-gradient(180deg, #f4f0e6 0%, #ded9cf 60%, #9e9587 100%);
  border: 1.5px solid #5c5549;
  border-radius: 8px;
  color: #1a140e;
  font-weight: 900;
  box-shadow: 
    inset 0 1px 0 #ffffff,
    inset 0 -3px 0 #5c5549,
    0 4px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}

.btn-collect:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Right: 12-Slot Crew Grid */
.crew-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
}

.crew-slot {
  background: rgba(222, 217, 207, 0.7);
  border: 1.5px solid #786f62;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -2px 0 #5c5549,
    0 3px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
  padding: 4px;
}

.crew-slot:active {
  transform: scale(0.95);
}

.crew-slot.active {
  border-color: #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
  background: rgba(244, 240, 230, 0.95);
}

.slot-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

.slot-empty-icon {
  width: 32px;
  height: 32px;
  opacity: 0.2;
}

.slot-level-num {
  font-size: 0.75rem;
  font-weight: 900;
  color: #2c251e;
  line-height: 1;
  margin-top: 2px;
}

/* ==============================================================
   RECRUIT / TAVERN MARKET SECTION
   ============================================================== */
.market-section {
  margin-top: 6px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title {
  font-family: var(--font-pirate);
  font-size: 1rem;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pirate-card {
  background: rgba(222, 217, 207, 0.85);
  border: 1.5px solid #786f62;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -3px 0 #5c5549,
    0 4px 8px rgba(0, 0, 0, 0.5);
  position: relative;
}

.card-figure {
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.card-figure img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.card-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: #1a140e;
  text-align: center;
  margin-bottom: 2px;
}

.card-income-rate {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4a3e2c;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 6px;
}

.card-buy-btn {
  width: 100%;
  padding: 6px 0;
  font-size: 0.88rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #f4f0e6 0%, #ded9cf 60%, #9e9587 100%);
  border: 1px solid #5c5549;
  border-radius: 6px;
  color: #1a140e;
  box-shadow: 
    inset 0 1px 0 #ffffff,
    inset 0 -2px 0 #5c5549,
    0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.card-buy-btn:active {
  transform: translateY(1px);
}

.card-buy-btn .icon-gem {
  width: 18px;
  height: 18px;
}

/* ==============================================================
   PARTNERS / REFERRALS VIEW
   ============================================================== */
.partners-view, .profile-view, .finance-view, .admin-view {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.partners-view.active, .profile-view.active, .finance-view.active, .admin-view.active {
  display: flex;
}

.parchment-box {
  background: rgba(25, 17, 13, 0.88);
  border: 1.5px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.stats-dual-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card-item {
  background: rgba(45, 32, 25, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.stat-card-title {
  font-size: 0.75rem;
  color: #baa78e;
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.ref-link-box {
  background: #100b08;
  border: 1px solid #4a3726;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0;
  gap: 6px;
}

.ref-link-text {
  font-size: 0.82rem;
  color: #e6dfcf;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
}

.crew-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 8px;
}

.crew-table th {
  text-align: left;
  color: var(--gold-light);
  padding: 6px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.crew-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e0d8c7;
}

/* ==============================================================
   PROFILE VIEW
   ============================================================== */
.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--gold-primary);
  margin: 0 auto 10px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1c140e;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-family: var(--font-pirate);
  font-size: 1.25rem;
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 2px;
}

.profile-id-badge {
  text-align: center;
  font-size: 0.82rem;
  color: #ab9b85;
  margin-bottom: 12px;
}

.profile-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.profile-action-btn {
  padding: 12px 10px;
  font-size: 0.92rem;
}

/* ==============================================================
   DEPOSIT & WITHDRAW VIEWS
   ============================================================== */
.input-label {
  font-size: 0.82rem;
  color: #c9bea9;
  margin-bottom: 4px;
  display: block;
}

.pirate-input {
  width: 100%;
  background: #0f0a07;
  border: 1px solid #4a3726;
  border-radius: 8px;
  color: #fff;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 10px;
  outline: none;
}

.pirate-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* ==============================================================
   ADMIN PANEL VIEW (Strictly Authorized)
   ============================================================== */
.admin-badge {
  background: #b71c1c;
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: inline-block;
  margin-bottom: 8px;
}

.admin-grid-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

/* ==============================================================
   FLOATING BOTTOM BAR & LANGUAGE SELECTOR
   ============================================================== */
.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--bottom-bar-height);
  background: rgba(13, 9, 7, 0.95);
  border-top: 1px solid rgba(212, 175, 55, 0.3);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  z-index: 100;
}

.lang-selector-btn {
  background: linear-gradient(180deg, #f4f0e6 0%, #ded9cf 60%, #9e9587 100%);
  border: 1px solid #5c5549;
  border-radius: 8px;
  padding: 6px 12px;
  color: #1a140e;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 
    inset 0 1px 0 #ffffff,
    inset 0 -2px 0 #5c5549,
    0 2px 5px rgba(0, 0, 0, 0.4);
}

.lang-selector-btn .arrow-icon {
  font-size: 0.65rem;
  color: #5c5549;
}

/* ==============================================================
   MODALS (Language Drawer, Alerts, Confirmations)
   ============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet {
  background: #1c140f;
  border-top: 2px solid var(--gold-primary);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  padding: 20px 16px 30px 16px;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.8);
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-title {
  font-family: var(--font-pirate);
  color: var(--gold-light);
  font-size: 1.15rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #8c7b67;
  font-size: 1.5rem;
  cursor: pointer;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.lang-item-btn {
  background: rgba(45, 32, 25, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  color: #f1ebd9;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-item-btn:active, .lang-item-btn.selected {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

/* Toast Message */
.toast-msg {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(180deg, #f4f0e6 0%, #ded9cf 100%);
  color: #1a140e;
  border: 1px solid #786f62;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  z-index: 300;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  font-size: 0.88rem;
  pointer-events: none;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
}
