/* Littlewhile – warm wood, soft pastels, rounded shapes */

:root {
  --paper: #f6ecdc;
  --wood: #c8925a;
  --wood-dark: #8a5a33;
  --ink: #4a3627;
  --ink-soft: #7d6655;
  --card: #fffaf2;
  --sky: #cfe3ea;
  --sage: #cfe0c3;
  --peach: #f5d3bd;
  --error: #b5523b;
  --radius: 18px;
  --shadow: 0 4px 0 rgba(138, 90, 51, 0.18), 0 10px 24px rgba(74, 54, 39, 0.08);
  /* System fonts cover non-Latin scripts (Cyrillic, Greek, Arabic, CJK, ...) */
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(circle at 20% 0%, var(--sky) 0, transparent 45%),
    radial-gradient(circle at 100% 100%, var(--peach) 0, transparent 40%),
    var(--paper);
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.05rem; margin: 0; }
p  { margin: 0; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--wood-dark);
  margin-bottom: 6px;
}

.lead { color: var(--ink-soft); margin-bottom: 20px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}

/* Forms */
label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
}
.optional { font-weight: 400; color: var(--ink-soft); }

input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 12px 14px;
  border: 2px solid #e6d5bd;
  border-radius: 12px;
  background: #fff;
  outline: none;
}
input[type="text"]:focus { border-color: var(--wood); }

.error { color: var(--error); font-size: 0.9rem; margin-top: 6px; }

.preview {
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--sage);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.preview-label { font-size: 0.8rem; color: var(--ink-soft); }
.preview-name {
  font-size: 1.3rem;
  font-weight: 700;
  /* long names: cut off with "…" instead of breaking the layout */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fineprint { font-size: 0.8rem; color: var(--ink-soft); margin-top: 14px; text-align: center; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
  background: #efe2cf;
  color: var(--ink);
}
.btn-primary {
  width: 100%;
  background: var(--wood);
  color: #fff;
  box-shadow: 0 3px 0 var(--wood-dark);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-dark); }
.btn-small { width: auto; padding: 9px 16px; font-size: 0.95rem; }

.btn-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  color: var(--wood-dark);
  cursor: pointer;
}

