/* ChoreQuest - Main Responsive Layout & Component Styling */

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Press Start 2P', monospace;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-size: 0.65rem;
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: 'Press Start 2P', monospace;
}

/* App Wrapper */
#app {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px 80px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  overflow-x: hidden;
}

#app > * {
  min-width: 0;
  max-width: 100%;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  background-color: var(--bg-card);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 0.95rem;
  color: var(--gold-xp);
  text-shadow: 2px 2px 0 #000;
}

.month-badge {
  font-size: 0.6rem;
  color: #cbd5e1;
  background: #11111b;
  padding: 4px 8px;
  border: 2px solid #000;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Player Switcher */
.player-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.68rem;
  border: 3px solid #000;
  cursor: pointer;
  transition: transform 0.05s ease;
}

.player-alex {
  background-color: var(--alex-dark);
  color: #fff;
  box-shadow: 3px 3px 0 #000;
}

.player-briana {
  background-color: var(--briana-dark);
  color: #fff;
  box-shadow: 3px 3px 0 #000;
}

/* Top Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab-btn {
  font-size: 0.68rem;
  padding: 8px 14px;
  white-space: nowrap;
  background-color: #181825;
  color: var(--text-dim);
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
  cursor: pointer;
}

.nav-tab-btn.active {
  background-color: #313244;
  color: var(--gold-xp);
  border-color: #000;
  box-shadow: 2px 2px 0 #facc15;
}

/* Fairness & Scoreboard Container */
.fairness-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #181825 0%, #11111b 100%);
}

.scoreboard-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.player-card {
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid #000;
  background-color: #1e1e2e;
}

.player-avatar-box {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #11111b;
  border: 2px solid #000;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.player-name {
  font-size: 0.82rem;
  font-weight: bold;
}

.player-title {
  font-size: 0.55rem;
  color: var(--text-dim);
}

.player-score {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--gold-xp);
}

/* Tug of War Split Bar */
.tug-of-war-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tug-of-war-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  font-weight: bold;
}

.tug-bar-track {
  height: 22px;
  display: flex;
  background: #11111b;
  border: 2px solid #000;
  box-shadow: inset 1px 1px 0 #000;
  overflow: hidden;
}

.tug-alex {
  background-color: var(--alex-color);
  height: 100%;
  transition: width 0.4s ease;
}

.tug-briana {
  background-color: var(--briana-color);
  height: 100%;
  transition: width 0.4s ease;
}

.balance-status-banner {
  text-align: center;
  font-size: 0.62rem;
  padding: 6px;
  background: #11111b;
  border: 2px solid #313244;
  color: #a6e3a1;
}

/* Co-op Party Milestone */
.coop-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(250, 204, 21, 0.05);
  border: 2px dashed #ca8a04;
}

.coop-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  line-height: 1.5;
}

/* Action Bar (Buttons: Forge Quest, Quick Swap, Grimoire) */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.action-bar-left {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-bar-left .retro-select,
#preset-pairing-select {
  width: auto;
  min-width: 220px;
  max-width: 300px;
  flex: 0 1 auto;
}

/* Room Grid */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.room-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  min-width: 0;
  max-width: 100%;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  gap: 8px;
  min-width: 0;
}

.room-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.room-name {
  font-size: 0.8rem;
  color: #fff;
}

.room-subtitle {
  font-size: 0.55rem;
  color: var(--text-dim);
}

.owner-pill {
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.58rem;
  border: 2px solid #000;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.1s ease;
  flex-shrink: 0;
}

.owner-pill:hover {
  opacity: 0.85;
}

.owner-alex {
  background-color: var(--alex-color);
  color: #fff;
}

.owner-briana {
  background-color: var(--briana-color);
  color: #fff;
}

.owner-shared {
  background-color: var(--purple);
  color: #fff;
}

/* Quest List & Items (Pixel Design matching user reference) */
.quest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quest-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 14px 16px;
  background-color: #171a22;
  border: 2px solid #000;
  box-shadow: 0 4px 0 #000;
  transition: transform 0.08s ease, background-color 0.1s ease, border-color 0.1s ease;
  position: relative;
  box-sizing: border-box;
}

.quest-item:hover {
  background-color: #1c202a;
}

/* Left Accent Borders: Solid Black 4px per user specification */
.quest-item,
.quest-type-weekly,
.quest-type-extra,
.quest-type-monthly,
.quest-item.quest-done {
  border-left: 4px solid #000 !important;
}

.quest-item.quest-done {
  background-color: #142023;
}

.quest-item.quest-done:hover {
  background-color: #18272b;
}

