:root {
  /* この3色は app.mjs が太陽の高度から計算して上書きする */
  --zenith: #0a1433;
  --horizon: #15224d;
  --ink: #f2f5ff;
  --gutter: clamp(16px, 3vw, 40px);
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  color-scheme: dark;
}

:root[data-sky="light"] { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--zenith);
  color: var(--ink);
  line-height: 1.9;
  font-size: 1rem;
  transition: background-color 1.2s linear;
}

.stage {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(0, 1fr) minmax(280px, 340px);
  gap: var(--gutter);
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--gutter);
}

/* 子午線と同じ縦の線になるよう、題字とリードを縦書きにする */
.intro {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas: "title lead" "transport transport";
  justify-content: start;
  gap: 2rem 1.25rem;
  align-self: stretch;
  align-content: center;
}

h1 {
  grid-area: title;
  margin: 0;
  writing-mode: vertical-rl;
  font-size: clamp(4rem, 8vw, 7rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.14em;
}

.lead {
  grid-area: lead;
  margin: 0.4rem 0 0;
  writing-mode: vertical-rl;
  font-size: 1.05rem;
  line-height: 1.8;
  letter-spacing: 0.08em;
}

.transport {
  grid-area: transport;
  display: grid;
  gap: 0.9rem;
}

button,
select {
  font: inherit;
  color: inherit;
}

#play {
  border: 0;
  border-radius: 999px;
  padding: 0.7em 1.8em;
  background: var(--ink);
  color: var(--zenith);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.transport-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

#pause { padding: 0.45em 1em; }

#play[aria-pressed="true"] {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.volume {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.9rem;
}

input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* 星図。方角の文字を円の外側に十字に置く */
.chart {
  display: grid;
  grid-template: auto 1fr auto / auto minmax(0, 1fr) auto;
  grid-template-areas: ". north ." "east disc west" ". south .";
  gap: 0.35rem 0.6rem;
  align-items: center;
  justify-items: center;
  margin: 0;
  width: 100%;
  max-width: calc(100svh - 2 * var(--gutter));
  justify-self: center;
}

.chart canvas {
  grid-area: disc;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.dir-label { font-size: 1rem; font-weight: 600; }
.north { grid-area: north; }
.south { grid-area: south; }
.east { grid-area: east; }
.west { grid-area: west; }

.readout { font-size: 0.95rem; }

.when {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: lining-nums;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.7rem;
}

select,
.quiet {
  border: 1px solid color-mix(in srgb, var(--ink) 55%, transparent);
  border-radius: 6px;
  background: transparent;
  padding: 0.25em 0.6em;
  cursor: pointer;
}

select option { color: #0b1c3d; background: #f2f5ff; }

.status {
  min-height: 1.5em;
  margin: 0.2rem 0 0.4rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.speeds {
  border: 0;
  margin: 0 0 1.1rem;
  padding: 0;
}

.speeds legend {
  padding: 0;
  margin-bottom: 0.15rem;
}

.speeds label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  line-height: 1.7;
  cursor: pointer;
}

.speeds input { accent-color: var(--ink); margin: 0; }

.bodies {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.1rem;
  font-variant-numeric: lining-nums tabular-nums;
}

.bodies caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.bodies th,
.bodies td {
  padding: 0.14rem 0;
  text-align: left;
  font-weight: 400;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
}

.bodies thead th { font-size: 0.82rem; }
.bodies tbody th { font-weight: 600; }

.solo {
  border: 0;
  border-radius: 999px;
  margin-left: -0.55em;
  padding: 0.05em 0.55em;
  background: transparent;
  font-weight: inherit;
  text-decoration: underline dotted 1px;
  text-underline-offset: 0.25em;
  cursor: pointer;
}

.solo[aria-pressed="true"] {
  background: var(--ink);
  color: var(--zenith);
  text-decoration: none;
}

.hint {
  margin: -0.7rem 0 1.1rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* 地平線の下の天体は、音と同じように表でも一段沈める */
.bodies tr[data-up="false"] > * { color: color-mix(in srgb, var(--ink) 72%, var(--zenith)); }
.bodies tr[data-up="false"] .solo[aria-pressed="true"] { color: var(--zenith); }
.bodies tr[data-up="false"] > th { font-weight: 400; }

.facts { margin: 0; }

.facts div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 1em;
}

.facts dt { font-size: 0.85rem; }
.facts dd { margin: 0; font-weight: 600; }

/* 音の決まり方 */
.rules {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem var(--gutter) 4rem;
}

.rules h2 {
  margin: 0 0 1.2rem;
  font-size: 1.6rem;
  font-weight: 600;
}

.rules dl {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 0.8rem 1rem;
  margin: 0 0 2rem;
}

.rules dt { font-weight: 600; }
.rules dd { margin: 0; }
.rules .note, .rules .credit { margin: 0 0 0.6rem; font-size: 0.88rem; }
.rules a { color: inherit; }

@media (max-width: 1080px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .intro {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "title transport" "title lead";
    align-items: start;
  }
  h1 { font-size: 4.2rem; }
  .lead { writing-mode: horizontal-tb; margin: 0; letter-spacing: 0.02em; }
  .lead br { display: none; }
  .chart { max-width: 640px; }
  .readout { max-width: 640px; width: 100%; justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}
