:root {
  --page-bg: #f8f0e7;
  --bg: linear-gradient(145deg, var(--page-bg) 0%, #f0f3ed 52%, #edf1f7 100%);
  --card: #fffdf9;
  --surface: #f5f0e9;
  --text: #27252a;
  --muted: #77737b;
  --border: #e8e0d7;
  --accent: #c96f52;
  --accent-text: #fffaf7;
  --accent-soft: rgba(201, 111, 82, 0.14);
  --danger: #c93c3c;
  --ok: #2a9d8f;
  --game-p0: color-mix(in srgb, var(--accent) 82%, #5d4037);
  --game-p1: color-mix(in srgb, var(--ok) 78%, #245b61);
  --ev-arrival: #2a9d8f;
  --ev-dropoff: #3d8bfd;
  --ev-meal: #f4a261;
  --ev-activity: #9b5de5;
  --shadow: 0 18px 48px rgba(52, 42, 35, 0.12);
  --shadow-soft: 0 6px 20px rgba(52, 42, 35, 0.08);
  --radius: 28px;
  --radius-sm: 18px;
  --control-radius: 16px;
  --ease: cubic-bezier(0.22, 0.8, 0.25, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html {
  height: 100%;
  background-color: var(--page-bg);
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--page-bg);
  background-image: var(--bg);
  background-repeat: no-repeat;
  background-size: cover;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
::selection { background: var(--accent-soft); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; letter-spacing: -0.025em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.hint { font-size: 0.85rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.view { position: relative; z-index: 1; min-height: 100%; }
.center { display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); min-height: 100dvh; overflow: auto; }
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 24px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 480px; text-align: center;
}
.panel.narrow { max-width: 420px; }
.logo {
  display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 16px;
  border-radius: 24px; background: var(--accent-soft); font-size: 2.35rem; line-height: 1;
}
.stack { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 16px; }
.stack label { font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.card-lite { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px; margin-top: 16px; }
.card-lite h2 { text-align: left; }

/* Keep Clerk's auth surface flat so the app panel is the only visible card. */
#view-login .auth-panel { max-width: 430px; padding: 34px 28px 26px; }
#view-login .logo { font-size: 2.15rem; }
#view-login h1 { font-size: 1.65rem; margin-bottom: 6px; }
#view-login > .auth-panel > p.muted { max-width: 300px; margin: 0 auto; }
#view-login .clerk-auth-mount { width: 100%; max-width: 380px; margin: 20px auto 0; text-align: left; }
#view-login .clerk-auth-mount,
#view-login .clerk-auth-mount * {
  box-sizing: border-box;
}
#view-login .clerk-auth-mount > * { width: 100%; max-width: 100%; }
#view-login .cl-card,
#view-login .cl-cardBox,
#view-login .cl-rootBox,
#view-login .cl-footer,
#view-login .clerk-card {
  width: 100% !important;
  max-width: 100% !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}
#view-login .clerk-primary-button,
#view-login .cl-formButtonPrimary {
  display: flex !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-inline: 0 !important;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 6px 14px var(--accent-soft);
}
#view-login .clerk-input,
#view-login .cl-formFieldInput {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 48px;
  border-radius: var(--control-radius);
}
#view-login .cl-headerTitle,
#view-login .cl-headerSubtitle,
#view-login .cl-socialButtonsBlockButton,
#view-login .cl-socialButtonsBlockButtonText,
#view-login .cl-socialButtons,
#view-login .cl-dividerRow {
  display: none !important;
}
#view-login .clerk-link,
#view-login .cl-footerActionLink {
  color: var(--accent);
}
#view-login .cl-footer {
  display: none !important;
}
#view-login .clerk-hide,
#view-login .cl-footerAction { display: none !important; }
#view-login .auth-switch {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 24px;
  margin: 16px 0 0;
  text-align: center;
}
#view-login .auth-switch .link { display: block; white-space: normal; }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea {
  width: 100%; padding: 12px 15px; border-radius: var(--control-radius); border: 1px solid var(--border);
  background: var(--card); color: var(--text); min-height: 50px;
  box-shadow: inset 0 1px 2px rgba(44, 35, 29, 0.03);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { min-height: 80px; resize: vertical; }
