:root {
  --bg: #1c1b1f;
  --bg-2: #2a282f;
  --card: #26242b;
  --line: #3a3741;
  --text: #f4eef3;
  --muted: #a49ba6;
  --pink: #ff4fa3;
  --pink-light: #ff8cc6;
  --pink-deep: #c42d78;
  /* Per-person series colors, validated as a pair on --card (dark). */
  --beci: #f2449a;
  --csaba: #8f74ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  background: radial-gradient(120% 60% at 50% 0%, #3a2433 0%, var(--bg) 60%) var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea { user-select: text; -webkit-user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Login: the only thing shown until someone logs in */

body:not(.authed) > :not(.login-screen):not(.toast) { display: none !important; }
body.authed .login-screen { display: none; }

.login-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 20px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 40px rgba(255, 79, 163, .35); }
.login-box h1 {
  margin: 14px 0 22px;
  font-size: 34px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink-light), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-step p { margin: 0 0 14px; font-size: 17px; }
.login-step { display: flex; flex-direction: column; gap: 10px; }
.login-step p.error { margin: 0; font-size: 14px; }
.login-step label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13px; color: var(--muted); }
.login-step .primary { height: 50px; font-size: 17px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who button {
  height: 110px;
  border-radius: 22px;
  border: 2px solid var(--who);
  background: color-mix(in srgb, var(--who) 18%, var(--card));
  font-size: 22px;
  font-weight: 800;
}
.who button:active { background: var(--who); }
.who .beci { --who: var(--beci); }
.who .csaba { --who: var(--csaba); }
.login-box > .hint { margin-top: 22px; }

/* Header */

.top { display: flex; align-items: center; justify-content: center; position: relative; padding: 10px 12px 0; }
.top h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, var(--pink-light), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.icon-btn {
  position: absolute;
  right: 12px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 17px;
  padding: 0;
}

/* Views */

main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 16px; }
body.on-meter main { overflow: hidden; padding-bottom: 10px; }

.view-meter { height: 100%; display: flex; flex-direction: column; }
.view-title { margin: 14px 0 8px; font-size: 20px; }
.hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-align: center; }
.hint.left { text-align: left; margin: 2px 0 0; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 10px;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; margin-top: 10px; }

/* Buttons */

.primary { border: 0; border-radius: 14px; background: var(--pink); color: #fff; font-weight: 700; }
.ghost { border: 1px solid var(--line); border-radius: 14px; background: transparent; font-weight: 600; }
.small { height: 38px; padding: 0 14px; font-size: 14px; }
.link { border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 4px; }

/* Kanométer */

.duo {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  min-height: 0;
}

.meter {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
}

.name { margin: 0; font-size: 19px; font-weight: 700; }

/* Your own toy stands out; the partner's can only be watched */
.meter.mine { border: 2px solid var(--pink); box-shadow: 0 0 26px rgba(255, 79, 163, .28), inset 0 0 30px rgba(255, 79, 163, .06); }
.meter.mine .name::after {
  content: 'TE';
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  vertical-align: middle;
}
.meter:not(.mine) .step, .meter:not(.mine) .slider { visibility: hidden; }

.stage { position: relative; flex: 1; width: 100%; min-height: 0; display: flex; align-items: flex-end; justify-content: center; }
.stage .toy { position: relative; z-index: 1; }

/* Background heart: brighter and beating faster the higher the level */
.heart {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 92%;
  max-height: 60%;
  transform: translate(-50%, -50%);
  fill: var(--pink);
  opacity: calc(.04 + var(--lvl, 5) * .028);
  filter: blur(calc(6px - var(--lvl, 5) * .4px));
  animation: beat calc(2.6s - var(--lvl, 5) * .17s) ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  12% { transform: translate(-50%, -50%) scale(1.07); }
  24% { transform: translate(-50%, -50%) scale(.98); }
  36% { transform: translate(-50%, -50%) scale(1.04); }
}

/* Mood speech bubble above the toy */
.bubble {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 94%;
  margin: 0;
  padding: 7px 11px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px; height: 10px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.toy { width: 100%; max-height: 100%; overflow: visible; transform-origin: 50% 100%; filter: drop-shadow(0 6px 14px rgba(255, 79, 163, var(--glow, .2))); }

.value { margin-top: 4px; width: 100%; display: flex; align-items: center; justify-content: space-between; font-variant-numeric: tabular-nums; }
.num { font-size: 40px; font-weight: 800; color: var(--pink); line-height: 1; }
.step {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--pink-light);
  font-size: 22px;
  line-height: 1;
  padding: 0;
}
.step:active { background: var(--pink-deep); color: var(--text); }

.updated { margin: 2px 0 6px; font-size: 11px; color: var(--muted); opacity: .7; min-height: 1.3em; }

.slider {
  width: 100%;
  min-width: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--pink) var(--fill, 50%), var(--line) var(--fill, 50%));
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--pink-light);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--pink);
}
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--pink-light); border: 3px solid var(--bg); }

.combo {
  margin-top: 8px;
  text-align: center;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
}
.combo b { color: var(--pink); }

/* Bottom tabs */

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(28, 27, 31, .96);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
}
.tabs a span { font-size: 21px; line-height: 1; filter: grayscale(.6); opacity: .75; }
.tabs a.on { color: var(--pink-light); }
.tabs a.on span { filter: none; opacity: 1; }
.badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--pink);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  line-height: 16px;
  text-align: center;
}
.badge:empty { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 6px; }

/* Sex dates */

