:root {
  --bg-1: #fff4e3;
  --bg-2: #ffd6a5;
  --bg-3: #ffadad;
  --ink: #2d1b3e;
  --ink-soft: #6b5a7a;
  --accent: #ff7e5f;
  --accent-2: #feb47b;
  --accent-3: #f8485e;
  --gold: #ffb627;
  --card: rgba(255, 255, 255, 0.78);
  --card-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(45, 27, 62, 0.08);
  --shadow: 0 18px 40px -18px rgba(45, 27, 62, 0.25);
  --shadow-soft: 0 8px 24px -12px rgba(45, 27, 62, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top, var(--bg-1) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-3) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sun {
  position: fixed;
  top: -120px;
  right: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff2c4 0%, #ffd56b 40%, transparent 70%);
  filter: blur(20px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  max-width: 720px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
}

.brand-mark {
  font-size: 22px;
  color: var(--gold);
  filter: drop-shadow(0 1px 2px rgba(255, 182, 39, 0.4));
}

.brand-text {
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-year {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.admin-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-strong);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.admin-btn:hover { transform: rotate(35deg); box-shadow: var(--shadow); }
.admin-btn:active { transform: rotate(35deg) scale(0.95); }
.admin-btn.is-admin {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  border-color: transparent;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 10px 32px;
}

.intro {
  text-align: center;
  margin: 8px 0 16px;
}

.intro h1 {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800;
  font-size: clamp(34px, 8vw, 52px);
  line-height: 1.15;
  margin: 0;
  padding: 0.1em 0;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--ink) 0%, var(--accent-3) 60%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.4;
}

.score-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  position: relative;
}

.stat + .stat::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: var(--line);
}

.stat-value {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
}

.stat.highlight .stat-value {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  margin-top: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}

.grid-wrap {
  background: var(--card);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
}

.cell {
  min-height: 72px;
  background: var(--card-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.25s ease, color 0.25s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}

.cell.empty {
  color: var(--ink-soft);
  font-style: italic;
  opacity: 0.7;
}

.cell.admin-mode {
  cursor: pointer;
}

.cell.admin-mode:active { transform: scale(0.96); }

.cell.checked {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-3) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px -6px rgba(248, 72, 94, 0.55);
}

.cell.checked::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: calc(var(--radius-sm) - 6px);
  pointer-events: none;
}

.cell.in-bingo {
  background: linear-gradient(135deg, var(--gold) 0%, var(--accent) 100%);
  box-shadow: 0 8px 22px -6px rgba(255, 182, 39, 0.65);
}

.cell.in-bingo::before {
  content: '★';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  color: #fff;
  opacity: 0.7;
}

.hint {
  margin: 16px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  opacity: 0.75;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(45, 27, 62, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.22s ease;
}

.modal.hidden { display: none; }

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 24px 22px 28px;
  box-shadow: 0 -20px 50px -20px rgba(45, 27, 62, 0.3);
  position: relative;
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(45, 27, 62, 0.06);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.modal-close:hover { background: rgba(45, 27, 62, 0.12); }

.modal-card h2 {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.modal-sub {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fdfaf6;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.primary-btn {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  box-shadow: 0 8px 20px -6px rgba(248, 72, 94, 0.5);
}

.primary-btn:hover { box-shadow: 0 10px 24px -6px rgba(248, 72, 94, 0.6); }
.primary-btn:active { transform: scale(0.98); }

.ghost-btn {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ghost-btn:hover { background: rgba(45, 27, 62, 0.04); }

.admin-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.activity-list {
  list-style: none;
  counter-reset: item;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  counter-increment: item;
}

.activity-list li::before {
  content: counter(item);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-2), var(--accent-2));
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

.activity-list input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fdfaf6;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.activity-list input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.activity-list input.saving {
  border-color: var(--accent-2);
}

.activity-list input.saved {
  border-color: #6bcb77;
}

.error {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--accent-3);
  text-align: center;
}

.cell-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.cell-modal-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 15px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(248, 72, 94, 0.5);
}

.cell-modal-title {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.02em;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

#cellInput {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fdfaf6;
  color: var(--ink);
  margin-bottom: 18px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#cellInput:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 12px 14px;
  background: #fdfaf6;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle:hover { background: #fff; }

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  background: #e5dccf;
  border-radius: 999px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle input:checked + .toggle-track {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
}

.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

.toggle-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.cell-modal-actions {
  display: flex;
  gap: 10px;
}

.cell-modal-actions .ghost-btn { flex: 1; padding: 14px; font-size: 14px; font-weight: 600; }
.cell-modal-actions .primary-btn { flex: 1; padding: 14px; }

.hidden { display: none !important; }

.bingo-flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bingo-flash.show { opacity: 1; }

.bingo-flash .word {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 900;
  font-size: clamp(64px, 18vw, 140px);
  background: linear-gradient(135deg, var(--gold), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.04em;
  filter: drop-shadow(0 8px 24px rgba(255, 126, 95, 0.4));
  animation: pop 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@media (min-width: 640px) {
  .cell {
    font-size: 13px;
    padding: 8px;
    border-radius: 14px;
  }
  .grid { gap: 8px; }
  .grid-wrap { padding: 14px; }
  .modal {
    align-items: center;
    padding: 20px;
  }
  .modal-card {
    border-radius: 24px;
    padding: 28px;
  }
}

@media (min-width: 900px) {
  .cell { font-size: 14px; }
}
