:root {
  --bg: #0b1020;
  --panel: rgba(16,26,51,0.8);
  --text: #e7ecff;
  --muted: #aab4dd;
  --border: rgba(255,255,255,0.10);
  --radius: 16px;
}

/* ------------------ BASE ------------------ */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 900px at 20% -10%, #2b2456 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.pageWrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}

/* Slightly tighter on very small screens */
@media (max-width: 600px) {
  .pageWrap {
    padding: 12px;
  }
}

.hidden { display: none; }
.muted { color: var(--muted); }

/* ------------------ HEADER ------------------ */
h1 {
  margin: 0;
  font-size: 26px;
}

/* ------------------ TOP INFO ROW ------------------ */
.topRow {
  display: flex;
  gap: 16px;
  margin: 16px 0;
}

.infoBox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  backdrop-filter: blur(6px);
}

.imageBox {
  border-radius: 14px;
  padding: 0;
  overflow: hidden; 
  border: 1px solid rgba(255,255,255,0.08);
  width: 150px;
  height: 150px;
}


.imageBox img {
  width: 100%;
  height: 100%;
  object-fit: cover;        
  object-position: center;    
  display: block;
}


.envBox {
  flex: 1;
}

.statsLine {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ------------------ THINKING INDICATOR ------------------ */
.thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.thinking.hidden {
  display: none;
}

.thinking .dot {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out;
}

.thinking .dot:nth-child(1) { animation-delay: 0s; }
.thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.thinking .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%   { opacity: 0.2; }
  50%  { opacity: 1; }
  100% { opacity: 0.2; }
}

.thinkingText {
  margin-left: 6px;
}


/* ------------------ STORY ------------------ */
#storyBox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  backdrop-filter: blur(6px);
}

#narrative {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 17px;
}

#choices {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.choice {
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
}

.choice:hover {
  background: rgba(255,255,255,0.10);
}

/* ------------------ TABS ------------------ */
.tabBar {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.tabBtn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
}

.tabBtn.active {
  background: var(--panel);
  color: var(--text);
  border-bottom-color: transparent;
}

/* ------------------ TAB CONTENT ------------------ */
#tabContent {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0 16px 16px 16px;
  padding: 14px;
  min-height: 120px;
  backdrop-filter: blur(6px);
}

.tabPanel:not(.hidden) {
  display: block;
}


/* ------------------ LOG ------------------ */
.logEntry {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  margin-bottom: 10px;
}

/* ------------------ ACTION BUTTONS ------------------ */
.bottomActions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

button {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(40%);
}


button:hover {
  background: rgba(255,255,255,0.10);
}

.inventoryHeader {
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--muted);
}

.inventoryList {
  display: grid;
  gap: 8px;
}

.inventoryItem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
}

.inventoryItem:hover {
  background: rgba(255,255,255,0.08);
}

.inventoryItem.selected {
  background: rgba(120,140,255,0.18);
  border-color: rgba(120,140,255,0.5);
}

.inventoryActions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}




/* ------------------ STATS INFO LAYOUT ------------------ */
.statsLayout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.statInfoPanel {
  flex: 1;
  min-width: 240px;

  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;

  color: var(--text);
}

.statInfoPanel h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.statInfoPanel p {
  line-height: 1.5;
  color: var(--muted);
}


/* ------------------ STAT BUTTONS ------------------ */
.statsGrid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.statBubble {
  width: 350px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;

  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  text-align: left;

  transition: background 0.15s ease, transform 0.05s ease;
}

.statBubble:hover {
  background: rgba(255,255,255,0.10);
}

.statBubble:active {
  transform: translateY(1px);
}

.statBubble:focus-visible {
  outline: 2px solid rgba(120,140,255,0.8);
  outline-offset: 2px;
}

.statLabel {
  font-weight: 500;
}

.statValue {
  font-weight: 600;
  color: var(--muted);
}
/* ------------------ MOBILE OPTIMIZATION ------------------ */
@media (max-width: 768px) {

  /* Prevent desktop shrink-to-fit */
  .pageWrap {
    max-width: 100%;
    width: 100%;
    padding: 14px;
  }

  body {
    font-size: 16px;
  }

  /* Narrative readability */
  #narrative {
    font-size: 18px;
    line-height: 1.6;
  }

  .choice {
    font-size: 16px;
    padding: 14px 16px;
  }

  /* Stack top section */
  .topRow {
    flex-direction: column;
    gap: 12px;
  }

  /* Image fills box, no borders */
  .imageBox {
    width: 100%;
    height: 180px;
  }

  .imageBox img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* Tabs wrap cleanly */
  .tabBar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tabBtn {
    flex: 1 1 auto;
    font-size: 15px;
    padding: 10px 12px;
    text-align: center;
  }

  /* Stats layout becomes vertical */
  .statsLayout {
    flex-direction: column;
    gap: 12px;
  }

  .statsGrid {
    width: 100%;
  }

  .statBubble {
    width: 100%;
    font-size: 16px;
    padding: 14px 16px;
  }

  .statInfoPanel {
    width: 100%;
    padding: 12px;
  }

.choice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
