:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #66717d;
  --paper: #f7f6f0;
  --panel: #ffffff;
  --line: #d9ded7;
  --green: #2f8f6b;
  --green-dark: #1f654b;
  --blue: #2f6f9f;
  --amber: #d88b22;
  --red: #c94d42;
  --coal: #2c3135;
  --shadow: 0 18px 44px rgba(27, 36, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 246, 240, 0.96)),
    radial-gradient(circle at 16% 10%, rgba(47, 143, 107, 0.16), transparent 28%),
    radial-gradient(circle at 84% 16%, rgba(216, 139, 34, 0.14), transparent 22%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body[data-theme="harbor"] {
  --green: #267f7a;
  --blue: #245f86;
  --amber: #d69b33;
  --paper: #f3f7f5;
}

body[data-theme="metro"] {
  --green: #4c7c54;
  --blue: #5a6fa4;
  --amber: #c58235;
  --paper: #f5f3f0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(252px, 300px) minmax(420px, 1fr) minmax(260px, 320px);
  align-items: start;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.brand-block,
.topbar,
.session-bar,
.panel {
  border: 1px solid rgba(23, 33, 43, 0.09);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 80px;
  padding: 16px;
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  align-items: end;
  gap: 4px;
  width: 48px;
  height: 48px;
  padding: 9px;
  border-radius: 8px;
  background: var(--coal);
}

.brand-mark span {
  display: block;
  border-radius: 2px 2px 0 0;
  background: #f2c94c;
}

.brand-mark span:nth-child(1) {
  height: 18px;
}

.brand-mark span:nth-child(2) {
  height: 28px;
  background: #72c7a4;
}

.brand-mark span:nth-child(3) {
  height: 22px;
  background: #9cc6de;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.42rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.panel {
  padding: 14px;
  border-radius: 8px;
}

.panel.compact {
  display: grid;
  gap: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.progress-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin: 0 auto;
}

.progress-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 10;
}

.progress-ring .track {
  stroke: #e5e8e0;
}

.progress-ring .meter {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 302;
  stroke-dashoffset: 302;
  transition: stroke-dashoffset 300ms ease;
}

.progress-ring div {
  display: grid;
  place-items: center;
}

.progress-ring strong {
  font-size: 1.7rem;
  line-height: 1;
}

.progress-ring span {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-grid,
.slot-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-grid div,
.rules div {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.stat-grid span,
.rules span {
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-grid strong,
.rules strong {
  font-size: 0.96rem;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.button,
.icon-button {
  border: 1px solid rgba(23, 33, 43, 0.12);
  border-radius: 8px;
  color: var(--ink);
  background: #f5f6f2;
  font-weight: 800;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.button {
  min-height: 42px;
  padding: 0 14px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(27, 36, 43, 0.12);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.button.primary,
.icon-button.primary {
  color: #fff;
  background: var(--green);
}

.button.warning {
  color: #472700;
  background: #ffd58c;
}

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
}

.icon-button.danger {
  color: #fff;
  background: var(--red);
}

.play-icon {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid currentColor;
}

.stop-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: currentColor;
}

.reset-icon {
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.slot-list {
  display: grid;
  gap: 8px;
  max-height: 170px;
  overflow: auto;
}

.slot-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.slot-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.city-stage {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-width: 0;
}

.topbar,
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 78px;
  padding: 14px 16px;
  border-radius: 8px;
}

.topbar h2 {
  font-size: 1.35rem;
}

.topbar-actions,
.quick-actions,
.buddy-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.session-bar strong {
  display: block;
  margin-top: 3px;
  font-size: 1.32rem;
}

.session-bar span {
  color: var(--muted);
  font-weight: 700;
}

.city-wrap {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 43, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #b9d9e8 0 48%, #c6d5b0 48% 74%, #7c8d74 74% 100%);
  box-shadow: var(--shadow);
}

body[data-theme="harbor"] .city-wrap {
  background:
    linear-gradient(180deg, #b6d5e1 0 45%, #8eb7bc 45% 63%, #5f8d99 63% 74%, #6f806d 74% 100%);
}

body[data-theme="metro"] .city-wrap {
  background:
    linear-gradient(180deg, #c8d3dc 0 48%, #b8c2aa 48% 74%, #6f776d 74% 100%);
}

.city-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 8px;
  width: min(370px, calc(100% - 140px));
}

.city-hud div {
  display: grid;
  gap: 2px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 33, 43, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(6px);
}

.city-hud span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.city-hud strong {
  font-size: 1rem;
}

.skyline {
  position: absolute;
  inset: 0;
}

.sun {
  position: absolute;
  top: 34px;
  right: 44px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #f4c74b;
  box-shadow: 0 0 0 10px rgba(244, 199, 75, 0.22);
}

.cloud {
  position: absolute;
  width: 112px;
  height: 30px;
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.68);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 10px;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  left: 18px;
  width: 44px;
  height: 44px;
}

.cloud::after {
  right: 16px;
  width: 34px;
  height: 34px;
}

.cloud-a {
  top: 66px;
  left: 9%;
}

.cloud-b {
  top: 118px;
  right: 19%;
  transform: scale(0.78);
}

.city-grid {
  position: absolute;
  right: 6%;
  bottom: 92px;
  left: 6%;
  display: grid;
  grid-template-columns: repeat(8, minmax(38px, 1fr));
  align-items: end;
  gap: 12px 10px;
  min-height: 330px;
  z-index: 3;
}

.lot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  height: 92px;
  padding-bottom: 4px;
}

.building {
  position: relative;
  width: min(58px, 100%);
  min-width: 34px;
  height: calc(34px + var(--floors) * 13px);
  border: 2px solid rgba(18, 29, 36, 0.18);
  border-bottom-width: 4px;
  border-radius: 5px 5px 2px 2px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.28) 0 7px,
      transparent 7px 13px
    ),
    var(--building-color);
  box-shadow: 0 9px 0 rgba(18, 29, 36, 0.12);
}

.building::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 9px;
  right: 9px;
  height: calc(100% - 18px);
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 246, 172, 0.92) 0 6px,
      transparent 6px 13px
    );
  opacity: 0.78;
}

