:root {
  --cpc-blue: #0d6ef5;
  --cpc-blue-deep: #0a3d8f;
  --cpc-night: #061a3d;
  --cpc-ice: #cfe9ff;
  --cpc-gold: #ffb627;
  --dock-w: 72px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #1b6ff0 0%, var(--cpc-blue-deep) 45%, var(--cpc-night) 100%);
  color: #fff; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

/* HUD cut-out: the Flash chat bar (bottom strip), news/mail icons (top-left) and the moderator shield (top-right)
   keep their true colours and stay snow-free; the overlays only cover the room art. 760x480 stage percentages. */
/* Snow never falls over the HUD: the clip leaves out the chat bar (bottom centre), the news/mail icons (top-left)
   and the moderator shield (top-right). The night tint has no hard clip (it would show as a lighter rectangle);
   it stays readable on the HUD because it is weak and mostly a hue shift. */
:root { --snow-clip: polygon(17.5% 0, 90.5% 0, 90.5% 17%, 100% 17%, 100% 100%, 86% 100%, 86% 91%, 18% 91%, 18% 100%, 0 100%, 0 15%, 17.5% 15%); }
#daynight { position: absolute; inset: 0; pointer-events: none; z-index: 5; mix-blend-mode: multiply; transition: background 2s linear; }
#daynight-hue { position: absolute; inset: 0; pointer-events: none; z-index: 5; mix-blend-mode: color; transition: background 2s linear; }
#snow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; clip-path: var(--snow-clip); display: none; /* drawn inside the game (interface.swf); the canvas only serves the landing page */ }  /* lives inside #stage: snow only over the room art */

#app { position: fixed; inset: 0; display: flex; }

#dock {
  width: calc(var(--dock-w) + var(--safe-l)); padding: calc(8px + var(--safe-t)) 6px 8px calc(6px + var(--safe-l));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(4, 18, 48, 0.55); backdrop-filter: blur(10px); z-index: 20;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.dock-logo img { width: 48px; height: 48px; border-radius: 12px; display: block; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.dock-btn {
  width: 58px; height: 54px; border: 0; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,0.08); color: var(--cpc-ice);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
  transition: background .15s, transform .1s;
}
.dock-btn .ico { font-size: 20px; line-height: 1; }
.dock-btn:hover { background: rgba(255,255,255,0.18); }
.dock-btn:active { transform: scale(.96); }
.dock-btn.active { background: var(--cpc-blue); color: #fff; }

#stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px; min-width: 0; }
#stage {
  position: relative; width: 100%; max-width: calc((100vh - 12px) * 760 / 480); aspect-ratio: 760 / 480;
  max-height: 100%; border-radius: 10px; overflow: hidden; background: #0b5fb5; flex: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08);
}
#game-host { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
#game-host ruffle-player { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }

#splash {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(800px 500px at 50% 30%, #1b6ff0, #061a3d 80%); z-index: 5; text-align: center; padding: 20px;
}
#splash img { max-width: min(70%, 360px); height: auto; filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
#splash p { margin: 0; color: var(--cpc-ice); font-weight: 600; }
.spinner { width: 34px; height: 34px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary {
  border: 0; border-radius: 999px; padding: 12px 28px; font-size: 17px; font-weight: 800; cursor: pointer;
  background: linear-gradient(#ffd166, var(--cpc-gold)); color: #3a2400; box-shadow: 0 4px 0 #b8771a, 0 8px 20px rgba(0,0,0,.4);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #b8771a; }

#toasts { position: fixed; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 220px; max-width: 340px; padding: 10px 14px; border-radius: 12px;
  background: rgba(6, 26, 61, .92); border: 1px solid rgba(255,255,255,.15); box-shadow: 0 8px 24px rgba(0,0,0,.4);
  color: #fff; font-size: 14px; animation: toast-in .25s ease-out;
}
.toast strong { color: var(--cpc-gold); }
.toast.mascot { border-color: var(--cpc-gold); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

#panel { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 12px; }
#panel-card {
  width: min(96vw, 980px); max-height: min(94vh, 760px); display: flex; flex-direction: column;
  background: linear-gradient(#123f8f, #0a2a63); border-radius: 16px; border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); overflow: hidden;
}
#panel-card header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: rgba(0,0,0,.25); }
#panel-card h2 { margin: 0; font-size: 18px; }
#panel-close { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; cursor: pointer; }
#panel-body { padding: 14px; overflow: auto; flex: 1; }
#panel-body table { width: 100%; border-collapse: collapse; }
#panel-body td, #panel-body th { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.1); text-align: left; }
#panel-body .muted { color: var(--cpc-ice); opacity: .8; }
#panel-body a { color: var(--cpc-gold); }
/* "or / Log in with Discord" over the create form's password step (stage coords: under the email field) */
#cpc-discord-signup { position: absolute; left: 41.2%; top: 80.4%; width: 24%; height: 9%; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; pointer-events: none; font-family: "Segoe UI", system-ui, sans-serif; }
#cpc-discord-signup.hidden { display: none; }
#cpc-discord-signup .cpc-or { font-size: 12px; color: #555; line-height: 1; }
#cpc-discord-btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 6px; padding: 5px 12px; background: #5865F2; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: 0 2px 0 #3c45b0; white-space: nowrap; }
#cpc-discord-btn:hover { background: #4752c4; }
#cpc-discord-btn:disabled { background: #3ba55d; box-shadow: none; cursor: default; }
#cpc-discord-status { font-size: 11px; color: #333; text-align: center; line-height: 1.2; max-width: 100%; }
@media (max-width: 760px) { #cpc-discord-btn { font-size: 11px; padding: 4px 8px; } #cpc-discord-signup .cpc-or { font-size: 10px; } #cpc-discord-status { font-size: 9px; } }
/* Mascots panel: icon-as-bullet list */
.mascot-list { list-style: none; margin: 0; padding: 0; }
.mascot-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px; border-bottom: 1px solid rgba(255,255,255,.1); }
.mascot-row:last-child { border-bottom: 0; }
.mascot-row.is-live { background: rgba(255,255,255,.07); border-radius: 10px; }
.mascot-ico { width: 44px; height: 44px; flex: 0 0 44px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); }
.mascot-text { min-width: 0; }
.mascot-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 15px; }
.mascot-when { color: var(--cpc-ice); opacity: .9; }
.mascot-live { color: var(--cpc-gold); font-weight: 700; }
.mascot-sub { font-size: 13px; margin-top: 2px; }
@media (max-width: 760px) { .mascot-ico { width: 36px; height: 36px; flex-basis: 36px; } .mascot-head { font-size: 14px; } }

#rotate-hint { display: none; position: fixed; inset: 0; z-index: 80; background: var(--cpc-night); align-items: center; justify-content: center; flex-direction: column; gap: 12px; text-align: center; padding: 24px; }
#rotate-hint img { width: 72px; border-radius: 16px; }

/* Phones: dock becomes a bottom bar, stage fills the rest */
@media (max-width: 760px), (max-height: 480px) {
  #app { flex-direction: column-reverse; }
  #stage-wrap { min-height: 0; }
  #dock {
    width: 100%; flex-direction: row; justify-content: space-around; gap: 2px;
    padding: 4px calc(6px + var(--safe-r)) calc(4px + var(--safe-b)) calc(6px + var(--safe-l));
    border-right: 0; border-top: 1px solid rgba(255,255,255,0.08);
  }
  .dock-logo { display: none; }
  .dock-btn { width: 52px; height: 44px; font-size: 10px; }
  .dock-btn .ico { font-size: 17px; }
  #stage-wrap { padding: 0; }
  #stage { border-radius: 0; max-width: 100%; max-height: 100%; }
}
@media (max-width: 760px) and (orientation: portrait) {
  #rotate-hint { display: flex; }
}

