/* هندنا — ByHamad4 · diwaniya night: black, deep green & gold */
:root {
  color-scheme: dark;
  --bg: #070B08; --text: #F4EFE2; --muted: #A9ADA0; --faint: #6F746B;
  --line: rgba(212,175,55,.22); --line2: rgba(255,255,255,.07);
  --gold: #D4AF37; --gold2: #F6DC86; --goldtext: #E8C766; --goldgrad: linear-gradient(180deg, #FBE7A1 0%, #E1BD55 45%, #B8862A 100%);
  --green: #3DDC84; --greenbg: rgba(26,120,70,.28); --greenline: rgba(61,220,132,.55);
  --red: #FF5A66; --redbg: rgba(150,30,40,.35); --redline: rgba(255,90,102,.6);
  --amber: #F2B84B;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tabbar: 74px;
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.small { font-size: 12px; }
.center { text-align: center; }
.heart { color: var(--red); font-weight: 400; }
.title { font-family: 'Lalezar', 'IBM Plex Sans Arabic', sans-serif; font-weight: 400; margin: 0; font-size: 24px; color: var(--goldtext); }

/* Background: warm diwaniya night */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(520px 360px at 50% -5%, rgba(212,175,55,.16), transparent 70%),
    radial-gradient(420px 420px at 100% 35%, rgba(120,70,20,.22), transparent 70%),
    radial-gradient(420px 420px at 0% 70%, rgba(20,90,55,.28), transparent 70%),
    repeating-linear-gradient(45deg, rgba(212,175,55,.025) 0 2px, transparent 2px 22px),
    #070B08;
}
.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 14px calc(var(--tabbar) + var(--safe-b) + 28px); }
#screen-home, #screen-end { padding-bottom: 0; }

/* Header */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; padding: 2px 0 8px; }
.brand { text-align: center; line-height: 1; }
.logo { font-family: 'Lalezar', sans-serif; font-size: 58px; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0,0,0,.6)) drop-shadow(0 0 18px rgba(212,175,55,.25)); }
.tag { font-family: 'Lalezar', sans-serif; font-size: 20px; color: var(--goldtext); margin-top: 2px; }
.side { font-size: 12px; color: var(--goldtext); display: flex; align-items: center; gap: 6px; line-height: 1.35; opacity: .9; }
.side-r { justify-content: flex-start; }
.side-l { justify-content: flex-end; flex-direction: column; align-items: flex-end; text-align: center; }
.suit { font-size: 22px; color: var(--gold); }

