:root {
  --bg: #15110d;
  --card: #1e1811;
  --card-2: #271f17;
  --elev: #32271d;
  --accent: #c9955f;      /* caramel */
  --accent-soft: #e0b489; /* light amber */
  --accent-deep: #a06e42; /* bronze */
  --text: #efe7db;
  --muted: #a3927e;
  --line: #362b20;
  --danger: #cf6f5f;
  --grad: linear-gradient(120deg, #c9955f, #a06e42);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(201,149,95,.14), transparent 60%),
    radial-gradient(900px 500px at 90% 8%, rgba(160,110,66,.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; justify-content: center; align-items: center;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Device frame ---------- */
.app {
  position: relative;
  width: 100%; max-width: 400px;
  height: min(860px, 94vh);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 34px;
  box-shadow: 0 40px 100px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.03);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.app::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 90px;
  background: linear-gradient(180deg, rgba(201,149,95,.06), transparent);
  pointer-events: none; z-index: 0;
}

.view { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 26px 22px; z-index: 1;
  animation: viewIn .28s cubic-bezier(.2,.7,.3,1); }
.view.hidden, .hidden { display: none !important; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-view { justify-content: center; gap: 8px; }
.ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

/* ---------- Hero / brand ---------- */
.hero { text-align: center; margin-bottom: 24px; }
.logo {
  width: 74px; height: 74px; margin: 0 auto; border-radius: 21px;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 800; color: #fff; letter-spacing: -1px;
  box-shadow: 0 16px 36px rgba(160,110,66,.34), inset 0 1px 0 rgba(255,255,255,.18);
}
.brand { font-size: 31px; font-weight: 800; letter-spacing: -.4px; margin-top: 16px; color: var(--text); }
.brand.small { font-size: 22px; }
.brand.tiny { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.tag { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 12px 4px 0; }
.tag b { color: var(--accent-soft); font-weight: 600; }

.hero-form { width: 100%; }

/* ---------- Inputs ---------- */
label { display: block; font-size: 11px; color: var(--muted); margin: 14px 2px 8px; text-transform: uppercase; letter-spacing: .7px; font-weight: 600; }
.lbl-soft { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; }
input {
  width: 100%; padding: 15px 16px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #6f6151; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,149,95,.16); }
input.code { text-align: center; letter-spacing: 14px; font-size: 26px; font-weight: 700; padding-left: 14px; }

/* ---------- Buttons ---------- */
button { border: none; cursor: pointer; font-family: inherit; }
.primary {
  width: 100%; margin-top: 18px; padding: 15px; border-radius: 13px;
  background: var(--grad); color: #fff; font-size: 15.5px; font-weight: 700;
  box-shadow: 0 12px 28px rgba(160,110,66,.3); transition: transform .08s, filter .15s;
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: scale(.98); }
.primary.big { padding: 16px; font-size: 16px; box-shadow: 0 14px 32px rgba(160,110,66,.34); }
.link { background: none; color: var(--accent-soft); font-weight: 600; font-size: 13px; padding: 0; }
.link:hover { text-decoration: underline; }
.link.back { align-self: flex-start; position: absolute; top: 24px; left: 22px; }
.icon-btn {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; transition: background .15s;
}
.icon-btn:hover { background: var(--elev); }

.fineprint { color: var(--muted); font-size: 12px; margin-top: 20px; line-height: 1.6; text-align: center; }
.fineprint:nth-of-type(2) { margin-top: 10px; font-size: 11px; }
.fineprint a { color: var(--accent-soft); text-decoration: none; }
.fineprint a:hover { text-decoration: underline; }
.inline-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; text-align: center; }

/* ---------- Avatar ---------- */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar.xs { width: 34px; height: 34px; font-size: 14px; }

/* ---------- App header / footer ---------- */
.app-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); margin: -4px -22px 0; padding: 4px 22px 16px; }
.head-titles { flex: 1; min-width: 0; }
.head-sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-with { font-size: 16px; font-weight: 700; }

.scroll-body { flex: 1; overflow-y: auto; margin: 0 -22px; padding: 16px 22px; }
.scroll-body::-webkit-scrollbar { width: 0; }

.app-foot { border-top: 1px solid var(--line); margin: 0 -22px -4px; padding: 14px 22px 4px; }
.app-foot .primary { margin-top: 0; }

/* ---------- Nudge ---------- */
.nudge { display: flex; gap: 13px; align-items: center;
  background: linear-gradient(120deg, rgba(201,149,95,.14), rgba(160,110,66,.14));
  border: 1px solid rgba(201,149,95,.5); border-radius: 14px; padding: 14px 16px; font-size: 14px; margin-bottom: 20px; }
.nudge-eyes { font-size: 22px; }
.nudge-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Sections & lists ---------- */
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 12px; }
.section-head:first-child { margin-top: 0; }
.section-head h3 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.section-head .sub { color: var(--muted); font-size: 11.5px; }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.list li { display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; font-size: 14px; background: var(--card-2); }
.list li.empty { flex-direction: column; gap: 6px; color: var(--muted); text-align: center; padding: 26px 15px; border-style: dashed; }
.list li.empty .empty-emoji { font-size: 24px; opacity: .7; }
.list li.empty .empty-sub { font-size: 12px; opacity: .8; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-sub { color: var(--muted); font-size: 11.5px; }
.badge { font-size: 11px; padding: 5px 11px; border-radius: 20px; white-space: nowrap; font-weight: 600; }
.badge.pending { background: var(--elev); color: var(--muted); }
.badge.matched { background: var(--grad); color: #fff; }
.list li.match { cursor: pointer; border-color: rgba(201,149,95,.4); transition: background .15s, transform .08s; }
.list li.match:hover { background: var(--elev); }
.list li.match:active { transform: scale(.99); }
.withdraw { color: var(--muted); font-size: 12px; background: none; padding: 6px 8px; border-radius: 8px; }
.withdraw:hover { color: var(--danger); background: rgba(207,111,95,.1); }

.result { margin-top: 20px; font-size: 14px; line-height: 1.65; padding: 15px 16px; border-radius: 13px; }
.result.win { background: linear-gradient(120deg, rgba(201,149,95,.14), rgba(160,110,66,.14)); border: 1px solid rgba(201,149,95,.5); color: var(--accent-soft); }
.result.wait { background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.result b { color: var(--accent-soft); }

/* ---------- Chat ---------- */
.chat-head { gap: 10px; }
.menu { position: absolute; right: 20px; top: 70px; background: var(--elev); border: 1px solid var(--line); border-radius: 13px; padding: 6px; z-index: 6; box-shadow: 0 16px 40px rgba(0,0,0,.55); min-width: 140px; }
.menu-item { width: 100%; text-align: left; background: none; color: var(--text); font-size: 13.5px; padding: 10px 12px; border-radius: 9px; font-weight: 500; }
.menu-item:hover { background: var(--card-2); }
.menu-item.danger { color: var(--danger); }
.chat-log { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 17px; font-size: 14px; line-height: 1.45; word-wrap: break-word; animation: msgIn .2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }
.msg.them { background: var(--elev); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.me { background: var(--grad); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.chat-empty { color: var(--muted); text-align: center; font-size: 13.5px; margin: auto; line-height: 1.7; }
.chat-empty .big-heart { font-size: 34px; display: block; margin-bottom: 10px; opacity: .85; }
.composer { display: flex; gap: 10px; align-items: center; }
.composer input { margin: 0; border-radius: 22px; }
.composer button { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 50%; background: var(--grad); color: #fff; font-size: 16px; box-shadow: 0 8px 20px rgba(160,110,66,.3); }

/* ---------- Celebration ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,7,4,.86); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 50; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.celebrate-card { position: relative; text-align: center; background: var(--card); border: 1px solid rgba(201,149,95,.5); border-radius: 24px; padding: 36px 32px; width: 320px; box-shadow: 0 30px 80px rgba(160,110,66,.35); animation: pop .45s cubic-bezier(.2,1.5,.4,1); z-index: 2; }
@keyframes pop { from { transform: scale(.7); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.celebrate-emoji { font-size: 54px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.07)} }
.celebrate-title { font-size: 27px; font-weight: 800; margin: 12px 0; color: var(--accent-soft); letter-spacing: -.3px; }
.celebrate-body { color: var(--text); font-size: 15px; margin-bottom: 24px; }
.celebrate-body b { color: var(--accent-soft); }
.hearts { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.hearts span { position: absolute; bottom: -30px; color: var(--accent); animation: rise linear forwards; }
@keyframes rise { to { transform: translateY(-110vh) rotate(180deg); opacity: 0; } }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: var(--elev); border: 1px solid var(--line); color: var(--text); padding: 13px 20px; border-radius: 30px; font-size: 13.5px; z-index: 60; box-shadow: 0 14px 34px rgba(0,0,0,.5); animation: toastIn .25s cubic-bezier(.2,1.3,.4,1); max-width: 340px; text-align: center; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast b { color: var(--accent-soft); font-size: 16px; letter-spacing: 2px; }
