/* Vazirmatn (SIL Open Font License, see /fonts/OFL.txt): one Persian and Latin typeface on every phone. */
@font-face { font-family: Vazirmatn; src: url('/fonts/vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0a0a0a; --tile: #111; --tile2: #181818; --line: #2a2a2a; --line2: #3a3a3a;
  --text: #f6f6f6; --dim: #8f8f8f; --red: #eb0d3f; --red2: #b80a31; --green: #2fd08a; --amber: #f2b13c;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font-family: Vazirmatn, "IRANSansX", "Segoe UI", system-ui, -apple-system, Roboto, Tahoma, sans-serif;
  font-size: 16px; line-height: 1.65;
}
main {
  max-width: 560px; margin: 0 auto; display: grid; gap: 8px;
  padding: 8px 8px calc(40px + env(safe-area-inset-bottom));
  padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
}
#colL, #colR { display: grid; gap: 8px; align-content: start; min-width: 0; }

/* Tiles: the whole page is a grid of bordered black tiles. */
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; position: relative; overflow: hidden; }
.tile.hot { border-color: var(--red); background: linear-gradient(160deg, #1d0a10 0%, var(--tile) 55%); }
.lbl { font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.lbl.red { color: var(--red); }
.lbl::before { content: ""; width: 7px; height: 7px; border: 1.5px solid var(--red); flex: none; }
.lbl.plain::before { display: none; }
h1 { font-size: 1rem; margin: 0; font-weight: 800; line-height: 1.3; }
.sub { color: var(--dim); font-size: .78rem; }
.small { font-size: .8rem; color: var(--dim); }
.hide { display: none !important; }
.empty { color: var(--dim); padding: 10px 0; font-size: .9rem; }
.msg { color: var(--red); min-height: 1.5em; font-size: .88rem; margin: 4px 0; }
.msg.ok { color: var(--green); }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ball { width: 30px; height: 30px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #ff5d7f, var(--red) 55%, #6b0519); }
.topbtns { display: flex; align-items: center; gap: 6px; flex: none; }
.hero { font-size: clamp(2.2rem, 12vw, 3.6rem); font-weight: 900; line-height: 1.05; margin: 18px 0 6px; letter-spacing: -.02em; }
.hero-sub { color: var(--dim); margin-bottom: 18px; }

/* Buttons */
button { font: inherit; color: var(--text); background: var(--tile2); border: 1px solid var(--line2); border-radius: 99px; padding: 10px 18px; cursor: pointer; font-weight: 700; min-height: 44px; }
button:active { transform: scale(.98); }
button:disabled { opacity: .4; cursor: default; }
button.red { background: var(--red); border-color: var(--red); color: #fff; }
button.ghost { background: transparent; color: var(--dim); font-weight: 500; }
button.sm { min-height: 40px; padding: 6px 14px; font-size: .84rem; }
button:focus-visible, a:focus-visible, .pick .row:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
button.danger { border-color: var(--red2); color: #ff6f8f; background: transparent; }
/* The main action: a red pill with a circled arrow at its end. */
button.pill { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--red); border-color: var(--red); color: #fff; font-size: 1.05rem; font-weight: 800; padding-block: 7px; padding-inline: 22px 7px; min-height: 58px; text-align: start; }
button.pill::after { content: ""; width: 42px; height: 42px; flex: none; border-radius: 50%; border: 1.5px solid #0009; background: no-repeat center / 16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 12 12 4M5.5 4H12v6.5' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E"); }
[dir="rtl"] button.pill::after { transform: scaleX(-1); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > button { flex: 1; }

/* Forms */
input { font: inherit; width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line2); background: #0a0a0a; color: var(--text); margin-bottom: 12px; }
input:focus { outline: 2px solid var(--red); outline-offset: 1px; }
label { display: block; font-size: .8rem; color: var(--dim); margin-bottom: 4px; }
.tabs { display: flex; gap: 18px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-radius: 0; padding: 8px 0; color: var(--dim); font-weight: 600; min-height: 40px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--red); }

/* Rows */
.av { width: 36px; height: 36px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; background: var(--tile2); border: 1px solid var(--line2); flex: none; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.me { background: linear-gradient(90deg, #eb0d3f22, transparent); margin-inline: -16px; padding-inline: 16px; }
.pos { width: 26px; text-align: center; font-weight: 900; color: var(--dim); flex: none; font-variant-numeric: tabular-nums; }
.pos.p1 { color: var(--red); font-size: 1.25rem; }
.val { font-weight: 900; font-size: 1.2rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.up { color: var(--green); } .down { color: #ff5d7f; }
.score { font-weight: 900; white-space: nowrap; font-size: 1.05rem; display: inline-flex; gap: .35em; vertical-align: middle; font-variant-numeric: tabular-nums; }
.score.res { font-size: 2.6rem; line-height: 1.1; }
.chip { display: inline-block; font-size: .7rem; padding: 1px 9px; border-radius: 99px; border: 1px solid var(--line2); color: var(--dim); white-space: nowrap; margin-inline-end: 4px; }
.chip.warn { border-color: #6b5320; color: var(--amber); } .chip.bad { border-color: var(--red2); color: #ff6f8f; } .chip.good { border-color: #1f6b4a; color: var(--green); }

/* My numbers */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { min-width: 0; }
.stats b { display: block; font-size: clamp(1.3rem, 7vw, 2rem); font-weight: 900; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stats span { font-size: .72rem; color: var(--dim); }

/* The match tile */
.vs { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: center; margin: 4px 0 14px; }
.vs .side { flex: 1; min-width: 0; }
.vs .av { width: 54px; height: 54px; font-size: 1.4rem; border-radius: 12px; margin-bottom: 6px; }
.vs .mid { flex: none; min-width: 96px; }
.timer { font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums; direction: ltr; line-height: 1.1; letter-spacing: -.02em; }
.vsmark { font-weight: 900; color: var(--red); font-size: 1.3rem; letter-spacing: .1em; }
.stakes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stakes div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; font-size: .72rem; color: var(--dim); }
.stakes b { display: block; font-size: 1.3rem; font-weight: 900; color: var(--text); direction: ltr; }
.stakes b.up { color: var(--green); } .stakes b.down { color: #ff5d7f; }
/* Five start lights, the "this match is live" signal. */
.lights { display: inline-flex; gap: 5px; margin-inline-start: auto; }
.lights i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--red); animation: light 2.5s infinite; }
.lights i:nth-child(2) { animation-delay: .25s; } .lights i:nth-child(3) { animation-delay: .5s; } .lights i:nth-child(4) { animation-delay: .75s; } .lights i:nth-child(5) { animation-delay: 1s; }
@keyframes light { 0%, 15% { background: transparent; } 25%, 80% { background: var(--red); } 90%, 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .lights i { animation: none; background: var(--red); } }
.center { text-align: center; }

.pick { max-height: 236px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; padding: 0 12px; background: #0a0a0a; -webkit-overflow-scrolling: touch; }
.pick .row { cursor: pointer; min-height: 52px; }
.pick .row.sel { background: #eb0d3f26; margin-inline: -12px; padding-inline: 12px; }
.pick .row.sel .av { border-color: var(--red); }
.pick .row.off { opacity: .4; cursor: default; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-bottom: 16px; }
.tables button { border-radius: 10px; padding: 0; min-height: 52px; font-size: 1.15rem; font-weight: 900; }
.tables button.sel { background: var(--red); border-color: var(--red); }
.stepper { display: flex; align-items: center; gap: 4px; justify-content: center; }
.stepper button { width: 44px; height: 48px; min-height: 0; padding: 0; font-size: 1.4rem; flex: none; border-radius: 12px; }
.stepper span { font-size: 2.3rem; font-weight: 900; min-width: 1.2em; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.two label { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#net { position: fixed; inset-inline: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--red2); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: .85rem; text-align: center; z-index: 5; }

/* Wide screens: two columns of tiles. */
@media (min-width: 900px) {
  main { max-width: 1080px; grid-template-columns: 1fr 1fr; align-items: start; }
  .top { grid-column: 1 / -1; }
}

/* Club TV */
body.tv main { max-width: none; grid-template-columns: 3fr 2fr; align-items: start; padding: 1vw; gap: .8vw; font-size: 1.5vw; }
body.tv #colL, body.tv #colR { gap: .8vw; }
body.tv .top { grid-column: 1 / -1; padding: 1.2vw 1.6vw; }
body.tv .tile { padding: 1.4vw 1.6vw; }
body.tv h1 { font-size: 2.2vw; } body.tv .sub { font-size: 1.2vw; } body.tv .lbl { font-size: 1vw; } body.tv .small { font-size: 1.05vw; }
body.tv .notv { display: none !important; }
body.tv .ball { width: 3vw; height: 3vw; }
body.tv .av { width: 2.8vw; height: 2.8vw; font-size: 1.3vw; }
body.tv .pos { width: 2.4vw; } body.tv .pos.p1 { font-size: 2.2vw; }
body.tv .val { font-size: 2.2vw; } body.tv .score { font-size: 1.8vw; } body.tv .chip { font-size: 1vw; }
body.tv .row { padding: .55vw 0; gap: 1vw; }
body.tv .row.me { background: none; }
.tvcode b { display: block; font-size: 6vw; font-weight: 900; letter-spacing: .25em; color: var(--red); direction: ltr; line-height: 1.1; text-align: center; }

/* Rank medals: the snooker balls in order of value. */
.md { display: inline-block; width: .9em; height: .9em; border-radius: 50%; vertical-align: -.08em; flex: none; box-shadow: inset -.12em -.14em .2em #0007, inset .1em .1em .14em #fff5; }
.md0 { background: #d81e3a; } .md1 { background: #f2c230; } .md2 { background: #1f9d55; } .md3 { background: #8a5a2b; }
.md4 { background: #2b6fe0; } .md5 { background: #f48fb1; } .md6 { background: #050505; box-shadow: inset -.12em -.14em .2em #000, inset .12em .12em .16em #fff7, 0 0 0 1.5px #777; }
.md.big { width: 46px; height: 46px; }
.medalrow { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.medalname { font-size: 1.25rem; font-weight: 900; line-height: 1.2; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 4px; }
a { color: var(--text); }
.tokenbox { font-size: 1.35rem; font-weight: 900; letter-spacing: .06em; direction: ltr; text-align: center; padding: 14px 8px; border: 1px dashed var(--red); border-radius: 10px; margin: 8px 0 10px; user-select: all; overflow-wrap: anywhere; }
select { font: inherit; min-height: 36px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line2); background: var(--tile2); color: var(--text); max-width: 150px; }
body.tv .md { width: 1.4vw; height: 1.4vw; }

.linkbox { direction: ltr; text-align: start; overflow-wrap: anywhere; font-size: .9rem; padding: 10px 12px; border: 1px dashed var(--line2); border-radius: 10px; margin-bottom: 10px; user-select: all; }
.steps { margin: 0 0 12px; padding-inline-start: 1.2em; color: var(--dim); font-size: .88rem; }
.steps li { margin-bottom: 4px; }
.tvlink { font-size: 2.2vw; font-weight: 900; direction: ltr; text-align: center; overflow-wrap: anywhere; line-height: 1.3; }