input[type="color"] { width: 48px; height: 48px; border: none; padding: 0; background: none; border-radius: 14px; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 700; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-weight: 700; min-height: 46px;
  box-shadow: 0 2px 5px rgba(44, 35, 29, 0.04);
  transition: transform 0.16s var(--ease), background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; box-shadow: 0 6px 14px var(--accent-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: transparent; box-shadow: none; }
.btn.big { width: 100%; font-size: 1.05rem; min-height: 52px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 600; }

@media (hover: hover) {
  .btn:not([disabled]):hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
  .btn.primary:not([disabled]):hover { box-shadow: 0 9px 20px var(--accent-soft); }
  .btn.ghost:not([disabled]):hover { background: var(--accent-soft); box-shadow: none; }
}

.banner {
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--border); border-radius: var(--control-radius);
  padding: 13px 15px; font-weight: 700; text-align: center;
}
.banner strong { font-size: 1.5rem; letter-spacing: 0.2em; display: block; margin-top: 4px; }

/* ----- Main app layout ----- */
.app {
  display: flex; flex-direction: column; height: 100dvh; min-height: 100%;
  padding: var(--sat) var(--sar) 0 var(--sal);
  background: var(--bg);
  background-attachment: scroll;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 6px;
}
.iconbtn, .avatarbtn, .navbtn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s var(--ease), box-shadow 0.16s ease, background 0.16s ease;
}
.todaybtn {
  min-width: 66px; height: 42px; padding: 0 15px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 0.86rem;
  box-shadow: 0 7px 18px var(--accent-soft);
  transition: transform 0.16s var(--ease), box-shadow 0.16s ease, filter 0.16s ease;
}
.avatarbtn { font-size: 1.35rem; border-width: 2px; }
.datepill {
  flex: 1; max-width: 300px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-weight: 750; font-size: 0.96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 3px 12px rgba(44, 35, 29, 0.05);
}
.datepill .rel { color: var(--accent); }
.monthnav { display: flex; align-items: center; flex: 1; min-width: 0; max-width: 300px; }
.monthnav .datepill { min-width: 0; padding: 10px 4px; text-align: center; }
.month-arrow {
  flex: 0 0 36px; min-height: 44px; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 1.8rem; transition: color 0.16s ease, background 0.16s ease, transform 0.16s var(--ease);
}

.weekstrip { overflow: hidden; touch-action: pan-y; }
.weekstrip-track {
  display: flex; width: 300%; transform: translateX(-33.333333%); will-change: transform;
}
.weekstrip-track.animating { transition: transform 0.28s var(--ease); }
.week-panel {
  display: flex; flex: 0 0 33.333333%; gap: 7px; padding: 10px 18px 12px;
  justify-content: space-between; box-sizing: border-box;
}
.weekstrip button {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; border-radius: 18px; padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); min-height: 58px;
  transition: transform 0.16s var(--ease), color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.weekstrip button .dow { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.weekstrip button .dom { font-weight: 750; color: var(--text); font-size: 1rem; }
.weekstrip button .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0; }
.weekstrip button.has .dot { opacity: 1; }
.weekstrip button.active { background: var(--card); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-soft); }
.weekstrip button.today .dom { color: var(--accent); }
.weekstrip button.active.today .dom { color: var(--accent); }

.deck { position: relative; flex: 1; min-height: 0; margin: 4px 18px; perspective: 1000px; }
.card {
  position: absolute; inset: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; will-change: transform;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; border: 1px solid var(--border);
}
.card.back1 { transform: translateY(10px) scale(0.965); opacity: 0.7; pointer-events: none; }
.card.back2 { transform: translateY(20px) scale(0.93); opacity: 0.38; pointer-events: none; }
.card.top { z-index: 3; }
.card.back1 { z-index: 2; }
.card.back2 { z-index: 1; }
.card.animating { transition: transform 0.32s var(--ease), opacity 0.32s ease; }
.card.rising { transform: translateY(0) scale(1); opacity: 1; }
.card.dragging { cursor: grabbing; }

