/* Kintsugi Hearth Design System */
:root {
  --bg-dark: #121418;
  --bg-workbench: #1a1d23;
  --bg-card: rgba(26, 29, 35, 0.85);
  --gold-primary: #f5b027;
  --gold-light: #ffe875;
  --gold-glow: rgba(245, 176, 39, 0.4);
  --text-main: #e6e8ec;
  --text-muted: #8e95a5;
  --accent-red: #e74c3c;
  --border-muted: rgba(255, 255, 255, 0.1);
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  user-select: none;
  -webkit-user-select: none;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 50%, #1e222a 0%, #101216 100%);
}

/* Header Navbar */
header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  background: rgba(16, 18, 22, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-muted);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold-light);
  text-shadow: 0 0 10px var(--gold-glow);
}

.artifact-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.artifact-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.artifact-stage {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.controls-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-muted);
  color: var(--text-main);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover, .icon-btn:active {
  background: rgba(245, 176, 39, 0.2);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Progress Bar Bar */
.progress-container {
  position: absolute;
  top: 60px;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  z-index: 10;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f5b027, #ffe875);
  box-shadow: 0 0 8px var(--gold-primary);
  transition: width 0.3s ease;
}

/* Main Workbench Canvas */
#game-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* Contextual Hint Badge */
#hint-badge {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 18, 22, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--gold-glow);
  color: var(--gold-light);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.5s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  text-align: center;
  max-width: 90%;
}

/* Artifact Completion & Gallery Modal Overlays */
.modal-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 20;
}

.modal-container.active {
  display: flex;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

#completion-modal {
  background: rgba(10, 12, 16, 0.75);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
}

#gallery-modal {
  background: rgba(8, 9, 12, 0.92);
  backdrop-filter: blur(16px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal-card {
  background: #1c2027;
  border: 1px solid var(--gold-primary);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--gold-glow);
  transform: translateY(20px);
  transition: transform 0.4s ease;
}

#completion-modal.active .modal-card {
  transform: translateY(0);
}

.modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: rgba(245, 176, 39, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
}

.modal-icon svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.modal-subtitle {
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 6px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #ffffff;
}

.modal-description {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.action-btn {
  background: linear-gradient(135deg, #f5b027, #d48c08);
  color: #000;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(245, 176, 39, 0.3);
  min-height: 44px;
}

.action-btn:hover, .action-btn:active {
  background: linear-gradient(135deg, #ffe875, #f5b027);
  transform: scale(1.03);
  box-shadow: 0 6px 20px rgba(245, 176, 39, 0.5);
}

.gallery-header {
  text-align: center;
  margin-bottom: 24px;
}

.gallery-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 6px;
  text-shadow: 0 0 12px var(--gold-glow);
}

.gallery-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  max-width: 800px;
  width: 100%;
  max-height: 55vh;
  overflow-y: auto;
  padding: 10px;
  margin-bottom: 24px;
}

.gallery-card {
  background: rgba(26, 30, 38, 0.8);
  border: 1px solid rgba(245, 176, 39, 0.3);
  border-radius: 12px;
  padding: 16px;
  width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.gallery-card-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
}

.gallery-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.gallery-card-tag {
  font-size: 0.7rem;
  color: var(--gold-primary);
  margin-top: 4px;
}

/* Stress Indicator Pill on Canvas UI */
.stress-pill {
  position: absolute;
  top: 72px;
  right: 16px;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid var(--accent-red);
  color: #ff6b6b;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 5;
}

.stress-pill.active {
  opacity: 1;
}

.stress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.2); }
}

@media (max-width: 480px) {
  header {
    height: 52px;
    padding: 0 10px;
  }
  .brand-title {
    font-size: 0.95rem;
  }
  .artifact-title {
    font-size: 0.85rem;
  }
  .progress-container {
    top: 52px;
  }
  .modal-card {
    padding: 20px;
  }
  .gallery-card {
    width: 110px;
    padding: 10px;
  }
}
