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

:root {
  --gold:       #E8C44A;
  --gold-light: #F5DFA0;
  --gold-dark:  #B8920A;
  --bg:         #0f0d08;
  --surface:    #1a1710;
  --surface2:   #252118;
  --border:     #332e1a;
  --text:       #d4c98a;
  --text-muted: #7a6e42;
  --green:      #4a8c5c;
  --red:        #8c4a4a;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Libre Baskerville', Georgia, serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 1000; opacity: 0.5;
}

/* ── Header ─────────────────────────────────── */
.header {
  background: linear-gradient(160deg, #1e1a0d 0%, #0f0d08 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 20px 24px;
  text-align: center;
  position: relative;
}
.header::after {
  content: '';
  position: absolute; bottom: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}
.header-eyebrow { font-size: 0.65rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.header-title { font-family: 'Playfair Display', Georgia, serif; font-size: 2rem; font-weight: 900; color: var(--gold); line-height: 1.1; text-shadow: 0 2px 20px rgba(232,196,74,0.25); }
.header-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; font-style: italic; }

/* ── Progress ring ───────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; align-items: center; margin: 20px 0 4px; }

/* ── Filter bar ──────────────────────────────── */
.filter-bar { display: flex; margin: 16px 16px 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.filter-btn {
  flex: 1; padding: 10px 4px; background: var(--surface); border: none;
  color: var(--text-muted); font-family: 'Libre Baskerville', serif;
  font-size: 0.7rem; letter-spacing: 0.06em; cursor: pointer; transition: all 0.2s;
  border-right: 1px solid var(--border);
}
.filter-btn:last-child { border-right: none; }
.filter-btn.active { background: var(--surface2); color: var(--gold); }

/* ── Coin list ───────────────────────────────── */
.list { padding: 12px 16px 80px; display: flex; flex-direction: column; gap: 8px; }

.coin-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: flex; align-items: flex-start; gap: 12px; padding: 20px;
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
  position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
.coin-row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; transition: background 0.2s; }
.coin-row.collected { border-color: rgba(232,196,74,0.2); background: #1c1a0e; }
.coin-row.collected::before { background: var(--gold-dark); }
.coin-row:active { opacity: 0.8; }

/* ── Coin disc ───────────────────────────────── */
.coin-disc {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface2);
  display: flex; align-items: center; justify-content: center; transition: all 0.25s;
}
.coin-disc img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.coin-disc.collected {
  background: radial-gradient(circle at 35% 30%, #FFE566, #D4A800 55%, #8B6500);
  border-color: #B8920A;
  box-shadow: 0 0 12px rgba(232,196,74,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ── Row content ─────────────────────────────── */
.row-main { flex: 1; min-width: 0; }
.year-line { display: flex; align-items: center; gap: 8px; }
.year-num { font-family: 'Playfair Display', Georgia, serif; font-size: 1.25rem; font-weight: 700; color: var(--text-muted); transition: color 0.2s; line-height: 1; }
.coin-row.collected .year-num { color: var(--gold); }

/* ── Note ────────────────────────────────────── */
.note-area { margin-top: 8px; }
.note-display { font-size: 0.78rem; color: var(--text-muted); font-style: italic; line-height: 1.4; cursor: pointer; padding: 2px 0; margin-top: 5px;}
.note-display:empty::before { content: 'tap to add details…'; color: #4a4430; }
.added-by-tag { color: var(--gold-dark); font-style: normal; font-size: 0.7rem; }
.note-edit-wrap { display: flex; gap: 6px; align-items: flex-end; margin-top: 4px; }
.note-input {
  flex: 1; background: var(--bg); border: 1px solid var(--gold-dark); border-radius: 5px;
  color: var(--text); font-family: 'Libre Baskerville', serif; font-size: 0.78rem;
  padding: 7px 10px; outline: none; line-height: 1.4;
}
.note-input::placeholder { color: #4a4430; font-style: italic; }
.note-save-btn {
  background: var(--gold-dark); border: none; border-radius: 5px; color: #0f0d08;
  font-family: 'Playfair Display', serif; font-size: 0.75rem; font-weight: 700;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* ── Added by ───────────────────────────────── */
.added-by-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.added-by-label { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.added-by-select {
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); font-family: 'Libre Baskerville', serif; font-size: 0.75rem;
  padding: 6px 10px; outline: none; cursor: pointer;
}

/* ── Detail actions ─────────────────────────── */
.detail-header { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.close-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  position: absolute; top: 10px; right: 10px;
}
.close-btn:active { opacity: 0.7; }
.coin-actions { display: flex; gap: 10px; margin-top: 40px; justify-content: center; }
.got-it-btn {
  flex: 1; background: var(--gold-dark); border: none; border-radius: 5px; color: #0f0d08;
  font-family: 'Playfair Display', serif; font-size: 0.78rem; font-weight: 700;
  padding: 9px 14px; cursor: pointer; max-width: 200px; margin: 0;
}
.got-it-btn:active { opacity: 0.8; }
.coin-actions-remove { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.remove-btn {
  background: var(--red); border: none; border-radius: 5px; color: #fff;
  font-family: 'Libre Baskerville', serif; font-size: 0.68rem;
  padding: 8px 16px; cursor: pointer; white-space: nowrap;
}
.remove-btn:active { opacity: 0.7; }
.close-text-btn {
  background: none; border: 1px solid var(--border); border-radius: 5px;
  color: var(--text-muted); font-family: 'Libre Baskerville', serif; font-size: 0.68rem;
  padding: 8px 16px; cursor: pointer; white-space: nowrap;
}
.close-text-btn:active { opacity: 0.7; }

/* ── Photo section ───────────────────────────── */
.photo-section { margin-top: 20px; padding-top: 20px; }
.photo-section-label { font-size: 1rem; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 25px; text-align: center;}
.photo-slots { display: flex; gap: 10px; max-width: 300px; margin: 0 auto; }
.photo-slot { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.photo-slot-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); text-align: center; }

.photo-frame {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface2); overflow: hidden;
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color 0.2s;
}
.photo-frame:active { opacity: 0.75; }
.photo-frame.has-photo { border-color: rgba(184,146,10,0.4); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-frame-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}
.photo-frame-empty-text { font-size: 0.55rem; letter-spacing: 0.06em; color: var(--text-muted); opacity: 0.6; text-align: center; line-height: 1.4; }

.photo-uploading {
  position: absolute; inset: 0; background: rgba(15,13,8,0.8);
  display: flex; align-items: center; justify-content: center;
}
.upload-spinner { width: 24px; height: 24px; border: 2px solid rgba(232,196,74,0.2); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.photo-delete-btn {
  position: absolute; top: 3px; right: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(140,74,74,0.92); border: none;
  color: #fff; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── Lightbox ─────────────────────────────────── */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.94); flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox-img {
  max-width: min(90vw, 90vh); max-height: min(90vw, 90vh);
  width: min(90vw, 90vh); height: min(90vw, 90vh);
  border-radius: 50%; object-fit: cover;
  border: 3px solid var(--gold-dark);
  box-shadow: 0 0 60px rgba(232,196,74,0.2);
}
.lightbox-label { margin-top: 18px; font-family: 'Playfair Display', serif; color: var(--gold); font-size: 1rem; letter-spacing: 0.12em; }
.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Loading / error ─────────────────────────── */
.loading-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg); }
.loading-coin { width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFE566, #D4A800 55%, #8B6500); animation: flipCoin 1.5s ease-in-out infinite; box-shadow: 0 0 24px rgba(232,196,74,0.3); }
@keyframes flipCoin { 0%, 100% { transform: rotateY(0deg); } 50% { transform: rotateY(180deg); } }
.loading-text { font-family: 'Playfair Display', serif; color: var(--text-muted); font-size: 0.85rem; letter-spacing: 0.15em; }

.error-banner { background: var(--red); color: #fff; padding: 10px 16px; font-size: 0.75rem; text-align: center; display: none; }
.error-banner.visible { display: block; }

.config-notice { margin: 20px 16px; border: 1px dashed var(--gold-dark); border-radius: 8px; padding: 20px; text-align: center; display: none; }
.config-notice.visible { display: block; }
.config-notice h2 { font-family: 'Playfair Display', serif; color: var(--gold); font-size: 1.1rem; margin-bottom: 8px; }
.config-notice p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; }
.config-notice code { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; padding: 2px 5px; font-size: 0.72rem; color: var(--gold-light); display: inline-block; margin-top: 4px; }
