/* ==========================================================================
   FALLOUT PIP-BOY D&D - CLEAN & FULLY RESPONSIVE STYLES
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Share+Tech+Mono&display=swap');

:root {
  --pip-green: #18ff62;
  --pip-green-dim: #0ea63e;
  --pip-green-dark: #072610;
  --pip-glow: rgba(24, 255, 98, 0.35);
  --pip-bg: #090e0b;
  --pip-panel: #0f1a13;
  --pip-card: #132219;
  --pip-border: #1a5e2f;
  --pip-border-active: #18ff62;
  --pip-text: #d4ffd8;
  --pip-text-muted: #78a883;
  --gold: #ffb642;
  --danger: #ff4747;
}

[data-theme="amber"] {
  --pip-green: #ffb642;
  --pip-green-dim: #b87a1c;
  --pip-green-dark: #291804;
  --pip-glow: rgba(255, 182, 66, 0.35);
  --pip-bg: #0d0a07;
  --pip-panel: #1a130b;
  --pip-card: #241a10;
  --pip-border: #664112;
  --pip-border-active: #ffb642;
  --pip-text: #ffeacc;
  --pip-text-muted: #b89b7b;
  --gold: #ffcf70;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--pip-bg);
  color: var(--pip-text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle CRT scanlines */
.scanlines {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%);
  background-size: 100% 4px;
  opacity: 0.35;
}

/* Top App Bar */
.top-bar {
  background: var(--pip-panel);
  border-bottom: 2px solid var(--pip-border);
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

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

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-wrap img {
  height: 28px;
  width: auto;
  filter: drop-shadow(0 0 5px var(--pip-glow));
}

.room-badge {
  background: var(--pip-green-dark);
  border: 1px solid var(--pip-border-active);
  color: var(--pip-green);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}

.room-badge:hover {
  background: var(--pip-border);
  color: #fff;
}

.role-badge {
  font-size: 11px;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.role-badge.gm {
  background: var(--gold);
  color: #000;
}

.role-badge.player {
  background: var(--pip-border-active);
  color: #000;
}

/* Common Buttons */
.btn {
  background: var(--pip-card);
  border: 1px solid var(--pip-border);
  color: var(--pip-green);
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--pip-border-active);
  background: var(--pip-border);
  color: #fff;
  box-shadow: 0 0 8px var(--pip-glow);
}

.btn-gold {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 182, 66, 0.1);
}

.btn-gold:hover {
  background: var(--gold);
  color: #000;
  box-shadow: 0 0 10px rgba(255, 182, 66, 0.5);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Compact Dice Bar */
.dice-strip {
  background: var(--pip-panel);
  border-bottom: 1px solid var(--pip-border);
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.dice-strip-label {
  color: var(--pip-text-muted);
  font-weight: bold;
  font-size: 12px;
}

.dice-btn {
  background: #000;
  border: 1px solid var(--pip-border);
  color: var(--pip-green);
  padding: 4px 8px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.dice-btn:hover {
  border-color: var(--pip-border-active);
  background: var(--pip-green-dark);
  box-shadow: 0 0 8px var(--pip-glow);
}

.dice-mod-input {
  background: #000;
  border: 1px solid var(--pip-border);
  color: var(--pip-green);
  width: 44px;
  padding: 4px;
  font-family: inherit;
  font-size: 13px;
  text-align: center;
  outline: none;
  border-radius: 3px;
}

.dice-last-roll {
  margin-left: auto;
  font-size: 13px;
  color: #fff;
  background: var(--pip-card);
  padding: 4px 10px;
  border: 1px dashed var(--pip-border-active);
  border-radius: 4px;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

/* GM Links Hub Card */
.gm-links-card {
  background: var(--pip-panel);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: 0 0 12px rgba(255, 182, 66, 0.15);
}

.gm-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.link-item-box {
  background: var(--pip-card);
  border: 1px solid var(--pip-border);
  border-radius: 6px;
  padding: 10px 12px;
}

.link-item-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: bold;
  color: var(--pip-text-muted);
  margin-bottom: 6px;
}

.link-tip-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #331f00;
  color: var(--gold);
  border: 1px solid var(--gold);
}

.link-tip-badge.player {
  background: var(--pip-green-dark);
  color: var(--pip-green);
  border-color: var(--pip-border-active);
}

.link-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.link-readonly-input {
  flex: 1;
  background: #000;
  border: 1px solid var(--pip-border);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  outline: none;
}

.link-help-text {
  font-size: 11px;
  color: var(--pip-text-muted);
  line-height: 1.3;
}

/* Player Personal Link Card */
.player-personal-link-card {
  background: var(--pip-panel);
  border: 1px solid var(--pip-border-active);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  box-shadow: 0 0 12px var(--pip-glow);
}

/* Teammates Squad Bar */
.teammates-bar {
  margin-bottom: 20px;
}

.bar-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--pip-text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--pip-border);
}

