:root {
  --parchment: #f5e6c8;
  --parchment-dark: #ead5a8;
  --brown: #3d1f00;
  --brown-light: #6b3a10;
  --gold: #d4a017;
  --gold-dark: #b8880e;
  --green: #2d5016;
  --green-light: #3d6b1f;
  --red: #c0392b;
  --red-light: #f8d7d4;
  --shadow: 0 4px 16px rgba(61,31,0,0.15);
  --shadow-sm: 0 2px 8px rgba(61,31,0,0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--parchment);
  color: var(--brown);
  min-height: 100vh;
  padding: 0 0 2rem;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(212,160,23,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(45,80,22,0.06) 0%, transparent 50%);
}

/* ---- Layout ---- */
.page-center {
  max-width: 420px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}
.page-center--wide {
  max-width: 680px;
}

/* ---- Back link ---- */
.back-link {
  display: inline-block;
  color: var(--brown-light);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.back-link:hover { background: var(--parchment-dark); }

/* ---- Hero ---- */
.hero { text-align: center; padding: 1.5rem 0 1rem; }
.hero-icon { font-size: 3.5rem; margin-bottom: 0.5rem; animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.hero-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 2.2rem;
  color: var(--brown);
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.hero-subtitle {
  color: var(--brown-light);
  font-size: 1rem;
  margin-top: 0.4rem;
  font-weight: 600;
}

/* ---- Role cards ---- */
.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}
.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.role-card:active { transform: scale(0.96); }
.role-card--organizer { background: var(--brown); color: var(--parchment); }
.role-card--player { background: var(--gold); color: var(--brown); }
.role-card__icon { font-size: 2.2rem; margin-bottom: 0.4rem; }
.role-card__label { font-family: 'Luckiest Guy', cursive; font-size: 1.1rem; letter-spacing: 0.03em; }
.role-card__desc { font-size: 0.78rem; font-weight: 600; opacity: 0.75; margin-top: 0.2rem; text-align: center; }

.footer-note { text-align: center; color: var(--brown-light); font-weight: 600; font-size: 0.9rem; margin-top: 1.5rem; }

/* ---- Page header ---- */
.page-header { text-align: center; margin-bottom: 1.5rem; }
.page-header__icon { font-size: 2.5rem; margin-bottom: 0.25rem; }
.page-header__title { font-family: 'Luckiest Guy', cursive; font-size: 1.8rem; letter-spacing: 0.04em; }
.page-header__subtitle { color: var(--brown-light); font-size: 0.95rem; font-weight: 600; margin-top: 0.2rem; }

/* ---- Cards ---- */
.card {
  background: #fff8ee;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card--gold { border-color: var(--gold); background: #fffbf0; }
.card__title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  margin-bottom: 0.9rem;
  color: var(--brown);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  min-height: 48px;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--gold); color: var(--brown); }
.btn--primary:hover { background: var(--gold-dark); }

.btn--outline {
  background: transparent;
  color: var(--brown);
  border: 2px solid var(--parchment-dark);
  box-shadow: none;
}
.btn--outline:hover { background: var(--parchment-dark); }

.btn--full { width: 100%; }
.btn--large { font-size: 1.1rem; padding: 0.9rem 1.5rem; }

