/*
 * Developer additions on top of the design (portal.css, style.css, theme.css):
 * standalone sign-in pages and the night scene of the dark theme.
 */

/* Sign-in, sign-up, e-mail and password pages (and every page a guest sees) stand alone: no cabinet menu. */
body.is-standalone .sidebar,
body.is-standalone .mobile-nav,
body.is-standalone .profile-chip { display: none }
body.is-standalone .app-shell { grid-template-columns: minmax(0, 1fr) }
body.is-standalone .auth-wrap { width: min(1040px, 100%); margin-inline: auto }
@media (max-width: 900px) { body.is-standalone { padding-bottom: 0 } body.is-standalone .app-shell { padding-bottom: 24px } }

/* Separate buttons under the sign-in forms. */
.auth-form .btn + .btn, .auth-form .btn + a.btn { margin-top: 10px }

/* Dark theme: the same world at night — starry sky, square moon, moonlit water — instead of a dimmed day. */
html[data-theme="dark"] .world,
html[data-theme="dark"] .portal-world {
  background-color: #0b1020;
  background-image: url('/assets/cardboard-world-night-v1.jpg');
  filter: none;
  opacity: 1;
}
html[data-theme="dark"] .world:after,
html[data-theme="dark"] .portal-world:after { background: linear-gradient(180deg, rgba(6, 10, 24, .08), rgba(6, 10, 22, .45)) }
@media (max-width: 760px) { html[data-theme="dark"] .portal-world { background-image: url('/assets/cardboard-world-mobile-night-v1.jpg') } }
@media (max-width: 700px) { html[data-theme="dark"] .world { background-image: url('/assets/cardboard-world-mobile-night-v1.jpg') } }