.building.saved {
  outline: 3px solid rgba(47, 143, 107, 0.44);
}

.building.saved::after {
  content: "";
  position: absolute;
  top: -10px;
  right: -7px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--green);
}

.building.burning::after {
  content: "";
  position: absolute;
  top: -26px;
  left: 50%;
  width: 30px;
  height: 34px;
  border-radius: 55% 55% 55% 0;
  background:
    radial-gradient(circle at 54% 58%, #ffe66d 0 25%, transparent 27%),
    linear-gradient(135deg, #ffb000 0 38%, #ef4b2d 39% 100%);
  transform: translateX(-50%) rotate(-45deg);
  animation: flame 620ms ease-in-out infinite alternate;
}

.building.ruined {
  height: 36px;
  background:
    linear-gradient(145deg, transparent 0 22%, rgba(44, 49, 53, 0.3) 23% 31%, transparent 32%),
    #5d6261;
  filter: grayscale(0.55);
}

.building.repairing {
  outline: 3px solid rgba(216, 139, 34, 0.5);
}

.building.ruined::before {
  display: none;
}

.building.empty {
  height: 24px;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.23);
  box-shadow: none;
}

.building.empty::before,
.building.empty::after {
  display: none;
}

@keyframes flame {
  from {
    transform: translateX(-50%) rotate(-48deg) scale(0.92);
  }
  to {
    transform: translateX(-50%) rotate(-39deg) scale(1.08);
  }
}

.road {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: space-around;
  height: 78px;
  background: #384049;
  z-index: 2;
}

body[data-theme="harbor"] .road {
  background: #2f5560;
}

body[data-theme="metro"] .road {
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(244, 233, 186, 0.35) 12% 14%, transparent 14%),
    #3f4448;
}

.road span {
  width: 72px;
  height: 6px;
  margin-top: 34px;
  border-radius: 20px;
  background: #f4e9ba;
}

.fire-truck {
  position: absolute;
  bottom: 48px;
  left: -150px;
  width: 118px;
  height: 54px;
  z-index: 5;
  transition: left 760ms cubic-bezier(0.2, 0.9, 0.22, 1);
}

.fire-truck.active {
  left: calc(50% - 60px);
}

.truck-body,
.truck-cab {
  position: absolute;
  bottom: 12px;
  border: 2px solid rgba(39, 20, 20, 0.25);
  background: #d93a33;
}

.truck-body {
  left: 18px;
  width: 72px;
  height: 30px;
  border-radius: 5px;
}

