:root { font-family: "Yu Gothic UI", "Meiryo", sans-serif; color: #15283a; background: #eef3f7; }
* { box-sizing: border-box; }
body { margin: 0; }
main { width: min(1040px, 100%); margin: auto; padding: clamp(10px, 3vw, 30px); }
.broadcast { position: relative; background: transparent; }
.scene { position: relative; isolation: isolate; --inset: clamp(8px, 2vw, 16px); overflow: hidden; border-radius: 16px; color: #fff; }
#issued { position: absolute; z-index: 1; top: var(--inset); left: var(--inset); max-width: calc(100% - 2 * var(--inset) - 52px); margin: 0; padding: 6px 10px; border-radius: 9px; background: rgb(10 30 46 / 76%); font-size: clamp(.72rem, 1.7vw, 1rem); font-weight: 700; }
.picture { position: relative; display: grid; place-items: center; min-width: 0; background: #173e59; }
.artwork { position: relative; width: 100%; }
.picture img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: contain; }
.picture img[hidden] { visibility: hidden; }
.picture img.portrait { padding: 12px; background: #315974; }
.forecast-info { display: contents; }
.forecast { position: absolute; top: calc(var(--inset) + 2.5em); left: var(--inset); max-width: min(44%, calc(100% - 2 * var(--inset))); padding: 7px 12px; overflow-wrap: anywhere; border-radius: 9px; background: rgb(10 30 46 / 76%); }
h1 { margin: 0; font-size: clamp(25px, 5vw, 49px); line-height: 1.1; }
.today { margin-top: 3px; font-size: clamp(.85rem, 1.9vw, 1.2rem); font-weight: 700; line-height: 1.35; }
#tonight { margin: 3px 0 0; font-size: clamp(.65rem, 1.4vw, .85rem); }
#next-update { margin: 6px 0 0; font-size: .75rem; line-height: 1.45; }
.credit { position: absolute; right: var(--inset); bottom: var(--inset); margin: 0; padding: 4px 8px; border-radius: 8px; background: rgb(10 30 46 / 76%); font-size: .72rem; }
button { cursor: pointer; border: 1px solid #285873; border-radius: 6px; padding: 7px 13px; background: #fff; color: #173e59; font: inherit; }
button:disabled { cursor: default; opacity: .65; }
:focus-visible { outline: 3px solid #bc5e00; outline-offset: 3px; }
#status:empty { display: none; }
#status { margin: 0; padding: 0 12px 12px; text-align: center; font-size: .88rem; }
#script { white-space: pre-line; }
a { color: #1c5479; text-underline-offset: .25em; }
.broadcast:fullscreen { background: #12293a; display: flex; flex-direction: column; justify-content: center; }
.broadcast:fullscreen .scene { flex: none; width: min(100%, calc((100dvh - 36px) * 1.5)); align-self: center; }
.broadcast:fullscreen #status { color: #fff; }

.menu { position: absolute; z-index: 2; top: clamp(8px, 2vw, 16px); right: clamp(8px, 2vw, 16px); }
.menu summary { display: grid; place-items: center; position: relative; z-index: 1; width: 42px; height: 42px; margin-left: auto; cursor: pointer; list-style: none; border-radius: 9px; background: rgb(10 30 46 / 76%); color: #fff; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary span { width: 18px; height: 2px; background: currentColor; box-shadow: 0 -6px currentColor, 0 6px currentColor; }
.menu-panel { width: min(360px, calc(100vw - 44px)); max-height: calc(100dvh - 80px); overflow: auto; margin-top: 6px; padding: 14px; border: 1px solid #c5d5e0; border-radius: 9px; background: #fff; box-shadow: 0 5px 18px #102c4029; line-height: 1.6; }
.menu-panel > :last-child { margin-bottom: 0; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#screen-play { position: absolute; z-index: 1; left: var(--inset); bottom: var(--inset); width: 42px; height: 42px; padding: 0; place-items: center; border: 1px solid #ffffff85; border-radius: 9px; background: rgb(10 30 46 / 76%); color: #fff; }
#screen-play:not([hidden]) { display: grid; }
#screen-play span { width: 0; height: 0; margin-left: 3px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid currentColor; }
.tomorrow-forecast { margin-top: 3px; border-top: 1px solid #fff5; padding-top: 3px; font-size: clamp(.72rem, 2vw, 1.05rem); }
#regeneration-status:empty { display: none; }
.license-credit { position: absolute; z-index: 1; left: 50%; bottom: var(--inset); transform: translateX(-50%); white-space: nowrap; padding: 4px 9px; border-radius: 8px; background: rgb(10 30 46 / 76%); font-size: .92rem; }
.license-credit a { color: #fff; }
#character-license, #admin-dialog { width: min(33rem, calc(100% - 2rem)); max-height: calc(100% - 2rem); margin: auto; padding: 20px; border: 1px solid #c5d5e0; border-radius: 12px; background: #fff; color: #15283a; line-height: 1.7; }
#character-license::backdrop, #admin-dialog::backdrop { background: #0a1e2eaa; }
#character-license h2, #admin-dialog h2 { margin: 0; font-size: 1.15rem; }
#character-license a { overflow-wrap: anywhere; }
#character-license form, .dialog-close { text-align: right; }

#screen-play.playing span { width: 14px; height: 14px; margin-left: 0; border: 0; background: currentColor; }

.admin-entry { border-top: 1px solid #c5d5e0; padding-top: 10px; }
#admin-login, #admin-actions { margin-block: 12px; }
#admin-password { display: block; width: min(100%, 22rem); margin: 4px 0 8px; padding: 6px; font: inherit; }
#admin-login-status { margin: 8px 0 0; }
#admin-login-status:empty { display: none; }
#lip-sync { position: absolute; pointer-events: none; }

@media (max-width: 640px), (max-width: 960px) and (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  main { padding: 12px; }
  .scene { color: #15283a; background: #fff; box-shadow: 0 4px 16px rgb(21 40 58 / 10%); }
  .picture { color: #fff; }
  #issued {
    position: static;
    max-width: none;
    padding: 16px 16px 0;
    background: none;
    color: #506577;
    font-size: .8125rem;
    line-height: 1.5;
  }
  #issued-message { display: inline-block; }
  .forecast { position: static; max-width: none; padding: 5px 16px 16px; background: none; }
  .forecast h1 { font-size: clamp(1.75rem, 8vw, 2.25rem); }
  .today, .tomorrow-forecast {
    display: grid;
    grid-template-columns: 2.75em minmax(0, 1fr);
    gap: 8px;
    margin: 0;
    padding: 8px 0;
    font-size: .95rem;
    line-height: 1.6;
  }
  .today { margin-top: 5px; }
  .forecast-label { color: #245b7b; font-weight: 700; white-space: nowrap; }
  .tomorrow-forecast { border-top: 1px solid #dbe5ec; }
  #tonight { margin: 2px 0 0; color: #506577; font-size: .75rem; line-height: 1.45; }
  #screen-play, .menu summary { width: 44px; height: 44px; }
  .license-credit { padding: 0; font-size: .875rem; }
  .license-credit a { display: grid; min-height: 44px; padding-inline: 8px; place-items: center; }
  .credit { text-align: right; font-size: .68rem; line-height: 1.35; }
  .credit span { display: block; }
  .menu-panel { max-height: min(70dvh, calc(100dvh - 82px)); }
  .menu-actions button { min-height: 44px; }
  #status { padding: 9px 12px 0; line-height: 1.5; }
  .broadcast:fullscreen { display: block; overflow: auto; }
  .broadcast:fullscreen .scene { width: 100%; border-radius: 0; }
}

@media (max-width: 640px) and (orientation: portrait) {
  :root { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  main { --portrait-margin: 6px; padding: var(--portrait-margin); }
  .scene {
    --portrait-height: calc(100svh - 2 * var(--portrait-margin));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(calc(var(--portrait-height) * .55), 1fr) auto calc(44px + 2 * var(--inset));
    min-height: var(--portrait-height);
    color: #fff;
    box-shadow: none;
  }
  .broadcast:fullscreen .scene { --portrait-height: 100svh; }
  .picture { position: absolute; inset: 0; display: block; overflow: hidden; }
  /* Crop the image and its lip-sync canvas together. */
  .artwork {
    position: absolute;
    top: 0;
    left: 50%;
    width: auto;
    height: 100%;
    aspect-ratio: 3 / 2;
    transform: translateX(-50%);
  }

  .forecast-info {
    display: block;
    position: relative;
    grid-area: 2 / 1;
    justify-self: start;
    max-width: calc(100% - 2 * var(--inset));
    margin-inline: var(--inset);
    padding: 9px 12px;
    border-radius: 12px;
    background: rgb(10 25 40 / 78%);
  }
  #issued { padding: 0; color: #e0edf5; font-size: .6875rem; line-height: 1.45; }
  #issued-at { white-space: nowrap; }
  .forecast { margin-top: 5px; padding: 0; }
  .forecast h1 { font-size: clamp(1rem, 4.6vw, 1.125rem); line-height: 1.15; }
  .today, .tomorrow-forecast {
    grid-template-columns: 2.5em minmax(0, 1fr);
    gap: 6px;
    padding-block: 4px;
    font-size: clamp(.75rem, 3.2vw, .8125rem);
    line-height: 1.5;
  }
  .today { margin-top: 3px; }
  .forecast-label, #tonight, #next-update { color: #e0edf5; }
  .tomorrow-forecast { border-color: rgb(224 237 245 / 35%); padding-bottom: 0; }
  #tonight, #next-update { margin-top: 4px; font-size: .6875rem; }
  .license-credit, #status { font-size: .75rem; }
  .credit { font-size: .625rem; }
}

@media (min-width: 560px) and (max-width: 960px) and (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  main { padding: 8px; }
  .scene {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .picture { grid-area: 1 / 1 / 3 / 2; align-self: center; }
  #issued { grid-area: 1 / 2; padding-right: 60px; }
  .forecast { grid-area: 2 / 2; }
  .broadcast:fullscreen .scene { width: min(100%, calc((100dvh - 32px) * 2.4)); margin-inline: auto; }
}
