/* Adda — mobile first. Designed at 360px, tested up to desktop.
   Colour never carries meaning alone: every team also has a name and a symbol. */

:root {
  --bg: #FBF6EC;
  --surface: #FFFDF8;
  --ink: #22201C;
  --muted: #6C6559;
  --edge: #E7DCC7;
  --team-a: #C25E0C;
  --team-a-soft: #FBEAD7;
  --team-b: #0F7A6B;
  --team-b-soft: #DDF0EC;
  --accent: #B3122A;
  --ok: #1D7A45;
  --ok-soft: #E4F2E9;
  --warn: #9A5B00;
  --radius: 14px;
  --tap: 48px;
  --shadow: 0 1px 2px rgba(34,32,28,.06), 0 6px 18px rgba(34,32,28,.06);
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Devanagari", Roboto, Arial, sans-serif;
}

html[data-theme="diwali"] {
  --bg: #FFF4E0;
  --surface: #FFFBF2;
  --edge: #F0D9A8;
  --team-a: #C0500F;
  --team-b: #0E6E62;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: 10px 14px; z-index: 50;
}
.skip:focus { left: 8px; top: 8px; }

#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 12px; }
small, .small { font-size: .85rem; color: var(--muted); }

/* ------------------------------- controls -------------------------------- */