.truck-cab {
  right: 9px;
  width: 34px;
  height: 38px;
  border-radius: 6px 6px 4px 4px;
}

.ladder {
  position: absolute;
  top: 4px;
  left: 16px;
  width: 82px;
  height: 8px;
  border: 2px solid #f7d667;
  border-right: 0;
  border-left: 0;
  transform: rotate(-8deg);
}

.wheel {
  position: absolute;
  bottom: 4px;
  width: 20px;
  height: 20px;
  border: 4px solid #202327;
  border-radius: 50%;
  background: #d8e0e3;
}

.wheel.left {
  left: 28px;
}

.wheel.right {
  right: 14px;
}

/* ---- Social / Be with me ---- */
.social-panel {
  border-color: rgba(47, 111, 159, 0.25);
}

.social-body {
  display: grid;
  gap: 10px;
}

.social-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.code-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4fbff;
}

.code-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.code-chip strong {
  font-size: 1.15rem;
  letter-spacing: 3px;
}

.add-friend {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.add-friend input {
  text-transform: uppercase;
  letter-spacing: 2px;
}

.friend-list {
  display: grid;
  gap: 8px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.friend-row.studying {
  border-color: rgba(47, 143, 107, 0.4);
  background: #f0faf5;
}

.friend-row.pending {
  border-color: rgba(216, 139, 34, 0.4);
  background: #fdf6e9;
}

.friend-row strong {
  font-size: 0.9rem;
}

.friend-row span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.friend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2c8c0;
}

.dot.live {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(47, 143, 107, 0.5);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  to {
    box-shadow: 0 0 0 7px rgba(47, 143, 107, 0);
  }
}

.social-msg {
  margin: 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: #eef6f1;
  color: var(--green-dark);
  font-size: 0.8rem;
}

.social-msg.error {
  background: #fbecea;
  color: var(--red);
}

/* ---- Onboarding modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, 0.5);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: grid;
  gap: 10px;
  width: min(380px, 100%);
  padding: 22px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-size: 1.6rem;
}

.modal-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 0.82rem;
}

.event-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 300px;
}

.event-log {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 410px;
  margin-top: 12px;
  overflow: auto;
}

.event {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #fbfbf8;
}

.event.fire {
  border-left-color: var(--red);
}

.event.buddy {
  border-left-color: var(--blue);
}

.event strong {
  font-size: 0.86rem;
}

.event span {
  color: var(--muted);
  font-size: 0.78rem;
}

.rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rules div {
  min-height: 68px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 280px 1fr;
  }

  .right-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  /* Stadt zuerst – sie ist der Star der App, die Steuerung folgt darunter. */
  .city-stage {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .right-rail {
    order: 3;
    display: flex;
  }

  .topbar,
  .session-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .city-wrap {
    min-height: 480px;
  }

  .city-hud {
    grid-template-columns: repeat(3, 1fr);
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }

  .city-hud div {
    min-height: 46px;
    padding: 7px 8px;
  }

  .city-grid {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
    gap: 10px 8px;
    bottom: 86px;
  }

  .lot {
    height: 78px;
  }

  .building {
    height: calc(30px + var(--floors) * 10px);
  }

  .sun {
    right: 22px;
    width: 52px;
    height: 52px;
  }
}

/* ---- View toggle (Meine Stadt / Crew) ---- */
.view-toggle {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 33, 43, 0.12);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px rgba(27, 36, 43, 0.12);
}
.toggle-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
}
.toggle-btn.active {
  color: #fff;
  background: var(--green);
}

