:root {
  color-scheme: dark;
  --bg: #101013;
  --panel: #18181d;
  --raised: #202026;
  --line: #34343d;
  --text: #f6f3f5;
  --muted: #b1aab6;
  --accent: #ff9a9f;
  --action: #ae2737;
  --display: "Russo One", Impact, sans-serif;
  font-family: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); }
.bar, main { width: min(100%, 1280px); margin: auto; padding-inline: clamp(14px, 3vw, 36px); }
header { background: #151518; border-bottom: 1px solid var(--line); }
.bar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font: 17px var(--display); }
.brand img { width: auto; height: 24px; }
.bar a { color: var(--muted); text-decoration: none; font-size: 13px; }
.bar a:hover { color: var(--text); }
main { padding-block: clamp(16px, 3vw, 32px); }
h1, h2, p { margin: 0; }
h1 { font: clamp(26px, 4vw, 43px)/1.12 var(--display); }
h2 { font: 17px var(--display); }
small, p { color: var(--muted); }
.intro { border: 1px solid #442a32; border-radius: 15px; padding: clamp(18px, 3vw, 30px); display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; background: radial-gradient(ellipse at 96% 0%, #391822, transparent 68%), linear-gradient(110deg, #21171d, #16151a 75%); }
.intro p { font-size: 13px; margin-top: 7px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 360px); gap: 16px; align-items: start; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.stage { min-height: clamp(340px, 55vh, 610px); display: grid; place-items: center; padding: 16px; background-color: #111115; background-image: radial-gradient(#36323a 1px, transparent 1px); background-size: 20px 20px; }
canvas { display: block; max-width: 100%; max-height: 62vh; object-fit: contain; touch-action: none; cursor: grab; border-radius: 5px; box-shadow: 0 14px 45px #0008; }
canvas:active { cursor: grabbing; }
#empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 26px; background: #18181df5; border: 1px dashed #51404b; border-radius: 14px; }
#empty img { width: min(165px, 100%); height: auto; }
#empty p { font-size: 13px; }
.tools { padding: 15px; display: grid; gap: 14px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; font-weight: 700; font-size: 13px; }
button, .upload { min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #16161a; color: var(--text); font: 600 13px/1.2 Inter, system-ui, sans-serif; cursor: pointer; }
button:hover, .upload:hover { border-color: #8c6675; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed="true"] { background: #3b2029; border-color: #91434d; color: #ffd5d7; }
.upload, #download { display: inline-flex; align-items: center; justify-content: center; background: var(--action); border-color: #c13c4c; color: #fff; }
#download { flex-shrink: 0; }
input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 7px; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; }
.overlay-option { display: grid; place-items: center; gap: 5px; padding: 7px 4px; }
.overlay-option img { display: block; width: 100%; height: 36px; object-fit: contain; background: #131217; border-radius: 4px; }
.overlay-option img.death-thumb { object-fit: cover; }
.overlay-actions { margin-top: 8px; }
details { background: #15151a; border: 1px solid var(--line); border-radius: 9px; }
summary { padding: 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.details-body { padding: 0 12px 12px; }
.adjust { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
input[type=range] { width: 100%; margin: 3px 0 0; min-height: 26px; accent-color: #e45362; }
output { float: right; color: var(--text); }
#status { display: block; font-size: 12px; overflow-wrap: anywhere; }
#status:empty { display: none; }
@media (max-width: 760px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .stage { min-height: 255px; }
  canvas { max-height: 50vh; }
}
@media (max-width: 370px) {
  .intro { align-items: flex-start; flex-direction: column; }
}
.photo-actions, #reset-photo-frame { margin-top: 8px; }
#drag-hint { margin: 7px 0 10px; font-size: 12px; }
.editor { grid-template-columns: minmax(0, 1fr); }
.editor > .panel:first-child { width: min(100%, 960px); justify-self: center; }
#selection { color: var(--accent); font-size: 12px; margin-left: auto; }
@media (min-width: 850px) {
  .tools { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  #status { grid-column: 1 / -1; }
}

/* A single workspace, with tools directly below the canvas. */
.editor { display: block; max-width: 960px; margin-inline: auto; }
.editor > .panel:first-child { width: 100%; }
.panel-header { flex-wrap: wrap; background: #1c191f; }
.panel-header h1 { font-size: clamp(19px, 3vw, 25px); margin-right: auto; }
#selection { margin-left: 0; }
.stage {
  background: radial-gradient(ellipse at 50% 0%, #251a23, #111115 68%);
  min-height: clamp(270px, 47vh, 560px);
}
#empty { border: 0; background: transparent; }
#empty img { width: min(215px, 100%); }
.tool-dock { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.tool-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 5px; background: #131317; border-radius: 11px 11px 0 0; }
.tool-switch button { background: transparent; border-color: transparent; padding-inline: 5px; }
.tool-switch button[aria-pressed="true"] { background: #3b2029; border-color: #91434d; }
.tools { display: block; width: min(100%, 550px); margin: auto; padding: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#status { margin-top: 8px; }
@media (max-width: 530px) {
  .panel-header { padding: 10px; gap: 6px; }
  .panel-header button { padding-inline: 8px; }
  #selection { order: 1; width: 100%; }
}

.overlay-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.bar :is(.editor-link, .portal-link) {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #874653;
  border-radius: 8px;
  background: #382128;
  color: #fff4f6;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.bar :is(.editor-link, .portal-link):hover { background: #512a34; border-color: var(--accent); }
:is(.editor-link, .portal-link) span { color: var(--accent); font-size: 16px; }
@media (max-width: 370px) {
  .bar .editor-link { padding-inline: 8px; gap: 4px; font-size: 12px; }
  .bar .brand { font-size: 13px; }
}
