:root {
  --bg: #0b1220;
  --bg-2: #0f1a2e;
  --card: #15213a;
  --card-2: #1b2a48;
  --line: #24345a;
  --text: #eef2fb;
  --muted: #8b9bbd;
  --green: #22c55e;
  --green-d: #16a34a;
  --red: #f87171;
  --gold: #f5c542;
  --blue: #60a5fa;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --display: 'Bricolage Grotesque', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -200px, #14305a 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.num { font-variant-numeric: tabular-nums; }

#app { max-width: 520px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 16px calc(var(--safe-b) + 110px); }

/* ----------------------------------------------------------- tipografi */
h1, h2, h3, .display { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 26px 2px 10px; font-family: var(--body); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ----------------------------------------------------------- butonlar */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 20px;
  border-radius: 16px; font-weight: 700; font-size: 17px;
  background: var(--card-2); border: 1px solid var(--line);
  transition: transform .08s ease, filter .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #2bd46a, var(--green-d)); border-color: transparent; color: #04140a; box-shadow: 0 8px 24px -10px #22c55e99; }
.btn.gold { background: linear-gradient(180deg, #ffd95e, #e0a91f); border-color: transparent; color: #241800; }
.btn.danger { background: transparent; color: var(--red); border-color: #f8717155; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 42px; font-size: 15px; border-radius: 12px; padding: 0 14px; width: auto; }
.btn .ico { font-size: 22px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack { display: grid; gap: 12px; }

/* ----------------------------------------------------------- ana sayfa */
.hero { text-align: center; padding: 8vh 0 6vh; }
.logo {
  width: 92px; height: 92px; margin: 0 auto 22px; border-radius: 26px;
  background: linear-gradient(160deg, #2bd46a, #128a3e);
  display: grid; place-items: center; font-size: 50px;
  box-shadow: 0 20px 50px -15px #22c55e88, inset 0 2px 0 #ffffff40;
  transform: rotate(-6deg);
}
.hero h1 { font-size: 40px; font-weight: 800; line-height: 1; }
.hero h1 span { color: var(--gold); }
.hero p { color: var(--muted); margin: 12px 0 0; font-size: 16px; }

.resume {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px;
  text-align: left; width: 100%;
}
.resume b { font-family: var(--display); font-size: 18px; }

/* ----------------------------------------------------------- formlar */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; min-height: 44px; }
.topbar h2 { flex: 1; }
.back { width: 44px; height: 44px; border-radius: 12px; background: var(--card); display: grid; place-items: center; font-size: 20px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; height: 56px; padding: 0 16px; border-radius: 14px;
  background: var(--bg-2); border: 1.5px solid var(--line); color: var(--text);
  font-size: 18px; font-weight: 600; outline: none;
}
.input:focus { border-color: var(--green); }
.input.code { text-align: center; font-family: var(--display); font-size: 34px; letter-spacing: .35em; text-transform: uppercase; height: 72px; padding-left: calc(16px + .35em); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--bg-2); border-radius: 16px; border: 1px solid var(--line); }
.seg button { min-height: 52px; border-radius: 12px; font-weight: 700; font-size: 15px; color: var(--muted); line-height: 1.2; }
.seg button.on { background: var(--card-2); color: var(--text); box-shadow: 0 2px 8px #0005; }
.emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emojis button { aspect-ratio: 1; border-radius: 14px; background: var(--bg-2); border: 1.5px solid var(--line); font-size: 26px; }
.emojis button.on { border-color: var(--gold); background: #f5c54222; }
.err { color: var(--red); font-weight: 600; min-height: 20px; margin: 4px 2px 12px; font-size: 14px; }

/* ----------------------------------------------------------- lobi */
.codebox { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 22px 18px; }
.codebox .qr { width: min(64vw, 260px); aspect-ratio: 1; margin: 0 auto 16px; background: #fff; border-radius: 18px; padding: 10px; }
.codebox .qr img { width: 100%; height: 100%; display: block; }
.codebox .code { font-family: var(--display); font-size: 46px; font-weight: 800; letter-spacing: .25em; padding-left: .25em; color: var(--gold); line-height: 1; }

.plist { display: grid; gap: 8px; }
.pitem { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.pitem .name { flex: 1; font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 24px; position: relative;
  background: color-mix(in srgb, var(--c, #888) 22%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c, #888) 70%, transparent);
}
.avatar.lg { width: 56px; height: 56px; font-size: 30px; border-radius: 18px; }
.avatar.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 10px; }
.dot { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; background: #64748b; border: 2.5px solid var(--card); }
.dot.on { background: var(--green); }
.tag { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: var(--card-2); color: var(--muted); }
.tag.gold { background: #f5c54222; color: var(--gold); }

/* ----------------------------------------------------------- oyun üst bar */
.gbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gbar .gcode { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: .12em; color: var(--gold); }
.gbar .conn { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.gbar .conn.off { background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1s infinite; }
.gbar .sp { flex: 1; }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 19px; }
@keyframes blink { 50% { opacity: .3; } }

/* ----------------------------------------------------------- bakiye kartı */
.wallet {
  position: relative; overflow: hidden; border-radius: 26px; padding: 22px 22px 20px;
  background:
    radial-gradient(400px 200px at 110% -20%, color-mix(in srgb, var(--c) 55%, transparent), transparent 70%),
    linear-gradient(160deg, #1d2d50, #121c33);
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line));
  box-shadow: 0 24px 50px -24px color-mix(in srgb, var(--c) 60%, transparent);
}
.wallet .who { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.wallet .lbl { margin-top: 18px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.wallet .bal { font-family: var(--display); font-weight: 800; font-size: clamp(44px, 14vw, 64px); line-height: 1.05; letter-spacing: -0.03em; }
.wallet .bal.neg { color: var(--red); }
.wallet .bal small { font-size: .5em; color: var(--gold); margin-right: 4px; vertical-align: .35em; }
.bump { animation: bump .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.qbtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; text-align: left; min-height: 86px;
  transition: transform .08s;
}
.qbtn:active { transform: scale(.96); }
.qbtn .ico { font-size: 24px; }
.qbtn b { font-size: 15px; }
.qbtn span { font-size: 12px; color: var(--muted); }
.qbtn.wide { grid-column: span 2; flex-direction: row; align-items: center; min-height: 64px; }
.qbtn.wide b { flex: 1; }
.qbtn.go { background: linear-gradient(160deg, #1f3d2c, #15281f); border-color: #22c55e55; }

.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pcard {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; transition: transform .08s;
}
.pcard:active { transform: scale(.96); }
.pcard .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .b { font-family: var(--display); font-weight: 700; font-size: 20px; }

/* ----------------------------------------------------------- istek bandı */
.reqs { display: grid; gap: 10px; margin-bottom: 14px; }
.req {
  padding: 14px; border-radius: 18px; background: linear-gradient(160deg, #3a2a0a, #2a1f0b);
  border: 1.5px solid #f5c54288; animation: pulse 2s infinite;
}
.req.mine { background: var(--card); border: 1px dashed var(--line); animation: none; }
.req .t { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.req .t .txt { flex: 1; font-size: 15px; line-height: 1.35; min-width: 0; }
.req .amt { font-family: var(--display); font-weight: 800; font-size: 24px; color: var(--gold); white-space: nowrap; }
.req.mine .amt { color: var(--text); font-size: 18px; }
.req.mine .t { margin-bottom: 0; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px #f5c54222; } }

/* ----------------------------------------------------------- kasa */
.bankrow { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.bankrow .info { flex: 1; min-width: 0; }
.bankrow .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bankrow .b { font-family: var(--display); font-weight: 700; font-size: 18px; }
.bankrow .acts { display: flex; gap: 6px; }
.bankrow .acts button { width: 46px; height: 46px; border-radius: 13px; font-weight: 800; font-size: 13px; }
.a-give { background: #22c55e22; color: var(--green); border: 1px solid #22c55e55 !important; }
.a-take { background: #f8717122; color: var(--red); border: 1px solid #f8717155 !important; }
.a-go { background: #f5c54222; color: var(--gold); border: 1px solid #f5c54255 !important; }

/* ----------------------------------------------------------- akış */
.feed { display: grid; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.fitem { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); }
.fitem + .fitem { border-top: 1px solid #ffffff0a; }
.fitem .mid { flex: 1; min-width: 0; }
.fitem .line1 { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fitem .line2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fitem .amt { font-family: var(--display); font-weight: 700; font-size: 17px; white-space: nowrap; }
.fitem .amt.in { color: var(--green); }
.fitem .amt.out { color: var(--red); }
.fitem.undone { opacity: .4; }
.fitem.undone .amt { text-decoration: line-through; }
.fitem .undo { font-size: 12px; font-weight: 700; padding: 7px 9px; border-radius: 9px; background: var(--card-2); color: var(--muted); }
.arrow { color: var(--muted); font-weight: 400; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ----------------------------------------------------------- alt menü */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px);
  width: min(488px, calc(100% - 32px)); display: flex; gap: 4px; padding: 6px;
  background: #0f1a2ee6; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; z-index: 10;
  box-shadow: 0 12px 30px -10px #000a;
}
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 16px; font-size: 11px; font-weight: 700; color: var(--muted); position: relative; }
.tabs button .ico { font-size: 21px; filter: grayscale(1); opacity: .7; }
.tabs button.on { background: var(--card-2); color: var(--text); }
.tabs button.on .ico { filter: none; opacity: 1; }
.tabs .badge { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold); color: #241800; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }

/* ----------------------------------------------------------- alt sayfa (sheet) */
.scrim { position: fixed; inset: 0; background: #000a; z-index: 20; animation: fade .2s; }
.panel {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 21;
  width: min(520px, 100%); max-height: 94dvh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 28px 28px 0 0; padding: 10px 16px calc(var(--safe-b) + 16px);
  animation: up .25s cubic-bezier(.2, .9, .3, 1);
}
.panel .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.panel .ph { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.panel .ph h2 { flex: 1; font-size: 20px; line-height: 1.2; }
@keyframes up { from { transform: translate(-50%, 100%); } }
@keyframes fade { from { opacity: 0; } }

.amount { text-align: center; padding: 10px 0 4px; }
.amount .v { font-family: var(--display); font-weight: 800; font-size: 54px; line-height: 1.1; letter-spacing: -0.03em; min-height: 60px; }
.amount .v small { font-size: .5em; color: var(--gold); margin-right: 4px; vertical-align: .35em; }
.amount .v.zero { color: #ffffff30; }
.amount .hint { font-size: 13px; color: var(--muted); min-height: 18px; }
.amount .hint.bad { color: var(--red); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.chip.on { background: #f5c54226; border-color: var(--gold); color: var(--gold); }
.chip.add { color: var(--green); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.keypad button { height: 58px; border-radius: 16px; background: var(--card); font-family: var(--display); font-size: 26px; font-weight: 700; transition: transform .06s, background .1s; }
.keypad button:active { transform: scale(.94); background: var(--card-2); }

.choice { display: grid; gap: 10px; margin-top: 8px; }

/* ----------------------------------------------------------- bildirimler */
#toasts { position: fixed; top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%); width: min(488px, calc(100% - 32px)); z-index: 40; display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px;
  background: #1b2a48f2; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: 0 14px 30px -10px #000c; font-weight: 600; font-size: 15px;
  animation: drop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.toast.in { border-color: #22c55e88; background: #0f2f1ef2; }
.toast.out { border-color: #f8717166; }
.toast.req { border-color: #f5c542aa; background: #33270cf2; }
.toast.err { border-color: #f87171aa; background: #3a1414f2; }
.toast .ico { font-size: 24px; }
.toast .big { font-family: var(--display); font-weight: 800; font-size: 20px; margin-left: auto; white-space: nowrap; }
.toast.hide { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes drop { from { opacity: 0; transform: translateY(-20px) scale(.95); } }

/* ----------------------------------------------------------- istatistik */
.winner { text-align: center; padding: 22px; border-radius: 24px; background: linear-gradient(160deg, #3d2f08, #1f1a0c); border: 1px solid #f5c54266; margin-bottom: 6px; }
.winner .crown { font-size: 44px; }
.winner .avatar { margin: 8px auto; }
.winner h2 { font-size: 26px; }
.podium { display: grid; gap: 8px; }
.podium .pitem .rank { font-family: var(--display); font-weight: 800; font-size: 20px; width: 26px; text-align: center; color: var(--muted); }
.podium .pitem:first-child .rank { color: var(--gold); }
.podium .pitem .b { font-family: var(--display); font-weight: 700; font-size: 18px; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 10px 10px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 6px 2px; font-size: 13px; font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.award { padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.award .ico { font-size: 26px; }
.award .t { font-size: 12px; color: var(--muted); font-weight: 700; margin: 6px 0 4px; text-transform: uppercase; letter-spacing: .05em; }
.award .w { font-weight: 700; font-size: 15px; }
.award .v { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--gold); margin-top: 2px; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 18px; overflow: hidden; font-size: 14px; }
.table th, .table td { padding: 11px 8px; text-align: right; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--card-2); }
.table th:first-child, .table td:first-child { text-align: left; padding-left: 14px; }
.table td:last-child, .table th:last-child { padding-right: 14px; }
.table tr + tr td { border-top: 1px solid #ffffff0a; }

.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #f8717122; border: 1px solid #f8717155; color: #fecaca; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.spin { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 30vh auto 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
