* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: #0d0f14;
  color: #e8e8e8;
}
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.5px;
}
.subtitle { color: #b8b8b8; margin-top: 6px; }
.history-summary {
  margin: 16px 0;
  padding: 12px 16px;
  background: #131721;
  border: 1px solid #1f2532;
  border-radius: 12px;
  color: #cfd6e2;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.section-header strong {
  color: #f1f5ff;
  letter-spacing: 0.3px;
}
.section-toggle {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
}
.history-summary.collapsed #historySummaryText {
  display: none;
}
.image-section.collapsed #imageWrap {
  display: none;
}
.status {
  margin: 16px 0 8px;
  color: #b1d4b8;
  font-weight: 600;
}
.status.waiting {
  opacity: 0.7;
}
.scene {
  background: #141820;
  border: 1px solid #1f2530;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 5px 18px rgba(0,0,0,0.3);
}
.scene.waiting {
  opacity: 0.6;
}
.image-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  background: #0a0c10;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid #222836;
}
#sceneImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.img-fallback {
  padding: 16px;
  text-align: center;
  color: #9aa4b2;
}
.map-container {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}
.middle-earth-map {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid #1f2530;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: block;
}
#mapPins {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: crimson;
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0,0,0,0.7);
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
}
.pin-label {
  position: absolute;
  transform: translate(-50%, 0);
  margin-top: 4px;
  padding: 2px 4px;
  font-size: 10px;
  background: rgba(0,0,0,0.7);
  color: #f8f8f0;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}
.desc { line-height: 1.5; font-size: 16px; }
.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.btn {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #2b3342;
  background: #1a2030;
  color: #e8e8e8;
  cursor: pointer;
  transition: transform 0.04s ease, background 0.2s ease;
  text-align: left;
}
.btn:hover { transform: translateY(-1px); background: #21283a; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.selected { 
  background: #2d4a3e; 
  border-color: #3d6a4e; 
  box-shadow: 0 0 8px rgba(45, 106, 56, 0.4);
}
.primary { background: #244a2c; border-color: #2d6a38; }
.primary:hover { background: #2d6a38; }
.ghost { background: transparent; color: #9aa4b2; }
.lbl { display:block; margin-bottom: 6px; color: #b8b8b8; }
textarea {
  width: 100%;
  background: #0f131b;
  color: #e8e8e8;
  border: 1px solid #263045;
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
}
.row { display: flex; gap: 10px; margin-top: 10px; }
.game-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  line-height: 1.5;
  font-size: 16px;
}
.game-result.lose strong {
  color: #ff6b6b;
}
.game-result.win strong {
  color: #51cf66;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #2a3344;
  border-top-color: #8fd1a5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