.date-form { display: flex; flex-direction: column; gap: 8px; }
.date-form > * { min-width: 0; }
.date-form .form-title { margin: 0; font-size: 16px; }
.date-form .reply-info { margin: 0; text-align: left; }
.date-form .row { justify-content: flex-end; }
.date-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.date-form input:focus { border-color: var(--pink); }
.date-form input[type="datetime-local"] {
  display: block;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
  color-scheme: dark;
}
.date-form input::-webkit-date-and-time-value { text-align: left; }

.section { margin: 16px 0 8px; font-size: 15px; }
.date { border-left: 4px solid var(--who); }
.date.beci { --who: var(--beci); }
.date.csaba { --who: var(--csaba); }
.date .when { margin: 0; font-size: 16px; font-weight: 700; }
.date .when::first-letter { text-transform: uppercase; }
.date .note { margin: 4px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.date .by { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.date .status { font-size: 13px; color: var(--muted); margin-right: auto; }

/* Scratch-off secrets */

.ticket {
  position: relative;
  margin-bottom: 12px;
  padding: 16px 14px 14px;
  border-radius: 20px;
  background: linear-gradient(150deg, #4a2340, #2b1f33 60%, #3a2148);
  border: 2px dashed var(--pink);
  text-align: center;
  box-shadow: 0 8px 30px rgba(255, 79, 163, .25);
}
.ticket.revealed { animation: glow 1.2s ease-out; }
.ticket-from { margin: 0; font-size: 13px; color: var(--pink-light); font-weight: 700; }
.ticket-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.scratch { position: relative; margin-top: 10px; min-height: 110px; border-radius: 14px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.scratch .secret-text { margin: 0; padding: 18px 14px; font-size: 22px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity .5s; }
.scratch canvas.gone { opacity: 0; pointer-events: none; }
.ticket .after { margin-top: 12px; }
@keyframes glow { 0% { box-shadow: 0 0 0 rgba(255, 79, 163, 0); } 40% { box-shadow: 0 0 60px rgba(255, 79, 163, .8); } 100% { box-shadow: 0 8px 30px rgba(255, 79, 163, .25); } }

.reactions-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.reactions-row button { min-height: 48px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); font-size: 14px; font-weight: 700; }
.reactions-row button.on { background: var(--pink); border-color: var(--pink); color: #fff; }

.secret-form { display: flex; flex-direction: column; gap: 8px; }
.secret-form h3 { margin: 0; font-size: 17px; }
.secret-form .hint { margin: 0; }
.secret-form textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
  resize: none;
}
.secret-form textarea:focus { border-color: var(--pink); }
.secret-form .primary { height: 48px; font-size: 16px; }
.secret-list h3 { margin: 0 0 4px; font-size: 15px; }
.secret-item { padding: 10px 0; border-top: 1px solid var(--line); }
.secret-item p { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.secret-item small { color: var(--muted); font-size: 11px; }
.secret-item .row { margin-top: 6px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.pill.on { background: var(--pink-deep); color: #fff; }

/* Toast & dialogs */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--pink-deep);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

dialog {
  width: calc(100% - 32px);
  max-width: 380px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }

.sheet { display: flex; flex-direction: column; gap: 10px; padding: 20px; }
.sheet h3 { margin: 0; font-size: 19px; text-align: center; }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.error { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--pink-light); text-align: center; }

.pin {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 26px;
  letter-spacing: 14px;
  text-align: center;
  outline: none;
}
.pin:focus { border-color: var(--pink); }

.actions { display: flex; gap: 10px; }
.actions button { flex: 1; height: 46px; font-size: 16px; }
#menu-pins { height: 46px; font-size: 16px; }

.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.menu-row b { font-size: 15px; }
.menu-row .ghost { flex: none; }

/* Match celebration: both meters show the same level */

.celebrate { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.celebrate.hot { animation: flash 1.2s ease-in-out 3; }
.celebrate span { position: absolute; top: -50px; animation: fall linear forwards; }
.celebrate.warm span, .celebrate.sleepy span { top: auto; bottom: -50px; animation-name: rise; }
.celebrate.sleepy span { animation-timing-function: ease-in-out; opacity: .8; }
.celebrate .banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  width: calc(100% - 40px);
  max-width: 340px;
  padding: 18px 16px;
  border-radius: 22px;
  background: rgba(28, 27, 31, .92);
  border: 2px solid var(--pink);
  box-shadow: 0 0 40px rgba(255, 79, 163, .5);
  text-align: center;
  animation: pop 4.2s ease forwards;
}
.celebrate.sleepy .banner { border-color: var(--csaba); box-shadow: 0 0 40px rgba(143, 116, 255, .45); }
.celebrate .banner b { display: block; font-size: 22px; }
.celebrate .banner small { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }

.celebrating-hot .toy { animation: hop .45s ease-in-out 6; }
.celebrating-warm .toy { animation: sway 1s ease-in-out 3; }
.celebrating-sleepy .toy { animation: snooze 2s ease-in-out 2; }

@keyframes fall {
  from { transform: translate(0, 0) rotate(0); }
  to { transform: translate(var(--drift), calc(100dvh + 100px)) rotate(240deg); }
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--drift), calc(-100dvh - 100px)); opacity: 0; }
}
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  10% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  16%, 85% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(.9); opacity: 0; }
}
@keyframes flash { 0%, 100% { background: transparent; } 50% { background: rgba(255, 79, 163, .14); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-14px) scale(1.04); } }
@keyframes sway { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes snooze { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.94); } }
