:root {
  --panel: #1e1a2b; --panel-2: #2a2340; --edge: #3a3150; --gold: #e8b85a; --text: #efe6d6; --muted: #b9b2c4;
  --cyan: #7af0ff; --shadow: 0 10px 30px rgba(27, 20, 36, .55), 0 2px 6px rgba(27, 20, 36, .4);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1424; color: var(--text); font-family: var(--font); }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }

/* velo de carga */
#veil { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #3d2c5c 0%, #2a1f3d 45%, #1b1424 100%); transition: opacity .8s ease; }
#veil.gone { opacity: 0; pointer-events: none; }
.veil-in { display: grid; justify-items: center; gap: 18px; color: var(--muted); font-size: 15px; letter-spacing: .04em; }
.gem { width: 26px; height: 44px; background: linear-gradient(160deg, #c6ecf5, #7af0ff 45%, #b48cff);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); filter: drop-shadow(0 0 14px rgba(122, 240, 255, .8)); animation: gem 1.6s ease-in-out infinite; }
@keyframes gem { 50% { transform: translateY(-8px) rotate(8deg); } }

/* marca */
.brand { position: fixed; top: 16px; left: 16px; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 8px 18px 8px 8px;
  background: linear-gradient(180deg, rgba(42, 35, 64, .86), rgba(30, 26, 43, .86)); border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .06); backdrop-filter: blur(8px); }
.back { color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px;
  background: rgba(232, 184, 90, .12); border: 1px solid rgba(232, 184, 90, .35); transition: background .2s, transform .2s; }
.back:hover, .back:focus-visible { background: rgba(232, 184, 90, .24); transform: translateX(-2px); outline: none; }
.title h1 { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--gold); letter-spacing: .02em; line-height: 1.1;
  text-shadow: 0 1px 0 #2a1d14; }
.title .sub { font-size: 12px; color: var(--muted); letter-spacing: .06em; }

/* tooltip de edificios */
.tip { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; max-width: 270px; padding: 10px 14px 11px;
  background: linear-gradient(180deg, #2a2340, #1e1a2b); border: 1px solid var(--edge); border-left: 3px solid var(--gold); border-radius: 12px;
  box-shadow: var(--shadow); display: grid; gap: 3px; transition: opacity .15s; }
.tip[hidden] { display: none; }
.tip b { font-family: var(--serif); font-size: 16px; color: var(--gold); }
.tip span { font-size: 13px; color: var(--text); opacity: .9; line-height: 1.35; }

/* barra de controles */
.bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; width: min(860px, calc(100vw - 28px));
  background: linear-gradient(180deg, rgba(42, 35, 64, .9), rgba(30, 26, 43, .92)); border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .06); backdrop-filter: blur(10px); }
.btn { appearance: none; border: 1px solid var(--edge); background: linear-gradient(180deg, #342b4d, #251f37); color: var(--text);
  cursor: pointer; display: grid; place-items: center; transition: transform .15s, border-color .2s, background .2s; font: 600 15px var(--font); }
.btn.round { width: 42px; height: 42px; border-radius: 13px; flex: none; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn:hover, .btn:focus-visible { border-color: var(--gold); transform: translateY(-1px); outline: none; }
.btn.on { color: #2a1d14; background: linear-gradient(180deg, #f3cf7f, #e8b85a); border-color: #f3cf7f; }
.clock { display: flex; align-items: center; gap: 8px; min-width: 84px; font-variant-numeric: tabular-nums; }
.clock output { font: 600 17px var(--font); color: var(--text); }
.sky-ico svg { width: 22px; height: 22px; display: block; }
.sky-ico.sun svg { fill: #ffd27a; stroke: #ffd27a; filter: drop-shadow(0 0 6px rgba(255, 210, 122, .6)); }
.sky-ico.moon svg { fill: #c6ecf5; filter: drop-shadow(0 0 6px rgba(180, 140, 255, .7)); }

input[type=range] { --p: 50%; flex: 1; min-width: 120px; height: 28px; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; border: 1px solid var(--edge);
  background: linear-gradient(90deg, #1b1424 0%, #3d2c5c 20%, #ff9d4a 26%, #79c3e0 36%, #c6ecf5 50%, #79c3e0 64%, #ffd27a 72%, #ff6a3d 77%, #3d2c5c 84%, #1b1424 100%); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 6px; border: 1px solid var(--edge);
  background: linear-gradient(90deg, #1b1424 0%, #3d2c5c 20%, #ff9d4a 26%, #79c3e0 36%, #c6ecf5 50%, #79c3e0 64%, #ffd27a 72%, #ff6a3d 77%, #3d2c5c 84%, #1b1424 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff1c1, #e8b85a 60%, #b8925a); border: 2px solid #2a1d14; box-shadow: 0 2px 8px rgba(27, 20, 36, .6); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff1c1, #e8b85a 60%, #b8925a); border: 2px solid #2a1d14; }
input[type=range]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

.seg { display: flex; padding: 3px; gap: 2px; background: #1b1424; border: 1px solid var(--edge); border-radius: 12px; flex: none; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font); padding: 8px 10px; border-radius: 9px; cursor: pointer; min-width: 38px; }
.seg button:hover, .seg button:focus-visible { color: var(--text); outline: none; background: rgba(255, 255, 255, .05); }
.seg button.on { color: #2a1d14; background: linear-gradient(180deg, #f3cf7f, #e8b85a); }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: none; color: var(--muted); font-size: 13px; font-weight: 600; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.knob { width: 38px; height: 22px; border-radius: 12px; background: #1b1424; border: 1px solid var(--edge); position: relative; transition: background .2s; }
.knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + .knob { background: rgba(122, 240, 255, .2); border-color: rgba(122, 240, 255, .5); }
.switch input:checked + .knob::after { transform: translateX(16px); background: var(--cyan); box-shadow: 0 0 8px rgba(122, 240, 255, .8); }
.switch input:focus-visible + .knob { outline: 2px solid var(--gold); outline-offset: 2px; }

/* tooltips de la barra (hover, foco y toque) */
.has-tip { position: relative; }
.has-tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translate(-50%, 4px); width: max-content; max-width: 240px;
  padding: 8px 11px; font: 500 12.5px/1.35 var(--font); color: var(--text); text-align: center; background: #1e1a2b; border: 1px solid var(--edge); border-radius: 10px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; white-space: normal; }
.has-tip:hover::after, .has-tip:focus-visible::after, .has-tip:focus-within::after, .has-tip:active::after { opacity: 1; transform: translate(-50%, 0); }
.help { color: var(--gold); font-family: var(--serif); font-size: 18px; }
.help.has-tip::after { left: auto; right: -6px; transform: translate(0, 4px); }
.help.has-tip:hover::after, .help.has-tip:focus-visible::after { transform: translate(0, 0); }

#err { position: fixed; top: 80px; left: 16px; right: 16px; z-index: 100; margin: 0; padding: 12px 14px; max-height: 40vh; overflow: auto;
  background: rgba(140, 59, 59, .95); color: #fff1c1; border: 1px solid #ff6a3d; border-radius: 10px; font: 12px/1.4 Consolas, monospace; white-space: pre-wrap; }

@media (max-width: 720px) {
  .brand { top: 10px; left: 10px; padding: 6px 12px 6px 6px; gap: 10px; }
  .title h1 { font-size: 17px; }
  .title .sub { display: none; }
  .bar { flex-wrap: wrap; justify-content: space-between; bottom: 10px; gap: 8px 6px; padding: 10px; border-radius: 18px; }
  .bar input[type=range] { order: 10; flex-basis: 100%; }
  .btn.round { width: 38px; height: 38px; border-radius: 12px; }
  .clock { min-width: 0; gap: 4px; }
  .clock output { font-size: 15px; }
  .seg button { padding: 7px 6px; min-width: 32px; }
  .switch .lbl { display: none; }
}
@media (max-width: 400px) { .sky-ico { display: none; } .seg button { min-width: 30px; } }