.card-head { padding: 22px 22px 11px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-head h2 { font-size: 1.42rem; margin: 0; }
.card-head .sub { color: var(--accent); font-weight: 750; font-size: 0.82rem; }
.card-body { flex: 1; overflow-y: auto; padding: 0 20px 22px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.section { margin-top: 14px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between; margin: 0 0 9px;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}
.section-title .count { background: var(--surface); border-radius: 999px; padding: 2px 9px; font-weight: 750; }
.list { display: flex; flex-direction: column; gap: 9px; margin: 0; padding: 0; list-style: none; }

.event {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 13px; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid transparent; border-left: 4px solid var(--ev-color); width: 100%; text-align: left;
  transition: transform 0.16s var(--ease), border-color 0.16s ease, background 0.16s ease;
}
.event .icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 11px; background: var(--card); font-size: 1.15rem; line-height: 1; }
.event .body { flex: 1; min-width: 0; }
.event .time { font-weight: 750; font-size: 0.78rem; color: var(--ev-color); letter-spacing: 0.01em; }
.event .title { font-weight: 700; display: block; margin-top: 2px; }
.event .meta { color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }

.task {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid transparent;
  transition: transform 0.16s var(--ease), border-color 0.16s ease, opacity 0.16s ease;
}
.task .check {
  width: 24px; height: 24px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--ok); cursor: pointer;
}
.task .body { flex: 1; min-width: 0; background: none; border: none; padding: 0; text-align: left; color: inherit; }
.task .title { font-weight: 700; display: block; }
.task.done { opacity: 0.68; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .meta { color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }
.task-shell { pointer-events: none; user-select: none; }
.task-shell-check {
  width: 24px; height: 24px; margin: 2px 0 0; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 6px; background: var(--card);
}
.task-shell-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; padding-top: 2px; }
.task-shell-line { display: block; height: 10px; border-radius: 999px; background: var(--border); opacity: 0.72; }
.task-shell-line-main { width: min(58%, 180px); }
.task-shell-line-meta { width: min(36%, 112px); height: 8px; opacity: 0.48; }
.late { color: var(--danger); font-weight: 700; }
.carried { background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)); border: 1px solid var(--border); border-radius: 22px; padding: 12px 12px 6px; margin-top: 14px; }
.carried .section-title { color: var(--text); }

.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px 2px 5px; font-size: 0.78rem; }
.chip .av { font-size: 0.95rem; }
.safe-av { display:inline-grid; place-items:center; overflow:hidden; flex:0 0 auto; line-height:1; }
.safe-av img { width:100%; height:100%; object-fit:cover; display:block; }
.safe-av .av-fallback { display:block; }
.avatarbtn .safe-av { width:30px; height:30px; }
.big-av .safe-av { width:52px; height:52px; border-radius:18px; }
.chip .safe-av { width:22px; height:22px; border-radius:50%; }
.member-row > .chip .safe-av { width:28px; height:28px; }
.tag { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.07em; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 2px 7px; color: var(--muted); }

.empty { text-align: center; padding: 36px 14px; color: var(--muted); }
.empty .big-emoji { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 26px; background: var(--surface); font-size: 2.25rem; }
.empty .skip-next { width: 100%; max-width: 280px; margin: 4px auto 0; color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.empty .actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.inline-add .btn { flex: 1; }

.swipe-hint {
  position: absolute; top: 20px; padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 1rem;
  border: 2px solid currentColor; opacity: 0; transform: rotate(-6deg); pointer-events: none; background: var(--card);
}
.swipe-hint.next { right: 18px; color: var(--accent); transform: rotate(6deg); }
.swipe-hint.prev { left: 18px; color: var(--ev-dropoff); }
.card-tint { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: var(--radius); }

.decknav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 18px calc(14px + var(--sab));
}
.navbtn { width: 50px; height: 50px; font-size: 1.65rem; font-weight: 700; line-height: 1; padding-bottom: 3px; }
.fab-group { display: flex; gap: 8px; flex: 1; justify-content: center; }
.fab-group .btn { min-width: 110px; }

@media (hover: hover) {
  .iconbtn:hover, .avatarbtn:hover, .navbtn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
  .month-arrow:hover { color: var(--text); background: var(--accent-soft); }
  .weekstrip button:hover { background: var(--accent-soft); transform: translateY(-1px); }
  .weekstrip button.active:hover { background: var(--card); }
  .event:hover, .task:hover { transform: translateY(-1px); border-color: var(--border); }
}

