/* ── Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Great+Vibes&family=Raleway:wght@300;400;500;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --white:       #FFFFFF;
  --green:       #5A6B47;
  --green-mid:   #7A8F6A;
  --green-light: #C8D8BC;
  --green-bg:    #F4F8F2;
  --green-deep:  #3D4E2E;
  --gray:        #F7F7F5;
  --text:        #3A3A3A;
  --text-light:  #888;
  --radius:      12px;
  --shadow:      0 4px 20px rgba(0,0,0,0.07);
  --transition:  0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Raleway', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--gray);
  min-height: 100vh;
}

/* ── Typography ────────────────────────────────────────── */
h1, h2, h3 { font-family: 'Raleway', sans-serif; font-weight: 700; }
h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); color: var(--green); }
h2 { font-size: clamp(1.3rem, 4vw, 1.8rem); }
h3 { font-size: 1.1rem; }
.script { font-family: 'Great Vibes', cursive; font-weight: 400; }

/* ── Page wrapper ──────────────────────────────────────── */
.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
}

/* ── Divider ───────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green-light), transparent);
  margin: 1.5rem 0;
  border: none;
}

/* ── Header decoration ─────────────────────────────────── */
.header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}
.header .monogram {
  font-family: 'Great Vibes', cursive;
  font-size: 3.5rem;
  color: var(--green);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.header p { color: var(--text-light); font-size: 1rem; margin-top: 0.5rem; }

/* ── Form ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.form-group input, .form-group textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--green-light);
  border-radius: var(--radius);
  font-family: 'Raleway', sans-serif;
  font-size: 1rem;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background: var(--white);
  color: var(--text);
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--green);
}
.form-group .hint {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  border: none;
  font-family: 'Raleway', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--green);
  color: var(--white);
  width: 100%;
}
.btn-secondary {
  background: var(--green-bg);
  color: var(--green-deep);
  border: 1px solid var(--green-light);
}
.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid #e0e0e0;
}
.btn-danger {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #EF9A9A;
}

/* ── Spinner ───────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.loading .spinner { display: block; }
.loading .btn-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error / success messages ──────────────────────────── */
.msg {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-top: 0.75rem;
  display: none;
}
.msg.show { display: block; }
.msg-error   { background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; }
.msg-success { background: var(--green-bg); color: var(--green-deep); border: 1px solid var(--green-light); }

/* ── Bingo grid ────────────────────────────────────────── */
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.score-badge {
  background: var(--green);
  color: var(--white);
  padding: 0.4rem 1rem;
  border-radius: 2rem;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.rush-banner {
  background: linear-gradient(135deg, #2d5a1e, #1a3d10);
  color: var(--white);
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: none;
  animation: pulse 1.5s ease-in-out infinite;
}
.rush-banner.active { display: block; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.85; }
}

.bingo-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 1.5rem;
}
.bingo-grid.size-3 { grid-template-columns: repeat(3, 1fr); }
.bingo-grid.size-4 { grid-template-columns: repeat(4, 1fr); }
.bingo-grid.size-5 { grid-template-columns: repeat(5, 1fr); }

.bingo-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--green-light);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  cursor: pointer;
  font-size: clamp(0.55rem, 2.2vw, 0.75rem);
  line-height: 1.2;
  font-family: 'Raleway', sans-serif;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.bingo-cell:active { transform: scale(0.95); }
.bingo-cell.done {
  background: var(--green-bg);
  border-color: var(--green-mid);
  color: var(--green-deep);
}
.bingo-cell.free {
  background: var(--green-bg);
  border-color: var(--green-light);
  cursor: default;
  font-family: 'Great Vibes', cursive;
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: var(--green-mid);
}
.bingo-cell.done::after {
  content: '✓';
  position: absolute;
  top: 2px; right: 4px;
  font-size: 0.7rem;
  color: var(--green);
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.modal-title {
  font-family: 'Raleway', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  padding-right: 2rem;
  color: var(--green-deep);
}
.modal-desc {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* Camera / file upload area */
.upload-area {
  border: 1px dashed var(--green-mid);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  background: var(--green-bg);
  cursor: pointer;
  transition: border-color var(--transition);
}
.upload-area:hover { border-color: var(--green); }
.upload-area input[type="file"] { display: none; }
.upload-area .upload-icon { color: var(--green-mid); margin-bottom: 0.5rem; }
.upload-area p { color: var(--text-light); font-size: 0.9rem; }
.upload-area .preview-img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  display: none;
  margin: 0 auto;
}
.upload-area.has-image .upload-icon,
.upload-area.has-image p { display: none; }
.upload-area.has-image .preview-img { display: block; }

/* ── Scores page ───────────────────────────────────────── */
.score-list { list-style: none; }
.score-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid #eee;
}
.score-item:last-child { border-bottom: none; }
.rank {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--text);
}
.rank.gold   { background: var(--green);       color: var(--white); }
.rank.silver { background: var(--green-mid);   color: var(--white); }
.rank.bronze { background: var(--green-light); color: var(--green-deep); }
.score-info { flex: 1; min-width: 0; }
.score-info .name  { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-info .table { font-size: 0.82rem; color: var(--text-light); }
.score-pts { font-weight: 700; color: var(--green); font-size: 1.05rem; white-space: nowrap; }
.refresh-note { text-align: center; font-size: 0.8rem; color: var(--text-light); margin-top: 1rem; }

/* ── Nav links ─────────────────────────────────────────── */
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  margin-bottom: 1.25rem;
}

/* ── Result toast ──────────────────────────────────────── */
.result-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(4rem);
  background: var(--white);
  border-radius: var(--radius);
  border-top: 3px solid var(--green);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  padding: 1rem 1.5rem;
  text-align: center;
  z-index: 200;
  min-width: 260px;
  max-width: 90vw;
  transition: transform 0.35s ease, opacity 0.35s ease;
  opacity: 0;
}
.result-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.result-toast .toast-icon {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
  color: var(--green);
  font-weight: 700;
}
.result-toast .toast-title {
  font-family: 'Raleway', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-deep);
  letter-spacing: 0.03em;
}
.result-toast .toast-sub { font-size: 0.85rem; color: var(--text-light); margin-top: 0.2rem; }

/* Watercolor leaf decorations (corner ornaments matching the wedding program) */
body::before,
body::after {
  content: '';
  position: fixed;
  width: clamp(180px, 32vw, 360px);
  aspect-ratio: 500 / 694;
  background: url('/static/img/leaves.png') no-repeat center / contain;
  pointer-events: none;
  z-index: 0;
  opacity: 0.95;
}
body::before {
  top: -28px;
  left: -28px;
  transform: scaleY(-1);
}
body::after {
  bottom: -28px;
  right: -28px;
  transform: scaleX(-1);
}
@media (max-width: 480px) {
  body::before, body::after { width: 42vw; opacity: 0.9; }
}
.page { position: relative; z-index: 1; }