.btn--small {
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  min-height: 36px;
  border-radius: 8px;
}
.btn--warning { background: #f39c12; color: #fff; }
.btn--danger { background: var(--red); color: #fff; }
.btn--ghost { background: transparent; color: var(--brown); border: 2px solid var(--parchment-dark); }
.btn--ghost:hover { background: var(--parchment-dark); }
.btn--sm { font-size: 0.82rem; padding: 0.35rem 0.75rem; min-height: 36px; border-radius: 8px; }

/* ---- Game list ---- */
.game-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0; }
.game-list__item { border-bottom: 1.5px solid var(--parchment-dark); }
.game-list__item:last-child { border-bottom: none; }
.game-list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0.25rem;
  text-decoration: none;
  color: inherit;
  gap: 0.5rem;
  transition: background 0.15s;
  border-radius: var(--radius-sm);
}
.game-list__link:hover { background: var(--parchment-dark); padding-left: 0.5rem; }
.game-list__info { display: flex; flex-direction: column; gap: 0.2rem; }
.game-list__title { font-size: 1rem; font-weight: 800; color: var(--brown); }
.game-list__meta { font-size: 0.8rem; color: #a08060; }
.game-list__arrow { font-size: 1.5rem; color: var(--gold); font-weight: 900; flex-shrink: 0; }

.btn-row { display: flex; gap: 0.75rem; margin-top: 1rem; }
.btn-row .btn { flex: 1; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-label { font-weight: 700; font-size: 0.9rem; color: var(--brown); }
.form-label .required { color: var(--red); }
.form-input {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  background: #fff;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  width: 100%;
  min-height: 48px;
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--gold); }
.form-textarea { resize: vertical; min-height: 90px; }

/* ---- Verify toggle ---- */
.verify-toggle { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.verify-option { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.verify-option input[type="radio"] { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; }
.verify-option__label { font-weight: 700; font-size: 0.9rem; }

/* ---- Alerts ---- */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
}
.alert--error { background: var(--red-light); color: var(--red); border: 1.5px solid var(--red); }
.alert--success { background: #d4f5d4; color: var(--green); border: 1.5px solid var(--green); }

/* ---- Info box ---- */
.info-box {
  background: rgba(212,160,23,0.12);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brown-light);
  margin-top: 0.5rem;
}

/* ---- Game header ---- */
.game-header { text-align: center; margin-bottom: 1rem; }
.game-header__title { font-family: 'Luckiest Guy', cursive; font-size: 1.6rem; letter-spacing: 0.04em; }
.game-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--brown);
  color: var(--parchment);
  border-radius: 50px;
  padding: 0.3rem 1rem;
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
}
.game-code-badge__code { font-family: monospace; font-size: 1.1rem; letter-spacing: 0.1em; color: var(--gold); }

/* ---- Share section ---- */
.share-url-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.share-url {
  flex: 1;
  font-family: monospace;
  font-size: 0.78rem;
  background: var(--parchment);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  word-break: break-all;
  color: var(--brown);
  min-width: 0;
}
.copy-confirm { color: var(--green); font-weight: 700; font-size: 0.85rem; margin-top: 0.25rem; }
.qr-code { margin-top: 0.75rem; max-width: 140px; }
.qr-code svg { width: 100%; height: auto; border-radius: 8px; background: #fff; padding: 4px; }

/* ---- Section header ---- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.section-title { font-family: 'Luckiest Guy', cursive; font-size: 1.15rem; letter-spacing: 0.03em; }
.auto-refresh-note { font-size: 0.78rem; color: var(--brown-light); font-weight: 600; }

/* ---- Task list ---- */
.task-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.task-card {
  background: #fff8ee;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--radius);
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.task-card__thumb {
  width: 80px;
  min-width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: var(--radius) 0 0 var(--radius);
}
.task-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-card__body { flex: 1; padding: 0.6rem 0.5rem; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.task-card__meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; flex-wrap: wrap; }
.task-number { font-weight: 800; font-size: 0.82rem; color: var(--brown-light); }
.verify-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
}
.verify-badge--ai { background: rgba(45,80,22,0.12); color: var(--green); }
.verify-badge--code { background: rgba(212,160,23,0.2); color: var(--brown); }
.task-card__instructions { font-size: 0.82rem; color: var(--brown-light); font-weight: 600; line-height: 1.4; }
.task-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  justify-content: center;
  border-left: 1.5px solid var(--parchment-dark);
}

/* ---- Photo preview ---- */
.photo-preview { margin-top: 0.5rem; }
.photo-preview img { max-width: 100%; max-height: 160px; object-fit: cover; border-radius: var(--radius-sm); }

/* ---- Participants ---- */
.participant-list { display: flex; flex-direction: column; gap: 0.6rem; }
.participant-card {
  background: #fff8ee;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow-sm);
}
.participant-card__name { flex: 1; font-weight: 800; font-size: 0.95rem; }
.participant-card__status { font-size: 0.8rem; color: var(--brown-light); font-weight: 600; }
.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
}
.status-badge--active { background: rgba(212,160,23,0.2); color: var(--brown); }
.status-badge--done { background: rgba(45,80,22,0.15); color: var(--green); }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-state__icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state__text { color: var(--brown-light); font-weight: 600; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61,31,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: #fff8ee;
  border: 2px solid var(--parchment-dark);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(61,31,0,0.3);
}

