/* Михалыч: вечерняя кухня. Цвета сняты с картинок: янтарь абажура, ночное окно, тёмное дерево, клеёнка. */
:root {
  --night: #14110c;          /* тёмный угол кухни */
  --night-2: #1d1812;
  --wood: #2b2015;           /* стол, полки */
  --wood-2: #3a2b1c;
  --amber: #e0a548;          /* лампа */
  --honey: #c9853a;
  --cream: #efe3c8;          /* клеёнка */
  --cream-ink: #2b2016;
  --window: #50607c;         /* ночное окно */
  --sage: #8fa38a;           /* кафель */
  --rust: #b0533a;           /* варенье */
  --text: #f1e7d2;
  --muted: #b8a88c;
  --line: rgba(239, 227, 200, .12);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --shadow-quiet: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 6px rgba(0, 0, 0, .16);
  --radius: 18px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

.avatar { border-radius: 50%; object-fit: cover; border: 2px solid rgba(224, 165, 72, .55); flex: none; }

.primary {
  border: 0; border-radius: 999px; padding: 12px 22px;
  background: linear-gradient(180deg, var(--amber), var(--honey));
  color: #24170a; font-weight: 500; letter-spacing: normal;
  box-shadow: var(--shadow-quiet);
  transition: filter .2s ease-in-out, box-shadow .2s ease-in-out, opacity .2s ease-in-out;
}
.primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 2px 10px rgba(224, 165, 72, .22); }
.primary:active:not(:disabled) { filter: brightness(.96); }
.primary:disabled { opacity: .45; cursor: default; box-shadow: none; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; color: var(--muted);
         transition: color .2s ease-in-out, border-color .2s ease-in-out, background-color .14s ease-out; }
.ghost:hover { color: var(--cream); border-color: rgba(239, 227, 200, .28); background: rgba(239, 227, 200, .05); }

/* --- Сцена: картинка кухни --- */
.scene { position: fixed; inset: 0; z-index: 0; }
.scene img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 1.2s ease; }
.scene::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(20, 17, 12, 0) 0%, rgba(20, 17, 12, .55) 70%),
              linear-gradient(180deg, rgba(20, 17, 12, .1) 0%, rgba(20, 17, 12, .75) 100%);
}

/* --- Вход --- */
.landing { position: relative; min-height: 100%; display: flex; align-items: center; justify-content: flex-end;
           padding: 32px clamp(16px, 5vw, 72px); }
.card {
  position: relative; z-index: 1; width: min(460px, 100%);
  background: rgba(29, 24, 18, .86); backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  padding: 24px 24px 20px;
  animation: rise .6s ease both;
}
.card-head { display: flex; gap: 14px; align-items: center; }
h1 { font-weight: 500; font-size: 2rem; line-height: 1.2; letter-spacing: -.02em; margin: 0; color: var(--cream); }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 22px; }
.honest { margin: 18px 0 14px; padding: 0; list-style: none; display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }
.honest li { padding-left: 18px; position: relative; }
.honest li::before { content: "•"; position: absolute; left: 4px; color: var(--amber); }

