/* Bingo: one small stylesheet for every page. */
:root {
    --bg: #f4f1ea;
    --panel: #ffffff;
    --ink: #222;
    --muted: #6b6b6b;
    --line: #ddd6c8;
    --accent: #c0392b;
    --accent-dark: #962d22;
    --ok: #2e7d32;
    --warn: #b26a00;
    --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}
.page-narrow { max-width: 560px; margin: 0 auto; padding: 16px; }
.page-wide { max-width: 1100px; margin: 0 auto; padding: 16px; }
@media (max-width: 600px) {
    .page-narrow, .page-wide { padding: 10px; }
    .panel { padding: 12px; margin-bottom: 12px; }
    .topbar { margin-bottom: 12px; }
    .btn.big { font-size: 1.25rem; padding: 14px 20px; }
}
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.center { text-align: center; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--accent); color: #fff; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
}
.topbar a, .topbar button.link { color: #fff; }
.topbar b { font-size: 1.05rem; }
.pin-box { flex: 0 0 auto; background: #fff; color: var(--accent); border-radius: 8px; padding: 4px 10px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.pin-box b { font-size: 1.5rem; letter-spacing: .12em; margin-left: 4px; vertical-align: -2px; }

/* Forms */
label { display: block; margin-bottom: 10px; font-weight: 600; }
label input, label select { font-weight: normal; }
input[type=text], input[type=number], input[type=password], select {
    width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #bbb; border-radius: 8px; background: #fff; margin-top: 4px;
}
input[type=file] { margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.btn {
    display: inline-block; padding: 10px 16px; font-size: 1rem; font-weight: 600; cursor: pointer;
    border: 1px solid #999; border-radius: 8px; background: #fff; color: var(--ink); text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #f3f3f3; }
.btn.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ok { background: var(--ok); border-color: #1b5e20; color: #fff; }
.btn.danger { background: #e0502a; border-color: #b23d1c; color: #fff; }
.btn.danger:hover { background: #c7431f; }
.btn.big { font-size: 1.4rem; padding: 18px 28px; width: 100%; }
.btn.small { font-size: .85rem; padding: 6px 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert.error { background: #fdecea; border-color: #f5c6c2; color: #8a1c10; }
.alert.ok { background: #e8f5e9; border-color: #b7dfb9; color: #1b5e20; }
.alert.warn { background: #fff6e5; border-color: #ffd699; color: #7a4a00; }
.alert.idle { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Called images: a small picture beside its name instead of a full-width image */
.last-called .last-row { display: flex; align-items: center; gap: 14px; }
.last-called .last-row img {
    width: 96px; height: 96px; flex: 0 0 auto; object-fit: contain;
    border: 2px solid var(--ink); border-radius: 8px; background: #fff;
}
.last-called .name { font-size: 1.35rem; font-weight: 700; line-height: 1.15; word-break: break-word; }
.last-called p { margin: 0; }
.panel > .last-called { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
@media (min-width: 800px) { .last-called .last-row img { width: 130px; height: 130px; } }
.called-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.called-grid .item { width: 64px; text-align: center; font-size: .65rem; line-height: 1.1; color: var(--muted); }
.called-grid img { width: 64px; height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.called-grid.tiny { gap: 4px; }                       /* player page: pictures only, no captions */
.called-grid.tiny .item, .called-grid.tiny img { width: 44px; }
.called-grid.tiny img { height: 44px; border-radius: 4px; }
.count { color: var(--muted); font-weight: normal; }

/* Collapsible panel headers: chevron on the right, rotates when open */
.fold-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; margin: -4px 0 0; -webkit-tap-highlight-color: transparent; }
.fold-head + * { margin-top: 10px; }   /* the gap only exists while the section is open (hidden = display:none) */
.fold-head .fold {
    background: none; border: 0; padding: 4px; margin: 0; color: var(--muted); cursor: pointer; line-height: 0; border-radius: 6px;
    transition: transform .2s;
}
.fold-head .fold[aria-expanded="true"] { transform: rotate(180deg); }

/* Winners */
.winners { list-style: none; padding: 0; margin: 0; }
.winners li { padding: 8px 10px; background: #fff8e1; border: 1px solid #ffe08a; border-radius: 8px; margin-bottom: 6px; font-weight: 600; }
.winners li .card-no { color: var(--muted); font-weight: normal; font-size: .85rem; }
.winners .none { background: none; border: 0; color: var(--muted); font-weight: normal; }

/* Player's own card */
.mini-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.mini-card .cell { position: relative; aspect-ratio: 1; background: #fff; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.mini-card .cell img { width: 100%; height: 100%; object-fit: contain; }
.mini-card .cell.free { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--accent); font-size: .8rem; }
.mini-card .cell.hit { outline: 3px solid var(--ok); outline-offset: -3px; }
.mini-card .cell.hit::after {
    content: ""; position: absolute; inset: 0; background: rgba(46,125,50,.35);
}
.mini-card .cell.free.hit::after { background: none; }

/* Bingo banner for the player */
.bingo-banner {
    position: sticky; top: 8px; z-index: 40;   /* stays in view while the player is scrolled down at their card */
    background: #ffd54f; color: #4a2d00; text-align: center; font-size: 2rem; font-weight: 900; padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.03); } }

/* Full-screen flash the moment the player's card wins */
.bingo-splash {
    position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f39c12, #c0392b); color: #fff; text-align: center; padding: 24px; cursor: pointer;
    animation: splash-in .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.bingo-splash .big { font-size: 4.5rem; font-weight: 900; letter-spacing: .04em; line-height: 1; text-shadow: 0 4px 16px rgba(0,0,0,.35); animation: toast-bounce .8s .4s ease-in-out 3; }
.bingo-splash .who { font-size: 1.5rem; font-weight: 700; margin-top: 12px; word-break: break-word; }
.bingo-splash .tap { font-size: .85rem; opacity: .8; margin-top: 24px; }
.bingo-splash.bye { animation: splash-out .4s ease-in both; }
.bingo-splash .confetti i { width: 12px; height: 18px; animation: confetti-fall-far 3s linear infinite; }
@keyframes splash-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splash-out { to { opacity: 0; } }
@keyframes confetti-fall-far { 0% { transform: translateY(0) rotate(0deg); } 100% { transform: translateY(110vh) rotate(540deg); } }

/* Caller layout */
.caller-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 800px) { .caller-grid { grid-template-columns: 1fr; } }
.player-list { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; }
.player-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.player-list li.won { background: #fff8e1; font-weight: 700; }
.player-list .x { color: var(--muted); }
.ban-list { list-style: none; padding: 0; margin: 0; }
.ban-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px; border: 1px solid #f5c6c2; background: #fdecea; border-radius: 8px; margin-bottom: 6px; font-size: .9rem; }
.ban-list .ban-info { min-width: 0; }
.ban-list .agent { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-list .stepper { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.player-list .stepper b { min-width: 1.2em; text-align: center; }
.player-list .stepper .btn { width: 32px; padding: 4px 0; text-align: center; }
.player-list .badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: #1b5e20; background: #e8f5e9; border: 1px solid #b7dfb9; border-radius: 10px; padding: 1px 7px; vertical-align: 1px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; margin: 0 0 12px; }
label.check input { width: 20px; height: 20px; margin: 0; }
#all-won .btn { margin-top: 8px; display: block; }
.wins-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wins-row .stepper { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.wins-row .stepper b { min-width: 1.4em; text-align: center; font-size: 1.2rem; }
.wins-row .stepper .btn { width: 36px; padding: 6px 0; text-align: center; font-size: 1.1rem; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-tile { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; cursor: pointer; background: #fff; }
.theme-tile:hover { border-color: var(--accent); }
.theme-tile img { width: 100%; height: 90px; object-fit: contain; }
.theme-tile.bad { opacity: .6; cursor: not-allowed; }

/* Bingo pattern pickers and previews */
.pat { display: inline-grid; grid-template-columns: repeat(5, 9px); gap: 2px; flex: 0 0 auto; }
.pat i { display: block; width: 9px; height: 9px; background: #e3ded3; border-radius: 1px; }
.pat i.on { background: var(--accent); }
.pat.big { grid-template-columns: repeat(5, 16px); gap: 2px; padding: 4px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; }
.pat.big i { width: 16px; height: 16px; border-radius: 2px; }
/* Caller's pattern picker: two columns of tiles laid out name / preview / description */
.pat-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
@media (min-width: 800px) { .pat-tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.pat-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; line-height: 1.2; font-size: .9rem; text-align: center; }
.pat-tile .small { font-size: .78rem; }
/* Caller's main screen: the chosen pattern as one small line beside the change button */
.pat-current { display: flex; align-items: center; gap: 10px; }
.pat-current > div { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: .9rem; line-height: 1.2; }
.pat-current .small { font-size: .78rem; }
.pat-current .btn { flex: 0 0 auto; }
.panel.compact { padding: 10px 12px; margin-bottom: 12px; }
.panel.compact h3 { margin-bottom: 6px; }
.pat-tile[data-key]:hover { border-color: var(--accent); }
.pat-tile.selected { border-color: var(--accent); background: #fdf1ef; cursor: default; }

/* Player: goal and last called side by side, each as heading / picture / caption */
.duo { display: flex; gap: 10px; }
.duo .col { flex: 1 1 0; min-width: 0; text-align: center; border-right: 1px solid var(--line); padding-right: 10px; }
.duo .col:last-child { border-right: 0; padding-right: 0; }
.duo h3 { margin-bottom: 6px; }
.duo p { margin: 0; }
.duo img { width: 96px; height: 96px; object-fit: contain; border: 2px solid var(--ink); border-radius: 8px; background: #fff; vertical-align: top; }
.duo .name { font-size: 1.1rem; font-weight: 700; line-height: 1.15; margin-top: 4px; word-break: break-word; }
.duo .small { line-height: 1.2; }

/* Winner pop-ups on the caller's screen */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
    position: relative; overflow: hidden; pointer-events: auto; cursor: pointer; width: 280px; max-width: calc(100vw - 32px);
    background: linear-gradient(135deg, #f39c12, #c0392b); color: #fff; border-radius: 14px; padding: 16px 18px 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.35); text-align: center;
    animation: toast-in .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.toast .big { font-size: 2.2rem; font-weight: 900; letter-spacing: .04em; line-height: 1; animation: toast-bounce .8s .5s ease-in-out 2; text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.toast .who { font-size: 1.25rem; font-weight: 700; margin-top: 6px; word-break: break-word; }
.toast .tap { font-size: .7rem; opacity: .8; margin-top: 8px; }
.toast.bye { animation: toast-out .4s ease-in both; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -10px; width: 7px; height: 11px; border-radius: 2px; opacity: .9; animation: confetti-fall 2.4s linear infinite; }
.confetti i:nth-child(1)  { left: 4%;  background: #fff176; animation-delay: 0s;   transform: rotate(15deg); }
.confetti i:nth-child(2)  { left: 11%; background: #4fc3f7; animation-delay: .3s; }
.confetti i:nth-child(3)  { left: 18%; background: #aed581; animation-delay: .9s; }
.confetti i:nth-child(4)  { left: 25%; background: #fff;    animation-delay: .5s; }
.confetti i:nth-child(5)  { left: 32%; background: #ce93d8; animation-delay: 1.4s; }
.confetti i:nth-child(6)  { left: 39%; background: #fff176; animation-delay: .2s; }
.confetti i:nth-child(7)  { left: 46%; background: #4fc3f7; animation-delay: 1.1s; }
.confetti i:nth-child(8)  { left: 53%; background: #fff;    animation-delay: .7s; }
.confetti i:nth-child(9)  { left: 60%; background: #aed581; animation-delay: 1.7s; }
.confetti i:nth-child(10) { left: 67%; background: #ce93d8; animation-delay: .4s; }
.confetti i:nth-child(11) { left: 74%; background: #fff176; animation-delay: 1.3s; }
.confetti i:nth-child(12) { left: 81%; background: #4fc3f7; animation-delay: .8s; }
.confetti i:nth-child(13) { left: 88%; background: #fff;    animation-delay: 1.9s; }
.confetti i:nth-child(14) { left: 95%; background: #aed581; animation-delay: .1s; }
@keyframes toast-in { from { transform: translateX(120%) rotate(6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateX(120%); opacity: 0; } }
@keyframes toast-bounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18) rotate(-3deg); } }
@keyframes confetti-fall { 0% { transform: translateY(0) rotate(0deg); } 100% { transform: translateY(140px) rotate(360deg); } }

/* Admin */
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.nav a { padding: 8px 14px; border-radius: 8px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; }
.nav a.active { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.img-grid .it { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; text-align: center; }
.img-grid .it img { width: 100%; height: 90px; object-fit: contain; }
.img-grid .it input { font-size: .85rem; padding: 6px; margin-top: 4px; }
.img-grid .it .key { font-size: .7rem; color: var(--muted); }
.qr-box { text-align: center; }
.qr-box svg { width: 260px; height: 260px; }
.url { word-break: break-all; font-family: Consolas, monospace; font-size: .85rem; background: #f6f6f6; padding: 8px; border-radius: 6px; }

/* Printing the caller QR page: just the title, the code and the address */
.print-title { font-size: 1.6rem; margin-bottom: 12px; }
@media print {
    body { background: #fff; }
    .topbar, .nav, .alert, .no-print { display: none !important; }
    .panel { border: 0; padding: 0; margin: 0; }
    .print-sheet { text-align: center; padding-top: 1.5in; }
    .print-title { font-size: 28pt; margin-bottom: 0.4in; }
    .qr-box svg { width: 4in; height: 4in; }
    .url { background: none; font-size: 12pt; margin-top: 0.3in; }
}