/* Panels */
.panel {
  position: relative; margin-top: 12px; padding: 16px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(30,36,31,.88), rgba(14,18,15,.92));
  border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05);
}
.panel-head { display: flex; justify-content: center; }
.pill-title {
  font-family: 'Lalezar', sans-serif; font-weight: 400; margin: 0; font-size: 28px; padding: 6px 28px 2px; border-radius: 999px;
  background: rgba(0,0,0,.45); border: 1px solid var(--line); color: var(--goldtext); box-shadow: inset 0 0 20px rgba(212,175,55,.08);
}
.board-panel { padding-top: 18px; overflow: visible; }
.deco-cards { position: absolute; top: 10px; right: 12px; width: 70px; height: 54px; pointer-events: none; }
.pc {
  position: absolute; width: 34px; height: 46px; border-radius: 6px; background: linear-gradient(160deg, #FFF8E6, #E7DAB8);
  color: #1A1A1A; font-weight: 800; font-size: 12px; padding: 3px 5px; box-shadow: 0 4px 10px rgba(0,0,0,.5); line-height: 1;
}
.pc i { display: block; font-style: normal; font-size: 18px; text-align: center; margin-top: 4px; }
.pc1 { right: 18px; transform: rotate(-12deg); }
.pc2 { right: 0; top: 4px; transform: rotate(10deg); color: #C0262D; }
.deco-note { position: absolute; top: 12px; left: 14px; font-size: 11px; color: var(--goldtext); text-align: center; line-height: 1.3; opacity: .85; }
#roundPill { color: var(--goldtext); font-weight: 600; }

/* Board */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 26px; }
.pcard {
  position: relative; border-radius: 16px; padding: 20px 4px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: linear-gradient(180deg, rgba(40,46,41,.9), rgba(18,22,19,.95)); border: 1px solid var(--line2);
}
.rank-badge {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; background: #2A2F2A; border: 1px solid var(--line); color: var(--text);
}
.pcard .crown { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); font-size: 26px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.pcard.r1 .rank-badge { background: var(--goldgrad); color: #2A1E05; top: -10px; left: auto; right: -6px; transform: none; }
.pcard .pname { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; line-height: 1.2; }
.pcard .ptotal { font-family: 'Lalezar', sans-serif; font-size: 30px; line-height: 1.1; direction: ltr; }
.pcard .status { font-size: 12px; font-weight: 700; line-height: 1.25; }
.pcard .sub2 { font-size: 11px; color: var(--muted); line-height: 1.25; }
.pcard .bar { width: 40%; height: 3px; border-radius: 2px; margin-top: 6px; background: var(--faint); }
.pcard.r1 { border-color: var(--greenline); background: linear-gradient(180deg, rgba(26,90,56,.55), rgba(12,30,20,.95)); box-shadow: 0 0 22px rgba(61,220,132,.18); }
.pcard.r1 .ptotal, .pcard.r1 .status { color: var(--green); } .pcard.r1 .bar { background: var(--green); }
.pcard.r3 .bar { background: var(--amber); }
.pcard.r4 { border-color: var(--redline); background: linear-gradient(180deg, rgba(120,24,32,.55), rgba(34,10,12,.95)); box-shadow: 0 0 22px rgba(255,90,102,.18); }
.pcard.r4 .ptotal, .pcard.r4 .status { color: var(--red); } .pcard.r4 .bar { background: var(--red); }
.pcard.fresh { border-color: var(--line2); background: linear-gradient(180deg, rgba(40,46,41,.9), rgba(18,22,19,.95)); box-shadow: none; }
.pcard.fresh .ptotal { color: var(--text); }
.pcard.fresh .status, .pcard.fresh .sub2, .pcard.fresh .crown { visibility: hidden; }

/* Banners */
.banners { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.banner-chip { border-radius: 16px; padding: 10px 12px; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 6px; line-height: 1.35; }
.banner-chip .emo { font-size: 22px; flex-shrink: 0; }
.banner-chip.win { background: var(--greenbg); border: 1px solid var(--greenline); }
.banner-chip.lose { background: var(--redbg); border: 1px solid var(--redline); }

/* Record card */
.rec-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; text-align: center; margin-bottom: 4px; }
.plus-badge { width: 40px; height: 40px; border-radius: 50%; background: var(--goldgrad); color: #2A1E05; font-size: 26px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 6px 14px rgba(212,175,55,.3); }
.mini-cards { position: relative; width: 48px; height: 46px; }
.mini-cards .pc { width: 26px; height: 36px; font-size: 10px; } .mini-cards .pc i { font-size: 13px; margin-top: 2px; }
.mini-cards .pc2 { color: #1A1A1A; }
.record .step { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line2); }
.step-label { font-size: 13px; color: var(--goldtext); margin-bottom: 8px; font-weight: 700; }
.hint { font-weight: 500; color: var(--muted); font-size: 12px; }
.choices { display: flex; flex-wrap: wrap; gap: 7px; }
.choices.four { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  min-height: 48px; padding: 7px 10px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35); font-weight: 700; font-size: 15px; flex: 1 1 auto; overflow-wrap: anywhere;
}
.choice[aria-pressed="true"] { background: var(--goldgrad); color: #2A1E05; border-color: transparent; font-weight: 800; box-shadow: 0 6px 14px rgba(212,175,55,.22); }
.choice:disabled { opacity: .3; }
.choice .sub { display: block; font-size: 11px; font-weight: 500; opacity: .75; }
.choice.wide { grid-column: 1 / -1; }
.choice.zat[aria-pressed="false"] { border-color: rgba(212,175,55,.55); color: var(--goldtext); }
.downs { display: flex; flex-direction: column; gap: 7px; }
.down-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; align-items: center; }
.down-row .choice { width: 100%; }
.down-off { font-size: 13px; color: var(--faint); text-align: center; }
.cards { height: 48px; width: 100%; padding: 0 12px; border-radius: 14px; border: 1px solid var(--gold); background: rgba(0,0,0,.45); color: var(--text); font-size: 18px; text-align: center; }
.cards:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.preview-box { margin-top: 14px; padding: 10px; border-radius: 16px; background: rgba(0,0,0,.3); border: 1px solid var(--line2); }
.preview-title { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; min-height: 52px; }
.preview .pv { text-align: center; font-size: 12px; padding: 6px 2px; border-radius: 12px; background: rgba(255,255,255,.04); overflow-wrap: anywhere; }
.preview .pv small { display: block; font-size: 10px; color: var(--goldtext); }
.preview .pv b { display: block; margin-top: 3px; font-size: 16px; direction: ltr; border-radius: 8px; padding: 2px 0; }
.preview .pv b.good { background: rgba(61,220,132,.16); }
.preview .pv b.bad { background: rgba(255,90,102,.16); }
.preview .note { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--goldtext); font-weight: 600; font-size: 13px; }
.good { color: var(--green); }
.bad { color: var(--red); }

.record-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 14px; }
.record-row .btn.big { margin-top: 0; }
.story { font-size: 12px; color: var(--goldtext); text-align: center; line-height: 1.3; }
.btn-suit { font-size: 20px; margin-inline-end: 6px; }

