/* The same palette is inherited by the actual screen and its miniature preview. */
[data-theme="simple"] { --stage: #17191c; --ink: #f5f6f8; --secondary: #a9aeb6; --title: #f5f6f8; --positive: #ff92af; --negative: #8cceff; --positive-bg: #2b2228; --negative-bg: #202b32; --positive-line: #9d5368; --negative-line: #456e89; --track: #363a40; --fill: #ef7397; --control: #2d3036; --frame: transparent; --display-font: inherit; }
[data-theme="kawaii"] { --stage: #fff0f5; --ink: #a52252; --secondary: #875a6c; --title: #b42f60; --positive: #bd2855; --negative: #256dad; --positive-bg: #fffafd; --negative-bg: #f0f8ff; --positive-line: #e7a3ba; --negative-line: #9fc6e2; --track: #efd5e0; --fill: #db4a83; --control: #fffafd; --frame: #e8afc5; --display-font: inherit; }
[data-theme="royal"] { --stage: #171416; --ink: #fff0cf; --secondary: #cbb990; --title: #f6ce73; --positive: #ffb3c1; --negative: #afdbff; --positive-bg: #302125; --negative-bg: #202a35; --positive-line: #c09650; --negative-line: #8eaec9; --track: #3c3330; --fill: #eac469; --control: #322b28; --frame: #7d663e; --display-font: Georgia, "Hiragino Mincho ProN", serif; }
[data-theme="paper"] { --stage: #f6f8fa; --ink: #23312f; --secondary: #62716f; --title: #23312f; --positive: #bd3555; --negative: #246ba3; --positive-bg: #ffffff; --negative-bg: #ffffff; --positive-line: #e7b3c0; --negative-line: #afd0e4; --track: #dbe5e3; --fill: #237e70; --control: #e7efed; --frame: transparent; --display-font: inherit; }
[data-theme="aqua"] { --stage: #073e43; --ink: #e5fffb; --secondary: #a1d4cd; --title: #a0f8e9; --positive: #ffc1b3; --negative: #9de6fb; --positive-bg: #205350; --negative-bg: #104d5a; --positive-line: #dd998c; --negative-line: #65bfcd; --track: #25666a; --fill: #75e4ce; --control: #1b595b; --frame: #39858a; --display-font: inherit; }
[data-theme="pop"] { --stage: #f8f067; --ink: #322047; --secondary: #67516b; --title: #322047; --positive: #ae2559; --negative: #2b56a0; --positive-bg: #fff5fa; --negative-bg: #eff2ff; --positive-line: #bf3971; --negative-line: #5369bb; --track: #dfd665; --fill: #9a47c0; --control: #fffbe3; --frame: #59417b; --display-font: inherit; }

html { background: #f5f5f7; }
/* Slot positions stay stable when an unassigned frame is hidden during a live. */
.dx-vacant-slot { visibility: hidden; pointer-events: none; }
body[data-surface="display"] .display-screen.is-editing.is-mirrored { transform: none; }
body[data-surface="display"] .display-card .dx-display-actions { flex-wrap: wrap; height: auto; min-height: 36px; }
body[data-surface="display"] .dx-edit-slot { position: relative; }
body[data-surface="display"] .dx-edit-slot.is-empty { border: 1px dashed var(--secondary); background: transparent; color: var(--secondary); }
.dx-edit-slot.is-empty > svg { align-self: center; justify-self: center; width: 24px; height: 24px; }
.dx-edit-slot.is-empty > span { font-size: 11px; line-height: 18px; }
.dx-slot-index { position: absolute; z-index: 1; top: 3px; left: 3px; min-width: 17px; padding: 1px 3px; border-radius: 3px; background: var(--stage); color: var(--ink); font-size: 10px; line-height: 14px; }
.dx-editing-label { color: var(--ink); font-size: 12px; font-weight: 700; }
body[data-surface="display"] .dx-edit-actions [data-action="dx-finish-edit"] { color: white; background: #b9305c; }
.dx-edit-launch { display: flex; justify-content: center; padding: 12px 0 24px; }
body .dx-library { overflow: hidden; }
body .dx-library .gift-library-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); grid-template-rows: none; grid-auto-rows: 164px; align-content: start; height: auto; gap: 12px; overscroll-behavior: contain; }
body .dx-library .library-gift-card { grid-template-rows: 88px 34px 16px; align-content: start; gap: 4px; height: 164px; min-height: 164px; max-height: 164px; padding: 8px 4px; overflow: hidden; }
body .dx-library .library-gift-card img { width: 88px; height: 88px; max-width: 100%; background: none; object-fit: contain; }
body .dx-library .library-gift-card strong { height: 34px; min-height: 34px; line-height: 17px; font-size: 12px; overflow: hidden; }
@media (max-width: 600px) and (orientation: portrait) {
  body .dx-library .gift-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
body .app-shell { inset: auto 0 auto 0; width: 100%; height: var(--dx-viewport-height, 100dvh); min-height: 0; }
body[data-surface="display"] { background: var(--stage); color: var(--ink); color-scheme: normal; }
body[data-surface="display"] .app-shell { background: var(--stage); }
body[data-surface="settings"] .dx-navbar { position: relative; z-index: 2; opacity: 1; background: #fff; filter: none; backdrop-filter: none; -webkit-backdrop-filter: none; text-shadow: none; }
body[data-surface="settings"] .dx-navbar > * { opacity: 1; filter: none; }
.dx-settings .dx-settings-content { display: block; }
.dx-navbar strong { line-height: 1.4; }
.dx-field-row > span { line-height: 1.45; }
.dx-theme-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 12px; }
.dx-theme-option { min-width: 0; }
body .dx-theme-sample { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr) minmax(0, 1fr); align-items: center; height: 112px; padding: 12px 6px; gap: 5px; background: var(--stage); color: var(--ink); border: 1px solid var(--track); border-radius: 6px; font-family: var(--display-font); }
.dx-theme-option[aria-pressed="true"] .dx-theme-sample { outline: 2px solid var(--dx-tint); outline-offset: 2px; border-color: var(--track); }
.dx-sample-gift { display: grid; align-content: center; justify-items: center; min-width: 0; padding: 4px 0; border: 1px solid var(--positive-line); border-radius: 4px; background: var(--positive-bg); color: var(--positive); }
.dx-sample-gift.negative { border-color: var(--negative-line); background: var(--negative-bg); color: var(--negative); }
.dx-sample-gift img { width: 100%; height: 38px; }
.dx-sample-gift small { font-size: 9px; line-height: 1.4; }
.dx-sample-center { display: grid; gap: 10px; min-width: 0; }
.dx-sample-center strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.dx-sample-meter { height: 3px; background: var(--track); border-radius: 2px; }
.dx-sample-meter::before { content: ""; display: block; width: 60%; height: 100%; background: var(--fill); }
.dx-theme-option > svg { z-index: 2; }
.dx-layout-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 24px; }
.dx-layout-picker button { display: grid; align-content: start; justify-items: center; gap: 7px; min-width: 0; padding: 12px 4px; border: 1px solid var(--dx-line); border-radius: 6px; background: white; color: var(--dx-muted); }
.dx-layout-picker button[aria-pressed="true"] { border-color: var(--dx-tint); color: var(--dx-tint); background: #fff5f8; }
.dx-layout-picker strong { font-size: 13px; font-weight: 600; }
.dx-layout-picker small { font-size: 10px; }
.dx-layout-diagram { display: grid; grid-template-columns: repeat(var(--columns), 9px); align-content: center; gap: 3px; height: 60px; }
.dx-layout-diagram i { width: 9px; height: 9px; border: 1px solid currentColor; border-radius: 2px; }
.dx-effect-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--dx-line); }
.dx-effect-row:last-child { border: 0; }
.dx-effect-select { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 54px; padding: 0; background: none; color: var(--dx-text); text-align: left; }
.dx-effect-select > span:nth-child(2) { flex: 1; }
.dx-effect-select strong { display: block; font-size: 15px; font-weight: 550; }
.dx-effect-select small { display: block; margin-top: 4px; color: var(--dx-muted); font-size: 11px; }
.dx-effect-select > svg { color: var(--dx-tint); width: 20px; }
.dx-effect-row > button:last-child { color: var(--dx-tint); }
.dx-effect-art { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 6px; background: #edf8f5; color: #2f9b80; }
.dx-effect-art.heart { background: #fff0f5; }
.dx-effect-art.burst { background: #f5efff; color: #8956b3; }
.dx-effect-art img { width: 30px; height: 30px; object-fit: contain; }
body .dx-field-row .dx-toggle { appearance: none; -webkit-appearance: none; justify-self: end; width: 48px; min-height: 28px; height: 28px; padding: 3px; border: 0; border-radius: 16px; background: #d4d4dc; cursor: pointer; box-shadow: none; }
.dx-toggle::before { content: ""; display: block; width: 22px; height: 22px; background: white; border-radius: 50%; transition: transform .15s; }
body .dx-field-row .dx-toggle:checked { background: #239e74; }
.dx-toggle:checked::before { transform: translateX(20px); }
.dx-volume { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dx-volume > svg { width: 18px; color: var(--dx-muted); }
body .dx-volume input { flex: 1; min-width: 0; min-height: 42px; accent-color: var(--dx-tint); }
.dx-volume output { flex: none; width: 38px; color: var(--dx-muted); font-size: 12px; text-align: right; }

/* Explicit square rows avoid the percentage-image / automatic-grid-track cycle. */
body[data-surface="display"] .display-screen { position: relative; align-items: stretch; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(178px, 1.1fr) minmax(0, 1fr); gap: 12px; background-color: var(--stage); }
body[data-surface="display"] .display-screen::before { display: none; }
body[data-surface="display"] .display-card { max-height: none; align-self: stretch; justify-content: center; gap: 4px; padding: 6px; border: 0; font-family: var(--display-font); }
body[data-surface="display"] .display-card h1 { font-size: 24px; line-height: 1.25; color: var(--title); text-shadow: none; }
body[data-surface="display"] .display-score .number { font-size: 116px; color: var(--ink); font-weight: 700; line-height: 1.1; text-shadow: none; }
body[data-surface="display"] .display-sub { min-height: 18px; line-height: 18px; color: var(--secondary); }
body[data-surface="display"] .display-sub span { color: inherit; line-height: inherit; }
body[data-surface="display"] .display-meter { height: 24px; min-height: 24px; margin-top: 0; }
body[data-surface="display"] .display-meter .meter { height: 5px; background: var(--track); }
body[data-surface="display"] .display-meter .meter > span { background: var(--fill); }
body[data-surface="display"] .display-meter-foot { font-size: 11px; color: var(--secondary); line-height: 15px; min-height: 15px; }
body[data-surface="display"] .dx-display-actions { height: 36px; min-height: 36px; gap: 5px; }
body[data-surface="display"] .dx-display-actions .dx-action, body[data-surface="display"] .dx-display-actions .dx-icon-button { color: var(--ink); background: var(--control); }
body[data-surface="display"] .dx-live-chip { color: var(--secondary); }
body[data-surface="display"] .side-display { grid-template-columns: var(--side-width, 150px) minmax(0, 1fr) var(--side-width, 150px); grid-template-rows: minmax(0, 1fr); gap: 14px; }
body[data-surface="display"] .side-display > .side-gift-panel, body[data-surface="display"] .side-display > .side-center-card, body[data-surface="display"] .side-display > .side-center-stack { grid-column: auto; }
body[data-surface="display"] .side-gift-panel { grid-template-rows: 28px minmax(0, 1fr); gap: 6px; max-height: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
body[data-surface="display"] .center-gift-panel { box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
body[data-surface="display"] .side-plus h2 { color: var(--positive); }
body[data-surface="display"] .side-minus h2 { color: var(--negative); }
body[data-surface="display"] .side-gift-panel h2 { width: 100%; white-space: nowrap; height: 28px; font-size: 14px; }
body[data-surface="display"] .side-gift-grid { grid-template-columns: repeat(var(--side-columns, 2), var(--tile-size, 65px)); grid-auto-rows: var(--tile-size, 65px); gap: 6px; justify-content: center; }
body[data-surface="display"] .side-gift-btn, body[data-surface="display"] .mini-gift-btn { grid-template-rows: minmax(0, 1fr) 18px; width: 100%; height: 100%; min-height: 0; max-height: none; aspect-ratio: auto; padding: 3px 3px 2px; color: var(--positive); border: 1px solid var(--positive-line); background: var(--positive-bg); }
body[data-surface="display"] .side-gift-btn.gift-minus, body[data-surface="display"] .mini-gift-btn.gift-minus { color: var(--negative); border-color: var(--negative-line); background: var(--negative-bg); }
body[data-surface="display"] .side-gift-value, body[data-surface="display"] .mini-value { color: inherit; height: 18px; line-height: 18px; font-size: 13px; text-overflow: clip; }
body[data-surface="display"] .quick-rail { grid-template-columns: repeat(var(--bottom-columns, 7), minmax(0, 1fr)); grid-auto-rows: var(--bottom-tile-size, 95px); gap: 8px; align-content: start; }
body[data-surface="display"] .center-gift-grid { grid-template-columns: repeat(6, var(--tile-size, 65px)); grid-template-rows: none; grid-auto-rows: var(--tile-size, 65px); justify-content: center; gap: 6px; }
body[data-surface="display"] .side-center-stack { grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
body[data-surface="display"][data-theme="royal"] .display-card { border-block: 1px solid var(--frame); }
body[data-surface="display"][data-theme="royal"] .side-gift-btn { border-width: 2px; border-radius: 3px; }
body[data-surface="display"][data-theme="royal"] .display-card::before, body[data-surface="display"][data-theme="royal"] .display-card::after { content: ""; position: absolute; width: 40px; height: 40px; background: url("assets/gifts/rose.webp") center / contain no-repeat; opacity: .6; pointer-events: none; }
body[data-surface="display"][data-theme="royal"] .display-card::before { top: 5px; left: 0; }
body[data-surface="display"][data-theme="royal"] .display-card::after { bottom: 5px; right: 0; }
body[data-surface="display"][data-theme="pop"] .side-gift-btn, body[data-surface="display"][data-theme="pop"] .mini-gift-btn { border-width: 2px; border-radius: 2px; }
body[data-surface="display"][data-theme="aqua"] .side-gift-btn { border-radius: 8px; }
body[data-surface="display"][data-theme="kawaii"] .display-card h1 { font-weight: 650; }

.dx-slot-stage, .dx-slot-stage.is-ipad { grid-template-columns: var(--dx-side-width, 130px) minmax(0, 1fr) var(--dx-side-width, 130px); gap: 16px; }
.dx-slot-stage .dx-slot-grid { grid-template-columns: repeat(var(--dx-columns, 2), var(--dx-slot-size, 65px)); grid-auto-rows: var(--dx-slot-size, 65px); gap: 8px; justify-content: center; }
.dx-slot-stage .dx-slot-center .dx-slot-grid { grid-template-columns: repeat(6, var(--dx-slot-size, 65px)); grid-auto-rows: var(--dx-slot-size, 65px); }
.dx-slot-stage .dx-slot { height: 100%; aspect-ratio: auto; min-height: 0; grid-template-rows: minmax(0, 1fr) 16px; padding: 3px; }
.dx-slot-stage .dx-slot-center .dx-slot { grid-template-rows: minmax(0, 1fr) 16px; }
.dx-slot-stage .dx-slot > span:last-child { line-height: 16px; font-size: 12px; }
.dx-slot-panel h3 { overflow: hidden; white-space: nowrap; }
.dx-slot-counter { min-height: 125px; padding: 12px 6px; }
.dx-slot-counter strong { font-size: 52px; }
.dx-slot-counter > span { line-height: 1.4; }

#dx-celebration-root { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
body .dx-celebration { z-index: auto; pointer-events: none; width: 100%; height: var(--dx-viewport-height, 100dvh); background: #10101818; }
.dx-celebration[data-preview="true"] { background: #101018e8; pointer-events: auto; }
.dx-celebration-mirrored { transform: scaleX(-1); }
.dx-achieved-title { position: absolute; top: 28%; left: 10%; width: 80%; text-align: center; color: #fff6ce; text-shadow: 0 2px 8px #171015; animation: dx-celebration-title 4.8s ease both; }
.dx-achieved-title > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dx-achieved-title > strong { display: block; font-size: 52px; font-weight: 800; line-height: 1.2; }
.dx-celebration[data-effect="heart"] .dx-achieved-title { color: #ffd4e4; }
.dx-celebration[data-effect="burst"] .dx-achieved-title { color: #e1fcff; }
.dx-celebration-piece { position: absolute; top: -28px; width: 9px; height: 17px; background: var(--color); animation: dx-celebration-fall 3.6s var(--delay) ease-in both; }
.dx-celebration-piece.petal { width: 21px; height: 15px; border-radius: 80% 12% 80% 12%; }
.dx-firework { position: absolute; width: 4px; height: 14px; border-radius: 2px; background: var(--color); animation: dx-firework 2.6s var(--delay) ease-out both; }
.dx-effect-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: grid; place-items: center; width: 44px; height: 44px; border-radius: 6px; color: white; background: #ffffff25; pointer-events: auto; }
@keyframes dx-celebration-title { 0% { opacity: 0; transform: scale(.75); } 12%, 72% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.03); } }
@keyframes dx-celebration-fall { 0% { opacity: 0; transform: translateY(0) rotate(0); } 8% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--drift), 110dvh) rotate(var(--spin)); } }
@keyframes dx-firework { 0% { opacity: 0; transform: rotate(var(--angle)) translateX(0); } 8% { opacity: 1; } 70%, 100% { opacity: 0; transform: rotate(var(--angle)) translateX(var(--distance)); } }

@media (orientation: landscape) and (max-height: 520px) {
  body[data-surface="display"] .display-card h1 { font-size: 20px; }
  body[data-surface="display"] .display-score .number { font-size: 88px; }
  body[data-surface="display"] .side-display { gap: 10px; }
  .dx-theme-sample { height: 92px; }
  .dx-slot-counter { min-height: 105px; }
}
@media (orientation: portrait) and (max-width: 600px) {
  body .dx-theme-sample { grid-template-columns: 1fr 1.5fr 1fr; height: 100px; gap: 2px; padding: 6px 3px; }
  .dx-sample-center strong { font-size: 11px; }
  .dx-sample-gift img { height: 25px; }
  .dx-sample-gift small { font-size: 8px; }
  .dx-field-row { grid-template-columns: minmax(100px, .4fr) minmax(0, 1fr); }
  .dx-slot-stage, .dx-slot-stage.is-ipad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dx-slot-center { grid-column: 1 / -1; grid-row: 1; }
  .dx-slot-stage .dx-slot-center .dx-slot-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: auto; }
  .dx-slot-stage .dx-slot-center .dx-slot { aspect-ratio: 1; height: auto; }
  .dx-slot-stage .dx-slot-center .dx-slot.empty > span { display: none; }
  body[data-surface="display"] .display-screen:not(.side-display) { grid-template-rows: minmax(220px, 2fr) minmax(0, 3fr); }
  body[data-surface="display"] .side-display { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(220px, auto) minmax(0, 1fr); overflow-y: auto; }
  body[data-surface="display"] .side-display > .side-center-card, body[data-surface="display"] .side-display > .side-center-stack { grid-column: 1 / -1; grid-row: 1; }
  body[data-surface="display"] .side-gift-panel { overflow: visible; }
  body[data-surface="display"] .side-gift-grid { overflow: visible; }
  body[data-surface="display"] .display-score .number { font-size: 92px; }
  body[data-surface="display"] .center-gift-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: auto; }
  body[data-surface="display"] .center-gift-grid .side-gift-btn { aspect-ratio: 1; height: auto; }
  .dx-achieved-title > strong { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .dx-celebration-piece, .dx-firework { display: none; }
  .dx-achieved-title { animation: none; }
}
