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

:root {
  --bg: #0a0e1a;
  --card: #1a1f2e;
  --accent: #f59e0b;
  --text: #f3f4f6;
  --dim: #b8bfc9;  /* Improved contrast: was #9ca3af (3.8:1), now ~5.2:1 */
  --border: #374151;
  --danger: #ef4444;
  --success: #10b981;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link - visible on focus for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Inline icons */
.inline-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.25rem;
}

.inline-icon svg {
  display: block;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html, body {
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, #111827 100%);
  color: var(--text);
  min-height: 100vh;
  padding: 1rem;
}

/* SVG Icon styling */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.icon svg {
  display: block;
}

.screen { max-width: 700px; margin: 0 auto; }

/* Hide focus outline on main content (used for screen reader focus management) */
#main-content:focus {
  outline: none;
}

.title { 
  font-size: 3rem; 
  font-weight: 800; 
  color: var(--accent); 
  text-align: center; 
  margin-bottom: 1rem;
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.subtitle { 
  text-align: center; 
  color: var(--dim); 
  margin-bottom: 2rem;
  font-size: 1.125rem;
}

.scenario-name {
  text-align: center;
  color: var(--accent);
  font-size: 1.25rem;
  font-style: italic;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.btn {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.btn:focus {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.time { 
  font-size: 1.25rem; 
  color: var(--accent);
  font-weight: 600;
}

.toggle {
  cursor: pointer;
  font-size: 0.875rem;
  font: inherit;
  color: var(--dim);
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s;
}

.toggle:hover { 
  color: var(--text);
  border-color: var(--accent);
}

.toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle:focus:not(:focus-visible) {
  outline: none;
}

.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Flashlight toggle - icon-only pill in header */
.flashlight-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.2s;
}

.flashlight-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.flashlight-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flashlight-toggle:focus:not(:focus-visible) {
  outline: none;
}

.flashlight-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flashlight-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
}

/* Inventory toggle - icon-only pill */
.inventory-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.2s;
}

.inventory-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.inventory-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inventory-toggle:focus:not(:focus-visible) {
  outline: none;
}

.inventory-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inventory-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
}

.inventory-toggle.highlight {
  animation: pulse 1.5s infinite;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.inventory-toggle .toggle-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.25rem;
}

.inventory-toggle.active {
  width: auto;
  padding: 0 0.75rem;
}

.toggle.highlight {
  animation: pulse 1.5s infinite;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Light indicator in header */
.light-indicator {
  font-size: 1.25rem;
  opacity: 0.7;
  filter: grayscale(30%);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Resources */
.resources {
  background: var(--card);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.resource { text-align: center; }

.resource-label { 
  font-size: 0.75rem; 
  color: var(--dim); 
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.resource-value { 
  font-size: 1.125rem; 
  font-weight: 600;
}

.resource-value.warning { color: var(--accent); }
.resource-value.danger { color: var(--danger); }
.resource-value.success { color: var(--success); }

/* Stat animations */
.resource-value.stat-new {
  animation: statNew 1.5s ease-out;
}

.resource-value.stat-increased {
  animation: statIncrease 0.6s ease-out;
}

.resource-value.stat-decreased {
  animation: statDecrease 0.6s ease-out;
}

@keyframes statNew {
  0% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); color: var(--accent); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes statIncrease {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); color: var(--success); }
  100% { transform: scale(1); }
}

@keyframes statDecrease {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); color: var(--danger); }
  100% { transform: scale(1); }
}

/* Inventory */
.inventory {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.inventory-header {
  font-size: 0.75rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
}

.inventory-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.75rem;
  font-size: 0.875rem;
}

.inventory-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(245, 158, 11, 0.05);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font: inherit;
  color: inherit;
  text-align: center;
}

.inventory-item:hover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
}

.inventory-item:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.inventory-item:focus:not(:focus-visible) {
  outline: none;
}

.inventory-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inventory-item.active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
}

.inventory-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
}

.inventory-icon .icon svg {
  width: 20px;
  height: 20px;
}

.inventory-name {
  font-size: 0.75rem;
  text-align: center;
  color: var(--dim);
}

.inventory-detail {
  font-size: 0.7rem;
  color: var(--accent);
  text-align: center;
}

.inventory-empty {
  font-size: 0.875rem;
  color: var(--dim);
  font-style: italic;
}