/* Buttons */
.btn { min-height: 50px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--line); background: rgba(0,0,0,.3); font-weight: 700; }
.btn.big { width: 100%; min-height: 58px; font-size: 22px; margin-top: 14px; }
.btn.gold { font-family: 'Lalezar', 'IBM Plex Sans Arabic', sans-serif; font-weight: 400; font-size: 20px; background: var(--goldgrad); color: #2A1E05; border: 1px solid #F6DC86; box-shadow: 0 10px 24px rgba(212,175,55,.28), inset 0 1px 0 rgba(255,255,255,.5); }
.btn.gold:disabled { opacity: .35; box-shadow: none; }
.btn.ghost { background: rgba(0,0,0,.25); }
.btn.danger { color: var(--red); border-color: rgba(255,90,102,.4); }
.btn:active:not(:disabled) { transform: scale(.98); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.row-actions .btn { flex: 1 1 auto; }
.settings-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.settings-list .btn { text-align: start; padding: 0 16px; }

/* Home */
.names { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.field input { height: 50px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.4); font-size: 17px; color: var(--text); }
.field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.resume { border-color: rgba(212,175,55,.6); }
.hist { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.hist li { font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.3); }
.hist li b { color: var(--text); }

/* Rounds table */
.rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtable th, .rtable td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--line2); }
.rtable th { color: var(--goldtext); font-weight: 700; font-size: 12px; overflow-wrap: anywhere; }
.rtable td { direction: ltr; }
.rtable td.n { color: var(--muted); }
.rtable tfoot td { font-family: 'Lalezar', sans-serif; font-size: 18px; border-bottom: 0; color: var(--goldtext); }
.rtable .won { color: var(--green); font-weight: 700; }
.rtable tbody tr { cursor: pointer; }
.rtable tbody tr:active, .rtable tbody tr:focus-visible { background: rgba(212,175,55,.12); outline: none; }
.rtitle { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.rtitle h3 { margin: 0; font-family: 'Lalezar', sans-serif; font-weight: 400; font-size: 22px; color: var(--goldtext); }

/* Result */
.result { text-align: center; }
.result .trophy { font-size: 46px; }
.result h2 { font-family: 'Lalezar', sans-serif; font-weight: 400; font-size: 30px; margin: 4px 0; color: var(--goldtext); }
.result .winner-name { font-family: 'Lalezar', sans-serif; font-size: 40px; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.podium { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.podium li { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: rgba(0,0,0,.3); border: 1px solid var(--line2); }
.podium li.first { border-color: var(--greenline); background: var(--greenbg); }
.podium li.last { border-color: var(--redline); }
.podium .t { direction: ltr; font-weight: 700; }

/* Tab bar */
.tabbar {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b));
  width: min(532px, calc(100% - 28px)); height: var(--tabbar); border-radius: 24px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px;
  background: linear-gradient(180deg, rgba(34,38,34,.96), rgba(14,16,14,.98)); border: 1px solid var(--line); box-shadow: 0 -6px 30px rgba(0,0,0,.5);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 18px; }
.tab.on { color: var(--goldtext); background: rgba(212,175,55,.1); box-shadow: inset 0 2px 0 var(--gold); }

/* Quip overlay */
.quip { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(3,5,4,.75); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s ease; }
.quip-card { width: min(440px, 100%); text-align: center; padding: 26px 20px 20px; border-radius: 28px; background: linear-gradient(160deg, rgba(34,40,34,.98), rgba(8,10,9,.98)); border: 1px solid rgba(212,175,55,.55); box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.quip-name { color: var(--muted); font-weight: 700; }
.quip-title { font-family: 'Lalezar', sans-serif; font-size: 48px; line-height: 1.2; margin: 4px 0 8px; background: var(--goldgrad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.quip-line { font-size: 21px; font-weight: 700; margin: 0 0 16px; line-height: 1.5; }
.quip-deltas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.quip-deltas b { direction: ltr; display: inline-block; }
.quip-card .btn { width: 100%; font-size: 22px; }
.quip.zat .quip-card { background: radial-gradient(circle at 50% 0%, rgba(212,175,55,.35), rgba(8,10,9,.98) 65%); border-width: 2px; }
.quip.zat .quip-title { font-size: 60px; }
.quip.zat .quip-line { font-size: 24px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Edit sheet */
dialog.sheet {
  border: 1px solid rgba(212,175,55,.5); padding: 0; width: min(560px, 100%); max-width: 100%;
  margin: auto auto 0; border-radius: 28px 28px 0 0; color: var(--text);
  background: linear-gradient(180deg, rgba(34,40,34,.99), rgba(10,12,11,.99)); box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
dialog.sheet::backdrop { background: rgba(3,5,4,.65); }
.sheet-body { padding: 22px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.edit-rows { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px 120px; gap: 8px; align-items: center; font-weight: 700; }
.edit-row input { height: 50px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.4); color: var(--text); font-size: 18px; text-align: center; width: 100%; }
.sign { height: 50px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.3); font-size: 20px; font-weight: 800; color: var(--goldtext); }

/* Banner & toast */
.banner { padding: 12px 14px; border-radius: 16px; margin-top: 8px; font-size: 13px; border: 1px solid var(--redline); background: var(--redbg); }
#toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--tabbar) + 22px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #F4EFE2; color: #070B08; padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 700; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: #0F6B3A; font-weight: 800; margin-inline-start: 8px; min-height: 32px; }

@media (max-width: 370px) { .logo { font-size: 48px; } .side { font-size: 10px; } .pcard .ptotal { font-size: 25px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
