/* ============ Allwyn characters: the stage they play on ============
   Two stages, one behind the card and one in front, so a character can either
   duck behind the panel or walk over it. Both ignore the pointer entirely — a
   character is never in the way of a control. */
#char-back, #char-front { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#char-back { z-index: 0; }
#char-front { z-index: 60; }
/* The card has to sit above the back stage for "behind" to mean anything. */
.screen .card, .screen .print-card, .screen .print-panel, .screen .topbar { position: relative; z-index: 1; }

.char-cue { position: absolute; will-change: transform, opacity; transform-origin: 50% 50%; }
.char-cue > div { width: 100%; height: 100%; }
.char-cue svg, .char-cue canvas { display: block; width: 100%; height: 100%; }

/* The sheet that softens whatever is behind a character. Transparent on its own
   — everything it does is to the picture underneath it. */
.char-veil {
  position: fixed; inset: 0; pointer-events: none; background: transparent;
  -webkit-backdrop-filter: blur(0px); backdrop-filter: blur(0px);
}

/* ============ the authoring workspace — development only ============
   It takes the screen rather than sitting on top of the site, and the site runs
   inside it in real device frames. A panel pinned to the side covered exactly
   the part of the screen characters fly through. */
#char-stage {
  position: fixed; inset: 0; z-index: 10040; display: none;
  background: #08131A; align-items: stretch;
}
body.char-tool-open #char-stage { display: flex; }
body.char-tool-open.char-docked #char-stage { display: none; }
body.char-tool-open:not(.char-docked) { overflow: hidden; }

