:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101411;
  color: #eee8d9;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: radial-gradient(circle at 12% 0%, #26382a 0, #101411 35rem), #101411;
}

button { font: inherit; }

.shell { max-width: 1440px; margin: 0 auto; padding: 34px 30px 44px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: #8fa88c; font-size: 10px; font-weight: 800; letter-spacing: .19em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 700px; margin-bottom: 0; color: #f7f0df; font: 500 clamp(28px, 4vw, 50px)/1.02 Georgia, serif; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { margin-bottom: 4px; color: #f7f0df; font: 600 23px/1.1 Georgia, serif; }
.world-status { display: flex; align-items: center; gap: 10px; color: #d7ceb9; font-size: 13px; white-space: nowrap; }
.player-status { border: 1px solid #465345; border-radius: 99px; padding: 5px 9px; color: #aebba8; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.player-status.active { border-color: #d88959; color: #f4c17d; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #e0a95b; box-shadow: 0 0 14px #e0a95b; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.world-card, .panel { border: 1px solid #344037; background: rgba(22, 29, 23, .86); box-shadow: 0 18px 60px rgba(0, 0, 0, .24); }
.world-card { position: relative; min-width: 0; overflow: hidden; border-radius: 18px; }
#world { display: block; width: 100%; height: auto; background: #1d2d22; cursor: crosshair; touch-action: manipulation; }
.canvas-help { position: absolute; left: 16px; top: 14px; color: rgba(247, 240, 223, .7); font-size: 11px; }
.map-tooltip { position: absolute; z-index: 2; pointer-events: none; min-width: 150px; border: 1px solid #60725d; border-radius: 8px; padding: 8px 10px; color: #f7f0df; background: rgba(14, 20, 15, .94); box-shadow: 0 8px 22px rgba(0, 0, 0, .3); font-size: 11px; line-height: 1.35; }
.map-tooltip strong { display: block; margin-bottom: 2px; color: #f4c17d; font-family: Georgia, serif; font-size: 14px; }
.map-tooltip span { color: #aebba8; }
.map-legend { position: absolute; right: 14px; top: 12px; display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; max-width: 260px; color: rgba(247, 240, 223, .75); font-size: 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; border: 1px solid rgba(104, 125, 101, .6); border-radius: 99px; background: rgba(16, 23, 17, .68); }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.resident { background: #d88959; }
.legend-dot.child { background: #f2d5a4; }
.legend-dot.player { background: #f7f0df; box-shadow: 0 0 0 2px #d5b05e; }
.mobile-controls { display: none; }
.mobile-pad button, .mobile-action { -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; }
.controls { display: flex; min-width: 0; gap: 8px; padding: 12px; border-top: 1px solid #344037; }
.speed { cursor: pointer; border: 1px solid #465345; border-radius: 99px; padding: 7px 12px; color: #aebba8; background: #1a241c; font-size: 12px; transition: .2s ease; }
.speed:hover, .speed.active { border-color: #e0a95b; color: #171c17; background: #e0a95b; }
.utility-button { cursor: pointer; border: 1px solid #465345; border-radius: 8px; padding: 7px 10px; color: #b9c5b4; background: #1a241c; font-size: 11px; }
.utility-button:hover { border-color: #8fa88c; color: #f7f0df; }
.sidebar { display: grid; gap: 18px; }
.panel { border-radius: 16px; padding: 19px; }
.empty-state { min-height: 125px; display: grid; align-content: center; gap: 5px; border: 1px dashed #4a5748; border-radius: 10px; color: #84907f; font-size: 12px; text-align: center; }
.empty-state strong { margin-bottom: 3px; color: #e5ddca; font: 600 16px Georgia, serif; }
.person-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 50%; color: #152017; font: 700 18px Georgia, serif; }
#person-meta { margin-bottom: 0; color: #8e9c8b; font-size: 12px; }
.person-summary { min-height: 36px; color: #c5cdbd; font-size: 13px; line-height: 1.45; }
.decision-box { margin: 12px 0 14px; padding: 10px 11px; border-left: 2px solid #d88959; background: rgba(216, 137, 89, .08); }
.decision-box .eyebrow { margin-bottom: 5px; }
.decision-box p:not(.eyebrow) { margin-bottom: 5px; color: #e3d8c1; font-size: 12px; line-height: 1.4; }
.decision-box span { color: #91a28d; font-size: 11px; line-height: 1.35; }
.commitment-box { margin: 0 0 14px; padding-top: 12px; border-top: 1px solid #344037; }
.commitment-box ul { display: grid; gap: 5px; margin: 0; padding-left: 17px; color: #bdc9b9; font-size: 11px; line-height: 1.35; }
.conversation-panel { margin: 0 0 14px; padding: 11px; border: 1px solid #80684c; border-radius: 9px; background: rgba(128, 104, 76, .10); }
.conversation-panel > p:not(.eyebrow) { margin: 0 0 9px; color: #e3d8c1; font-size: 12px; line-height: 1.4; }
.conversation-options { display: grid; gap: 5px; }
.conversation-option { cursor: pointer; border: 1px solid #5c684f; border-radius: 7px; padding: 7px 8px; color: #c7d2bf; background: #1b251d; font-size: 11px; text-align: left; }
.conversation-option:hover { border-color: #d88959; color: #f7f0df; }
.relation-box { margin: 0 0 14px; padding-top: 12px; border-top: 1px solid #344037; }
.relation-box ul { display: grid; gap: 5px; margin: 0; padding-left: 17px; color: #9eae9a; font-size: 11px; line-height: 1.35; }
.play-button { width: 100%; margin: 2px 0 14px; cursor: pointer; border: 1px solid #b66e4e; border-radius: 9px; padding: 9px 12px; color: #1b2019; background: #d88959; font-size: 12px; font-weight: 700; transition: .2s ease; }
.play-button:hover { background: #f0a46c; }
.play-button.active { border-color: #d5b05e; color: #252016; background: #d5b05e; }
.bars { display: grid; gap: 7px; margin: 15px 0; }
.bar-row { display: grid; grid-template-columns: 66px 1fr 25px; align-items: center; gap: 8px; color: #8e9c8b; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.bar { height: 5px; overflow: hidden; border-radius: 4px; background: #303b31; }
.bar i { display: block; height: 100%; border-radius: inherit; background: #c98957; }
.trait-list { display: flex; flex-wrap: wrap; gap: 5px; }
.trait { border: 1px solid #405041; border-radius: 99px; padding: 5px 8px; color: #b7c6b3; font-size: 11px; }
.memory-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid #344037; }
.memory-box ul { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: #bdc5b6; font-size: 12px; line-height: 1.4; }
.panel-title-row { display: flex; justify-content: space-between; }
.event-count { color: #d79a5d; font-size: 11px; }
.event-log { display: grid; gap: 10px; max-height: 255px; overflow: hidden; }
.event { padding-bottom: 10px; border-bottom: 1px solid #2d382e; color: #aeb8a9; font-size: 12px; line-height: 1.4; }
.event:last-child { border-bottom: 0; }
.event-time { display: block; margin-bottom: 2px; color: #738373; font-size: 10px; }

@media (max-width: 940px) {
  .topbar { align-items: start; flex-direction: column; }
  .game-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .shell { padding: 18px 10px 26px; }
  .topbar > div, .game-layout, .world-card { width: 100%; min-width: 0; max-width: 100%; }
  h1 { font-size: 31px; }
  .topbar { gap: 13px; margin-bottom: 15px; }
  .world-status { flex-wrap: wrap; gap: 6px 8px; white-space: normal; font-size: 11px; }
  .world-status .player-status { width: 100%; text-align: center; }
  .world-card { border-radius: 14px; }
  .canvas-help { left: 10px; top: 10px; max-width: 185px; color: rgba(247, 240, 223, .78); font-size: 9px; line-height: 1.25; }
  .map-legend { top: auto; right: 8px; bottom: 10px; max-width: 225px; gap: 4px; font-size: 9px; }
  .map-legend span { padding: 3px 5px; }
  .controls { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; gap: 5px; padding: 8px; }
  .controls::-webkit-scrollbar { display: none; }
  .controls .speed, .controls .utility-button { flex: 0 0 auto; }
  .speed { padding: 6px 9px; font-size: 11px; }
  .utility-button { padding: 6px 8px; font-size: 10px; }
  .mobile-controls { position: absolute; z-index: 3; right: 10px; bottom: 54px; left: 10px; display: flex; align-items: end; justify-content: space-between; pointer-events: none; }
  .mobile-pad { display: grid; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(2, 38px); gap: 4px; pointer-events: auto; }
  .mobile-pad button { border: 1px solid rgba(235, 222, 190, .58); border-radius: 9px; color: #f7f0df; background: rgba(18, 26, 19, .84); font-size: 15px; }
  .mobile-pad button:nth-child(1) { grid-column: 2; }
  .mobile-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .mobile-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
  .mobile-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
  .mobile-pad button.pressed, .mobile-pad button:active { color: #182019; background: #e0a95b; }
  .mobile-action { display: grid; place-items: center; width: 66px; height: 66px; pointer-events: auto; border: 1px solid #e0a95b; border-radius: 50%; color: #1b2019; background: rgba(224, 169, 91, .94); font: 700 20px Georgia, serif; }
  .mobile-action span { margin-top: -18px; font: 600 9px Inter, sans-serif; text-transform: uppercase; }
  .sidebar { grid-template-columns: 1fr; }
}

@media (pointer: coarse) {
  .map-tooltip { display: none !important; }
}
