:root {
  --ink: #1c1914;
  --paper: #f8f5ee;
  --muted: #6b6559;
  --accent: #c4993d;
  --accent-ink: #1f1604;
  --danger: #9a3333;
  --panel: rgba(18, 16, 14, 0.82);
  --panel-ink: #f7f4ec;
  --gold-glow: rgba(196, 153, 61, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0a0a0d;
  color: var(--ink);
  font-family: Charter, 'Bitstream Vera Serif', 'Sitka Text', Cambria, Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.warn {
  background: #fdf2f2;
  color: #8c2020;
  border-left: 4px solid #c93b3b;
  padding: .7rem .9rem;
  border-radius: 6px;
  margin: .8rem 0;
  font-size: 0.95rem;
}
code { font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; }

/* Overlay screens */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 10;
}

.screen {
  pointer-events: auto;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: rgba(6, 6, 8, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: auto;
  padding: 32px 20px;
}

.card {
  background: var(--paper);
  border-radius: 16px;
  padding: 32px 38px;
  max-width: 660px;
  width: 100%;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(196, 153, 61, 0.2);
  border: 1px solid #e5ded0;
}

.card.wide { max-width: 1060px; }

h1 {
  font-size: 2.1rem;
  font-weight: 700;
  margin: 0 0 .7rem;
  letter-spacing: .02em;
  color: #14120e;
}

h2 {
  font-size: 1.55rem;
  font-weight: 600;
  margin: 0 0 .9rem;
  color: #1a1713;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.2rem 0 .5rem;
  color: #24201a;
}

p {
  line-height: 1.6;
  margin: .6rem 0;
  color: #2c2720;
}

button {
  font: inherit;
  padding: .65rem 1.25rem;
  border-radius: 8px;
  border: 1px solid #cfc7b7;
  background: #ffffff;
  color: #1a1713;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

button:hover {
  background: #f9f6ef;
  border-color: #b5ac9a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: linear-gradient(180deg, #d4a946 0%, #b88b28 100%);
  color: var(--accent-ink);
  border-color: #9c7318;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 6px rgba(184, 139, 40, 0.3);
}

button.primary:hover {
  background: linear-gradient(180deg, #e0b753 0%, #c49732 100%);
  box-shadow: 0 4px 12px var(--gold-glow);
}

button.primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.danger {
  background: #ffffff;
  color: var(--danger);
  border-color: #e2b1b1;
}

button.danger:hover {
  background: #fff5f5;
  border-color: var(--danger);
}

button.small {
  padding: .3rem .75rem;
  font-size: .88rem;
  margin-left: .5rem;
}

.row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.row > button { flex: 1 1 auto; }

hr {
  border: 0;
  border-top: 1px solid #e0d8c8;
  margin: 1.2rem 0;
}

.field {
  display: block;
  margin: 1rem 0;
  font-size: .95rem;
}

.field input[type=text], .field textarea, .field select {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .6rem .75rem;
  font: inherit;
  border: 1px solid #cac1af;
  border-radius: 7px;
  background: #ffffff;
  color: #1a1713;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease;
}

.field input[type=text]:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 153, 61, 0.2);
}

.field.inline { flex: 1 1 270px; }
.small-row { align-items: flex-end; }

.check {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin: .9rem 0;
  font-size: .95rem;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.brief-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 860px) { .brief-grid { grid-template-columns: 1fr; } }

#map svg, #map2 svg {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: #ede7dc;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #dcd3c3;
}

ul.controls { list-style: none; padding: 0; margin: 0; }
ul.controls li { margin: .45rem 0; line-height: 1.6; }

.key {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 .45em;
  margin: 0 .15em;
  border: 1px solid #b5ae9f;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #ffffff;
  font: bold .85rem ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
  color: #24201a;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.fav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 760px) { .fav-grid { grid-template-columns: repeat(2, 1fr); } }

.fav-grid label {
  display: block;
  border: 2px solid #ddd5c4;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.fav-grid label:hover {
  border-color: #bfa154;
  transform: translateY(-1px);
}

.fav-grid label:has(input:checked) {
  border-color: var(--accent);
  background: #fff9ed;
  box-shadow: 0 0 0 1px var(--accent);
}

.fav-grid input { margin-right: 6px; }

.fav-grid .thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #1e1c22;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}

.fav-grid .t {
  font-size: .94rem;
  font-weight: 700;
  color: #181511;
}

.fav-grid .a {
  font-size: .83rem;
  color: var(--muted);
  font-style: italic;
}

/* HUD Overlay */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  color: var(--panel-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Precision Crosshair */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8), inset 0 0 2px rgba(0, 0, 0, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

#look-label {
  position: absolute;
  left: 50%;
  top: calc(50% + 28px);
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 14px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

#look-label b {
  font-family: Georgia, serif;
  font-size: 15px;
  color: #f7eedb;
  letter-spacing: .02em;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 15px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#prompt {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(206, 162, 60, 0.98) 0%, rgba(176, 131, 36, 0.98) 100%);
  color: #1c1403;
  padding: 15px 24px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#prompt .prompt-keys {
  margin-top: 8px;
  font-size: 14px;
}

#prompt .key {
  background: #fff6e0;
  border-color: #8c6c21;
}

#audio-panel {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 350px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 14px 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.ap-title {
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff9ee;
}

