:root {
  --bg:        #f3f3f3;   /* biji-biji page background      */
  --surface:   #ffffff;   /* cards                          */
  --surface-2: #fbfbfa;   /* subtle panels                  */
  --ink:       #0e0f11;   /* near-black headings            */
  --body:      #333333;   /* body text                      */
  --muted:     #69727d;   /* secondary text                 */
  --line:      #e6e6e6;   /* hairline borders               */
  --accent:    #cc3366;   /* biji-biji raspberry            */
  --accent-soft: #fdf0f4; /* accent tint for marked cells   */
  --gap: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 16px 56px;
  font-family: 'Raleway', system-ui, sans-serif;
  color: var(--body);
  -webkit-font-smoothing: antialiased;
}

.view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.view[hidden] { display: none; }

/* ── HEADER ── */
header {
  text-align: center;
  margin-bottom: 30px;
}

.brand-logo {
  width: clamp(180px, 40vw, 260px);
  height: auto;
  display: block;
  margin: 0 auto 22px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}

h1 {
  font-family: 'Raleway', sans-serif;
  font-size: clamp(46px, 9vw, 78px);
  line-height: 0.95;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 span {
  font-weight: 800;
  color: var(--accent);
}

.subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-top: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.subtitle strong { color: var(--ink); font-weight: 700; }

/* ── LANDING FORM ── */
.join-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(14,15,17,0.06);
}

.join-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.join-form input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 14px;
  font-family: 'Raleway', sans-serif;
  font-size: 16px;          /* ≥16px keeps iOS from zooming on focus */
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.join-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204,51,102,0.12);
}
.join-form input#pinInput {
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 22px;
}

.btn-primary {
  font-family: 'Raleway', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 14px 24px;
  margin-top: 4px;
  border: none;
  cursor: pointer;
  border-radius: 44px;
  background: var(--ink);
  color: #fff;
  transition: background 0.18s ease, transform 0.1s ease;
}
.btn-primary:hover  { background: var(--accent); }
.btn-primary:active { transform: translateY(1px); }

.join-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

.error {
  color: #c0392b;
  font-size: 13px;
  min-height: 16px;
}

/* ── CARD WRAPPER ── */
.card-wrapper {
  position: relative;
  width: 100%;
  max-width: 820px;
}

.bingo-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(14,15,17,0.06);
}

/* ── HEADER ROW (B I N G O) ── */
.header-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.header-cell {
  background: var(--ink);
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 5vw, 32px);
  text-align: center;
  padding: 12px 4px;
  letter-spacing: 0.04em;
  border-radius: 12px;
}

/* ── GRID (5 cols × 6 rows) ── */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
}

.cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: center;
  padding: 12px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  overflow: hidden;
  font-family: 'Raleway', sans-serif;
  aspect-ratio: 1 / 1.4;
  min-width: 0;
  min-height: 112px;
}

.cell:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(204,51,102,0.14);
  z-index: 3;
}
.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cell-num {
  font-family: 'Raleway', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.5;
  line-height: 1;
  margin: 0 0 8px 0;
  flex-shrink: 0;
}

