:root {
  --brand-red: #E63946;
  --brand-cream: #F1FAEE;
  --brand-light-blue: #A8DADC;
  --brand-blue: #457B9D;
  --brand-navy: #1D3557;
  --ink: #162a45;
  --muted: #617187;
  --surface: #ffffff;
  --panel: #f6f8fb;
  --line: #dce3eb;
  --focus: #ffb703;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf1f5;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 12px 16px; background: #fff; color: var(--brand-navy); border-radius: 8px; }
.skip-link:focus { top: 16px; }
.app-header { min-height: 84px; padding: 16px clamp(18px, 3vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--brand-navy); color: #fff; }
.app-header h1 { margin: 2px 0 0; font-size: clamp(1.25rem, 2.2vw, 1.8rem); }
.eyebrow, .section-kicker { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 800; }
.eyebrow { color: var(--brand-light-blue); }
.format-badge { white-space: nowrap; padding: 8px 12px; border: 1px solid rgb(255 255 255 / .25); border-radius: 999px; background: rgb(255 255 255 / .08); font-size: .82rem; font-weight: 800; }

.workspace { display: grid; grid-template-columns: minmax(330px, 430px) minmax(520px, 1fr); min-height: calc(100vh - 84px); }
.control-panel { padding: 24px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; }
.preview-area { min-width: 0; padding: 24px clamp(16px, 3vw, 44px) 40px; }
.preview-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.preview-toolbar h2, .section-heading h2 { margin: 3px 0 0; font-size: 1.05rem; }
.preview-toolbar > span { color: var(--muted); font-size: .76rem; }
.section-kicker { color: var(--brand-blue); }

.demo-notice, .asset-warning { display: grid; gap: 2px; padding: 12px 14px; margin-bottom: 16px; border-radius: 10px; font-size: .82rem; }
.demo-notice { color: #70400b; background: #fff3d6; border: 1px solid #f2d28a; }
.demo-notice[data-origin="official"], .demo-notice[data-origin="official-cache"] { color: #155f42; background: #e9f8f0; border-color: #9ed8bb; }
.demo-notice[data-origin="manual"] { color: #70400b; background: #fff3d6; border-color: #f2d28a; }
.official-panel { display: grid; gap: 12px; }
.official-panel .section-heading { margin-bottom: 0; }
.origin-badge { max-width: 150px; padding: 5px 8px; color: var(--brand-blue); background: #e4f3f5; border-radius: 999px; font-size: .67rem; font-weight: 850; text-align: center; }
.official-load-button { width: 100%; }
.official-meta { display: grid; gap: 6px; margin: 0; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.official-meta div { display: grid; grid-template-columns: 125px 1fr; gap: 8px; font-size: .72rem; }
.official-meta dt { color: var(--muted); font-weight: 800; }
.official-meta dd { margin: 0; color: var(--ink); font-weight: 750; }
.official-games-status { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.official-games-status li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--status-color, var(--brand-blue)); border-radius: 7px; font-size: .72rem; }
.official-games-status li[data-status$="error"], .official-games-status li[data-status="date_mismatch"] { --status-color: var(--brand-red); }
.official-actions { display: grid; grid-template-columns: 1fr; gap: 7px; }
.asset-warning { color: #74232a; background: #fff0f1; border: 1px solid #f0b8bd; }
.panel-section { margin: 0 0 16px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
fieldset.panel-section { min-width: 0; }
.panel-section legend { padding: 0 6px; font-weight: 850; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; padding: 4px; background: #e5ebf1; border-radius: 10px; }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: block; padding: 9px 7px; text-align: center; border-radius: 7px; font-size: .8rem; font-weight: 800; }
.segmented-control input:checked + span { color: var(--brand-navy); background: white; box-shadow: 0 1px 4px rgb(29 53 87 / .12); }
.segmented-control input:focus-visible + span { outline: 3px solid var(--focus); }
.field { display: grid; gap: 6px; margin-top: 12px; color: #44546a; font-size: .76rem; font-weight: 800; }
.field input, .field textarea { width: 100%; padding: 10px 11px; color: var(--ink); background: #fff; border: 1px solid #c8d1dc; border-radius: 8px; font-weight: 500; }
.field input:invalid { border-color: var(--brand-red); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.count-badge { padding: 4px 8px; color: var(--brand-blue); background: #e4f3f5; border-radius: 999px; font-size: .72rem; font-weight: 850; }
.inline-warning { padding: 9px 10px; color: #70400b; background: #fff3d6; border-radius: 8px; font-size: .76rem; }
.games-editor { display: grid; gap: 8px; }
.game-editor { overflow: hidden; border: 1px solid #d6dee7; border-radius: 10px; background: #fff; }
.game-summary { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 11px; color: var(--ink); background: #fff; border: 0; text-align: left; }
.game-summary::after { content: "+"; font-size: 1.2rem; color: var(--brand-blue); }
.game-editor.is-open .game-summary::after { content: "−"; }
.game-summary .game-color { width: 8px; height: 28px; border-radius: 5px; background: var(--game-accent); }
.game-summary strong { font-size: .82rem; }
.game-summary small { display: block; color: var(--muted); font-size: .7rem; }
.game-fields { display: none; padding: 0 12px 14px; border-top: 1px solid #edf0f4; }
.game-editor.is-open .game-fields { display: block; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0 0; font-size: .78rem; font-weight: 800; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--brand-red); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field-grid .field-wide { grid-column: 1 / -1; }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.button { min-height: 43px; padding: 10px 12px; border: 0; border-radius: 9px; font-size: .8rem; font-weight: 850; }
.button:disabled { cursor: wait; opacity: .62; }
.button-primary { color: #fff; background: var(--brand-navy); }
.button-download { color: #fff; background: var(--brand-red); }
.button-secondary { color: var(--brand-navy); background: var(--brand-light-blue); }
.button-quiet { color: var(--brand-navy); background: #e8edf2; }
.app-status { min-height: 22px; margin: 12px 2px 0; color: var(--brand-blue); font-size: .78rem; font-weight: 750; }
.app-status.is-error { color: var(--brand-red); }
.copy-fallback { width: 100%; min-height: 180px; margin-top: 8px; padding: 10px; }

.preview-viewport { width: 100%; min-height: 540px; display: grid; place-items: start center; overflow: hidden; padding: 14px; background-color: #dfe5eb; background-image: linear-gradient(45deg, #d4dbe2 25%, transparent 25%), linear-gradient(-45deg, #d4dbe2 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d4dbe2 75%), linear-gradient(-45deg, transparent 75%, #d4dbe2 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; border: 1px solid #cbd4dd; border-radius: 16px; }
.canvas-scaler { position: relative; width: 1080px; height: 1920px; flex: none; transform-origin: top center; box-shadow: 0 16px 45px rgb(29 53 87 / .24); }
.social-canvas { position: relative; width: 1080px; height: 1920px; overflow: hidden; background: var(--brand-cream); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-area { padding: 20px 12px 32px; }
  .preview-toolbar > span { display: none; }
}
@media (max-width: 520px) {
  .app-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .format-badge { font-size: .74rem; }
  .control-panel { padding: 14px; }
  .panel-section { padding: 14px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .field-wide { grid-column: auto; }
  .panel-actions { grid-template-columns: 1fr; }
  .preview-viewport { min-height: 420px; padding: 8px; border-radius: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