/* ----- Scrim / menu ----- */
.scrim { position: fixed; inset: 0; background: rgba(32, 28, 34, 0.36); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 20; }
.menu {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); background: var(--card); z-index: 30;
  border-left: 1px solid var(--border); border-radius: 30px 0 0 30px;
  box-shadow: -18px 0 50px rgba(34, 28, 25, 0.16); transform: translateX(100%); transition: transform 0.3s var(--ease);
  overflow-y: auto; padding: calc(20px + var(--sat)) 20px calc(26px + var(--sab));
}
.menu.open { transform: translateX(0); }
.menu-head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.menu-head .big-av { width: 56px; height: 56px; border-radius: 21px; display: grid; place-items: center; font-size: 1.7rem; border: 2px solid var(--accent); background: var(--surface); }
.menu-head h2 { margin: 0; }
.menu-close { margin-left: auto; }
.roster { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.roster .chip { padding: 5px 11px 5px 7px; font-size: 0.82rem; }
.roster .chip.admin::after { content: "★"; color: var(--accent); margin-left: 2px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 2px; }
.toggle input { width: 24px; height: 24px; accent-color: var(--accent); }
details.section-d { border-top: 1px solid var(--border); padding: 5px 0; }
details.section-d summary {
  list-style: none; cursor: pointer; padding: 15px 10px; font-weight: 700;
  display: flex; align-items: center; gap: 10px; border-radius: var(--control-radius);
  transition: background 0.16s ease;
}
details.section-d summary::-webkit-details-marker { display: none; }
details.section-d summary .arrow { margin-left: auto; transition: transform 0.2s; color: var(--muted); }
details[open].section-d summary .arrow { transform: rotate(90deg); }
.d-body { padding: 2px 8px 16px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-weight: 700; font-size: 0.84rem; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row .btn { flex: 0 0 auto; }
.invite-code { font-size: 1.6rem; letter-spacing: 0.3em; font-weight: 800; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--control-radius); padding: 14px; user-select: all; }
.member-row { display: flex; align-items: center; gap: 9px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-row .name { flex: 1; min-width: 0; }
.member-row .name small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.emoji-grid button { font-size: 1.25rem; padding: 7px 0; border-radius: 12px; border: 2px solid transparent; background: var(--surface); }
.emoji-grid button.sel { border-color: var(--accent); background: var(--accent-soft); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; }
.swatches button.sel { border-color: var(--text); }
.menu-logout { margin-top: 16px; width: 100%; }
.profile-photo { display:flex; align-items:center; gap:12px; padding:10px; border:1px solid var(--border); border-radius:var(--control-radius); background:var(--surface); }
.profile-photo-preview { width:64px; height:64px; border-radius:50%; background:var(--card); border:2px solid var(--accent); display:grid; place-items:center; overflow:hidden; font-size:1.8rem; }
.profile-photo-preview img { width:100%; height:100%; object-fit:cover; }
.profile-photo-actions { display:flex; gap:7px; flex-wrap:wrap; }
.crop-modal { position:fixed; inset:0; z-index:70; display:flex; align-items:center; justify-content:center; padding:18px; background:rgba(32,28,34,.48); backdrop-filter:blur(7px); -webkit-backdrop-filter:blur(7px); }
.crop-panel { width:min(440px,100%); max-height:calc(100dvh - 32px); overflow:auto; background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:20px; box-shadow:var(--shadow); }
.crop-head { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; }
.crop-head h2 { margin-bottom:4px; }
.crop-head p { font-size:.85rem; }
.crop-viewport { width:min(350px,82vw); aspect-ratio:1; margin:12px auto 18px; position:relative; overflow:hidden; border-radius:var(--control-radius); background:#302b2b; touch-action:none; cursor:grab; }
.crop-viewport:active { cursor:grabbing; }
.crop-viewport img { position:absolute; max-width:none; user-select:none; pointer-events:none; transform-origin:center; }
.crop-mask { position:absolute; inset:0; pointer-events:none; border-radius:50%; box-shadow:0 0 0 999px rgba(25,21,21,.58); border:3px solid var(--card); }
.crop-zoom { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; font-weight:700; color:var(--muted); }
.crop-zoom input { min-height:0; padding:0; accent-color:var(--accent); }
.crop-zoom output { min-width:44px; text-align:right; font-variant-numeric:tabular-nums; }
/* ----- Sheet ----- */
.sheet {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(32, 28, 34, 0.36); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sheet-inner {
  background: var(--card); width: 100%; max-width: 560px; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 30px 30px 0 0; padding: 9px 22px calc(22px + var(--sab));
  max-height: 92dvh; overflow-y: auto; box-shadow: 0 -18px 50px rgba(34, 28, 25, 0.14); animation: sheet-in 0.28s var(--ease);
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 999px; background: var(--border); margin: 7px auto 16px; }
.sheet h2 { margin: 0 0 22px; font-size: 1.45rem; line-height: 1.2; }
.sheet form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.sheet .field { min-width: 0; gap: 8px; }
.sheet fieldset.field { display: block; min-inline-size: 0; }
.sheet fieldset legend { padding: 0; margin-bottom: 8px; line-height: 1.4; }
.sheet .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.sheet input:not([type="checkbox"]):not([type="radio"]), .sheet select, .sheet textarea {
  display: block; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box;
  min-height: 48px; font-size: 16px;
}
.sheet input[type="date"], .sheet input[type="time"] { -webkit-appearance: none; appearance: none; }
.sheet input::-webkit-date-and-time-value { text-align: left; }
.sheet textarea { min-height: 96px; }
.sheet .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet .seg label { position: relative; min-width: 0; }
.sheet .seg span { min-height: 48px; height: 100%; text-align: center; }
.sheet .people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sheet .people label { min-width: 0; }
.sheet .people span { display: flex; width: 100%; min-height: 44px; height: 100%; overflow-wrap: anywhere; border-radius: 12px; }
.sheet .toggle { margin: 0; min-height: 48px; gap: 12px; }
.sheet .toggle input { flex: 0 0 24px; }
.sheet .hint { margin: -8px 0 16px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 70px; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 5px; padding: 10px 8px;
  border-radius: var(--control-radius); border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 0.87rem; cursor: pointer; transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s var(--ease);
}
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.people label { position: relative; }
.people input { position: absolute; opacity: 0; width: 0; height: 0; }
.people span { display: inline-flex; align-items: center; gap: 4px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; }
.people input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.people input:focus-visible + span { outline: 3px solid var(--accent); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; padding-top: 18px; border-top: 1px solid var(--border); }
.sheet-actions .btn { flex: 1; min-width: 0; min-height: 48px; padding: 12px; }
.sheet-actions .btn.danger { flex: 0 0 auto; }
@media (max-width: 360px) {
  .sheet .row { grid-template-columns: minmax(0, 1fr); }
}

/* ----- Toasts ----- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(90px + var(--sab)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; background: #27252a; color: #fff; padding: 12px 14px; border-radius: 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; max-width: 480px; width: 100%; font-weight: 650; animation: sheet-in 0.2s var(--ease); }
.toast.error { background: var(--danger); }
.toast .btn { background: rgba(255, 255, 255, 0.18); border-color: transparent; color: #fff; min-height: 36px; padding: 6px 12px; }

/* ----- Charades ----- */
.charades { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); overflow: auto; }
.ch-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px clamp(16px,5vw,28px); width: 100%; max-width: 560px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; max-height: calc(100dvh - 32px); overflow: auto; }
.ch-panel h1 { font-size: 2rem; }
.ch-word { font-size: clamp(2.4rem, 11vw, 4.5rem); font-weight: 900; line-height: 1.05; padding: 24px 0; word-break: break-word; }
.ch-timer { font-size: clamp(3rem, 14vw, 5rem); font-weight: 900; font-variant-numeric: tabular-nums; }
.ch-timer.low { color: var(--danger); }
.ch-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ch-actions .btn { min-height: 90px; font-size: 1.5rem; border-radius: 24px; }
.ch-actions .btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.ch-actions .btn.skip { background: var(--surface); }
.ch-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface); }
.ch-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s linear; }
.ch-scores { display: flex; gap: 12px; justify-content: center; }
.ch-score { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 18px; }
.ch-score.active { border-color: var(--accent); background: var(--accent-soft); }
.ch-score .lbl { display: block; color: var(--muted); font-weight: 750; }
.ch-score .count { display: block; margin-top: 3px; font-size: 2.6rem; line-height: 1; font-weight: 900; }
.ch-list { text-align: left; columns: 2; column-gap: 16px; font-size: 0.95rem; }
.ch-list li { break-inside: avoid; }
.ch-list li.skipped { color: var(--muted); text-decoration: line-through; }
.ch-setup .field { text-align: left; }
.ch-setup { display: flex; flex-direction: column; gap: 18px; }
.ch-setup .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ch-setup .btn.chip { min-height: 48px; padding: 9px 8px; position: relative; }
.ch-setup .btn.chip.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.ch-setup .btn.chip.active .selection-mark { color: var(--accent); margin-left: 4px; }
.ch-setup .btn.chip.just-selected { animation: choice-pop .24s var(--ease); }
.setup-ack { min-height: 20px; }
.ch-play, .ch-results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ch-secondary-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
@keyframes choice-pop { 50% { transform: scale(1.035); } }