.gate { display: grid; gap: 12px; }
.ask { margin: 4px 0 0; font-weight: 500; font-size: 1.15rem; line-height: 1.4; letter-spacing: -.01em; color: var(--cream); min-height: 1.5em; }
.tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.item {
  height: 54px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(58, 43, 28, .7); font-size: 1.75rem; line-height: 1;
  display: grid; place-items: center; touch-action: none; user-select: none;
  transition: transform .2s ease-in-out, background .2s ease-in-out, opacity .2s ease-in-out;
}
.item:hover { background: rgba(80, 58, 36, .85); transform: translateY(-1px); }
.item.placed { opacity: .25; }
.item.dragging { position: fixed; z-index: 10; pointer-events: none; transform: scale(1.15); box-shadow: var(--shadow); }
.cloth {
  min-height: 74px; border-radius: 14px; padding: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(176, 83, 58, .22) 0 6px, transparent 7px),
    radial-gradient(circle at 70% 65%, rgba(143, 163, 138, .25) 0 7px, transparent 8px),
    radial-gradient(circle at 45% 80%, rgba(176, 83, 58, .18) 0 5px, transparent 6px),
    linear-gradient(180deg, #efe3c8, #e2d2ad);
  background-size: 64px 64px, 72px 72px, 56px 56px, auto;
  border: 2px dashed rgba(43, 32, 22, .25); color: var(--cream-ink);
  transition: box-shadow .2s ease-in-out;
}
.cloth.over { box-shadow: 0 0 0 3px var(--amber) inset; }
.cloth .item { background: rgba(255, 255, 255, .55); border-color: rgba(43, 32, 22, .15); width: 54px; opacity: 1; }
.cloth-hint { font-size: .85rem; color: rgba(43, 32, 22, .55); }
.cloth:has(.item) .cloth-hint { display: none; }
.adult { display: flex; gap: 10px; align-items: center; color: var(--text); }
.adult input { width: 20px; height: 20px; accent-color: var(--amber); }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.gate-error { margin: 0; min-height: 1.2em; color: #f0a58f; font-size: .9rem; }
.tg-login { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 10px; color: var(--muted); font-size: .9rem; }

/* --- Застолье --- */
.chat { position: relative; height: 100%; display: grid; grid-template-columns: 1fr; }
.chat .scene img { filter: brightness(.38) saturate(.9); }
.chat.done .scene img { filter: brightness(.18) saturate(.6); }
.talk { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; min-height: 0;
        background: linear-gradient(180deg, rgba(20, 17, 12, .55), rgba(20, 17, 12, .82)); }

.talk-head {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: rgba(29, 24, 18, .8); backdrop-filter: blur(8px);
  position: relative;
}
.who { display: grid; line-height: 1.2; flex: 1; }
.who strong { font-size: 1.1rem; font-weight: 500; letter-spacing: -.01em; color: var(--cream); }
.status { color: var(--muted); font-size: .85rem; }
.status.typing { color: var(--amber); }
.icon { background: none; border: 1px solid var(--line); border-radius: 50%; width: 40px; height: 40px; font-size: 1.3rem; line-height: 1; color: var(--muted);
        transition: color .2s ease-in-out, border-color .2s ease-in-out, background-color .14s ease-out; }
.icon:hover { color: var(--cream); border-color: rgba(239, 227, 200, .28); background: rgba(239, 227, 200, .05); }
.menu {
  position: absolute; right: 12px; top: calc(100% + 6px); z-index: 5; min-width: 260px;
  background: var(--night-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 6px; display: grid;
}
.menu > button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 10px;
                  transition: background-color .14s ease-out; }
.menu > button:hover { background: rgba(239, 227, 200, .07); }
.menu .tg-login { padding: 8px 4px 4px; border-top: 1px solid var(--line); margin-top: 4px; }

.log { list-style: none; margin: 0; padding: 18px 16px 8px; overflow-y: auto; flex: 1; min-height: 0;
       display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; overscroll-behavior: contain; }
.msg { max-width: min(78%, 560px); padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap;
       overflow-wrap: anywhere; animation: pop .22s ease both; }
.msg.him { align-self: flex-start; background: var(--cream); color: var(--cream-ink); border-bottom-left-radius: 6px;
           box-shadow: var(--shadow-quiet); }
.msg.me { align-self: flex-end; background: linear-gradient(180deg, var(--wood-2), var(--wood)); color: var(--text);
          border: 1px solid rgba(224, 165, 72, .25); border-bottom-right-radius: 6px; }
.msg.notice { align-self: center; max-width: 92%; text-align: center; background: rgba(80, 96, 124, .28);
              border: 1px solid rgba(80, 96, 124, .5); color: var(--text); font-size: .92rem; border-radius: 12px; }
.typing-dots { align-self: flex-start; background: var(--cream); border-radius: var(--radius); border-bottom-left-radius: 6px;
               padding: 12px 16px; display: flex; gap: 5px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: #8a7353; animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
.empty { align-self: center; margin: auto 0; text-align: center; color: var(--muted); font-weight: 500; font-size: 1.1rem; line-height: 1.4; letter-spacing: -.01em; max-width: 22em; }

.rating { margin: 0 16px 8px; padding: 12px 14px; border-radius: 14px; background: rgba(29, 24, 18, .92);
          border: 1px solid rgba(224, 165, 72, .35); }
.rating p { margin: 0 0 6px; font-weight: 500; letter-spacing: -.01em; color: var(--cream); }
.stars { display: flex; gap: 4px; }
.stars button { background: none; border: 0; font-size: 1.8rem; line-height: 1; color: rgba(239, 227, 200, .25); padding: 2px 4px; }
.stars button.on, .stars:hover button { color: var(--amber); }
.stars button:hover ~ button { color: rgba(239, 227, 200, .25); }
.review { display: grid; gap: 8px; margin-top: 8px; }
.review textarea { resize: vertical; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 17, 12, .6); padding: 10px; }
.review-actions { display: flex; gap: 8px; justify-content: flex-end; }

.table-buttons { display: flex; gap: 8px; padding: 6px 16px 0; }
.table-buttons button { flex: 1; border-radius: 999px; padding: 9px 12px; border: 1px solid rgba(224, 165, 72, .35);
                        background: rgba(43, 32, 21, .85); color: var(--cream); font-weight: 500;
                        transition: background .2s ease-in-out, border-color .2s ease-in-out; }
.table-buttons button:hover { background: rgba(70, 51, 31, .95); border-color: rgba(224, 165, 72, .55); }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 10px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; resize: none; max-height: 160px; border-radius: 22px; border: 1px solid var(--line);
                     background: rgba(29, 24, 18, .92); padding: 11px 16px; line-height: 1.4; }
.composer textarea:focus { border-color: rgba(224, 165, 72, .6); outline: none; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none;
        background: linear-gradient(180deg, var(--amber), var(--honey)); color: #24170a; font-size: 1.1rem;
        transition: filter .2s ease-in-out, opacity .2s ease-in-out; }
.send:hover:not(:disabled) { filter: brightness(1.07); }
.send:active:not(:disabled) { filter: brightness(.96); }
.chat.done .table-buttons { display: none; }

/* --- Широкий экран: кухня слева, разговор справа --- */
@media (min-width: 960px) {
  .chat { grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); }
  .chat .scene-table { position: relative; inset: auto; height: 100%; }
  .chat .scene img { filter: brightness(.9) saturate(1); }
  .chat.done .scene img { filter: brightness(.35) saturate(.7); }
  .chat .scene::after { background: linear-gradient(90deg, rgba(20, 17, 12, 0) 60%, rgba(20, 17, 12, .9) 100%); }
  .talk { background: rgba(20, 17, 12, .94); border-left: 1px solid var(--line); }
}

/* --- Телефон: карточка входа — снизу --- */
@media (max-width: 640px) {
  .landing { align-items: flex-end; justify-content: center; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .card { padding: 18px 16px 14px; border-radius: 20px; }
  h1 { font-size: 1.6rem; }
  .honest { font-size: .82rem; margin: 12px 0 10px; }
  .tray { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .item { height: 48px; font-size: 1.55rem; }
  .msg { max-width: 86%; }
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