/* 1. Title at top */
.quest-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.82rem;
  font-weight: normal;
  color: #ffffff;
  letter-spacing: 0px;
  text-transform: uppercase;
  line-height: 1.55;
  word-break: break-word;
}

/* 2. Stat Chips Row */
.quest-meta-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.52rem;
  color: #94a3b8;
  background: #10131a;
  border: 1px solid #242938;
  border-radius: 4px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

/* 3. Action Row: Button + XP Box */
.quest-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.btn-complete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  padding: 10px 16px;
  border: 3px solid #000;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0px;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  user-select: none;
}

.btn-alex-theme {
  background-color: var(--alex-color, #ef4444);
  box-shadow: 0 4px 0 var(--alex-dark, #991b1b), inset 1px 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-alex-theme:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--alex-dark, #991b1b);
}

.btn-briana-theme {
  background-color: var(--briana-color, #14b8a6);
  box-shadow: 0 4px 0 var(--briana-dark, #0f766e), inset 1px 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-briana-theme:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--briana-dark, #0f766e);
}

.btn-relog {
  background-color: #10b981;
  box-shadow: 0 4px 0 #065f46, inset 1px 1px 0 rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.btn-relog:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #065f46;
}

/* XP Box (Gold border, dark fill, gold text) */
.quest-xp-box {
  background-color: #11131a;
  border: 2px solid #facc15;
  color: #facc15;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.72rem;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: 2px 2px 0 #000;
}

/* 4. Subtle Divider */
.quest-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 6px 0 2px 0;
}

/* 5. Footer: Supplies on left, Badges on right */
.quest-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.quest-supplies-area {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.52rem;
  color: #94a3b8;
  line-height: 1.6;
  flex: 1;
  word-break: break-word;
}

.quest-badges-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.quest-badge-category {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: #94a3b8;
  background-color: #141720;
  border: 2px solid #334155;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.quest-badge-done {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: #34d399;
  background-color: #0b251e;
  border: 2px solid #10b981;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 99999;
}

.modal-content {
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #000;
  padding-bottom: 8px;
}

.modal-title {
  font-size: 1rem;
  color: var(--gold-xp);
}

.close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* Form inputs */
.pixel-input, .retro-input, .retro-select, .retro-textarea {
  width: 100%;
  background: #11111b;
  border: 2px solid #313244;
  color: #fff;
  padding: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  outline: none;
  box-sizing: border-box;
}

.pixel-input:focus, .retro-input:focus, .retro-select:focus, .retro-textarea:focus {
  border-color: var(--gold-xp);
}

.input-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  display: block;
}

/* History Feed */
.history-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #181825;
  border: 2px solid #000;
  font-size: 0.75rem;
}

/* Responsive Mobile Adjustments */
@media (max-width: 640px) {
  #app {
    padding: 8px 8px 100px 8px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .scoreboard-players {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100%;
  }

  .player-card {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .room-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    width: 100%;
    min-width: 0;
  }

  .room-card {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .logo-group {
    justify-content: space-between;
    width: 100%;
  }

  .app-title {
    font-size: 0.95rem;
  }
  
  .header-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }

  .player-toggle-btn {
    flex: 1 1 100%;
    min-height: 42px;
    justify-content: center;
    box-sizing: border-box;
  }

  .header-controls .pixel-btn {
    flex: 1 1 auto;
    min-height: 38px;
    padding: 6px 8px;
    font-size: 0.65rem;
    box-sizing: border-box;
  }

  /* Tug of War Mobile Labels */
  .tug-of-war-labels {
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
    font-size: 0.68rem;
  }
  
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  
  .action-bar-left {
    flex-direction: column;
    width: 100%;
    gap: 8px;
    min-width: 0;
  }

  #btn-open-forge, #btn-swap-pairs, #preset-pairing-select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 0.72rem;
  }

  #btn-open-forge {
    font-size: 0.75rem;
    padding: 10px 8px;
  }

  /* Quest Items on Mobile */
  .quest-item {
    padding: 14px 14px 12px 14px;
    gap: 10px;
  }

  .quest-title {
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .quest-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .btn-complete {
    flex: 1;
    height: 44px;
    min-height: 44px;
    font-size: 0.68rem;
  }

  .quest-xp-box {
    height: 44px;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 0.72rem;
  }

  /* Modals Mobile */
  .modal-overlay {
    padding: 8px;
  }

  .modal-content {
    padding: 14px;
    max-height: 92vh;
    border-width: 2px;
  }

  .nav-tabs {
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-tab-btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.72rem;
  }
}