/* ----- Responsive ----- */
@media (min-width: 700px) {
  .app { max-width: 760px; margin: 0 auto; }
  .deck { margin: 8px 26px; }
  .card-head h2 { font-size: 1.6rem; }
  .sheet-inner { border-bottom: 1px solid var(--border); border-radius: 30px; margin-bottom: 24px; }
  .sheet { align-items: center; }
}

@media (max-width: 480px) {
  .center { align-items: flex-start; padding: calc(14px + var(--sat)) 12px calc(14px + var(--sab)); }
  .panel { padding: 28px 20px; border-radius: 26px; }
  #view-login .auth-panel { padding: 28px 20px 22px; }
  .topbar { padding-inline: 12px; }
  .week-panel { padding-inline: 12px; gap: 4px; }
  .weekstrip button { border-radius: 16px; }
  .deck { margin-inline: 12px; }
  .card-head { padding-inline: 18px; }
  .card-body { padding-inline: 16px; }
  .decknav { padding-inline: 12px; }
  .fab-group .btn { min-width: 0; flex: 1; padding-inline: 12px; }
  .sheet-inner { padding-inline: 18px; }
  .charades { align-items: flex-start; padding-inline: 10px; }
  .ch-panel { max-height: calc(100dvh - 20px); border-radius: 24px; padding-inline: 14px; }
  .ch-panel .card-head { padding-inline: 4px; }
  .ch-play .ch-actions .btn { min-height: 76px; font-size: 1.2rem; }
  .dots-screen .game-title h1 { font-size: 2rem; }
}

