@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  color-scheme: light;
  --ink: #27463a;
  --ink-soft: #587365;
  --muted: #748579;
  --leaf: #3d7959;
  --leaf-bright: #82c895;
  --leaf-pale: #e4f1df;
  --cream: #f7f8f0;
  --paper: #fffef8;
  --line: #dce7d8;
  --sun: #f2c879;
  --rose: #e6a5a0;
  --shadow: 0 20px 50px rgba(40, 77, 57, .10);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 12% 0%, #edf6e8 0%, transparent 46%), var(--cream); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #77b9eb; outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
#app { min-height: 100vh; }
.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--ink-soft); }
.brand-mark { display: grid; place-items: center; font-size: 2.2rem; width: 64px; height: 64px; border-radius: 23px; background: #dcefd7; box-shadow: var(--shadow); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1240px; margin: auto; padding: 22px 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 900 1.22rem 'Nunito', sans-serif; letter-spacing: -.035em; }
.brand-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: #254e41; box-shadow: 0 6px 12px #244f4228; font-size: 1.25rem; }
.header-links { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; color: var(--ink-soft); background: #edf4e8; border: 1px solid #dce9d7; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 14px; padding: 11px 15px; min-height: 42px; color: var(--ink); font-weight: 800; font-size: .88rem; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { background: var(--leaf); color: white; box-shadow: 0 7px 18px #3d79592a; }
.button-primary:hover { background: #30684a; box-shadow: 0 10px 22px #3d795938; }
.button-secondary { background: #e5f1e1; border-color: #d4e6d0; }
.button-soft { background: #fffef8; border-color: var(--line); }
.button-danger { background: #fff0ed; color: #9e4f47; border-color: #f1d4cd; }
.button-small { padding: 8px 11px; min-height: 34px; border-radius: 11px; font-size: .78rem; }
.button-block { width: 100%; }
.hero { max-width: 1240px; margin: 22px auto 0; padding: 28px; display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(350px, .98fr); gap: 28px; align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--leaf); text-transform: uppercase; font-size: .72rem; font-weight: 900; letter-spacing: .13em; }
.eyebrow::before { content: ''; width: 22px; height: 2px; background: var(--leaf-bright); border-radius: 10px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: 'Nunito', system-ui, sans-serif; }
h1 { max-width: 650px; margin-bottom: 18px; font-size: clamp(2.4rem, 5.1vw, 4.6rem); letter-spacing: -.065em; line-height: 1.01; }
.headline-highlight { color: var(--leaf); }
.hero-copy { max-width: 560px; color: var(--ink-soft); font-size: 1.08rem; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 23px; }
.hero-note { margin-top: 17px; color: var(--muted); font-size: .8rem; }
.diorama-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid #d4e5ce; border-radius: 28px; background: linear-gradient(145deg, #d5edf0, #eff5e4 70%); box-shadow: var(--shadow); }
.diorama-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: absolute; z-index: 2; top: 15px; left: 17px; right: 17px; pointer-events: none; }
.diorama-title { display: grid; gap: 2px; }
.diorama-title strong { font: 900 .94rem 'Nunito', sans-serif; }
.diorama-title span { font-size: .72rem; color: var(--ink-soft); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #60ae76; display: inline-block; box-shadow: 0 0 0 4px #60ae7620; }
.preview-canvas { display: block; width: 100%; height: 350px; }
.preview-footer { position: absolute; z-index: 2; bottom: 12px; left: 13px; right: 13px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.preview-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid #ffffffa8; background: #fffef0d9; backdrop-filter: blur(8px); border-radius: 11px; padding: 7px 10px; font-size: .72rem; color: var(--ink-soft); font-weight: 800; }
.section { max-width: 1240px; margin: 22px auto 0; padding: 20px 28px 30px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); margin: 0; letter-spacing: -.045em; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.town-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.town-card { min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 21px; padding: 16px; box-shadow: 0 8px 22px #2b60410a; }
.town-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.theme-emblem { flex: 0 0 46px; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: #e5f1df; font-size: 1.35rem; }
.town-card h3 { margin: 0 0 3px; font-size: 1rem; letter-spacing: -.025em; }
.town-card .byline { color: var(--muted); font-size: .75rem; }
.town-card p { color: var(--ink-soft); font-size: .83rem; line-height: 1.55; min-height: 40px; margin-bottom: 13px; }
.card-metrics { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.metric { color: var(--ink-soft); background: #f0f5eb; border-radius: 8px; padding: 5px 8px; font-size: .7rem; font-weight: 800; }
.card-actions { display: flex; gap: 8px; }
.card-actions .button { flex: 1; }
.empty-state { padding: 28px; background: #f1f6ec; border: 1px dashed #cbdcc4; border-radius: 18px; color: var(--ink-soft); text-align: center; line-height: 1.6; }
.empty-state .empty-icon { font-size: 2rem; margin-bottom: 8px; }
.split-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.panel { border: 1px solid var(--line); background: var(--paper); border-radius: 22px; padding: 20px; box-shadow: 0 8px 24px #2b604108; min-width: 0; }
.panel h2, .panel h3 { margin-bottom: 8px; letter-spacing: -.03em; }
.panel-copy { color: var(--muted); font-size: .86rem; line-height: 1.6; }
.field { display: grid; gap: 6px; margin: 13px 0; }
.field label, .field-label { font-size: .8rem; font-weight: 800; color: var(--ink-soft); }
.input, .select { width: 100%; border: 1px solid #d6e2d2; border-radius: 12px; background: #fff; color: var(--ink); padding: 11px 12px; min-height: 43px; }
.input::placeholder { color: #a0afa2; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.identity-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.identity-handle { font: 900 1.45rem 'Nunito', sans-serif; letter-spacing: -.04em; }
.secret-box { margin-top: 14px; border: 1px solid #e5d39a; background: #fff8df; border-radius: 15px; padding: 14px; }
.secret-box strong { display: block; font-size: .85rem; margin-bottom: 5px; }
.secret-box p { color: #76633a; font-size: .8rem; line-height: 1.55; }
.secret-token { display: flex; gap: 8px; align-items: center; }
.secret-token code { flex: 1; border-radius: 9px; background: #fffef8; border: 1px solid #e7dcb7; padding: 10px; font: 800 .98rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.small-note { color: var(--muted); font-size: .75rem; line-height: 1.6; }
.toast { position: fixed; z-index: 20; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: min(90vw, 560px); color: #fff; background: #244f42; border-radius: 13px; padding: 12px 16px; box-shadow: var(--shadow); font-size: .85rem; }
.error-text { color: #9e4f47; font-size: .82rem; margin: 9px 0 0; }
.site-footer { max-width: 1240px; margin: 28px auto 0; padding: 20px 28px 34px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-top: 1px solid #e0e9dc; color: var(--muted); font-size: .75rem; }

/* Fullscreen town builder */
.town-page { width: min(1500px, 100%); margin: auto; padding: 8px 24px 30px; }
.town-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 15px; padding: 12px 0 20px; }
.town-header-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.town-header-title h1 { font-size: clamp(1.7rem, 3.5vw, 2.7rem); margin: 0; line-height: 1.1; }
.town-header-title p { color: var(--muted); font-size: .83rem; margin: 5px 0 0; }
.town-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.town-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .8fr); gap: 18px; align-items: start; }
.scene-card { position: relative; overflow: hidden; border: 1px solid #d2e2cc; border-radius: 24px; background: linear-gradient(180deg, var(--scene-sky, #c9eaf0), var(--scene-ground, #d9e9c7) 72%); box-shadow: var(--shadow); }
.scene-topline { position: absolute; top: 16px; left: 18px; right: 18px; z-index: 2; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; }
.scene-topline > * { border: 1px solid #ffffffb5; background: #fffef0cf; backdrop-filter: blur(7px); border-radius: 12px; padding: 8px 11px; }
.scene-title { font: 900 .84rem 'Nunito',sans-serif; }
.scene-season { font-size: .72rem; color: var(--ink-soft); }
.town-canvas { display: block; width: 100%; height: min(61vw, 600px); min-height: 380px; }
.scene-foot { display: flex; gap: 9px; flex-wrap: wrap; padding: 12px 15px; background: #fffef8d9; border-top: 1px solid #dfe9d6; }
.scene-foot span { color: var(--ink-soft); font-size: .76rem; font-weight: 800; }
.sidebar { display: grid; gap: 14px; min-width: 0; }
.sidebar .panel { padding: 17px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1.08rem; }
.panel-kicker { font-size: .67rem; letter-spacing: .1em; text-transform: uppercase; color: var(--leaf); font-weight: 900; }
.interaction-group + .interaction-group { margin-top: 14px; }
.interaction-title { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .66rem; font-weight: 900; margin: 0 0 8px; }
.interaction-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.interaction-button { display: grid; justify-items: center; gap: 5px; padding: 10px 5px; border-radius: 12px; background: #f4f7ef; color: var(--ink-soft); border: 1px solid #e0eadb; font-size: .68rem; font-weight: 800; line-height: 1.25; min-height: 72px; }
.interaction-button .emoji { font-size: 1.35rem; }
.interaction-button:hover { background: #e8f4e4; border-color: #c8e0c5; }
.project-list { display: grid; gap: 12px; }
.project-row { padding: 11px 12px; background: #f5f7ef; border: 1px solid #e4eadf; border-radius: 13px; }
.project-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.project-head strong { font-size: .83rem; }
.project-percent { font-weight: 900; font-size: .78rem; color: var(--leaf); }
.progress-track { height: 7px; margin: 9px 0 6px; background: #dce6d7; overflow: hidden; border-radius: 999px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #6cb583, #abd58b); border-radius: inherit; transition: width .4s ease; }
.project-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .7rem; }
.vote-option { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px; border-radius: 12px; text-align: left; border: 1px solid #dde8d7; background: #f7f8f0; color: var(--ink); margin-top: 7px; }
.vote-option:hover { border-color: #a9d1ac; background: #edf7e9; }
.vote-option .vote-icon { font-size: 1.35rem; }
.vote-option .vote-text { flex: 1; min-width: 0; font-size: .8rem; font-weight: 800; }
.vote-option .vote-count { color: var(--muted); font-size: .72rem; font-weight: 800; }
.vote-timer { color: var(--muted); font-size: .75rem; margin: 0 0 8px; }
.choice-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-check { display: flex; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 11px; font-size: .77rem; color: var(--ink-soft); }
.choice-check input { accent-color: var(--leaf); }
.event-list { display: grid; gap: 11px; }
.event-row { display: grid; grid-template-columns: 34px 1fr; gap: 9px; align-items: start; }
.event-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: #e9f2e3; }
.event-row strong { display: block; font-size: .8rem; margin: 1px 0 3px; }
.event-row p { color: var(--muted); font-size: .74rem; line-height: 1.45; margin: 0; }
.event-row time { color: #93a096; font-size: .67rem; }
.settings-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.settings-inline .field { margin: 0; }
.url-copy-box { display: flex; gap: 7px; align-items: center; }
.url-copy-box .input { min-width: 0; font-size: .75rem; }

/* OBS browser source */
html.overlay-document, body.overlay-document { width: 100%; height: 100%; min-height: 0; margin: 0; overflow: hidden; background: transparent !important; }
body.overlay-document #app { min-height: 0; background: transparent; }
.overlay-stage { --overlay-scale: 1; --overlay-x: auto; --overlay-y: auto; position: fixed; width: 560px; max-width: 100vw; transform: scale(var(--overlay-scale)); transform-origin: top left; color: var(--ink); }
.overlay-stage.corner-top-left { top: 20px; left: 20px; }
.overlay-stage.corner-top-right { top: 20px; right: 20px; transform-origin: top right; }
.overlay-stage.corner-bottom-left { bottom: 20px; left: 20px; transform-origin: bottom left; }
.overlay-stage.corner-bottom-right { bottom: 20px; right: 20px; transform-origin: bottom right; }
.overlay-shell { overflow: hidden; border-radius: 22px; border: 1px solid #ffffffb5; background: linear-gradient(155deg, #fffef2ed, #eaf5e3ed); box-shadow: 0 12px 45px #193a2c44; backdrop-filter: blur(10px); }
.overlay-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 15px 8px; }
.overlay-heading-name { font: 900 1rem 'Nunito', sans-serif; }
.overlay-heading-sub { color: var(--muted); font-size: .7rem; margin-top: 2px; }
.overlay-live { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; background: #e3f2dd; font-size: .66rem; font-weight: 900; color: var(--leaf); }
.overlay-canvas { display: block; width: 100%; height: 285px; }
.overlay-status { display: grid; gap: 6px; padding: 0 15px 13px; }
.overlay-status-line { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--ink-soft); font-size: .74rem; }
.overlay-status-line span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-mini-progress { flex: 0 0 82px; height: 5px; border-radius: 99px; overflow: hidden; background: #dce8d7; }
.overlay-mini-progress span { display: block; height: 100%; background: #76bd88; }
.overlay-join { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 15px; background: #254e41; color: #ecf9e9; font-size: .7rem; font-weight: 800; }
.overlay-reaction-burst { position: absolute; pointer-events: none; z-index: 5; font-size: 1.8rem; animation: float-up 2.6s ease-out both; }
@keyframes float-up { 0% { opacity: 0; transform: translateY(10px) scale(.65) rotate(-7deg); } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-80px) scale(1.22) rotate(8deg); } }
.overlay-hide-join .overlay-join { display: none; }
.quiet-mode .overlay-reaction-burst { display: none; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 24px; margin-top: 4px; }
  .hero-copy { max-width: 680px; }
  .diorama-card { max-width: 780px; width: 100%; }
  .town-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .town-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar > .panel:first-child { grid-row: span 2; }
}
@media (max-width: 640px) {
  .site-header { padding: 15px 17px; }
  .brand { font-size: 1.08rem; }
  .header-links .pill { display: none; }
  .hero, .section { padding-left: 17px; padding-right: 17px; }
  .hero { padding-top: 16px; }
  h1 { font-size: clamp(2.55rem, 12vw, 3.8rem); }
  .hero-copy { font-size: .98rem; }
  .preview-canvas { height: 275px; }
  .town-grid, .split-panels { grid-template-columns: 1fr; }
  .section-head { align-items: start; flex-direction: column; }
  .site-footer { padding: 18px 17px 28px; }
  .panel { padding: 16px; }
  .town-page { padding: 6px 13px 25px; }
  .town-header { align-items: start; }
  .town-header, .town-toolbar { width: 100%; }
  .town-toolbar .button { flex: 1; }
  .town-canvas { min-height: 300px; height: 74vw; }
  .sidebar { grid-template-columns: 1fr; }
  .sidebar > .panel:first-child { grid-row: auto; }
  .interaction-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-inline, .form-row { grid-template-columns: 1fr; }
  .identity-row { align-items: start; flex-direction: column; }
  .overlay-stage { width: min(560px, calc(100vw - 24px)); }
  .overlay-stage.corner-top-left { top: 12px; left: 12px; }
  .overlay-stage.corner-top-right { top: 12px; right: 12px; }
  .overlay-stage.corner-bottom-left { bottom: 12px; left: 12px; }
  .overlay-stage.corner-bottom-right { bottom: 12px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* First-release UI polish and creator setup helpers. */
.version-chip { color: var(--muted); font-size: .68rem; font-weight: 700; }
.identity-panel { padding: 22px; }
.identity-forms { gap: 18px; }
.panel-form { min-width: 0; }
.panel-form h3 { margin: 5px 0 8px; font-size: 1.15rem; }
.panel-form .panel-copy { min-height: 48px; }
.create-town-form { padding: 20px; }
.create-town-form .field { margin-top: 0; }
.create-town-form .small-note { margin: 12px 0 0; }
.token-input { text-transform: uppercase; letter-spacing: .08em; }
.settings-check { margin: 12px 0; }
.town-welcome { margin-top: 16px; }
.town-welcome h2 { margin-bottom: 7px; }
.town-welcome .panel-copy { margin-bottom: 0; }
.town-page:fullscreen { width: 100vw; height: 100vh; overflow: auto; background: var(--cream); padding: 12px clamp(12px, 2vw, 32px) 24px; }
.town-page:fullscreen .town-canvas { height: min(64vh, 720px); }
.overlay-shell { position: relative; }
.overlay-canvas { background: radial-gradient(ellipse at center, #fff8d730, transparent 70%); }
.overlay-document .overlay-stage { pointer-events: none; }
.overlay-document .overlay-shell { pointer-events: none; }
.overlay-document .overlay-stage { max-height: 100vh; }
.overlay-document .overlay-status-line { font-size: clamp(.66rem, .8vw, .78rem); }
.button[disabled], .interaction-button[disabled] { opacity: .55; cursor: wait; transform: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline-offset: 3px; }

@media (max-width: 640px) {
  .identity-forms { grid-template-columns: 1fr; }
  .panel-form .panel-copy { min-height: 0; }
  .town-page:fullscreen .town-canvas { min-height: 260px; height: 55vh; }
}