/* ---- Crew city (shared skyline) ---- */
.crew-city {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 64px 16px 90px;
}
.crew-city-head {
  align-self: center;
  width: min(440px, 100%);
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(23, 33, 43, 0.12);
  backdrop-filter: blur(6px);
  text-align: center;
}
.crew-city-head strong { display: block; font-size: 1.05rem; }
.crew-city-head span { color: var(--muted); font-size: 0.8rem; }
.crew-progress {
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: #e5e8e0;
  overflow: hidden;
}
.crew-progress div { height: 100%; background: var(--green); transition: width 400ms ease; }
.lm-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.lm-chip {
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: #fff5dc; color: #7a5a14; border: 1px solid #f0d89a;
}
.crew-districts {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 18px;
  overflow-x: auto;
}
.crew-district {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
}
.crew-district.mine { background: rgba(47, 143, 107, 0.12); outline: 2px solid rgba(47, 143, 107, 0.4); }
.cd-stack { display: flex; align-items: flex-end; gap: 4px; min-height: 30px; }
.cd-building {
  width: 22px;
  height: calc(20px + var(--floors) * 12px);
  border: 2px solid rgba(18, 29, 36, 0.18);
  border-bottom-width: 3px;
  border-radius: 4px 4px 1px 1px;
  background:
    repeating-linear-gradient(180deg, rgba(255, 246, 172, 0.85) 0 5px, transparent 5px 11px),
    var(--c, #5d83b7);
}
.cd-building.empty {
  height: 18px; border-style: dashed; background: rgba(255, 255, 255, 0.3);
}
.crew-district.burning .cd-stack { position: relative; }
.crew-district.burning .cd-stack::after {
  content: "🔥";
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 1.1rem;
  animation: flame 620ms ease-in-out infinite alternate;
}
.cd-label { text-align: center; }
.cd-label strong { font-size: 0.78rem; }
.cd-label span { display: block; color: var(--muted); font-size: 0.72rem; }
.crew-empty { margin: auto; text-align: center; color: var(--muted); }

.crew-panel { border-color: rgba(47, 143, 107, 0.25); }
.crew-body { display: grid; gap: 10px; }

.session-hint { color: var(--muted); font-size: 0.82rem; font-weight: 600; max-width: 320px; text-align: right; }

/* ============================================================= */
/* ===============  MOBILE APP SHELL (Redesign)  =============== */
/* ============================================================= */
body {
  display: flex;
  justify-content: center;
  background: #0e1417;
}
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 246, 240, 0.96)),
    var(--paper);
}

/* App bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(23, 33, 43, 0.08);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand strong { font-size: 1.12rem; }
.brand-logo {
  position: relative; display: block;
  width: 28px; height: 28px; border-radius: 8px; background: var(--coal);
}
.brand-logo::before {
  content: ""; position: absolute; left: 6px; bottom: 7px;
  width: 4px; height: 8px; background: #f2c94c;
  box-shadow: 6px -3px 0 #72c7a4, 12px 0 0 #9cc6de;
}
.appbar-right { display: flex; align-items: center; gap: 10px; }
.mini-ring { position: relative; width: 36px; height: 36px; display: grid; place-items: center; }
.mini-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.mini-ring circle { fill: none; stroke-width: 12; }
.mini-ring .track { stroke: #e5e8e0; }
.mini-ring .meter {
  stroke: var(--green); stroke-linecap: round;
  stroke-dasharray: 302; stroke-dashoffset: 302;
  transition: stroke-dashoffset 300ms ease;
}
.mini-ring strong { font-size: 0.66rem; }
.streak-chip { font-size: 0.86rem; font-weight: 800; white-space: nowrap; }
.icon-pill {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; font-size: 1.05rem;
  display: grid; place-items: center;
}

/* Screens */
.screens {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(98px + env(safe-area-inset-bottom));
}
.screen { display: none; }
.screen.active { display: block; }
.screen-head { margin: 2px 2px 10px; }
.screen-head h2 { font-size: 1.25rem; }
.screen-head .eyebrow { margin-bottom: 2px; }
.goal-line { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.screen .city-wrap { min-height: 56vh; border-radius: 14px; }

/* Social sub-switch */
.social-switch {
  display: flex; gap: 6px; padding: 4px; margin: 0 0 10px;
  background: #eef0ec; border-radius: 999px;
}
.social-switch .seg {
  flex: 1; border: 0; background: transparent; border-radius: 999px;
  padding: 9px; font-weight: 800; color: var(--muted);
}
.social-switch .seg.active { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); }
#socialCrewWrap, #socialFriendsWrap { display: grid; gap: 12px; }

