/* ==========================================
   Clicker Kingdom - Components & UI System
   ========================================== */

/* ---------- Section Header ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 10px;
}

.section-title {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: clamp(20px, 4.5vw, 28px);
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0;
  text-shadow: 0 0 16px rgba(212, 175, 55, 0.3);
}

/* ---------- Buy Button ---------- */
.buy-btn {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(212,175,55,0.3);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.buy-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(241,206,106,0.5);
}
.buy-btn:disabled {
  background: #3b3d56;
  color: #7b7e98;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Quick Upgrades Panel (Clicker View) ---------- */
.quick-upgrades-wrap {
  width: 100%;
  max-width: 480px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-upgrades-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  text-align: left;
  margin-bottom: 2px;
}

.quick-upgrade-card {
  background: rgba(28, 31, 66, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease;
}
.quick-upgrade-card:hover {
  border-color: var(--gold-bright);
}

.quick-upgrade-card.quick-upgrade-new {
  animation: popNewUpgrade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popNewUpgrade {
  0% { transform: scale(0.95); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.quick-upgrade-info {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.quick-upgrade-icon { font-size: 20px; }
.quick-upgrade-name { font-size: 13px; font-weight: 700; color: var(--parchment); }
.quick-upgrade-sub { font-size: 11px; color: var(--parchment-dim); }

/* ---------- Shop Cards & Item Lists ---------- */
.shop-tabs, .ranking-tabs, .modal-tabs {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-padding-inline: 8px;
  -webkit-overflow-scrolling: touch;
}

.shop-tab-btn, .rank-tab-btn, .modal-tab {
  background: rgba(239, 230, 202, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: var(--parchment-dim);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}
.shop-tab-btn:hover, .rank-tab-btn:hover, .modal-tab:hover {
  color: var(--parchment);
  background: rgba(239, 230, 202, 0.15);
}
.shop-tab-btn.active, .rank-tab-btn.active, .modal-tab.active {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  border-color: var(--gold-bright);
  box-shadow: 0 2px 10px rgba(212,175,55,0.4);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: rgba(28, 31, 66, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.item-card:hover {
  border-color: var(--gold-bright);
  transform: translateY(-2px);
}
.item-icon { font-size: 28px; flex-shrink: 0; }
.item-info { flex: 1; text-align: left; }
.item-name { font-size: 14px; font-weight: 700; color: var(--gold-bright); display: block; }
.item-count { font-size: 12px; color: var(--parchment); font-weight: 400; }
.item-desc { font-size: 12px; color: var(--parchment-dim); display: block; margin-top: 2px; }

/* ---------- Battle Setup & Mode Cards ---------- */
.battle-mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.battle-mode-card {
  background: rgba(28, 31, 66, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.battle-mode-card:hover {
  border-color: var(--gold-bright);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.battle-mode-icon { font-size: 32px; margin-bottom: 8px; }
.battle-mode-title { font-size: 15px; font-weight: 700; color: var(--gold-bright); margin-bottom: 4px; }
.battle-mode-desc { font-size: 12px; color: var(--parchment-dim); line-height: 1.5; }

.room-input-card {
  display: flex;
  gap: 8px;
  align-items: center;
}
.room-input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--parchment);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.room-input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(241,206,106,0.4);
}

/* ---------- Battle Arena & Tug-of-War Fill Bar ---------- */
.battle-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.battle-timer {
  font-family: 'Cinzel', serif;
  font-size: 36px;
  font-weight: 900;
  color: var(--ruby);
  text-shadow: 0 0 16px rgba(154,47,61,0.8);
}

.battle-clash-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(212,175,55,0.3);
  padding: 14px;
  border-radius: 16px;
}
.battle-army-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.battle-castle-icon { font-size: 32px; }
.battle-army-units { font-size: 14px; letter-spacing: 2px; }

.battle-center-clash {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.clash-sparks { font-size: 20px; animation: pulseSpark 0.5s infinite alternate; }
@keyframes pulseSpark {
  0% { transform: scale(0.9); }
  100% { transform: scale(1.2); }
}

.battle-vs-bar {
  width: 100%;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--gold);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.battle-frontline-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--gold-bright), var(--ruby));
  transition: width 0.15s ease-out;
  box-shadow: 0 0 12px var(--gold-bright);
}

.battle-tap-btn {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(180deg, #ff5e62, #ff9966);
  color: #fff;
  border: none;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(255, 94, 98, 0.5);
  cursor: pointer;
  transition: transform 0.08s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.battle-tap-btn:active { transform: scale(0.96); }

/* ---------- Ranking Leaderboard System ---------- */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-row {
  background: rgba(28, 31, 66, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.ranking-row.me {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--gold-bright);
  box-shadow: 0 4px 16px rgba(212,175,55,0.25);
}

.rank-badge {
  font-size: 18px;
  font-weight: 800;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  color: var(--parchment-dim);
  flex-shrink: 0;
}
.rank-badge.top1 { font-size: 22px; background: rgba(241, 206, 106, 0.25); box-shadow: 0 0 10px rgba(241,206,106,0.5); }
.rank-badge.top2 { font-size: 22px; background: rgba(220, 220, 220, 0.25); }
.rank-badge.top3 { font-size: 22px; background: rgba(205, 127, 50, 0.25); }

.rank-nickname {
  flex: 1;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--parchment);
}

.rank-title-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
}

.rank-score {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-bright);
  white-space: nowrap;
}

.ranking-empty {
  padding: 40px 20px;
  font-size: 14px;
  color: var(--parchment-dim);
  text-align: center;
  background: rgba(0,0,0,0.2);
  border-radius: 14px;
  border: 1px dashed rgba(212,175,55,0.3);
}

/* ---------- Titles Grid ---------- */
.titles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.title-card {
  background: rgba(28, 31, 66, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  padding: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.title-card:hover {
  border-color: var(--gold-bright);
  transform: translateY(-2px);
}
.title-card.equipped {
  border-color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.15);
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

.title-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-bright);
}
.title-card-desc {
  font-size: 12px;
  color: var(--parchment-dim);
  line-height: 1.5;
  flex: 1;
}

/* ---------- Missions List ---------- */
#missionsContainer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mission-card {
  background: rgba(28, 31, 66, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.mission-card:hover {
  border-color: var(--gold-bright);
}
.mission-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.mission-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-bright);
}
.mission-reward {
  font-size: 12px;
  color: var(--emerald);
  font-weight: 700;
}

/* ---------- Modal Overlays ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.6);
  position: relative;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  text-align: left;
}
.field label { font-size: 12px; color: var(--parchment-dim); }
.field input, .field select, .field textarea {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--parchment);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold-bright);
  outline: none;
}

.modal-submit {
  width: 100%;
  padding: 10px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border: none;
  border-radius: 8px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 8px;
  cursor: pointer;
}
.modal-submit:hover {
  filter: brightness(1.1);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--parchment-dim);
  font-size: 12px;
  margin-top: 10px;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--parchment);
}

/* ---------- Toast Notification ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border: 1px solid var(--gold-bright);
  color: var(--parchment);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 12px rgba(241,206,106,0.3);
  z-index: 200;
  animation: toastFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, 15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Cloud Sync Status ---------- */
.cloud-mini-badge {
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  background: rgba(255,255,255,0.04);
  color: var(--parchment-dim);
}
.cloud-mini-badge:hover {
  color: var(--parchment);
  transform: translateY(-1px);
}
.cloud-status-card {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(212, 175, 55, 0.18);
  background: linear-gradient(180deg, rgba(38, 42, 84, 0.78), rgba(20, 22, 46, 0.92));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 12px 28px rgba(0,0,0,0.18);
}
.cloud-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.cloud-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.cloud-status-pill.tone-idle {
  background: rgba(239, 230, 202, 0.08);
  color: var(--parchment-dim);
  border-color: rgba(239, 230, 202, 0.16);
}
.cloud-status-pill.tone-syncing {
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold-bright);
  border-color: rgba(212, 175, 55, 0.32);
}
.cloud-status-pill.tone-success {
  background: rgba(46, 107, 82, 0.22);
  color: #9ce7c4;
  border-color: rgba(92, 197, 149, 0.34);
}
.cloud-status-pill.tone-warning {
  background: rgba(212, 175, 55, 0.16);
  color: #ffe39a;
  border-color: rgba(241, 206, 107, 0.32);
}
.cloud-status-pill.tone-error {
  background: rgba(154, 47, 61, 0.22);
  color: #ffc2ca;
  border-color: rgba(201, 88, 108, 0.3);
}
.cloud-status-summary {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--parchment);
}
.cloud-status-detail {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--parchment-dim);
}
.cloud-status-diagnostic {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 175, 55, 0.14);
  font-size: 12px;
  color: var(--parchment-dim);
  line-height: 1.45;
}
.cloud-status-refresh {
  padding-inline: 10px;
}

@media (max-width: 640px) {
  .cloud-status-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ---------- Admin Page Card ---------- */
.admin-card {
  background: rgba(28, 31, 66, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}