button, .btn {
  font: inherit;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  width: 100%;
}
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink); }
button.ghost { background: transparent; border-color: var(--edge); color: var(--ink); font-weight: 600; }
button.small { min-height: 40px; padding: 6px 12px; font-size: .85rem; width: auto; border-radius: 10px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.stack > * + * { margin-top: 12px; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
input[type="text"], select {
  font: inherit; width: 100%; min-height: var(--tap);
  padding: 10px 12px; border: 1.5px solid var(--edge); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}

.card {
  background: var(--surface);
  border: 1.5px solid var(--edge);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

.banner {
  border-radius: var(--radius); padding: 10px 12px; font-size: .9rem;
  border: 1.5px dashed var(--edge); background: var(--surface); margin-bottom: 12px;
}
.banner.warn { border-color: var(--warn); color: var(--warn); }
.banner.lead { border-style: solid; border-color: var(--ink); background: var(--surface);
  font-size: 1rem; font-weight: 600; padding: 14px; }
.banner.sim { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; overflow-wrap: anywhere;
  font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  border: 1.5px solid var(--edge); background: var(--surface); color: var(--muted);
}
.chip.sim { border-color: var(--accent); color: var(--accent); }
.chip.ready { border-color: var(--ok); color: var(--ok); }
.chip.a { border-color: var(--team-a); color: var(--team-a); background: var(--team-a-soft); }
.chip.b { border-color: var(--team-b); color: var(--team-b); background: var(--team-b-soft); }

/* --------------------------------- header -------------------------------- */

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.brand { font-weight: 800; letter-spacing: .5px; font-size: 1rem; }
.brand span { color: var(--accent); }
.langtoggle { display: flex; border: 1.5px solid var(--edge); border-radius: 999px; overflow: hidden; }
.langtoggle button { width: auto; min-height: 44px; padding: 4px 14px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: .9rem; font-weight: 700; }
.langtoggle button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.conn { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1.5px solid var(--edge); color: var(--muted); }
.conn[data-state="live"] { color: var(--ok); border-color: var(--ok); }
.conn[data-state="lost"] { color: var(--accent); border-color: var(--accent); }

/* ------------------------------- scoreboard ------------------------------ */

.scoreboard { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: stretch; }
.team {
  border: 2px solid var(--edge); border-radius: var(--radius); padding: 10px 8px;
  text-align: center; background: var(--surface);
}
.team.a { border-color: var(--team-a); background: var(--team-a-soft); }
.team.b { border-color: var(--team-b); background: var(--team-b-soft); }
.team .sym { font-size: 1.3rem; }
.team .nm { font-weight: 700; font-size: .9rem; word-break: break-word; }
.team .sc { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.team.lead { box-shadow: 0 0 0 3px rgba(34,32,28,.12); }
.vs { align-self: center; color: var(--muted); font-weight: 700; font-size: .8rem; }

/* --------------------------------- caller -------------------------------- */

.caller { text-align: center; padding: 10px 0 4px; }
.calldisc {
  font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 108px; min-height: 108px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--surface);
}
.calldisc.pulse { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.82); } to { transform: scale(1); } }
.recent { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.recent b {
  font-variant-numeric: tabular-nums; font-size: .95rem; font-weight: 700;
  border: 1.5px solid var(--edge); border-radius: 8px; padding: 2px 8px; background: var(--surface); color: var(--muted);
}
.progress { height: 6px; background: var(--edge); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--ink); transition: width .4s linear; }

/* --------------------------------- ticket -------------------------------- */

.ticketwrap { margin-top: 12px; }
.ticket {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px;
  background: var(--edge); border: 2px solid var(--ink); border-radius: 10px; padding: 3px;
}
.cell {
  display: flex; align-items: center; justify-content: center;
  height: 42px;
  background: var(--surface); border-radius: 6px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: clamp(.78rem, 3.4vw, 1.1rem);
  border: 0; padding: 0; margin: 0; min-height: 0; min-width: 0; width: 100%;
  color: var(--ink); overflow: hidden;
}
.cell.empty { background: #F1EADB; }
.cell.called { box-shadow: inset 0 0 0 2px var(--warn); }
.cell.marked { background: var(--ink); color: var(--surface); }
.cell.marked.called { box-shadow: none; }
.ticket.big .cell { font-size: clamp(1rem, 5.2vw, 1.6rem); height: 58px; }
.ticketmeta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ticketmeta .small { flex: 1 1 auto; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; min-height: 38px; }
.switch input { width: 22px; height: 22px; }

/* ------------------------------- player list ----------------------------- */

.players { list-style: none; margin: 0; padding: 0; }
.players li {
  display: flex; align-items: center; gap: 6px; padding: 8px 0;
  border-bottom: 1px solid var(--edge); flex-wrap: wrap;
}
.players .manage { display: flex; gap: 6px; flex: 1 0 100%; margin-top: 4px; }
.players .manage button { flex: 1 1 auto; }
.players li:last-child { border-bottom: 0; }
.players .nm { font-weight: 600; flex: 1 1 auto; word-break: break-word; }
.players .pts { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--edge); flex: 0 0 auto; }
.dot.on { background: var(--ok); }

/* -------------------------------- reactions ------------------------------ */

.reactbar { display: flex; gap: 8px; margin-top: 12px; }
.reactbar button { flex: 1; font-size: .85rem; min-height: 44px; padding: 6px 4px; }
.reaction-layer { position: fixed; inset: auto 0 96px 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 30; }
.reaction-layer span {
  background: var(--ink); color: var(--surface); border-radius: 999px; padding: 6px 14px;
  font-size: .85rem; font-weight: 700; animation: rise 3.2s ease-out forwards;
}
@keyframes rise { 0% { opacity: 0; transform: translateY(10px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* --------------------------------- sheets -------------------------------- */

details.sheet { border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--surface); margin-top: 12px; }
details.sheet > summary { padding: 12px 14px; font-weight: 700; cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
details.sheet > div { padding: 0 14px 14px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px;
  font-size: .9rem; font-weight: 600; z-index: 60; max-width: 92vw; text-align: center;
}

/* --------------------------------- result -------------------------------- */

.resulthead { text-align: center; padding: 8px 0 4px; }
.resulthead .crown { font-size: 2.2rem; }
.bigscore { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; margin: 14px 0; }
.bigscore .sc { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cardpreview { width: 100%; border: 1.5px solid var(--edge); border-radius: var(--radius); }

table.scoretable { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.scoretable th, table.scoretable td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--edge); }
table.scoretable td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.footer-brand { text-align: center; margin-top: 22px; opacity: .8; }
.footer-brand a { color: var(--muted); }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--edge); border-top-color: var(--ink); border-radius: 50%; margin: 0 auto 10px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.diya-edge { height: 6px; border-radius: 999px; background: repeating-linear-gradient(90deg, var(--team-a) 0 10px, var(--edge) 10px 20px, var(--team-b) 20px 30px, var(--edge) 30px 40px); margin-bottom: 12px; }


/* ------------------------------- the quiz -------------------------------- */

/* Picking a game. Two big targets, because this is the first tap of the app. */
.gameswitch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gamecard {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  text-align: left; padding: 12px; min-height: 64px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--edge);
  border-radius: var(--radius); font-weight: 600; width: 100%;
}
.gamecard.on { border-color: var(--ink); background: var(--bg); }
.gamecard .gname { font-size: 1.05rem; font-weight: 800; }
.gamecard .gblurb { font-size: .78rem; font-weight: 500; color: var(--muted); line-height: 1.3; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button.pick {
  width: auto; min-height: 40px; padding: 7px 13px; border-radius: 999px;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--edge);
  font-size: .88rem; font-weight: 600;
}
button.pick.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }

.qhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lives { letter-spacing: 2px; color: var(--accent); font-size: 1.05rem; }
.progress.rev i { background: var(--ok); }

.qcard { padding: 16px; }
.qtext { font-size: 1.22rem; line-height: 1.35; font-weight: 700; margin: 0 0 14px; }

/* One option per row. Two columns at this size put a long answer on four
   lines and make the wrong one easy to hit. */
.opts { display: grid; gap: 10px; }
button.opt {
  display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 56px; padding: 10px 12px; width: 100%;
  background: var(--surface); color: var(--ink); border: 2px solid var(--edge);
  border-radius: var(--radius); font-size: 1rem; font-weight: 600;
}
button.opt .optkey {
  flex: 0 0 28px; height: 28px; border-radius: 8px; background: var(--edge);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
button.opt .opttext { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
button.opt.picked { border-color: var(--ink); }
button.opt.picked .optkey { background: var(--ink); color: var(--bg); }
button.opt.right { border-color: var(--ok); background: var(--ok-soft); }
button.opt.right .optkey { background: var(--ok); color: #fff; }
button.opt.wrong { border-color: var(--accent); }
button.opt.wrong .optkey { background: var(--accent); color: #fff; }
button.opt:disabled { opacity: 1; cursor: default; }
button.opt:disabled:not(.picked):not(.right):not(.wrong) { opacity: .62; }

.card.reveal { border-color: var(--ok); }

.quizboard li.isout { opacity: .55; }
.quizboard li.isout .nm { text-decoration: line-through; }

.qreview { border-bottom: 1px solid var(--edge); padding-bottom: 10px; }
.qreview:last-child { border-bottom: 0; }
table.scoretable tr.survived td { font-weight: 700; }

@media (min-width: 620px) {
  #app { padding-top: 28px; }
  .cell { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