#ap-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ecd38c 0%, #b89136 100%);
  color: #1c1404;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ap-sub {
  font-size: 13px;
  opacity: .9;
  margin: 6px 0 10px;
  color: #d8d3c8;
}

.ap-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  overflow: hidden;
}

#ap-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c4993d 0%, #e2be68 100%);
  transition: width .25s linear;
}

.ap-keys {
  font-size: 11px;
  opacity: .7;
  margin-top: 10px;
  color: #b0aaa0;
}

#zoom-indicator {
  position: absolute;
  right: 24px;
  bottom: 24px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 13px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #e8e3d8;
}

#top-bar {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 13px;
  opacity: .9;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  letter-spacing: .02em;
}

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ddd;
  font-family: Georgia, serif;
  font-size: 1.2rem;
  z-index: 20;
  background: #0a0a0d;
}

/* --- briefing map (v1.1) --- */
.card.xwide {
  max-width: 1200px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(196, 153, 61, 0.25);
}
#map svg, #map2 svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #d8cfbe;
}
.legend {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin: 16px 0 8px;
}
@media (max-width: 1000px) { .legend { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 600px) { .legend { grid-template-columns: repeat(2, 1fr); } }

.legend .lg {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #e2dac9;
  border-radius: 10px;
  padding: 7px 9px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}
.legend .lg:hover {
  background: #ffffff;
  border-color: #c4993d;
  transform: translateY(-1px);
}
.legend .lg .n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ecd38c 0%, #b89136 100%);
  color: #1a1304;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  font-family: Georgia, serif;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.legend .lg .t {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1a1713;
}
.legend .lg .a {
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brief-grid { margin-top: 16px; }

/* --- ranking list (questionnaire) --- */
.rank-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0.4rem;
  display: grid;
  gap: 8px;
}
.rank-item {
  display: grid;
  grid-template-columns: 36px 68px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #dcd4c2;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: grab;
  user-select: none;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.rank-item:hover {
  border-color: #bfa154;
  background: #fffdf9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.rank-item.dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.rank-item.over {
  border-color: var(--accent);
  background: #fff8e8;
  box-shadow: 0 0 0 2px var(--accent), 0 6px 18px var(--gold-glow);
}
.rank-item .rk {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(180deg, #221d18 0%, #110e0c 100%);
  color: #f7f3ea;
  border: 1px solid #c4993d;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  font-family: Georgia, serif;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.rank-item .rthumb {
  width: 68px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  background: #1c1a20;
  border: 1px solid #e0d8c8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.rank-item .rt {
  font-size: 0.96rem;
  line-height: 1.3;
  color: #181512;
}
.rank-item .rt b {
  font-size: 1rem;
  letter-spacing: .01em;
}
.rank-item .rt .a {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}
.rank-item .rbtns {
  display: flex;
  gap: 5px;
}
.rank-item .rbtns button {
  padding: 0.25rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 6px;
  border: 1px solid #cfc7b7;
  background: #fbf9f4;
  color: #3a342a;
  cursor: pointer;
  transition: all 0.12s ease;
}
.rank-item .rbtns button:hover:not(:disabled) {
  background: var(--accent);
  color: #1a1405;
  border-color: #9c7318;
}
.rank-item .rbtns button:disabled {
  opacity: 0.25;
  cursor: default;
  background: #f0ece3;
}