/* Item lookup tool */
.il-search input { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: #fff; font-size: 15px; }
.il-results { max-height: 220px; overflow: auto; margin: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.il-row { text-align: left; border: 0; background: rgba(255,255,255,.08); color: #fff; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.il-row:hover { background: rgba(255,255,255,.18); }
.il-id { color: var(--cpc-gold); font-weight: 700; margin-right: 6px; }
.il-detail { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.il-doll { position: relative; background: rgba(255,255,255,.08); border-radius: 12px; overflow: hidden; flex: 0 0 auto; }
.il-doll ruffle-player, .il-icon ruffle-player { position: absolute; left: 0; top: 0; }
.il-meta { flex: 1 1 220px; min-width: 200px; }
.il-meta h3 { margin: 0 0 8px; font-size: 18px; }
.il-meta table th { width: 110px; color: var(--cpc-ice); font-weight: 600; }
.il-copy { margin-left: 8px; border: 0; background: var(--cpc-gold); color: #222; padding: 4px 10px; border-radius: 8px; cursor: pointer; font-weight: 700; }

/* Phones in landscape: the 760x480 stage is wider than tall, so the leftover width holds a slim vertical dock on
   the right and the stage gets the full height (fitted by quality.js, never cropped). */
@media (max-height: 480px) and (orientation: landscape) {
  #app { flex-direction: row-reverse; }
  #dock {
    width: calc(56px + var(--safe-r)); height: 100%; flex-direction: column; justify-content: center; gap: 4px;
    padding: 4px calc(4px + var(--safe-r)) 4px 4px; border-top: 0; border-left: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
  }
  .dock-btn { width: 46px; height: 38px; font-size: 9px; border-radius: 9px; }
  .dock-btn .ico { font-size: 15px; }
  #btn-install.hidden { display: none !important; }
  #stage-wrap { padding: 0 0 0 var(--safe-l); }
}

/* Settings panel */
.set-row { margin-bottom: 16px; }
.set-row label { display: block; margin-bottom: 6px; font-size: 15px; }
.set-row input[type=range] { width: 100%; accent-color: var(--cpc-gold); }
.set-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--cpc-ice); opacity: .8; margin-top: 2px; }
.set-row .set-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.set-row .set-switch input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--cpc-gold); cursor: pointer; }

