/* ---------- mode ---------- */
:root, :root[data-mode="dark"] {
  --bg: #111; --fg: #eee; --btn-bg: #ffe14d; --btn-fg: #000; --btn-line: #000;
  --toast-bg: rgba(0, 0, 0, .85); --toast-fg: #fff; color-scheme: dark;
}
:root[data-mode="light"] {
  --bg: #f6f3ec; --fg: #1a1a1a; --btn-bg: #ffe14d; --btn-fg: #000; --btn-line: #000;
  --toast-bg: rgba(255, 255, 255, .92); --toast-fg: #111; color-scheme: light;
}
:root[data-mode="black"] {
  --bg: #000; --fg: #ddd; --btn-bg: #000; --btn-fg: #ffe14d; --btn-line: #ffe14d;
  --toast-bg: #000; --toast-fg: #ffe14d; color-scheme: dark;
}
#mode {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 10000;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--btn-line);
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 20px;
  line-height: 1;
  box-shadow: 3px 3px 0 var(--btn-line);
  cursor: pointer;
}
#mode:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--btn-line); }
#mode:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
#stage { min-height: 100vh; }

/* ---------- roll button ---------- */
#roll {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid var(--btn-line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 700 16px/1 system-ui, sans-serif;
  box-shadow: 3px 3px 0 var(--btn-line);
  cursor: pointer;
}
#roll:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--btn-line); }
#roll:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--btn-line); }
#roll:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; }
#roll .die { display: inline-flex; width: 28px; height: 28px; }
#roll .die svg { display: block; overflow: visible; }
#roll .die-body { fill: var(--btn-bg); stroke: var(--btn-fg); stroke-width: 2; stroke-linejoin: round; }
#roll .die-edge { fill: none; stroke: var(--btn-fg); stroke-width: 1; stroke-linejoin: round; opacity: .45; }
#roll .die-num { fill: var(--btn-fg); font: 800 10px system-ui, sans-serif; paint-order: stroke; stroke: var(--btn-bg); stroke-width: 2.5px; }
#roll.rolling .die { animation: roll-spin .6s ease-out; }
#roll .roll-result:empty { display: none; }
#roll .roll-result {
  min-width: 1.6em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--btn-line);
  color: var(--btn-bg);
  text-align: center;
}
@keyframes roll-spin {
  from { transform: rotate(0) scale(1); }
  50%  { transform: rotate(360deg) scale(1.4); }
  to   { transform: rotate(720deg) scale(1); }
}

/* ---------- theme name toast ---------- */
#theme-toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  z-index: 10000;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  font: 600 14px/1.2 system-ui, sans-serif;
  pointer-events: none;
  transition: opacity .4s;
  max-width: min(92vw, 460px);
  text-align: center;
}
#theme-toast.hide { opacity: 0; }

/* ---------- loading / error ---------- */
.shell-msg {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}
.shell-msg a { color: #ffe14d; }

@media (prefers-reduced-motion: reduce) {
  #roll.rolling .die { animation: none; }
}

/* link logos (js/logos.js) */
.rl { width: 1em; height: 1em; margin-right: .4em; vertical-align: -0.14em; flex: none; fill: currentColor; }
.theme-arcade .rl { image-rendering: pixelated; filter: drop-shadow(1px 0 0 currentColor); }
.theme-newspaper .rl { opacity: .85; }
.theme-receipt .rl { margin-right: .3em; }
.theme-nokia .rl { margin-right: .2em; }

/* ---------- fan note (js/shell.js "fan note") ---------- */
.fan-link {
  position: fixed; left: 50%; bottom: 76px; z-index: 9000; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 4px 12px; border: 1px solid currentColor; border-radius: 14px;
  background: var(--toast-bg); color: var(--toast-fg); font: 500 12px/1.3 system-ui, sans-serif;
  text-decoration: underline; cursor: pointer; opacity: .9;
}
.fan-link:hover { opacity: 1; }
.fan-link:focus-visible, .fan-dlg a:focus-visible, .fan-dlg button:focus-visible { outline: 3px solid #4da3ff; outline-offset: 3px; }
@media (min-width: 640px) { .fan-link { bottom: 22px; } }
.fan-dlg { width: min(92vw, 380px); padding: 18px 20px; border: 2px solid var(--fg); border-radius: 12px; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, sans-serif; text-align: left; }
.fan-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.fan-dlg h2 { margin: 0 0 10px; font-size: 18px; }
.fan-dlg p { margin: 0 0 8px; }
.fan-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.fan-dlg a { color: var(--fg); font-weight: 600; }
.fan-close { margin-left: auto; padding: 6px 16px; border: 2px solid var(--btn-line); border-radius: 8px; background: var(--btn-bg); color: var(--btn-fg); font: 600 14px system-ui, sans-serif; cursor: pointer; }
:root[data-mode="black"] .fan-close { border-color: var(--btn-fg); }