/* ---- Task progress (player) ---- */
.task-progress { margin-bottom: 1.25rem; }
.task-progress__bar {
  height: 8px;
  background: var(--parchment-dark);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.task-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--green));
  border-radius: 50px;
  transition: width 0.5s ease;
}
.task-progress__label { font-size: 0.85rem; font-weight: 700; color: var(--brown-light); text-align: center; display: block; }

/* ---- Task clue card ---- */
.task-clue-card {
  background: #fff8ee;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.task-clue-card__header {
  background: var(--brown);
  color: var(--gold);
  padding: 0.6rem 1rem;
  font-family: 'Luckiest Guy', cursive;
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.task-clue-card__photo { position: relative; }
.task-clue-card__photo img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.task-clue-card__photo-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(61,31,0,0.7);
  color: var(--parchment);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  text-align: center;
}
.task-clue-card__instructions {
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--brown);
}

/* ---- Photo capture ---- */
.photo-capture-area { display: flex; flex-direction: column; align-items: stretch; }
.photo-preview-area { display: flex; flex-direction: column; align-items: center; }

/* ---- Success banner ---- */
.success-banner {
  text-align: center;
  padding: 1.5rem;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.success-banner__check { font-size: 3rem; margin-bottom: 0.3rem; }
.success-banner__text { font-family: 'Luckiest Guy', cursive; font-size: 1.8rem; color: var(--green); letter-spacing: 0.05em; }

/* ---- Spinner ---- */
.spinner { font-size: 2rem; animation: spin 1.5s linear infinite; display: inline-block; }
@keyframes spin { 0%{ transform: rotate(0deg); } 100%{ transform: rotate(360deg); } }

/* ---- Complete screen ---- */
.complete-screen { text-align: center; padding: 2rem 0 1rem; }
.complete-screen__trophy { font-size: 5rem; margin-bottom: 0.5rem; animation: bounce 0.8s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.complete-screen__title { font-family: 'Luckiest Guy', cursive; font-size: 2.2rem; color: var(--brown); letter-spacing: 0.04em; }
.complete-screen__name { font-family: 'Luckiest Guy', cursive; font-size: 1.5rem; color: var(--gold); margin: 0.25rem 0; }
.complete-screen__subtitle { font-size: 1.1rem; font-weight: 700; margin-top: 0.5rem; }
.complete-screen__game { color: var(--brown-light); font-size: 0.9rem; font-weight: 600; margin-top: 0.25rem; }
.complete-screen__reward {
  margin-top: 1.1rem;
  background: var(--parchment-dark);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown);
  line-height: 1.5;
  white-space: pre-wrap;
}
.stars-row { text-align: center; font-size: 1.8rem; letter-spacing: 0.1em; margin-top: 0.5rem; animation: fadeIn 1s 0.5s both; }
@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform:none; } }

/* ---- Page fade in ---- */
body { animation: pageFadeIn 0.3s ease; }
@keyframes pageFadeIn { from { opacity:0; } to { opacity:1; } }

/* ---- Instruction photos (player view) ---- */
.task-clue-card__instr-photos {
  border-top: 2px dashed var(--parchment-dark);
  padding: 0.75rem 1rem 0.5rem;
}
.instr-photo-label {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--brown-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.instr-photo-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.instr-photo-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--parchment-dark);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.instr-photo-thumb:active { transform: scale(0.97); }

/* ---- Instruction photo lightbox ---- */
.instr-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,10,0,0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: zoom-out;
}
.instr-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
}
.instr-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Instruction photos (organizer form preview) ---- */
.instr-photos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.instr-photos-preview img {
  width: 72px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--parchment-dark);
}
.instr-photos-preview--edit img { opacity: 0.85; }

/* ---- Form hint inline ---- */
.form-hint-inline { font-size: 0.8rem; font-weight: 600; color: var(--brown-light); }
.form-hint { font-size: 0.82rem; color: var(--brown-light); margin-top: 4px; }
