/* Sternwarte bei Nacht: dunkler Grund, Bernstein für Funde, Petrol für Klang und Resonanz.
   Bewusst nur ein dunkles Erscheinungsbild. */
:root {
  --ground: #0E1116;
  --panel: #151A21;
  --sunk: #0A0C10;
  --line: #262D37;
  --line-strong: #3A4250;
  --ink: #E6E1D6;
  --muted: #8F97A5;
  --accent: #E8A33D;
  --accent-hi: #F3C277;
  --accent-ink: #1A1206;
  --teal: #5FB3A8;
  --danger: #E58A7A;
  --display: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--ground); color: var(--ink); }
body { margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; line-height: 1; }
h2 { font-size: 22px; line-height: 1.15; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.note { color: var(--muted); font-size: 12px; }
.accent { color: var(--accent); }
.teal { color: var(--teal); }

.app {
  min-height: 100%;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  grid-template-areas: "top top top" "left center right" "finds finds finds";
}
.top { grid-area: top; }
.left { grid-area: left; }
.center { grid-area: center; }
.right { grid-area: right; }
.finds { grid-area: finds; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 14px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.sub { color: var(--muted); }
.stats { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; }
.stat { display: grid; gap: 2px; }
.stat .label { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.stat .value { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-energy { grid-template-columns: auto auto; column-gap: 10px; align-items: center; }
.stat-energy .label { grid-column: 1 / -1; }
.meter { width: 64px; height: 5px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); width: 100%; transition: width .3s; }
.stat-energy .hint { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }

.left, .right {
  padding: 22px; display: flex; flex-direction: column; gap: 26px; min-width: 0;
}
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
.block { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-size: 13px;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.ghost { color: var(--muted); border-color: var(--line); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.playing { border-color: var(--teal); color: var(--teal); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px;
}
.tab[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.tab:disabled { opacity: .55; cursor: not-allowed; }

.atlas { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.cell {
  aspect-ratio: 1 / 1; min-width: 0; padding: 0; border-radius: 3px; cursor: pointer;
  background: #1B2029; border: 1px solid #2E3541;
}
.cell.s1 { background: #2C3A4A; border-color: transparent; }
.cell.s2 { background: var(--accent); border-color: transparent; }
.cell.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.cell.selected { outline: 2px dashed var(--accent); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-0 { background: #1B2029; border: 1px solid #2E3541; }
.sw-1 { background: #2C3A4A; }
.sw-2 { background: var(--accent); }
.region-info { display: flex; flex-direction: column; gap: 8px; min-height: 20px; }
.region-info .btn { align-self: flex-start; }

.missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.missions li { display: grid; gap: 3px; }
.missions .m-title { display: flex; justify-content: space-between; gap: 8px; }
.missions .m-reward { color: var(--teal); font-size: 11px; white-space: nowrap; }
.missions .m-text { color: var(--muted); font-size: 12px; }
.stage-progress { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.progress-row { display: grid; gap: 4px; font-size: 12px; }
.progress-row .row-between { color: var(--muted); }
.bar { height: 5px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.center { padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sight-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.sight-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.find-name {
  font-family: var(--display); font-size: 34px; line-height: 1.15; background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 0 6px; margin-left: -7px; width: 100%; min-width: 0; color: var(--ink);
}
.find-name:not([readonly]):hover, .find-name:not([readonly]):focus { border-color: var(--line-strong); }
.find-name[readonly] { cursor: default; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pill.hot { border-color: var(--accent); color: var(--accent); }
.pill.ok { border-color: var(--teal); color: var(--teal); }
.stars { letter-spacing: 0.05em; color: var(--accent); }
.stars .off { color: var(--line-strong); }

.viewport {
  position: relative; width: 100%; max-width: 680px; aspect-ratio: 1 / 1; align-self: center;
  background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.view-status {
  position: absolute; left: 12px; right: 12px; bottom: 10px; color: var(--muted); font-size: 12px;
  pointer-events: none; text-wrap: balance;
}
.view-status.center-msg { top: 50%; bottom: auto; transform: translateY(-50%); text-align: center; color: var(--ink); font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1 1 auto; }
.formula { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }

.slider { display: grid; gap: 6px; }
.slider label { display: flex; justify-content: space-between; }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; min-height: 24px; }
.field { display: grid; gap: 6px; }
select {
  min-height: 40px; background: var(--sunk); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 10px;
}

.palettes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.palette {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; min-height: 44px; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; font-size: 12px;
}
.palette[aria-pressed="true"] { border-color: var(--accent); }
.palette:disabled { cursor: not-allowed; opacity: .5; }
.palette .ramp { height: 10px; border-radius: 2px; }

.shop { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.shop li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.shop .owned { color: var(--teal); font-size: 12px; }

.save-actions, .confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.confirm span { color: var(--danger); font-size: 12px; width: 100%; }

.finds {
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px;
  padding-block: 16px 24px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  min-width: 0;
}
.strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.strip .empty { color: var(--muted); padding: 18px 0; }
.find {
  flex: 0 0 140px; display: flex; flex-direction: column; gap: 6px; padding: 8px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.find.active { border-color: var(--accent); }
.find img, .find .ph { width: 100%; aspect-ratio: 1 / 1; border-radius: 4px; background: var(--sunk); display: block; }
.find .f-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find .f-meta { font-size: 11px; color: var(--muted); }

.toasts {
  position: fixed; z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: min(380px, calc(100% - 32px)); pointer-events: none;
}
.toast {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 14px;
  font-size: 12px; color: var(--ink); animation: toast-in .25s ease-out;
}
.toast.hot { border-color: var(--accent); }
.toast.ok { border-color: var(--teal); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

dialog {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 26px; max-width: min(520px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(5, 6, 9, 0.7); }
dialog h2 { font-size: 30px; margin-bottom: 12px; }
dialog p, dialog ul { color: var(--muted); line-height: 1.6; margin: 0 0 14px; }
dialog ul { padding-left: 18px; }
dialog form { margin-top: 8px; }

.tut-spot {
  position: fixed; z-index: 20; pointer-events: none; border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(5, 6, 9, 0.6); outline: 2px solid var(--accent);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.tut-spot.empty { outline: none; }
.tut-card {
  position: fixed; z-index: 21; width: min(370px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 18px 18px 14px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  transition: left .25s ease, top .25s ease;
}
.tut-card h2 { font-size: 26px; }
.tut-card p { line-height: 1.6; }
.tut-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tut-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; min-height: 32px; padding: 0 4px; }
.tut-close:hover { color: var(--ink); }
.tut-prompt { color: var(--accent); }
.tut-prompt.done { color: var(--teal); }
.tut-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "top top" "center center" "left right" "finds finds"; }
  .right { border-left: none; }
  .left { border-right: 1px solid var(--line); }
  .left, .right { border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "center" "left" "right" "finds"; }
  .left { border-right: none; }
  .center, .left, .right {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .top, .finds {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .find-name { font-size: 28px; }
  .stats { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .tut-spot, .tut-card { transition: none; }
  .meter span { transition: none; }
}
