:root {
  --ink: #16110b;
  --ink-2: #261c12;
  --gold: #c9a24a;
  --gold-hi: #ecd28c;
  --paper: #f1e6cc;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Hoefler Text", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); overflow: hidden; }
body {
  font: 16px/1.4 var(--serif);
  color: var(--paper);
  -webkit-tap-highlight-color: transparent;
}
video, canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
canvas { pointer-events: none; }
[hidden] { display: none !important; }

#start {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px 28px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(201, 162, 74, 0.16), transparent 60%),
    linear-gradient(var(--ink-2), var(--ink));
}
#start::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(201, 162, 74, 0.55);
  outline: 1px solid rgba(201, 162, 74, 0.25);
  outline-offset: 5px;
  pointer-events: none;
}
.kicker { margin: 0; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(46px, 15vw, 92px);
  line-height: 0.95;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-hi);
  text-shadow: 0 2px 0 #6b4f1a, 0 10px 30px rgba(0, 0, 0, 0.6);
}
h1 span { font-style: italic; text-transform: none; letter-spacing: 0.02em; font-size: 0.62em; color: var(--paper); }
.how { margin: 0; max-width: 22em; font-size: 17px; color: rgba(241, 230, 204, 0.9); }
#go {
  font: italic 26px var(--serif);
  letter-spacing: 0.08em;
  padding: 12px 54px;
  color: var(--ink);
  background: linear-gradient(#ecd28c, #c9a24a 55%, #a07c2c);
  border: 1px solid #6b4f1a;
  border-radius: 2px;
  box-shadow: 0 0 0 4px var(--ink), 0 0 0 5px var(--gold), 0 12px 28px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
#go:active { transform: translateY(1px); filter: brightness(0.95); }
#go:disabled { filter: grayscale(0.5) brightness(0.8); }
.sources { color: rgba(241, 230, 204, 0.7); font-size: 15px; }
.load { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: rgba(241, 230, 204, 0.7); }
progress {
  appearance: none;
  width: 180px;
  height: 3px;
  border: 0;
  background: rgba(201, 162, 74, 0.2);
}
progress::-webkit-progress-bar { background: rgba(201, 162, 74, 0.2); }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }
#error { margin: 0; max-width: 22em; color: #f0a38a; }

#labels { position: fixed; inset: 0; pointer-events: none; }
.label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  text-align: center;
  will-change: transform;
}
.label.zone {
  width: 150px;
  font-size: 24px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold-hi);
  text-shadow: 0 1px 2px #000, 0 0 14px rgba(0, 0, 0, 0.75);
}
.label.name {
  width: 76px;
  pointer-events: auto;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 0 3px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  color: #2a1b0a;
  background: linear-gradient(#ecd28c, #c9a24a 60%, #a07c2c);
  border: 1px solid #6b4f1a;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 240, 200, 0.45);
}
.label.name small { display: block; font-size: 8.5px; font-weight: 400; color: #4a3414; white-space: pre-line; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hint {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, calc(100% - 32px));
  margin: 0;
  padding: 10px 16px;
  font-style: italic;
  text-align: center;
  background: rgba(22, 17, 11, 0.8);
  border: 1px solid rgba(201, 162, 74, 0.6);
  border-radius: 2px;
}
#cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: 46px;
  border: 2px solid rgba(241, 230, 204, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: width 0.12s, height 0.12s, border-color 0.12s, background 0.12s;
}
#cursor.over { border-color: var(--gold-hi); background: rgba(201, 162, 74, 0.18); }
#cursor.closed { width: 30px; height: 30px; background: rgba(201, 162, 74, 0.45); }

/* Registered so ui.js reads the insets back in px. */
@property --safe-top { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --safe-bottom { syntax: "<length>"; inherits: false; initial-value: 0px; }
#card {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  position: absolute;
  left: 0;
  top: 0;
  width: 224px;
  max-height: min(44vh, 320px);
  overflow: auto;
  padding: 10px 12px 9px;
  color: var(--ink);
  background: linear-gradient(rgba(241, 230, 204, 0.94), rgba(230, 214, 176, 0.94));
  border: 1px solid #8c6a2a;
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(22, 17, 11, 0.8), 0 0 0 3px var(--gold), 0 10px 26px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  scale: 0.94;
  transition: opacity 0.16s, scale 0.16s, visibility 0s 0.16s;
}
#card.open { opacity: 1; visibility: visible; scale: 1; transition: opacity 0.2s, scale 0.2s; }
#card.open.away { opacity: 0; scale: 0.96; pointer-events: none; transition: opacity 0.35s, scale 0.35s; }
#card h2 { margin: 0 22px 5px 0; font-size: 16px; font-weight: 600; line-height: 1.15; }
#card .text {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.38;
  cursor: pointer;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
#card.more .text { display: block; }
#card .pair { margin: 6px 0 0; padding-top: 5px; font-size: 12.5px; font-style: italic; color: #6b4f1a; border-top: 1px solid rgba(140, 106, 42, 0.45); }
#card dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 0; font-size: 12.5px; }
#card dl:empty { display: none; }
#card dt { font-style: italic; color: #6b4f1a; }
#card dd { margin: 0; }
#card .note { margin: 0 0 6px; padding: 3px 6px; font-size: 11.5px; font-style: italic; color: #5a1f12; background: rgba(140, 60, 30, 0.12); border-left: 2px solid #8c3c1e; }
#card .close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  padding: 0;
  font: 22px/1 var(--serif);
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}

#bar {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#status {
  padding: 7px 18px;
  font-size: 14px;
  letter-spacing: 0.16em;
  white-space: nowrap;
  color: var(--paper);
  background: rgba(22, 17, 11, 0.82);
  border: 1px solid rgba(241, 230, 204, 0.5);
  border-radius: 999px;
}
#status.on { color: var(--gold-hi); border-color: var(--gold); }
#loading { font-size: 12px; font-style: italic; color: var(--paper); text-shadow: 0 1px 2px #000; }
#loading.done { display: none; }