#char-stage .cs-frames {
  flex: 1 1 auto; display: flex; gap: 22px; padding: 16px 20px 24px;
  overflow: auto; align-items: flex-start; justify-content: center;
}
.cs-frame { display: flex; flex-direction: column; flex: 0 0 auto; min-width: 232px; }
.cs-bar {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
  background: #0F1F26; color: #CFE9E1; border-radius: 8px; padding: 6px 8px;
  font: 11px/1.2 -apple-system, system-ui, sans-serif;
}
.cs-bar b { color: #7BEFD1; letter-spacing: .06em; text-transform: uppercase; margin-right: 2px; }
.cs-bar select, .cs-bar button {
  background: #16303C; color: #E6F6F1; border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; padding: 4px 6px; font: inherit; cursor: pointer;
}
.cs-bar button:hover { background: #1E3E4D; }
.cs-bar input[type=range] { width: 84px; accent-color: #62DEC7; }
.cs-spacer { flex: 1 1 auto; }
.cs-touch { display: flex; align-items: center; gap: 4px; color: #8FB3AC; cursor: pointer; }
.cs-touch input { accent-color: #62DEC7; width: 13px; height: 13px; margin: 0; }

.cs-body { position: relative; }
.cs-device-frame {
  --shell-radius: 44px;
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: #080D10; border-radius: var(--shell-radius); padding: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.1),
              inset 0 0 0 5px rgba(0,0,0,.6);
}
.cs-device-frame iframe { border: 0; display: block; flex: 0 0 auto; background: #fff; }

/* ---- the strip above the page ---- */
.cs-status {
  position: relative; flex: 0 0 auto; display: flex; align-items: center;
  justify-content: space-between; padding: 0 22px; overflow: hidden;
  background: #E9EAED; color: #101418;
  border-radius: calc(var(--shell-radius) - 10px) calc(var(--shell-radius) - 10px) 0 0;
  font: 700 13px/1 -apple-system, system-ui, sans-serif;
}
/* The device chrome must not cover the app. The iframe is the same usable
   viewport the real mobile UI receives; status and browser bars sit outside it. */
.cs-frame-phone .cs-status {
  position: relative; top: auto; left: auto; right: auto; z-index: 3;
  background: #E9EAED; pointer-events: none; text-shadow: none;
}
.cs-frame-phone .cs-device-frame iframe { border-radius: 0; }
.cs-status .cs-time { letter-spacing: .01em; }
.cs-status .cs-icons { display: flex; align-items: center; gap: 5px; }
.cs-status svg { display: block; height: 11px; width: auto; fill: currentColor; }
.cs-status .cs-batt { height: 12px; }
/* The island only belongs on a phone that has one. */
.cs-island { display: none; }
.cs-device-frame.is-notched .cs-island {
  display: block; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: 33%; height: 30px;
  background: #080D10; border-radius: 16px;
}

/* ---- a desktop frame is a window, not a device ---- */
.cs-titlebar { justify-content: flex-start; gap: 12px; background: #E9EAED; }
.cs-dots {
  flex: 0 0 auto; width: 46px; height: 10px;
  background:
    radial-gradient(circle 5px at 5px 5px, #FF5F57 96%, transparent),
    radial-gradient(circle 5px at 23px 5px, #FEBC2E 96%, transparent),
    radial-gradient(circle 5px at 41px 5px, #28C840 96%, transparent);
}
.cs-titlebar .cs-pill { flex: 1 1 auto; max-width: 380px; }

/* ---- the strip below the page ---- */
.cs-urlbar {
  position: relative; flex: 0 0 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; overflow: hidden;
  background: #F2F2F5; color: #6B6B72;
  border-radius: 0 0 calc(var(--shell-radius) - 10px) calc(var(--shell-radius) - 10px);
  font: 12px/1 -apple-system, system-ui, sans-serif;
}
.cs-pill {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: #fff; border-radius: 10px; padding: 7px 14px; max-width: 78%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.cs-pill svg { height: 10px; width: auto; fill: currentColor; opacity: .65; flex: 0 0 auto; }
.cs-home { display: none; }
.cs-device-frame.is-notched .cs-home {
  display: block; width: 36%; height: 5px; border-radius: 3px; background: #1F2226; opacity: .85;
}
.cs-note {
  margin-top: 8px; color: #8FB3AC; background: #0F1F26; border-radius: 6px;
  padding: 4px 8px; align-self: flex-start;
  font: 11px/1.3 -apple-system, system-ui, sans-serif;
}
.cs-row {
  display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap;
  color: #8FB3AC; font: 11px/1.3 -apple-system, system-ui, sans-serif;
}
.cs-row input {
  width: 62px; background: #16303C; color: #E6F6F1; border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; padding: 4px 6px; font: inherit;
}
.cs-row button {
  background: #16303C; color: #E6F6F1; border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; padding: 4px 8px; font: inherit; cursor: pointer;
}

/* ---------------------------------------------------------- the panel */
#char-tool {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: 10050;
  background: #0F1F26; color: #CFE9E1; font: 12px/1.45 -apple-system, system-ui, sans-serif;
  overflow-y: auto; display: none; box-shadow: -8px 0 24px rgba(0,0,0,.3);
}
body.char-tool-open #char-tool { display: block; }
/* Inside the workspace it is a column, not something laid over the site. */
#char-stage > #char-tool {
  position: relative; top: auto; right: auto; bottom: auto;
  flex: 0 0 360px; width: 360px; height: 100%; box-shadow: none;
  border-right: 1px solid rgba(255,255,255,.12);
}
#char-tool h3 {
  margin: 0; padding: 12px 14px; font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; color: #7BEFD1; border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
#char-tool h3 button.ct-dock {
  background: #16303C; color: #CFE9E1; border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
  font: 10px/1.2 -apple-system, system-ui, sans-serif; text-transform: none; letter-spacing: 0;
}
#char-tool h3 button.ct-dock:hover { background: #1E3E4D; }
#char-tool .ct-body { padding: 12px 14px 40px; }
#char-tool .ct-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
#char-tool .ct-row > label { flex: 0 0 82px; color: #8FB3AC; }
#char-tool select, #char-tool input[type=text], #char-tool input[type=number] {
  flex: 1 1 auto; min-width: 0; background: #16303C; color: #E6F6F1; border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px; padding: 5px 7px; font: inherit;
}
#char-tool input[type=range] { flex: 1 1 auto; min-width: 0; accent-color: #62DEC7; }
#char-tool .ct-val { flex: 0 0 46px; text-align: right; font-variant-numeric: tabular-nums; color: #7BEFD1; }
#char-tool button {
  background: #16303C; color: #CFE9E1; border: 1px solid rgba(255,255,255,.18);
  border-radius: 7px; padding: 6px 10px; font: inherit; cursor: pointer;
}
#char-tool button:hover { background: #1E3E4D; }
#char-tool button.ct-primary { background: #62DEC7; color: #0F1F26; border-color: #62DEC7; font-weight: 700; }
#char-tool button.ct-danger { border-color: rgba(255,120,120,.5); color: #FFB3B3; }
#char-tool .ct-modes button { flex: 1 1 auto; }
#char-tool .ct-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
#char-tool .ct-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px;
  background: #16303C; cursor: pointer; border: 1px solid transparent;
}
#char-tool .ct-item.is-on { border-color: #62DEC7; }
#char-tool .ct-item span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#char-tool .ct-item button { flex: 0 0 auto; padding: 3px 7px; line-height: 1; }
#char-tool .ct-item button[disabled] { opacity: .3; cursor: default; }
#char-tool .ct-sep {
  margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12);
  color: #7BEFD1; letter-spacing: .06em; text-transform: uppercase; font-size: 11px;
}
#char-tool textarea {
  width: 100%; height: 130px; background: #0A171D; color: #7BEFD1; border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px; padding: 8px; font: 11px/1.4 'Courier New', monospace; resize: vertical;
}
#char-tool .ct-note { color: #8FB3AC; margin: 6px 0 0; }
#char-tool .ct-order { margin: 0 0 6px; }
#char-tool canvas.ct-curve { width: 100%; height: 110px; background: #0A171D; border-radius: 6px; cursor: crosshair; }
#char-tool .ct-keys { display: flex; flex-direction: column; gap: 4px; }
#char-tool .ct-key {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  background: #16303C; cursor: pointer; border: 1px solid transparent;
}
#char-tool .ct-key.is-on { border-color: #62DEC7; }
#char-tool .ct-key b { flex: 0 0 18px; color: #7BEFD1; }
#char-tool .ct-key span { flex: 1 1 auto; color: #8FB3AC; }
#char-tool .ct-check { display: flex; align-items: center; gap: 7px; flex: 1 1 auto; cursor: pointer; }
#char-tool .ct-check input { accent-color: #62DEC7; width: 15px; height: 15px; }
#char-tool .ct-row.ct-wide { display: block; }
#char-tool .ct-row.ct-wide .ct-check { display: flex; }
#char-tool button.ct-icon { padding: 4px 6px; line-height: 0; }
#char-tool button.ct-icon svg { width: 10px; height: 10px; display: block; fill: currentColor; }

/* A keyframe that has been placed by hand in the phone frame says so, because
   otherwise there is no telling one that was from one that simply follows. */
#char-tool .ct-key em.ct-hasphone { flex: 0 0 auto; line-height: 0; color: #D3F63A; }
#char-tool .ct-key em.ct-hasphone svg { width: 9px; height: 9px; display: block; fill: currentColor; }
#char-tool .ct-phoneset { color: #D3F63A; }

/* Handing the whole configuration to a real device. */
#char-tool canvas.ct-qr {
  display: block; margin: 8px auto 4px; background: #fff; border-radius: 8px;
  image-rendering: pixelated;
}
#char-tool .ct-qrnote { text-align: center; }
#char-tool input.ct-link {
  flex: 1 1 auto; min-width: 0; background: #0A171D; color: #7BEFD1;
  border: 1px solid rgba(255,255,255,.14); border-radius: 6px; padding: 5px 7px;
  font: 11px/1.3 'Courier New', monospace;
}

