:root {
  --panel: #1e1a2b;
  --panel-2: #262036;
  --edge: #3a3150;
  --gold: #e8b85a;
  --text: #efe6d6;
  --muted: #a99fb8;
  --shadow: 0 10px 28px rgba(27, 20, 36, .55), 0 2px 0 rgba(255, 241, 193, .04) inset;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1424; color: var(--text); }
#view {
  position: fixed; left: 0; top: 0;
  image-rendering: pixelated; image-rendering: crisp-edges;
  cursor: grab; touch-action: none;
}
#view.drag { cursor: grabbing; }

/* ---------- barra superior ---------- */
#hud-top {
  position: fixed; top: 14px; left: 14px; right: 14px;
  display: flex; gap: 10px; align-items: center; pointer-events: none;
}
.chip {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--edge); border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-size: 14px;
}
.back { color: var(--gold); font-weight: 600; letter-spacing: .2px; transition: transform .15s, border-color .15s; }
.back:hover, .back:focus-visible { border-color: var(--gold); transform: translateY(-1px); outline: none; }
.title .t1 { font-weight: 700; letter-spacing: .4px; }
.crest {
  width: 14px; height: 16px; display: inline-block;
  background: linear-gradient(135deg, #ffd27a, #e8b85a 55%, #b8925a);
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  position: relative;
}
.crest::after { content: ""; position: absolute; left: 5px; top: 4px; width: 4px; height: 6px; background: #7af0ff; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.help {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--edge); background: #2a2340; color: var(--muted);
  font: 700 12px/1 inherit; cursor: help; padding: 0;
}

/* ---------- barra de controles ---------- */
#bar {
  position: fixed; left: 0; right: 0; bottom: 14px; margin: 0 auto; width: max-content;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 20px);
  padding: 7px 8px;
  background: linear-gradient(180deg, rgba(38, 32, 54, .94), rgba(30, 26, 43, .94));
  border: 1px solid var(--edge); border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(232, 184, 90, .06);
  backdrop-filter: blur(6px);
}
.group {
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px; height: 34px;
  border-right: 1px solid rgba(58, 49, 80, .8);
}
.group:last-child { border-right: 0; }
.clock { gap: 8px; min-width: 150px; }
#phaseIcon { width: 18px; height: 18px; }
#clockTime { font: 700 16px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--gold); letter-spacing: .5px; }
#clockPhase { font-size: 12px; color: var(--muted); }

button {
  font: inherit; color: var(--text); cursor: pointer;
  background: linear-gradient(180deg, #2e2742, #241e35);
  border: 1px solid var(--edge); border-radius: 8px;
  height: 28px; min-width: 28px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  box-shadow: 0 1px 0 rgba(255, 241, 193, .06) inset, 0 2px 4px rgba(27, 20, 36, .35);
  transition: border-color .15s, background .15s, color .15s;
}
button:hover { border-color: #5a4a7a; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; }
.icon { padding: 0; font-size: 17px; font-weight: 700; }
#play .i-play { display: none; }
#play.paused .i-play { display: block; }
#play.paused .i-pause { display: none; }
#play svg { stroke: none; }

.seg { gap: 0; }
.seg button { border-radius: 0; margin-left: -1px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on, .toggle.on {
  color: #1e1a2b; border-color: var(--gold);
  background: linear-gradient(180deg, #ffd98a, #e8b85a);
  box-shadow: 0 0 10px rgba(232, 184, 90, .35), 0 1px 0 rgba(255, 255, 255, .35) inset;
}
#weather svg circle, #weather svg > path { stroke: none; }
#weather svg g { fill: none; }
.toggle { font-size: 12px; font-weight: 600; color: var(--muted); }
.toggle svg { stroke: none; }
.zoom #zval { min-width: 26px; text-align: center; font: 700 13px/1 ui-monospace, Consolas, monospace; color: var(--gold); }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: clamp(120px, 22vw, 260px); height: 28px; background: transparent; cursor: pointer;
}
input[type=range]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 5px; border: 1px solid var(--edge);
  background: linear-gradient(90deg, #2a1f3d 0%, #3d2c5c 18%, #ff9d4a 26%, #ffd27a 34%, #fff1c1 50%, #ffd27a 66%, #ff6a3d 75%, #b48cff 80%, #2a1f3d 88%, #2a1f3d 100%);
}
input[type=range]::-moz-range-track { height: 8px; border-radius: 5px; border: 1px solid var(--edge); background: linear-gradient(90deg, #2a1f3d, #3d2c5c 18%, #ff9d4a 26%, #fff1c1 50%, #ff6a3d 75%, #b48cff 80%, #2a1f3d 88%); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1c1, #e8b85a 60%, #b8925a);
  border: 2px solid #1e1a2b; box-shadow: 0 0 0 1px var(--gold), 0 2px 6px rgba(27, 20, 36, .6);
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #e8b85a; border: 2px solid #1e1a2b; }

/* ---------- tooltips ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after, [data-tip].tip-open::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px; white-space: normal;
  padding: 7px 10px; border-radius: 8px;
  background: #f3e3c3; color: #2a1d14; border: 1px solid #b8925a;
  font: 500 12px/1.35 "Segoe UI", system-ui, sans-serif; text-align: left;
  box-shadow: 0 6px 18px rgba(27, 20, 36, .5);
  pointer-events: none; z-index: 10;
}
#hud-top [data-tip]:hover::after, #hud-top [data-tip]:focus-visible::after, #hud-top [data-tip].tip-open::after {
  bottom: auto; top: calc(100% + 10px); left: 0; transform: none;
}

#err {
  position: fixed; left: 14px; top: 64px; max-width: 70vw; padding: 10px 14px;
  background: #3a1620; color: #ffd27a; border: 1px solid #ff6a3d; border-radius: 8px;
  font: 12px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; z-index: 20;
}

@media (max-width: 720px) {
  #bar { bottom: 8px; gap: 2px; padding: 6px; width: calc(100vw - 16px); }
  .group { padding: 0 3px; height: 32px; }
  .clock { order: -2; min-width: 0; border-right: 0; }
  #clockPhase { display: none; }
  .timeline { order: -1; flex: 1 1 calc(100% - 110px); border-right: 0; }
  input[type=range] { width: 100%; flex: 1; }
  .seg button { min-width: 26px; padding: 0 5px; }
  .toggle span { display: none; }
  .title .t1 { font-size: 13px; }
  .chip { height: 32px; padding: 0 10px; }
}