/* Phone Overlay */
.phone-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.phone-screen {
  background: #000;
  border: 4px solid #333;
  border-radius: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.phone-header {
  padding: 1rem;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.phone-battery {
  color: #888;
  font-size: 0.875rem;
}

.phone-close {
  background: var(--danger);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

.phone-close:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

.phone-close:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.phone-content { padding: 1rem; }

.phone-emergency {
  background: var(--danger);
  color: white;
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
}

.phone-emergency:hover { opacity: 0.9; }

.phone-emergency:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

.phone-emergency:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.phone-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.phone-post {
  background: #1a1a1a;
  padding: 0.75rem;
  border-radius: 8px;
}

.phone-username {
  color: #1d9bf0;
  font-weight: 600;
  font-size: 0.875rem;
}

.phone-text {
  color: #e7e9ea;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.phone-time {
  color: #9ca3af;  /* Improved contrast: was #71767b (3.2:1), now ~4.6:1 */
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.phone-no-network {
  text-align: center;
  color: var(--dim);
  padding: 2rem;
  font-style: italic;
}

/* Narrative */
.narrative {
  background: var(--card);
  border-radius: 12px;
  border-top: 3px solid var(--accent);
  padding: 2rem;
  margin-bottom: 1.5rem;
  line-height: 1.8;
  font-size: 1rem;
}

.narrative strong {
  color: var(--accent);
  font-weight: 600;
}

.narrative .hint {
  color: var(--accent);
  font-style: italic;
}

.narrative .warning {
  color: var(--danger);
  font-weight: 600;
}

.narrative .success { color: var(--success); }

/* Choices - full-width stacked buttons for narrative decisions */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.choice {
  background: var(--card);
  border: 2px solid var(--border);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}

.choice:hover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
}

.choice:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.choice:focus:not(:focus-visible) {
  outline: none;
}

.choice:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.choice-detail {
  font-size: 0.875rem;
  color: var(--dim);
  line-height: 1.4;
}

/* Inline choices within narrative */
.choice-inline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 320px;
  margin: 1rem auto;
}

/* Override .btn styles within .choice-inline to match card style */
.choice-inline .btn {
  background: var(--card);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 1.25rem;
  text-align: left;
}

.choice-inline .btn:hover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
  opacity: 1;
  transform: none;
}

.choice-inline .btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.choice-inline .btn:focus:not(:focus-visible) {
  outline: none;
}

.choice-inline .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Actions */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.action {
  background: var(--card);
  border: 2px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font: inherit;
  color: inherit;
  text-align: left;
}

.action:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.action:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.action:focus:not(:focus-visible) {
  outline: none;
}

.action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.action.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.action.locked:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.action-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.action-detail {
  font-size: 0.875rem;
  color: var(--dim);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.action-cost {
  font-size: 0.75rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lock-reason {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--danger);
  font-style: italic;
}

/* ===========================================
   MOBILE RESPONSIVE STYLES
   =========================================== */

/* Medium screens - tablets and large phones */
@media (max-width: 640px) {
  body {
    padding: 0.75rem;
  }
  
  .title {
    font-size: 2.25rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .scenario-name {
    font-size: 1.125rem;
  }
  
  .header {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .time {
    font-size: 1rem;
  }
  
  .narrative {
    padding: 1.25rem;
    font-size: 0.9375rem;
  }
  
  .resources {
    padding: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
  }
  
  .resource-value {
    font-size: 1rem;
  }
  
  .actions {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .action {
    padding: 0.875rem;
  }
  
  .inventory-items {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  }
}

/* Small screens - mobile phones */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }
  
  .title {
    font-size: 1.875rem;
  }
  
  .subtitle {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
  }
  
  .scenario-name {
    font-size: 1rem;
  }
  
  .header {
    padding: 0.625rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .time {
    font-size: 0.9375rem;
  }
  
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
  
  .narrative {
    padding: 1rem;
    font-size: 0.9375rem;
    line-height: 1.7;
    margin-bottom: 1rem;
  }
  
  .resources {
    padding: 0.875rem;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  
  .resource-label {
    font-size: 0.625rem;
  }
  
  .resource-value {
    font-size: 0.875rem;
  }
  
  .actions {
    margin-bottom: 1.5rem;
  }
  
  .action {
    padding: 0.75rem;
  }
  
  .action-title {
    font-size: 0.9375rem;
  }
  
  .action-detail {
    font-size: 0.8125rem;
  }
  
  .action-cost {
    font-size: 0.6875rem;
  }
  
  .choice {
    padding: 0.875rem 1rem;
  }
  
  .choice-title {
    font-size: 0.9375rem;
  }
  
  .choice-detail {
    font-size: 0.8125rem;
  }
  
  .inventory {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }
  
  .inventory-items {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  
  .inventory-item {
    padding: 0.375rem;
  }
  
  .inventory-name {
    font-size: 0.625rem;
  }
  
  .inventory-detail {
    font-size: 0.5625rem;
  }
  
  .inventory-toggle,
  .flashlight-toggle {
    width: 36px;
    height: 36px;
  }
  
  /* Phone overlay adjustments */
  .phone-overlay {
    padding: 0.5rem;
  }
  
  .phone-screen {
    border-radius: 16px;
    max-height: 95vh;
  }
  
  .phone-header {
    padding: 0.75rem;
  }
  
  .phone-content {
    padding: 0.75rem;
  }
}

/* Extra small screens - older/smaller phones */
@media (max-width: 360px) {
  .title {
    font-size: 1.5rem;
  }
  
  .header {
    padding: 0.5rem;
  }
  
  .time {
    font-size: 0.875rem;
  }
  
  .resources {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .inventory-items {
    grid-template-columns: repeat(2, 1fr);
  }
}