/* The selected character is held still and takes the pointer, so it can be
   dragged. Everything else on the stage stays out of the way. */
.char-cue.is-picked { pointer-events: auto; cursor: move; }

/* The box around it: drag the body to move, a corner to resize, the stalk above
   to turn. Sliders were the wrong instrument for all three. */
#char-gizmo {
  position: fixed; z-index: 10045; display: none; pointer-events: none;
  outline: 1px dashed rgba(98,222,199,.9); outline-offset: 0;
}
#char-gizmo i, #char-gizmo b {
  position: absolute; width: 13px; height: 13px; border-radius: 3px;
  background: #62DEC7; border: 2px solid #0F1F26; pointer-events: auto;
}
#char-gizmo i[data-h=nw] { left: -7px; top: -7px; cursor: nwse-resize; }
#char-gizmo i[data-h=ne] { right: -7px; top: -7px; cursor: nesw-resize; }
#char-gizmo i[data-h=sw] { left: -7px; bottom: -7px; cursor: nesw-resize; }
#char-gizmo i[data-h=se] { right: -7px; bottom: -7px; cursor: nwse-resize; }
#char-gizmo b[data-h=rot] {
  left: 50%; top: -30px; margin-left: -7px; border-radius: 50%;
  background: #D3F63A; cursor: grab;
}
#char-gizmo b[data-h=rot]::after {
  content: ''; position: absolute; left: 50%; top: 11px; width: 2px; height: 17px;
  margin-left: -1px; background: rgba(98,222,199,.9);
}

/* What set is on screen, and whether it is the one in the file. Two browsers
   quietly showing two different things is the most confusing thing this can do. */
#char-tool .ct-state {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  background: #3A2A12; border: 1px solid rgba(211,246,58,.35); color: #F0E6B8;
  border-radius: 8px; padding: 7px 9px; line-height: 1.35;
}
#char-tool .ct-state.is-same { background: #16303C; border-color: rgba(98,222,199,.3); color: #A9D9CE; }
#char-tool .ct-state span { flex: 1 1 auto; }
#char-tool .ct-state b { color: #fff; }
#char-tool .ct-state.is-same b { color: #DFF7F0; }
#char-tool .ct-state button { flex: 0 0 auto; padding: 4px 8px; font-size: 11px; }

/* Where each frame actually put the held keyframe. Printed, not asserted. */
#char-tool .ct-landed {
  display: grid; grid-template-columns: 62px 1fr; gap: 4px 8px; margin: 8px 0 0;
  background: #0A171D; border-radius: 8px; padding: 8px 10px; color: #8FB3AC;
}
#char-tool .ct-landed i { font-style: normal; color: #7BEFD1; text-transform: uppercase;
  font-size: 10px; letter-spacing: .06em; padding-top: 2px; }
#char-tool .ct-landed b { color: #E6F6F1; font-variant-numeric: tabular-nums; }
#char-tool .ct-landed em { font-style: normal; color: #D3F63A; }
#char-tool .ct-landed p { grid-column: 1 / -1; margin: 4px 0 0; }
#char-tool .ct-landed p.ct-agree { color: #7BEFD1; }
#char-tool .ct-landed p.ct-disagree { color: #FFB3B3; }
