/* Player site. Built to live inside the LB Phone browser (an iframe in FiveM's NUI):
   everything self-hosted, no popups, no new tabs, sizes taken from the iframe's own viewport.
   One dark theme on purpose. Layout: bunny on top, one narrow panel under him; the chat takes the whole frame. */
@font-face {
  font-family: "Rubik Wet Paint";
  src: url("/assets/fonts/rubik-wet-paint-hebrew.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
:root {
  color-scheme: dark;
  --black: #000;
  --blood: #b3121a;      /* buttons, accents */
  --wet: #ff2a2a;        /* focus, his eyes */
  --clot: #4d0408;       /* shadows */
  --ink: #f1e9e9;        /* text */
  --mute: #a99c9f;       /* secondary text */
  --line: #3d161a;       /* borders */
  --field: #0e090a;      /* input background */
  --ui: "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  --paint: "Rubik Wet Paint", "Segoe UI", Arial, sans-serif;
  --bunny-h: clamp(120px, 36vh, 330px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--black); color: var(--ink);
  font: 16px/1.45 var(--ui); -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.room { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow-x: hidden; overflow-y: auto; background: var(--black); display: flex; }
/* a low red haze so he is not floating in nothing */
.room::before {
  content: ""; position: fixed; left: 50%; bottom: -34vh; width: 160vmax; height: 92vh;
  transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(closest-side, rgba(179, 18, 26, .32), rgba(77, 4, 8, .15) 55%, transparent 100%);
  animation: haze 5.5s ease-in-out infinite alternate;
}
@keyframes haze { from { opacity: .55 } to { opacity: 1 } }

/* margin:auto centres the stack when there is room and lets it scroll from the top when there is not */
.stack {
  position: relative; margin: auto; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center; padding: 14px 18px 22px;
}

/* ---------- the bunny ---------- */
.bunny {
  position: relative; flex: none; z-index: 1; cursor: pointer;
  height: var(--bunny-h); width: calc(var(--bunny-h) * 637 / 1337);
  padding: 0; border: 0; background: none; outline: none;
  transform-origin: 50% 100%; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.bunny-in { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transform-origin: 50% 100%; animation: sway 7s steps(14, end) infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(0deg) }
  22% { transform: rotate(-1.6deg) }
  48% { transform: rotate(.4deg) }
  74% { transform: rotate(1.8deg) }
}
.bunny img { position: absolute; display: block; max-width: none; pointer-events: none; -webkit-user-drag: none; }
.body { top: 0; left: 0; width: 100%; height: 100%; filter: brightness(1.08) contrast(1.08) drop-shadow(0 0 2.2vh rgba(179, 18, 26, .5)); }
.eye { opacity: 0; filter: drop-shadow(0 0 6px var(--wet)); }
.eye.l { left: 24.5%; top: 35.4%; width: 17.6%; }
.eye.r { left: 57.1%; top: 35.1%; width: 17%; }
.glow {
  position: absolute; width: 19%; padding-top: 19%; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 42, 42, .9), transparent 66%);
  mix-blend-mode: screen; animation: pulse 2.3s ease-in-out infinite alternate;
}
.glow.l { left: 33.3%; top: 39.1%; }
.glow.r { left: 65.6%; top: 38.8%; }
@keyframes pulse { from { opacity: .4 } to { opacity: 1 } }
/* lights out: only the shape and the eyes are left */
.bunny.sil .body { filter: brightness(.14) drop-shadow(0 0 2.2vh rgba(179, 18, 26, .6)); }
.bunny.sil .eye { opacity: 1; }
/* touch him */
.bunny.lunge { animation: lunge .62s cubic-bezier(.3, .9, .3, 1); z-index: 5; }
@keyframes lunge {
  0% { transform: scale(1) }
  22% { transform: scale(2.1) translateY(30%) rotate(-2deg) }
  34% { transform: scale(2.05) translateY(30%) rotate(2deg) }
  46% { transform: scale(2.1) translateY(30%) rotate(-2deg) }
  58% { transform: scale(2.05) translateY(30%) rotate(1deg) }
  100% { transform: scale(1) }
}
.flash { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 6; background: var(--blood); opacity: 0; pointer-events: none; mix-blend-mode: screen; }
.flash.on { animation: flash .5s ease-out; }
@keyframes flash { from { opacity: .7 } to { opacity: 0 } }

/* ---------- the panel ---------- */
.panel { position: relative; z-index: 2; width: 100%; margin-top: -6px; }
.view { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 14px; font-weight: 600; color: #e2cfd1; letter-spacing: .01em; }
input, textarea {
  width: 100%; min-width: 0; margin: 0; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; font: 17px/1.3 var(--ui);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input { height: 46px; padding: 0 14px; }
/* numbers read left to right but sit on the same side as the Hebrew labels */
input[dir="ltr"] { text-align: right; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: #5f5356; letter-spacing: .06em; }
textarea::placeholder { letter-spacing: 0; }
input:focus, textarea:focus { border-color: var(--wet); box-shadow: 0 0 0 3px rgba(255, 42, 42, .2); }
input[aria-invalid="true"] { border-color: #ff6b73; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-align: center;
  font: 600 16px/1.2 var(--ui); color: var(--ink); background: none;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
  transition: filter .15s, background-color .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--wet); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.primary {
  min-height: 52px; margin-top: 4px; color: #fff; font: 400 24px/1 var(--paint); letter-spacing: .02em;
  background: linear-gradient(#c5151e, #7a0a10); border-color: rgba(255, 90, 96, .35);
  box-shadow: 0 0 22px rgba(179, 18, 26, .45), inset 0 1px 0 rgba(255, 255, 255, .14);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .45);
}
.btn.primary:hover:not([disabled]) { filter: brightness(1.14); }
.btn.ghost { border-color: var(--line); color: #e9c3c6; background: rgba(14, 9, 10, .7); }
.btn.ghost:hover:not([disabled]) { border-color: #7a2229; background: #170d0f; }
.btn.small { width: auto; min-height: 34px; padding: 0 12px; font-size: 14px; align-self: center; }

.error { margin: 0; font-size: 14px; color: #ff8a90; text-align: center; }
.hint { margin: 0; font-size: 14px; color: var(--mute); text-align: center; text-wrap: balance; }
.hint.strong { color: #e2cfd1; font-weight: 600; font-size: 15px; }
.code {
  display: block; padding: 10px 8px; text-align: center; border-radius: 12px;
  font: 700 clamp(28px, 10vw, 38px)/1.1 Consolas, "Courier New", monospace; letter-spacing: .08em;
  color: #fff; background: var(--field); border: 1px dashed #8d1c24;
  text-shadow: 0 0 14px rgba(255, 42, 42, .8); -webkit-user-select: all; user-select: all;
}
.waiting {
  margin: 6px 0 2px; text-align: center; text-wrap: balance;
  font: 400 clamp(21px, 6.6vw, 27px)/1.3 var(--paint);
  background: linear-gradient(#ff4343 0%, #e51b25 55%, #c2141d 100%);   /* stays readable on the second line */
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 .3em rgba(179, 18, 26, .7));
  animation: throb 1.8s ease-in-out infinite;
}
@keyframes throb { 50% { filter: drop-shadow(0 0 .5em rgba(255, 42, 42, .85)) } }

/* short and wide (a phone held sideways): bunny beside the form */
@media (max-height: 430px) and (min-aspect-ratio: 1/1) {
  :root { --bunny-h: min(80vh, 300px); }
  .stack { flex-direction: row; align-items: center; gap: 14px; max-width: 560px; padding: 10px 14px; }
  .panel { margin-top: 0; }
}

/* ---------- the chat ---------- */
.room[data-view="chat"] .stack { display: none; }
.chat { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 3; display: flex; flex-direction: column; background: rgba(4, 2, 3, .9); }
.chat-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #0a0607; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid #7a2229;
  background: #000 url("/assets/bunny.webp") 50% 33% / 190% auto no-repeat;
  box-shadow: 0 0 12px rgba(179, 18, 26, .6);
}
.who { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.who strong { font: 400 20px/1.15 var(--paint); color: #ff3b3b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { font-size: 12px; color: var(--mute); }
.who small::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 5px; border-radius: 50%; background: #6b5d60; }
.who small[data-on="1"]::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }

/* sound on/off for the new-message chime */
.icon-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 34px; padding: 0;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(14, 9, 10, .7); color: #ff5a5a; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation; transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: #7a2229; }
.icon-btn:focus-visible { outline: 2px solid var(--wet); outline-offset: 2px; }
.icon-btn .slash { display: none; }
.icon-btn[aria-pressed="false"] { color: #7b6f72; }
.icon-btn[aria-pressed="false"] .slash { display: block; }

.msgs {
  flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  scrollbar-width: thin; scrollbar-color: #4a1a1f transparent; overscroll-behavior: contain;
}
.msgs > :first-child { margin-top: auto; }   /* few messages sit at the bottom, near the input */
.empty { margin: auto; color: var(--mute); font-size: 14px; text-align: center; }
.msg {
  max-width: 84%; padding: 7px 11px 5px; border-radius: 14px; font-size: 15px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start;
}
.msg time { display: block; margin-top: 2px; font-size: 11px; color: rgba(255, 255, 255, .5); direction: ltr; text-align: end; }
.msg.from-me { align-self: flex-end; background: linear-gradient(#8c1118, #5c0a0f); border-end-end-radius: 4px; }
.msg.from-bunny { align-self: flex-start; background: #1b1516; border: 1px solid #2f2224; border-end-start-radius: 4px; }
.msg.fresh { animation: fresh 1.6s ease-out; }     /* a message that just arrived glows once */
@keyframes fresh {
  from { box-shadow: 0 0 0 2px rgba(255, 42, 42, .95), 0 0 26px rgba(255, 42, 42, .85); }
  to { box-shadow: 0 0 0 0 rgba(255, 42, 42, 0), 0 0 0 rgba(255, 42, 42, 0); }
}
.chat-note { flex: none; margin: 0; padding: 4px 12px; font-size: 13px; color: #ff8a90; text-align: center; }
.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px 10px; border-top: 1px solid var(--line); background: #0a0607; }
.composer textarea { flex: 1 1 0; height: 44px; min-height: 44px; max-height: 120px; padding: 10px 12px; resize: none; font-size: 16px; line-height: 1.4; scrollbar-width: thin; }
.btn.send { width: auto; min-height: 44px; margin: 0; padding: 0 16px; font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  .room::before, .bunny-in, .glow, .waiting, .bunny.lunge, .msg.fresh { animation: none; }
}