/* Bottom hotbar */
.hotbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 30;
  width: min(480px, 100%);
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 6px 18px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(23, 33, 43, 0.1);
}
.tab {
  flex: 1; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0; color: var(--muted); font-size: 0.7rem; font-weight: 800;
}
.tab.active { color: var(--green); }
.tab-ico { font-size: 1.3rem; line-height: 1; }
.focus-tab .focus-ico {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--green); display: grid; place-items: center;
  margin-top: -24px; border: 3px solid #fff;
  box-shadow: 0 8px 18px rgba(47, 143, 107, 0.45);
}
.focus-tab .focus-ico::before {
  content: ""; width: 0; height: 0; margin-left: 3px;
  border-top: 9px solid transparent; border-bottom: 9px solid transparent;
  border-left: 14px solid #fff;
}
.focus-tab.running .focus-ico { background: var(--red); animation: pulse 1.6s ease-out infinite; }
.focus-tab.running .focus-ico::before {
  border: 0; width: 14px; height: 14px; margin: 0; border-radius: 2px; background: #fff;
}
.focus-tab .tab-lbl { color: var(--ink); }

/* Overlays (focus + settings sheet) */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: flex;
  background: rgba(14, 20, 23, 0.55); backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
#focusOverlay { align-items: center; justify-content: center; padding: 18px; }
.focus-card {
  width: min(360px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center;
  padding: 28px 22px; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow);
}
.focus-card .session-hint { text-align: center; max-width: none; }
.focus-timer { font-size: 3.1rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.button.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.button.danger { color: #fff; background: var(--red); }

#settingsOverlay { align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  display: grid; gap: 12px;
  padding: 8px 14px calc(20px + env(safe-area-inset-bottom));
  background: var(--paper); border-radius: 18px 18px 0 0;
}
.sheet h2 { font-size: 1.1rem; }
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: #cfd5cc; margin: 6px auto 2px; cursor: pointer; }

img.brand-logo { object-fit: cover; background: transparent; border: 1px solid rgba(23,33,43,.1); }
img.brand-logo::before { content: none; }

/* ============ Depth pass: Level / XP, Focus ritual, juice ============ */
.level-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.level-chip {
  font-size: 0.72rem; font-weight: 800; color: #fff; background: var(--green);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.xp-bar { flex: 1; height: 8px; border-radius: 999px; background: #e5e8e0; overflow: hidden; }
.xp-bar > #xpFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #7ec9a8); transition: width 500ms ease; }
.xp-label { font-size: 0.68rem; color: var(--muted); font-weight: 700; white-space: nowrap; }

/* Focus ritual ring */
.focus-ringwrap { position: relative; width: 184px; height: 184px; display: grid; place-items: center; margin: 4px auto 4px; }
.focus-ringwrap svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.focus-ringwrap circle { fill: none; stroke-width: 8; }
.frtrack { stroke: #e5e8e0; }
.frmeter { stroke: var(--green); stroke-linecap: round; stroke-dasharray: 339; stroke-dashoffset: 339; transition: stroke-dashoffset 600ms linear; }
.focus-ringwrap .focus-timer { font-size: 2.6rem; }

/* Sound toggle row */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-weight: 700;
}
.toggle-row input { width: auto; min-height: auto; transform: scale(1.3); }

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: 100px; transform: translate(-50%, 16px);
  z-index: 80; max-width: 82%; padding: 10px 18px; border-radius: 999px;
  background: var(--coal); color: #fff; font-weight: 800; font-size: 0.9rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; text-align: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Building polish + build animation */
.building {
  border-radius: 6px 6px 2px 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.06)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.30) 0 7px, transparent 7px 13px),
    var(--building-color);
  box-shadow: 0 10px 0 rgba(18, 29, 36, 0.10), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.building.grew { animation: grow-pop 520ms cubic-bezier(0.2, 0.9, 0.25, 1); transform-origin: bottom center; }
@keyframes grow-pop {
  0% { transform: scaleY(0.55) translateY(6px); opacity: 0.5; }
  60% { transform: scaleY(1.06); }
  100% { transform: none; opacity: 1; }
}
.cd-building.grew { animation: grow-pop 520ms cubic-bezier(0.2, 0.9, 0.25, 1); transform-origin: bottom center; }