/* A few stars twinkle over the picture's own stars. */
html[data-theme="dark"] .world:before,
html[data-theme="dark"] .portal-world:before {
  content: "";
  position: absolute;
  inset: 0 0 55% 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 14%, #fff 0 1.2px, transparent 2.4px),
    radial-gradient(circle at 19% 6%, #e8eeff 0 1px, transparent 2px),
    radial-gradient(circle at 31% 22%, #fff 0 1.4px, transparent 2.6px),
    radial-gradient(circle at 44% 9%, #dfe8ff 0 1px, transparent 2px),
    radial-gradient(circle at 52% 27%, #fff 0 1.1px, transparent 2.2px),
    radial-gradient(circle at 61% 5%, #fff 0 1.3px, transparent 2.5px),
    radial-gradient(circle at 77% 18%, #e8eeff 0 1px, transparent 2px),
    radial-gradient(circle at 86% 8%, #fff 0 1.4px, transparent 2.6px),
    radial-gradient(circle at 94% 25%, #fff 0 1px, transparent 2px);
  animation: md-twinkle 4.5s ease-in-out infinite alternate;
}
@keyframes md-twinkle { 0% { opacity: .25 } 45% { opacity: .9 } 100% { opacity: .45 } }
@media (prefers-reduced-motion: reduce) {
  html[data-theme="dark"] .world:before,
  html[data-theme="dark"] .portal-world:before { animation: none; opacity: .6 }
}

/* Dark theme readability on the landing: light plaques get dark text, dark ones light text. */
html[data-theme="dark"] .capability-visual span { color: #2b2620 }
html[data-theme="dark"] .signal-copy p:first-child { color: #fff }
html[data-theme="dark"] .signal-copy p:nth-child(2) { color: #10262a }
html[data-theme="dark"] .stamp,
html[data-theme="dark"] .console-label { color: #cfc8ba }
html[data-theme="dark"] .capability-copy p,
html[data-theme="dark"] .capability-copy small { color: #c9cdd3 }
html[data-theme="dark"] .safe-title em,
html[data-theme="dark"] .bonus-cta,
html[data-theme="dark"] .capability-link i { color: #10262a }
html[data-theme="dark"] .lang-switch button.is-active,
html[data-theme="dark"] [data-lang].is-active { color: #fff; background: var(--coral, #f05d50) }

/* Phones: pictures stay inside the screen. */
@media (max-width: 700px) {
  .hero-world img { width: 100%; margin-left: 0 }
  .events-scene img, .safety-scene img, .launch-scene img, .finale img { max-width: 100% }
}

/* Phones: every block fits the screen; tables turn into small cards ("label — value" lines). */
@media (max-width: 760px) {
  .content-grid, .owner-grid { grid-template-columns: minmax(0, 1fr) }
  .content-grid > *, .owner-grid > * { min-width: 0; max-width: 100%; grid-column: 1 / -1 }
  .card { min-width: 0; overflow-wrap: anywhere }
  .owner-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px }
  .owner-toolbar .owner-filter, .owner-toolbar input, .owner-toolbar select { width: 100%; min-width: 0 }
  .owner-actions-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) }
  .owner-actions-grid .btn { min-width: 0; white-space: normal; height: auto; min-height: 44px; padding: 8px 10px }
  .owner-nav { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch }
  .table-wrap { max-width: 100%; overflow-x: auto }
  .table-wrap.stack { overflow: visible; border: 0; background: transparent }
  .table-wrap.stack table, .table-wrap.stack tbody, .table-wrap.stack tr, .table-wrap.stack td { display: block; width: 100% }
  .table-wrap.stack thead { display: none }
  .table-wrap.stack tr { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line, rgba(127, 127, 127, .2)); border-radius: 14px }
  .table-wrap.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: 0; white-space: normal; text-align: right; overflow-wrap: anywhere }
  .table-wrap.stack td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; color: var(--muted, #8b8b8b); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; text-align: left }
  .table-wrap.stack td[data-label=""]::before { content: none }
  .table-wrap.stack td[data-label=""] { justify-content: flex-end }
}

/* Sign-out at the bottom of the menu. */
.sidebar-signout { width: 100%; min-height: 43px; margin-top: 10px; padding: 0 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 12px; color: var(--muted, #7a7368); background: transparent; font: 800 12px var(--body, inherit); cursor: pointer; text-align: left }
.sidebar-signout:hover { color: var(--ink, #222); background: rgba(240, 93, 80, .1) }
.sidebar-signout .nav-icon { color: var(--coral, #f05d50) }

/* Reactions: effect sets as tiles with pixel icons of what they do. */
.px-icon { display: inline-flex; width: 22px; height: 22px; margin-right: 4px; vertical-align: middle; image-rendering: pixelated; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)) }
.px-icon svg { width: 100%; height: 100% }
.fx-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px }
.fx-tile { position: relative; min-height: 86px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; border: 1px solid var(--line, rgba(127, 127, 127, .25)); border-radius: 15px; background: rgba(255, 255, 255, .05); cursor: pointer; transition: .15s }
.fx-tile input { position: absolute; opacity: 0; pointer-events: none }
.fx-tile b { font-size: 12px; line-height: 1.3 }
.fx-tile .fx-icons { display: flex; flex-wrap: wrap; gap: 2px }
.fx-tile .px-icon { width: 28px; height: 28px }
.fx-tile:has(input:checked) { border-color: var(--cyan, #20b9cd); background: rgba(32, 185, 205, .14); box-shadow: inset 0 0 0 2px rgba(32, 185, 205, .35) }
.fx-tile:has(input:checked)::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--cyan, #20b9cd); font-weight: 900 }
.fx-tile.is-off { opacity: .55; cursor: default }
.fx-list li span { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 2px }

/* The streamer's own gift rules. */
.gr-rule { margin-top: 14px; padding: 14px; border: 1px solid var(--line, rgba(127, 127, 127, .25)); border-radius: 18px; background: rgba(255, 255, 255, .04) }
.gr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.gr-head .tabs { margin: 0; flex: 1 1 auto }
.gr-num { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #fff; background: var(--coral, #f05d50); font-weight: 900 }
.gr-range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.gr-sub { margin: 14px 0 0; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .75 }
.fx-tile.is-selected { border-color: var(--cyan, #20b9cd); background: rgba(32, 185, 205, .14); box-shadow: inset 0 0 0 2px rgba(32, 185, 205, .35) }
button.fx-tile { font: inherit; color: inherit; text-align: left }
.gr-order { position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--cyan, #20b9cd); font: 900 11px var(--body, inherit); font-style: normal }
@media (max-width: 760px) { .gr-range { grid-template-columns: 1fr } }

/* Sign-out in the header: on every page and every screen size. */
.header-signout { height: 44px; padding: 0 14px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line, rgba(127, 127, 127, .25)); border-radius: 14px; color: var(--ink, #222); background: rgba(255, 255, 255, .35); font: 800 12px var(--body, inherit); cursor: pointer }
.header-signout span { color: var(--coral, #f05d50); font-size: 15px }
.header-signout:hover { background: rgba(240, 93, 80, .12) }
html[data-theme="dark"] .header-signout { background: rgba(255, 255, 255, .06) }
body.is-standalone .header-signout { display: none !important }
@media (max-width: 760px) { .header-signout { width: 40px; height: 40px; padding: 0; justify-content: center } .header-signout b { display: none } }

/* Tabs wrap instead of hiding options on narrow screens. */
.tabs { flex-wrap: wrap; height: auto; row-gap: 6px }

/* Reactions: the five sections as big buttons. */
.react-nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 14px }
.react-sec { min-height: 92px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px; border: 1px solid var(--line, rgba(127, 127, 127, .25)); border-radius: 16px; color: inherit; background: rgba(255, 255, 255, .05); font: inherit; text-align: left; cursor: pointer }
.react-sec .px-icon { width: 30px; height: 30px }
.react-sec b { font-size: 14px }
.react-sec small { opacity: .7; font-size: 10px }
.react-sec.is-active { border-color: var(--coral, #f05d50); background: rgba(240, 93, 80, .12); box-shadow: inset 0 0 0 2px rgba(240, 93, 80, .35) }
.gr-grow { flex: 1 }
@media (max-width: 760px) { .react-nav { grid-template-columns: repeat(2, minmax(0, 1fr)) } .react-sec:last-child { grid-column: 1 / -1 } }

/* Inline links inside cards ("What it is and mode settings →"). */
.text-link { color: var(--cyan, #46b9c9); font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
/* Main mode choice: two big cards side by side, stacked on phones. */
.mode-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .mode-pick { grid-template-columns: 1fr; } }
/* Profiles: name and summary, buttons wrap under them on phones. */
.profile-list li { display: grid; gap: 6px; }
.profile-list .btn-row { margin-top: 2px; flex-wrap: wrap; }
.prof-import summary { cursor: pointer; font-weight: 700; margin: 6px 0; }
.prof-import textarea { width: 100%; font: inherit; }
/* Two cards per row in the mode and style pickers: the reactions nav rule must not stretch the last one. */
.mode-pick .react-sec:last-child { grid-column: auto; }
/* Boss "for the boss" gifts as chips. */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--paper-2, rgba(0,0,0,.08)); font-weight: 700; }
.chip button { border: 0; background: transparent; font: inherit; font-size: 1.1em; cursor: pointer; padding: 0 6px; color: inherit; }
.chip-add { display: flex; gap: 8px; }
.chip-add input { flex: 1; min-width: 0; }