@media (hover: hover) {
  details.section-d summary:hover { background: var(--surface); }
  .seg span:hover { transform: translateY(-1px); border-color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  .card.animating, .menu, .sheet-inner, .toast, .crop-panel, .ch-setup .just-selected, .dots-score span { transition: none !important; animation: none !important; }
}
body.reduce-motion .card.animating, body.reduce-motion .menu, body.reduce-motion .sheet-inner, body.reduce-motion .toast, body.reduce-motion .crop-panel, body.reduce-motion .ch-setup .just-selected, body.reduce-motion .dots-score span { transition: none !important; animation: none !important; }

/* ----- Group games ----- */
.game-hub,.game-screen { width:min(760px,100%); max-height:100%; overflow:auto; background:var(--card); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:clamp(20px,5vw,42px); }
.game-hub { min-height:min(620px,calc(100dvh - 32px)); }
.game-head { display:flex; justify-content:space-between; gap:20px; align-items:flex-start; margin-bottom:30px; }.game-head h1,.game-title h1 { font-size:clamp(2.2rem,7vw,4rem); margin:4px 0 5px; }.eyebrow { color:var(--accent); font-size:.72rem; letter-spacing:.12em; text-transform:uppercase; font-weight:800; margin:0; }
.game-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }.game-tile { min-height:160px; padding:20px; border:1px solid var(--border); border-radius:24px; background:var(--surface); text-align:left; display:flex; flex-direction:column; justify-content:flex-end; gap:5px; transition:transform .16s var(--ease),border-color .16s; }.game-tile:hover { transform:translateY(-3px); border-color:var(--accent); }.game-tile-charades { background:var(--accent-soft); }.tile-mark { display:grid; place-items:center; width:48px; height:48px; margin-bottom:auto; border-radius:16px; background:var(--card); color:var(--accent); font-size:1.6rem; font-weight:900; }.game-tile strong { font-size:1.1rem; }.game-tile small { color:var(--muted); }.game-note { color:var(--muted); text-align:center; margin:28px 0 0; font-size:.88rem; }
.game-screen { min-height:min(680px,calc(100dvh - 32px)); display:flex; flex-direction:column; }.game-back { align-self:flex-start; margin:-8px 0 24px -10px; }.game-title { text-align:center; margin-bottom:20px; }.game-title .muted { margin:0; }.coin-stage { display:grid; place-items:center; flex:1; min-height:220px; }.coin { width:clamp(150px,35vw,220px); aspect-ratio:1; border-radius:50%; display:grid; place-items:center; background:var(--accent); color:var(--accent-text); border:12px solid color-mix(in srgb,var(--accent) 65%,var(--card)); box-shadow:inset 0 0 0 8px var(--accent-soft),0 18px 35px rgba(52,42,35,.16); font-size:2rem; font-weight:900; }.coin-heads { background:var(--ok); }.coin-tails { background:var(--ev-activity); }.result-line { text-align:center; color:var(--muted); min-height:24px; }.game-screen>.big { margin-top:auto; }
.dice-controls { display:flex; justify-content:center; gap:12px; margin:18px 0; }.dice-controls label,.draw-tools label { display:flex; align-items:center; gap:8px; color:var(--muted); font-weight:700; }.dice-controls select { min-height:44px; width:auto; padding:8px 12px; }.dice-results { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:12px; min-height:180px; }.die { display:grid; place-items:center; width:72px; height:72px; border-radius:18px; background:var(--surface); border:1px solid var(--border); font-size:2rem; font-weight:900; box-shadow:var(--shadow-soft); }.dice-placeholder { color:var(--muted); }.draw-tools { display:flex; gap:10px; align-items:center; flex-wrap:wrap; padding:10px; border:1px solid var(--border); border-radius:18px; background:var(--surface); }.draw-tools input[type=range] { width:100px; }.draw-tools input[type=color] { width:38px; height:38px; }.draw-canvas { width:100%; height:min(48vh,390px); margin-top:14px; border:1px solid var(--border); border-radius:20px; background:var(--card); touch-action:none; cursor:crosshair; }
.dots-score { display:flex; justify-content:center; gap:10px; margin:0 auto 14px; flex-wrap:wrap; }.dots-score span { padding:9px 14px; border-radius:999px; color:var(--muted); border:1px solid transparent; display:inline-flex; align-items:center; gap:7px; transition:transform .16s var(--ease), background .16s ease, border-color .16s ease; }.dots-score span i { width:10px; height:10px; border-radius:50%; background:var(--game-p0); }.dots-score .player-b i { background:var(--game-p1); }.dots-score span.active { color:var(--text); border-color:currentColor; background:var(--accent-soft); transform:translateY(-1px); }.dots-score .player-a.active { color:var(--game-p0); }.dots-score .player-b.active { color:var(--game-p1); }.dots-score b { margin-left:2px; font-size:1.2rem; }.dots-board { width:min(100%,420px); align-self:center; overflow:visible; max-height:48vh; }.dots-board circle { fill:var(--text); }.dots-board line { stroke:var(--game-p0); stroke-width:8; stroke-linecap:round; transition:stroke .18s ease; }.dots-board line.line-p1 { stroke:var(--game-p1); }.dots-board .box-fill.p0 { fill:color-mix(in srgb,var(--game-p0) 18%,var(--card)); }.dots-board .box-fill.p1 { fill:color-mix(in srgb,var(--game-p1) 22%,var(--card)); }.dot-hit rect { cursor:pointer; }.dot-hit:hover rect { fill:var(--accent-soft); }.turn-line { min-height:24px; text-align:center; font-weight:800; color:var(--game-p0); margin:8px 0 16px; }.turn-line.player-1 { color:var(--game-p1); }
.turn-line.neutral { color:var(--text); }
@media (max-width:520px) { .game-grid { grid-template-columns:1fr 1fr; gap:10px; }.game-tile { min-height:140px; padding:14px; }.game-hub,.game-screen { border-radius:24px; padding:20px 16px; }.dice-controls { justify-content:stretch; }.dice-controls label { flex:1; flex-direction:column; align-items:stretch; }.dice-controls select { width:100%; }.draw-tools { gap:7px; }.draw-tools label { flex:1; }.game-head h1 { font-size:2.4rem; } }
@media (prefers-reduced-motion:reduce) { .game-tile,.coin { transition:none!important; animation:none!important; } }
.dot-hit.active { pointer-events:none; }
