* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: #fbfaf7; color: #202322; }
header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: rgba(255,255,255,.96); border-bottom: 1px solid #dedbd2; }
h1 { margin: 0; font-size: clamp(20px, 4vw, 30px); }
nav { display: flex; gap: 8px; }
button { border: 1px solid #2b5962; background: #2b5962; color: #fff; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
button.active { background: #1a3a41; border-color: #1a3a41; }
main { padding: 20px; }
.hidden { display: none !important; }

/* Empty / loading / error states */
.empty-state, .loading, .error { text-align: center; padding: 40px 20px; color: #59615f; }
.error { color: #c0392b; }

/* Gallery grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid #dedbd2; border-radius: 8px; overflow: hidden; cursor: pointer; transition: box-shadow 0.15s; }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #ece9e1; display: block; }
.card-body { padding: 10px; }
.card-body h2 { margin: 0 0 4px; font-size: 16px; }
.card-body .year { margin: 0 0 6px; color: #59615f; font-size: 14px; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { background: #e8f0f1; color: #2b5962; font-size: 12px; border-radius: 4px; padding: 2px 7px; }

/* Ranking pair */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 980px; margin: 0 auto; }
.choice { background: #fff; border: 1px solid #dedbd2; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.choice img { width: 100%; height: min(58vh, 560px); object-fit: contain; background: #ece9e1; }
.choice h2 { margin: 0; font-size: 18px; }
.btn-prefer { width: 100%; padding: 10px; font-size: 15px; }
.invite-prompt { max-width: 400px; margin: 60px auto; display: flex; flex-direction: column; gap: 12px; }
.invite-prompt label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.invite-prompt input { padding: 8px; border: 1px solid #dedbd2; border-radius: 6px; font-size: 14px; }

/* Leaderboard */
.leaderboard { max-width: 840px; margin: 0 auto; background: #fff; border: 1px solid #dedbd2; border-radius: 8px; overflow: hidden; }
.rank-row { display: grid; grid-template-columns: 40px 52px 1fr 70px 90px; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eee; }
.rank-row:last-child { border-bottom: none; }
.rank-pos { font-weight: bold; text-align: right; color: #2b5962; }
.rank-thumb { width: 48px; height: 36px; object-fit: contain; background: #ece9e1; border-radius: 4px; display: block; }
.rank-title { font-size: 15px; }
.rank-elo { font-weight: bold; text-align: right; }
.rank-record { font-size: 13px; color: #59615f; text-align: right; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-body { position: relative; background: #fff; border-radius: 10px; max-width: 820px; width: 100%; max-height: 90vh; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.modal-body img { width: 100%; max-height: 70vh; object-fit: contain; background: #ece9e1; border-radius: 10px 0 0 10px; display: block; }
.modal-info { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.modal-info h2 { margin: 0; font-size: 22px; }
.modal-info .year, .modal-info .meta { margin: 0; color: #59615f; font-size: 14px; }
.modal-info .description { margin: 0; line-height: 1.55; }
.modal-close { position: absolute; top: 10px; right: 12px; background: transparent; border: none; color: #59615f; font-size: 22px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-body .loading { padding: 60px; grid-column: span 2; }

@media (max-width: 760px) {
  header { display: block; }
  nav { margin-top: 10px; }
  .pair { grid-template-columns: 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-body img { border-radius: 10px 10px 0 0; max-height: 50vw; }
  .rank-row { grid-template-columns: 30px 40px 1fr 60px; }
  .rank-record { display: none; }
}