.btn-link {
  font: inherit;
  font-size: 0.9rem;
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

/* Town */
.town-header { margin-bottom: 18px; }
.town-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.town-name {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rename-form { margin-top: 12px; }
.rename-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }

.bobbin {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  font-style: italic;
  color: var(--ink-soft);
}

.places { display: grid; gap: 12px; }
.place {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.place > div { flex: 1; min-width: 0; }
.place p { font-size: 0.9rem; color: var(--ink-soft); }
.place-icon {
  font-size: 1.5rem;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--sky);
  flex-shrink: 0;
}
.soon {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--wood-dark);
  background: #f3e6d3;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}

.town-footer { text-align: center; margin-top: 28px; }

/* The 3D town */
.town3d {
  position: relative;
  height: 68vh;
  height: 68svh;               /* "small viewport height": stays the same when the phone's address bar slides in and out */
  min-height: 360px;
  max-height: 680px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--paper);
  touch-action: none;          /* finger drags turn the town instead of scrolling the page */
}
.town3d canvas { display: block; cursor: grab; }
/* The "miniature" look: top and bottom of the town softly out of focus */
.tilt {
  position: absolute;
  left: 0;
  right: 0;
  height: 24%;
  pointer-events: none;
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
}
.tilt-top {
  top: 0;
  mask-image: linear-gradient(to bottom, #000 25%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 25%, transparent);
}
.tilt-bottom {
  bottom: 0;
  mask-image: linear-gradient(to top, #000 25%, transparent);
  -webkit-mask-image: linear-gradient(to top, #000 25%, transparent);
}
.town3d-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: rgba(255, 250, 242, 0.92);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.view-toggle-row { text-align: center; margin: 4px 0 10px; }

/* A place you can tap */
.place-open {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  border: none;
  cursor: pointer;
}
.place-open:active { transform: translateY(2px); }
.count {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--wood);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* Welcome Gate */
.btn-back {
  font: inherit;
  font-weight: 600;
  color: var(--wood-dark);
  background: none;
  border: none;
  padding: 6px 0;
  margin-bottom: 10px;
  cursor: pointer;
}
.btn-photo { font-size: 1.05rem; padding: 18px 20px; }

.gate-message {
  background: var(--sage);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-weight: 600;
}

.new-toy-photo, .toy-photo {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 14px;
  background: #f3e6d3;
}
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.form-actions .btn-primary { flex: 1; }
.form-actions .btn-small { flex: 0 0 auto; }

.section-title { margin: 26px 0 10px; font-size: 1.1rem; }
.empty { color: var(--ink-soft); font-size: 0.95rem; }

.residents {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.resident {
  font: inherit;
  color: inherit;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.resident img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #f3e6d3;
}
.name-tag {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* One toy */
.toy-title {
  margin: 14px 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toy-since { color: var(--ink-soft); font-size: 0.9rem; }

.confirm-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-top: 8px;
}
.confirm-box .rename-actions { justify-content: center; }
.btn-danger { background: var(--error); color: #fff; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ======================================================================
   Home overview
   ====================================================================== */
.checkin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--sage);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.checkin-card h2 { font-size: 1.05rem; margin: 0 0 2px; }
.checkin-card p { font-size: 0.9rem; color: var(--ink-soft); }
.checkin-card-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.checkin-done-note { font-weight: 600; color: #4f7a43; margin: 0 0 14px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.85rem; color: var(--ink-soft); }

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.home-actions .btn-primary { grid-column: 1 / -1; }

.suggestion {
  background: #efe6f7;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.92rem;
  margin: 0 0 6px;
}
.home-empty { margin: 10px 0; }
.status-section { scroll-margin-top: 12px; }
.section-note { font-size: 0.85rem; color: var(--ink-soft); margin: -6px 0 10px; }
.tile-sub { font-size: 0.72rem; color: var(--ink-soft); padding: 0 8px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resident .name-tag { padding-bottom: 0; }

.settings { margin-top: 26px; background: var(--card); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); }
.settings summary { font-weight: 600; cursor: pointer; }
.setting-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.stepper { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.stepper .btn { width: 40px; padding: 6px 0; }
.settings .fineprint { text-align: left; }

/* ======================================================================
   Check-in: swipe cards
   ====================================================================== */
.checkin-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.checkin-top .btn-back { margin: 0; }
.checkin-progress { font-weight: 700; color: var(--ink-soft); }

.card-stack { position: relative; height: min(58svh, 440px); margin: 6px 0 12px; }
.swipe-card {
  position: absolute;
  inset: 0;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.2s ease-out;
  cursor: grab;
}
.swipe-card.behind { transform: scale(0.95) translateY(10px); opacity: 0.7; pointer-events: none; }
.swipe-card img { width: 100%; flex: 1; min-height: 0; object-fit: contain; border-radius: 16px; background: #f3e6d3; pointer-events: none; }
.swipe-card h2 { margin: 10px 0 0; font-size: 1.3rem; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swipe-card p { font-size: 0.85rem; color: var(--ink-soft); }
.stamp {
  position: absolute;
  top: 24px;
  padding: 6px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.2rem;
  opacity: 0;
  pointer-events: none;
  border: 3px solid currentColor;
  background: rgba(255, 250, 242, 0.9);
}
.stamp-yes { left: 22px; color: #4f9a5b; transform: rotate(-12deg); }
.stamp-no { right: 22px; color: #8a6cc4; transform: rotate(12deg); }

.checkin-question { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 0 0 10px; }
.checkin-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer { font-size: 1.05rem; padding: 16px 10px; }
.answer-played { background: #cfe9c8; color: #2f5d32; }
.answer-snooze { background: #e4dbf3; color: #4d3b78; }
.checkin-finished { text-align: center; margin-top: 30px; }
.checkin-finished p { margin: 6px 0 18px; color: var(--ink-soft); }

/* One toy */
.toy-status { font-weight: 600; margin: 2px 0; }

/* ======================================================================
   Organising: suggestions, toy actions, places
   ====================================================================== */
#suggestions .suggestion { margin-bottom: 12px; }
#suggestions .suggestion p { margin: 0 0 10px; }
#suggest-back { background: #e3f1f4; }
.photo-strip { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.strip-photo { width: 46px; height: 46px; padding: 0; border: 2px solid #fffaf2; border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; }
.strip-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-more { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
#suggestions .fineprint { margin: 0; }

.away-line { font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); margin: -4px 0 12px; }

.toy-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.toy-actions .btn { width: 100%; text-align: left; padding: 12px 16px; }
.toy-message { margin: 12px 0 0; }

.place-form label { margin-top: 0; }
.place-form input { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.chip { font: inherit; font-size: 0.85rem; border: none; border-radius: 999px; padding: 6px 12px; background: #efe2cf; color: var(--ink); cursor: pointer; }

.memories { margin-top: 22px; }
.memories summary { font-weight: 700; font-size: 1.05rem; cursor: pointer; padding: 6px 0; }
.memories .section-note { margin-top: 6px; }