.cell-text {
  font-family: 'Raleway', sans-serif;
  font-size: 11px;
  line-height: 1.4;
  color: var(--body);
  font-weight: 500;
  position: relative;
  z-index: 1;
  overflow-wrap: break-word;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.cell-name {
  font-family: 'Raleway', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  margin: 8px 0 0 0;
  word-break: break-word;
  min-height: 15px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

/* marked state — question dims, name pops, accent tint */
.cell.marked {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cell.marked .cell-num  { color: var(--accent); opacity: 0.55; }
.cell.marked .cell-text { color: var(--muted); }
.cell.marked .cell-name { color: var(--accent); }

/* stamp */
.stamp {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
  opacity: 0.16;
}
.cell.marked .stamp { display: flex; }
.stamp svg {
  width: 66%;
  height: 66%;
  animation: stampIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes stampIn {
  from { transform: scale(2.2) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(-8deg); opacity: 1; }
}

/* ── TALLY ── */
.tally {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 18px;
  text-align: center;
}
.tally strong { color: var(--accent); font-size: 16px; font-weight: 800; }

/* ── CONTROLS ── */
.controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font-family: 'Raleway', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 11px 22px;
  border: none;
  cursor: pointer;
  border-radius: 44px;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}

.btn-reset {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.btn-reset:hover  { background: var(--ink); color: #fff; }
.btn-reset:active { transform: translateY(1px); }

.btn-secondary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}
.btn-secondary:hover { background: var(--accent); border-color: var(--accent); }
.btn-quiet {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-quiet:hover { background: transparent; color: var(--ink); border-color: var(--muted); }

/* ── MODAL ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(14,15,17,0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.18s ease;
}
.modal[hidden] { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 24px 22px;
  max-width: 460px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(14,15,17,0.22);
}

.modal-cat {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.modal-question {
  font-family: 'Raleway', sans-serif;
  font-size: 26px;
  line-height: 1.2;
  color: var(--ink);
  font-weight: 700;
}

.modal-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

#modalInput {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 13px 14px;
  font-family: 'Raleway', sans-serif;
  font-size: 16px;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#modalInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204,51,102,0.12);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-cancel:hover { color: var(--ink); border-color: var(--muted); }

.btn-clear {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-clear:hover { background: var(--accent-soft); }

.btn-submit {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}
.btn-submit:hover  { background: var(--accent); border-color: var(--accent); }
.btn-submit:active { transform: translateY(1px); }

/* ── LEADERBOARD ── */
.lb-card { max-width: 380px; }

.lb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.lb-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-family: 'Raleway', sans-serif;
}
.lb-list li.me { outline: 2px solid var(--accent); }

.lb-rank {
  color: var(--accent);
  font-weight: 800;
  margin-right: 10px;
}
.lb-name {
  color: var(--ink);
  font-weight: 500;
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lb-score {
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
}

.lb-tag {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.lb-actions { display: inline-flex; gap: 4px; margin-left: 8px; }

.lb-btn {
  font-family: 'Raleway', sans-serif;
  font-size: 14px;
  letter-spacing: normal;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--body);
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
  font-weight: 700;
}
.lb-btn:hover { border-color: var(--accent); color: var(--accent); }
.lb-btn-remove:hover { border-color: #c0392b; color: #c0392b; }

.lb-admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  margin-bottom: 4px;
}
.lb-admin-bar[hidden] { display: none; }

.lb-admin-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.lb-btn-clear-all {
  font-family: 'Raleway', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  border-radius: 44px;
}
.lb-btn-clear-all:hover { background: var(--accent); color: #fff; }

/* ── WIN BANNER ── */
.win-banner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(243,243,243,0.96);
  z-index: 400;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
}
.win-banner.show { display: flex; animation: fadeIn 0.35s ease forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.win-text {
  font-family: 'Raleway', sans-serif;
  font-size: clamp(64px, 16vw, 130px);
  font-weight: 800;
  color: var(--accent);
  animation: wobble 0.55s ease forwards;
  letter-spacing: -0.01em;
}
.win-sub {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

@keyframes wobble {
  0%   { transform: rotate(0deg) scale(0.6); }
  30%  { transform: rotate(-3deg) scale(1.12); }
  55%  { transform: rotate(2deg) scale(0.97); }
  75%  { transform: rotate(-1deg) scale(1.04); }
  100% { transform: rotate(0deg) scale(1); }
}

/* ── MOBILE TUNING ── */
@media (max-width: 600px) {
  body { padding: 22px 10px 40px; }
  .bingo-card { padding: 10px; border-radius: 16px; }
  :root { --gap: 6px; }
  .cell {
    padding: 8px;
    min-height: 104px;
    aspect-ratio: 1 / 1.5;
    border-radius: 12px;
  }
  .cell-num { font-size: 10px; margin: 0 0 6px 0; }
  .cell-text { font-size: 9.5px; line-height: 1.35; }
  .cell-name { font-size: 10px; margin: 6px 0 0 0; }
  .header-cell { font-size: 20px; padding: 9px 2px; border-radius: 10px; }
  .modal-question { font-size: 22px; }
}

@media (max-width: 400px) {
  .cell { padding: 6px; }
  .cell-num { margin: 0 0 4px 0; }
  .cell-text { font-size: 8.5px; line-height: 1.3; }
  .cell-name { font-size: 9px; margin: 4px 0 0 0; }
  .header-cell { font-size: 17px; padding: 7px 1px; }
}