/* ===================================================================== */
/* =================  COZY THEME (warm, premium, iso)  ================= */
/* ===================================================================== */
:root {
  --ink: #3c332b;
  --muted: #8b7e6f;
  --paper: #f4ece0;
  --panel: #fbf6ee;
  --line: #e7ddcd;
  --green: #6f9e7d;
  --green-dark: #517b60;
  --blue: #7a93b0;
  --amber: #e0a14e;
  --red: #cf6b54;
  --coal: #3c332b;
  --shadow: 0 14px 34px rgba(74, 58, 42, 0.14);
}
body { background: #2a241e; }
.app {
  background:
    radial-gradient(circle at 50% 0%, #fdf8f0, transparent 60%),
    linear-gradient(180deg, #fbf6ee, #f0e6d6);
}
body, button, input, select { font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif; }
h1, h2, .brand strong, .focus-timer, .level-chip, .crew-city-head strong, .sheet h2,
.modal-card h2, .panel-heading h2, .screen-head h2 {
  font-family: "Baloo 2", Inter, sans-serif;
  letter-spacing: 0.2px;
}

/* App bar + hotbar warm glass */
.appbar { background: rgba(251, 246, 238, 0.9); border-bottom-color: var(--line); }
.hotbar { background: rgba(251, 246, 238, 0.96); border-top-color: var(--line); }

/* Surfaces */
.brand-block, .topbar, .session-bar, .panel { background: var(--panel); border-color: var(--line); box-shadow: 0 8px 22px rgba(74, 58, 42, 0.08); }
.button, .icon-button { background: #efe7d9; border-color: var(--line); }
.icon-pill { background: var(--panel); border-color: var(--line); }
.icon-pill svg { width: 18px; height: 18px; color: var(--muted); }
.friend-row, .slot-item, .stat-grid div, .rules div, .toggle-row { background: #fcf8f1; border-color: var(--line); }
.social-switch { background: #ece3d4; }
.code-chip { background: #fcf3e3; border-color: var(--line); }

/* Icons */
.tab-ico { width: 24px; height: 24px; }
.streak-chip { display: flex; align-items: center; gap: 4px; }
.streak-chip svg { width: 16px; height: 16px; color: var(--amber); }

/* Cozy isometric city diorama */
.city-wrap.diorama {
  position: relative;
  min-height: 50vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 40%, #fbf3e6 0%, #efe1cd 100%);
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 10px rgba(74, 58, 42, 0.06);
}
.city-img {
  width: 100%;
  max-width: 430px;
  height: auto;
  display: block;
  filter: drop-shadow(0 16px 22px rgba(74, 58, 42, 0.16));
  transition: filter 0.5s ease, transform 0.5s ease;
  mix-blend-mode: multiply;
}
.city-img.smoky { filter: drop-shadow(0 16px 22px rgba(74, 58, 42, 0.16)) saturate(0.65) brightness(0.92); }
.city-wrap.diorama .city-hud {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  display: flex; gap: 8px; z-index: 2;
}
.city-wrap.diorama .city-hud > div {
  flex: 1; text-align: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 7px 6px; min-height: 0;
  backdrop-filter: blur(4px);
}
.city-wrap.diorama .city-hud span { font-size: 0.66rem; }
.city-wrap.diorama .city-hud strong { font-size: 0.95rem; }
.city-fire {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 7px;
  background: rgba(207, 107, 84, 0.96); color: #fff;
  font-weight: 800; font-size: 0.8rem; padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow); white-space: nowrap;
}
.flame-ico { width: 11px; height: 11px; border-radius: 50% 50% 50% 0; transform: rotate(45deg); background: #ffd58c; }

/* Crew screen warm scene to match */
#socialCrewWrap .city-wrap { background: radial-gradient(circle at 50% 40%, #fbf3e6, #efe1cd); border: 1px solid var(--line); border-radius: 18px; }
#socialCrewWrap .skyline { display: none; }

/* City growth: continuous scale + stage-up pop + next-stage hint */
.city-img { transform-origin: center bottom; transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.25, 1), filter 0.5s ease; }
.city-img.upgrade { animation: city-up 950ms ease; }
@keyframes city-up {
  0% { transform: scale(0.82) translateY(10px); filter: brightness(1.35) drop-shadow(0 16px 22px rgba(74,58,42,0.16)); }
  55% { transform: scale(1.05); }
  100% { filter: drop-shadow(0 16px 22px rgba(74, 58, 42, 0.16)); }
}
.city-next { text-align: center; color: var(--muted); font-size: 0.78rem; font-weight: 700; margin: 10px 2px 0; }

/* AdMob banner: lift hotbar above the ~50px banner when ads are shown */
body.ads-on .hotbar { bottom: 56px; }
body.ads-on .screens { padding-bottom: calc(154px + env(safe-area-inset-bottom)); }

/* ===================================================================== */
/* =====================  CLAY UI (cozy, animiert)  ==================== */
/* ===================================================================== */

/* Sanfte Screen-Einblendung beim Tab-Wechsel */
.screen.active { animation: screen-in 360ms cubic-bezier(0.2, 0.9, 0.25, 1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Karten als weiche Clay-Flächen */
.panel {
  border-radius: 18px;
  border: 1px solid rgba(231, 221, 205, 0.8);
  box-shadow: 8px 10px 22px rgba(74, 58, 42, 0.10), -6px -6px 16px rgba(255, 255, 255, 0.6);
}
.appbar { box-shadow: 0 6px 16px rgba(74, 58, 42, 0.06); }

/* Clay-Buttons mit Druck-Animation */
.button {
  border: 0; border-radius: 15px;
  background: linear-gradient(180deg, #fcf4e8, #ede0cb);
  color: var(--ink);
  box-shadow: 4px 5px 12px rgba(74, 58, 42, 0.16), -4px -4px 10px rgba(255, 255, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.button:active { transform: translateY(2px) scale(0.99); box-shadow: 2px 2px 6px rgba(74, 58, 42, 0.18), inset 0 2px 5px rgba(74, 58, 42, 0.12); }
.button.primary {
  color: #fff;
  background: linear-gradient(180deg, #82c198, #5a8d6c);
  box-shadow: 0 9px 18px rgba(47, 143, 107, 0.38), inset 0 2px 4px rgba(255, 255, 255, 0.45), inset 0 -5px 8px rgba(0, 0, 0, 0.14);
}
.button.danger { color: #fff; background: linear-gradient(180deg, #e08a76, #c4604a); box-shadow: 0 9px 18px rgba(196, 96, 74, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4); }
.button.big { border-radius: 18px; }
.icon-pill {
  border: 0;
  background: linear-gradient(180deg, #fcf4e8, #eee1cc);
  box-shadow: 3px 4px 9px rgba(74, 58, 42, 0.16), -3px -3px 8px rgba(255, 255, 255, 0.7);
}
.icon-pill:active { transform: translateY(1px); }

/* Bottom-Hotbar: weicher, aktiver Tab als Clay-Pille */
.hotbar { box-shadow: 0 -6px 18px rgba(74, 58, 42, 0.08); }
.tab .tab-ico { transition: transform 0.15s ease; }
.tab.active .tab-ico { transform: translateY(-2px) scale(1.08); }

/* Fokus-Button in der Mitte: Clay-Knopf mit sanftem „Atmen" */
.focus-tab .focus-ico {
  width: 62px; height: 62px; border-radius: 50%; margin-top: -28px; border: 3px solid #fdf8f0;
  background: radial-gradient(circle at 36% 30%, #8fcaa4, #56886a);
  box-shadow: 0 12px 22px rgba(47, 143, 107, 0.45), inset 0 3px 6px rgba(255, 255, 255, 0.55), inset 0 -6px 10px rgba(0, 0, 0, 0.18);
  animation: focus-bob 3.2s ease-in-out infinite;
}
.focus-tab .focus-ico::before {
  border-top: 11px solid transparent; border-bottom: 11px solid transparent; border-left: 17px solid #fff;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}
.focus-tab:active .focus-ico { transform: scale(0.93); animation: none; }
@keyframes focus-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.focus-tab.running .focus-ico { background: radial-gradient(circle at 36% 30%, #e6967f, #c4604a); animation: focus-pulse 1.5s ease-in-out infinite; }
@keyframes focus-pulse { 0%, 100% { box-shadow: 0 12px 22px rgba(196, 96, 74, 0.45), inset 0 3px 6px rgba(255,255,255,.5); } 50% { box-shadow: 0 12px 30px rgba(196, 96, 74, 0.7), inset 0 3px 6px rgba(255,255,255,.5); } }

/* Eingaben & Chips weicher */
input, select { border-radius: 12px; }
.code-chip, .friend-row, .slot-item, .toggle-row { border-radius: 14px; }
.social-switch { border-radius: 999px; }
.focus-card, .modal-card, .sheet { border-radius: 22px; }
.focus-card { box-shadow: 0 24px 50px rgba(74, 58, 42, 0.28); }

/* Level-/XP-Chip & Streak weicher */
.level-chip { box-shadow: 0 4px 10px rgba(47, 143, 107, 0.3); }
