:root {
  --ink: #3b2f3a;
  --muted: #7d6f7a;
  --paper: rgba(255, 252, 248, .92);
  --line: rgba(120, 80, 100, .15);
  --pink: #ff5d8f;
  --pink-soft: #ffe1eb;
  --green: #3fbf6a;
  --shadow: 0 6px 20px rgba(70, 40, 60, .16);
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe9b5; }
body {
  font-family: 'Baloo 2', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; display: block; }

/* Bovenbalk */
#topbar {
  position: fixed; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--paper); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius); padding: 6px 10px; box-shadow: var(--shadow);
  z-index: 10;
}
.icon-btn { border: 0; background: #fff; border-radius: 12px; width: 38px; height: 38px; font-size: 18px; box-shadow: 0 2px 0 var(--line); }
.icon-btn:active { transform: translateY(1px); }
.clock { display: flex; align-items: center; gap: 6px; font-size: 16px; white-space: nowrap; }
.clock #timeLabel { font-variant-numeric: tabular-nums; color: var(--muted); }
.love { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 140px; }
.love-heart { animation: beat 1.4s infinite; display: inline-block; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.22); } 24% { transform: scale(1); } 36% { transform: scale(1.14); } }
.bar { flex: 1; height: 9px; background: rgba(60, 40, 60, .1); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 50%; border-radius: 99px; transition: width .3s, background .3s; }
.love-bar { height: 13px; }
#loveVal { font-weight: 800; color: var(--pink); min-width: 24px; font-variant-numeric: tabular-nums; }
.stat { white-space: nowrap; font-size: 16px; background: #fff; border-radius: 10px; padding: 2px 9px; }
.speed { display: flex; background: #fff; border-radius: 12px; overflow: hidden; }
.speed button { border: 0; background: transparent; padding: 6px 9px; font-size: 12px; letter-spacing: -2px; color: var(--muted); }
.speed button.on { background: var(--pink); color: #fff; }

/* Takenlijst */
#tasks {
  position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 62px); left: 8px; z-index: 9;
  display: flex; flex-direction: column; gap: 5px; align-items: flex-start; max-width: min(340px, 60vw);
}
.task {
  border: 0; text-align: left; padding: 4px 10px; border-radius: 10px; font-size: 13px; line-height: 1.25;
  background: var(--paper); box-shadow: 0 2px 8px rgba(70, 40, 60, .12); border-left: 4px solid #bbb;
}
.task.bad { border-color: #ef5b5b; animation: pulse 1.6s infinite; }
.task.warn { border-color: #f2c14e; }
.task.good { border-color: var(--green); }
.task.love { border-color: var(--pink); }
@keyframes pulse { 50% { background: #ffe9e9; } }

/* Meldingen */
#toasts {
  position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 62px); right: 8px; z-index: 12;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; max-width: min(380px, 70vw);
}
.toast {
  background: #fff; border-radius: 12px; padding: 7px 12px; font-size: 14px; line-height: 1.3; box-shadow: var(--shadow);
  animation: pop .3s ease-out; transition: opacity .4s, transform .4s;
}
.toast.bad { background: #ffe4e4; }
.toast.warn { background: #fff4d6; }
.toast.good { background: #e3f8e9; }
.toast.love { background: var(--pink-soft); }
.toast.out { opacity: 0; transform: translateX(20px); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* Kaarten onderin */
#cards {
  position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end; justify-content: center; z-index: 10; pointer-events: none;
}
.card {
  pointer-events: auto; position: relative;
  display: flex; gap: 8px; align-items: center; width: 330px; max-width: calc(50% - 30px);
  background: var(--paper); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius); padding: 7px 10px 7px 7px; box-shadow: var(--shadow); cursor: pointer;
  border: 3px solid transparent; transition: border-color .2s, transform .2s;
}
.card.selected { border-color: #47d16b; transform: translateY(-3px); }
.portrait { width: 58px; height: 58px; flex: none; }
.card .info { flex: 1; min-width: 0; }
.card .name { display: flex; gap: 6px; align-items: baseline; font-size: 16px; line-height: 1.2; }
.card .act { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.needs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 3px; }
.need { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 13px; }
.need .bar { width: 100%; flex: none; height: 6px; }
.need.crit span { animation: shake .5s infinite; }
@keyframes shake { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.card .cancel { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 11px; }
#btnAnimals { pointer-events: auto; }
.icon-btn.round { width: 50px; height: 50px; border-radius: 50%; font-size: 24px; box-shadow: var(--shadow); flex: none; }

/* Contextmenu */
#ctxmenu {
  position: fixed; z-index: 20; width: 270px; background: #fffdfa; border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(70, 40, 60, .25); padding: 10px; animation: pop .15s ease-out;
}
#ctxmenu.sheet { left: 8px !important; right: 8px; width: auto; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 92px); top: auto !important; max-height: 55vh; overflow: auto; }
.mhead { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.mclose, .pclose { border: 0; background: #f3eef0; border-radius: 50%; width: 26px; height: 26px; font-size: 12px; }
.mstatus { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.mstatus:empty { display: none; }
.mini { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.mini .bar { height: 7px; }
.mnote { font-size: 12px; color: var(--muted); margin: 4px 0; }
.mact {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; text-align: left;
  border: 0; background: #f7f1f4; border-radius: 12px; padding: 8px 10px; margin-top: 5px; font-size: 15px;
}
.mact > span { font-size: 18px; }
.mact:hover:not(:disabled) { background: var(--pink-soft); }
.mact:disabled { opacity: .55; cursor: not-allowed; }
.mact.alt { background: #eef7f0; }
.mact em { font-style: normal; font-size: 11px; background: #fff; border-radius: 99px; padding: 0 7px; color: var(--muted); }
.mact em.duo, .mact em.lv { color: var(--pink); }
.mact small { width: 100%; font-size: 11px; color: #c0504d; padding-left: 28px; }

/* Panelen */
.panel {
  position: fixed; z-index: 15; top: calc(max(8px, env(safe-area-inset-top)) + 62px); left: 50%; transform: translateX(-50%);
  width: min(420px, calc(100% - 16px)); max-height: calc(100% - 200px); overflow: auto;
  background: #fffdfa; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(70, 40, 60, .25); padding: 12px;
}
.phead { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 6px; }
.phead span { font-size: 13px; margin-left: auto; }
.arow { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: #f7f1f4; border-radius: 12px; padding: 6px 10px; margin-top: 5px; text-align: left; }
.aemo { font-size: 22px; }
.aname { width: 70px; font-weight: 700; }
.abars { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; }
.abars > span { display: flex; align-items: center; gap: 3px; }
.hint { font-size: 12px; color: var(--muted); }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 15px; margin: 6px 0 10px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--pink); }
.pbtn { display: block; width: 100%; border: 0; background: #f7f1f4; border-radius: 12px; padding: 10px; margin-top: 6px; font-size: 15px; text-align: left; }
.pbtn.danger { background: #ffe4e4; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 228, 238, .78), rgba(190, 225, 170, .82));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.start-card {
  width: min(520px, 100%); max-height: 100%; overflow: auto; text-align: center;
  background: #fffdfa; border-radius: 26px; padding: 22px 20px; box-shadow: 0 16px 50px rgba(70, 40, 60, .25);
}
.logo { font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -1px; color: #2f8f55; }
.logo span { color: var(--pink); }
.logo.small { font-size: 32px; }
.couple { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 14px 0 6px; }
.couple figure { margin: 0; }
.couple canvas { width: 128px; height: 128px; }
.couple figcaption { font-weight: 800; font-size: 18px; }
.heart-big { font-size: 34px; animation: beat 1.4s infinite; }
.tagline { color: var(--muted); font-size: 15px; line-height: 1.4; margin: 6px 4px 14px; }
.start-buttons { display: flex; flex-direction: column; gap: 8px; }
.btn { border: 0; border-radius: 14px; padding: 12px 16px; font-size: 18px; font-weight: 700; }
.btn.primary { background: linear-gradient(180deg, #ff7aa2, #ff4d7e); color: #fff; box-shadow: 0 4px 0 #d63a66; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #d63a66; }
.btn.ghost { background: #f7f1f4; }
.help { text-align: left; }
.help .logo { text-align: center; }
.help h3 { margin: 12px 0 2px; font-size: 17px; }
.help p, .help li { font-size: 14px; line-height: 1.45; }
.help ul { padding-left: 18px; margin: 4px 0; }
.help .btn { width: 100%; margin-top: 12px; }
.go-reason { font-size: 18px; margin: 14px 0 6px; }
.go-days { color: var(--muted); }
.go-best { font-weight: 800; color: var(--pink); }

/* Telefoon */
@media (max-width: 640px) {
  #topbar { gap: 6px; padding: 5px 7px; }
  .icon-btn { width: 32px; height: 32px; font-size: 16px; }
  .clock { font-size: 14px; }
  .love { order: 10; flex-basis: 100%; }
  #loveVal { font-size: 14px; }
  .stat { font-size: 14px; padding: 1px 6px; }
  .speed { margin-left: auto; }
  .speed button { padding: 5px 7px; }
  #tasks, #toasts { top: calc(max(8px, env(safe-area-inset-top)) + 84px); }
  #toasts { left: 8px; right: 8px; max-width: none; align-items: stretch; }
  #tasks { top: auto; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 96px); max-width: 75vw; }
  .task { font-size: 12px; padding: 3px 8px; }
  .card { max-width: none; flex: 1; padding: 5px 6px 5px 5px; gap: 5px; }
  .portrait { width: 40px; height: 40px; }
  .card .name { font-size: 14px; flex-direction: column; gap: 0; }
  .card .act { font-size: 10.5px; max-width: 100%; }
  .need { font-size: 11px; }
  .needs { gap: 2px; }
  .icon-btn.round { width: 42px; height: 42px; font-size: 20px; }
  .logo { font-size: 38px; }
  .couple canvas { width: 104px; height: 104px; }
}