.il-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.il-tab { border: 0; background: rgba(255,255,255,.1); color: #fff; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.il-tab.active { background: var(--cpc-gold); color: #222; }
.il-add { border: 0; background: var(--cpc-gold); color: #222; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 14px; }
.il-prev ruffle-player { position: absolute; left: 0; top: 0; }
.il-row { display: flex; align-items: center; gap: 10px; }
.il-thumb { width: 36px; height: 36px; flex: 0 0 36px; object-fit: contain; background: rgba(255,255,255,.12); border-radius: 8px; }
.il-prev { display: flex; align-items: center; justify-content: center; }
.il-prev img, .il-icon img { display: block; object-fit: contain; image-rendering: auto; }
.il-icon { display: inline-flex; align-items: center; justify-content: center; width: 96px; height: 96px; background: rgba(255,255,255,.08); border-radius: 12px; margin: 8px 0; }


#cpc-gameload { position: absolute; inset: 0; z-index: 7; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, #1f8fe0 0%, #0d5cab 60%, #083f7a 100%); color: #fff; font-family: Arial, sans-serif; font-weight: 700; font-size: 20px; pointer-events: none; }
#cpc-gameload.show { display: flex; }
#cpc-gameload .gl-spin { width: 56px; height: 56px; border-radius: 50%; border: 7px solid rgba(255,255,255,.25); border-top-color: #fff; animation: cpc-spin 0.9s linear infinite; }
#cpc-gameload .gl-pct { font-size: 16px; opacity: .85; min-height: 20px; }
@keyframes cpc-spin { to { transform: rotate(360deg); } }

/* Star Wars AS3 mini-game overlay (starwars.js): loading screen while the game SWF streams in */
#sw-overlay .sw-loading { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; background: radial-gradient(800px 500px at 50% 30%, #1b6ff0, #061a3d 80%); }
#sw-overlay .sw-loading-box { text-align: center; color: var(--cpc-ice, #cfe9ff); }
#sw-overlay .sw-loading-box img { width: 220px; height: auto; border-radius: 12px; margin-bottom: 14px; }
#sw-overlay .sw-loading-title { font-size: 22px; font-weight: 800; color: #fff; margin-bottom: 12px; }
#sw-overlay .sw-loading-bar { width: 220px; height: 10px; margin: 0 auto; border-radius: 6px; background: rgba(0,0,0,.35); overflow: hidden; border: 1px solid rgba(0,0,0,.3); }
#sw-overlay .sw-loading-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, #4cc3ff, #0d6ef5); animation: swload 1.2s ease-in-out infinite alternate; }
@keyframes swload { from { transform: translateX(-30%); } to { transform: translateX(200%); } }