.teammates-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.teammate-mini-card {
  background: var(--pip-card);
  border: 1px solid var(--pip-border);
  padding: 6px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  flex: 1 1 200px;
  max-width: 280px;
}

.teammate-mini-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid var(--pip-border-active);
  background: #000;
  object-fit: cover;
  flex-shrink: 0;
}

.teammate-mini-info {
  flex: 1;
  min-width: 0;
}

.teammate-mini-name {
  font-weight: bold;
  font-size: 13px;
  color: var(--pip-green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive Cards Layout */
.cards-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 20px;
  align-items: start;
}

/* Character Card */
.char-card {
  background: var(--pip-panel);
  border: 2px solid var(--pip-border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  position: relative;
  transition: border-color 0.2s;
  width: 100%;
}

.char-card:hover {
  border-color: var(--pip-border-active);
}

.card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-avatar {
  width: 68px;
  height: 68px;
  border-radius: 6px;
  border: 2px solid var(--pip-border-active);
  background: #000;
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.card-avatar:hover {
  transform: scale(1.04);
}

.card-title-wrap {
  flex: 1;
  min-width: 0;
}

.char-name-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--pip-border);
  color: var(--pip-green);
  font-family: 'Rajdhani', sans-serif;
  font-size: 20px;
  font-weight: 700;
  outline: none;
  padding: 2px 0;
}

.char-name-input:focus {
  border-bottom-color: var(--pip-border-active);
}

/* HP Box */
.hp-control-box {
  background: #000;
  border: 1px solid var(--pip-border);
  border-radius: 4px;
  padding: 6px 8px;
  margin-top: 6px;
}

.hp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 4px;
}

.hp-inputs-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hp-num-input {
  width: 42px;
  background: var(--pip-card);
  border: 1px solid var(--pip-border);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  outline: none;
  border-radius: 3px;
  padding: 2px 0;
}

.hp-progress-track {
  height: 8px;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
}

.hp-progress-fill {
  height: 100%;
  background: var(--pip-green);
  transition: width 0.25s ease;
}

.hp-progress-fill.low {
  background: var(--danger);
}

/* Custom Key-Value Fields */
.fields-group {
  margin-bottom: 16px;
  border-top: 1px solid rgba(24, 255, 98, 0.12);
  padding-top: 10px;
}

.fields-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--pip-text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fields-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--pip-card);
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.field-name-input {
  width: 42%;
  min-width: 60px;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--pip-text-muted);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  padding: 2px 0;
}

.field-name-input:focus {
  border-bottom-color: var(--pip-border-active);
  color: #fff;
}

.field-val-input {
  flex: 1;
  min-width: 60px;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--pip-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  outline: none;
  padding: 2px 0;
}

.field-val-input:focus {
  border-bottom-color: var(--pip-border-active);
}

.field-del-btn {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  flex-shrink: 0;
}

.field-del-btn:hover {
  color: var(--danger);
}

/* Custom Text Sections */
.sections-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(24, 255, 98, 0.12);
  padding-top: 10px;
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-block {
  background: var(--pip-card);
  border: 1px solid var(--pip-border);
  border-radius: 4px;
  padding: 8px 10px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(24, 255, 98, 0.08);
  padding-bottom: 4px;
}

.section-title-input {
  background: transparent;
  border: none;
  color: var(--pip-green);
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  width: 85%;
}

.section-title-input:focus {
  color: #fff;
}

.section-textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--pip-text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
  min-height: 70px;
  display: block;
}

/* Avatar Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-box {
  background: var(--pip-panel);
  border: 2px solid var(--pip-border-active);
  border-radius: 8px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.avatar-choice {
  background: #000;
  border: 1px solid var(--pip-border);
  border-radius: 4px;
  padding: 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.avatar-choice:hover {
  border-color: var(--pip-border-active);
  transform: scale(1.04);
}

.avatar-choice img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  margin-bottom: 4px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Dice Log Flyout Drawer */
.dice-log-drawer {
  position: fixed;
  bottom: 0;
  right: 16px;
  width: 320px;
  max-width: 90vw;
  background: var(--pip-panel);
  border: 1px solid var(--pip-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
  z-index: 150;
  display: none;
}

.dice-log-header {
  padding: 8px 12px;
  background: var(--pip-card);
  border-bottom: 1px solid var(--pip-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: bold;
}

.dice-log-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

/* Toast Notification */
.pip-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: var(--pip-panel);
  border: 2px solid var(--pip-border-active);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.8), 0 0 15px var(--pip-glow);
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

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

/* Mobile Responsive Adjustments */
@media (max-width: 600px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .top-bar-left, .top-bar-right {
    justify-content: space-between;
  }
  .dice-strip {
    gap: 6px;
  }
  .dice-last-roll {
    width: 100%;
    margin-left: 0;
  }
  .cards-layout-grid {
    grid-template-columns: 1fr;
  }
  .char-card {
    padding: 12px;
  }
  .card-avatar {
    width: 56px;
    height: 56px;
  }
  .pip-toast {
    width: 90%;
    text-align: center;
    white-space: normal;
  }
}
