@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --ink: #17221d;
  --muted: #68736d;
  --paper: #f4f0e7;
  --card: #fffdf8;
  --line: #dcd7cb;
  --green: #234b3d;
  --green-light: #dce9df;
  --coral: #da6b51;
  --gold: #c9a44d;
  --error: #a83f36;
  --shadow: 0 24px 70px rgba(28, 48, 39, .11);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: "DM Sans", sans-serif; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: "Playfair Display", serif; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1.02; margin-bottom: .8rem; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: .45rem; }

.site-header { height: 72px; padding: 0 clamp(18px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(35,75,61,.12); background: rgba(244,240,231,.9); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; font-family: "Playfair Display", serif; text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; color: #fff; background: var(--green); border-radius: 50% 50% 45% 55%; font-size: 1.15rem; }
.header-actions { display: flex; align-items: center; gap: 15px; }
.user-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; color: var(--muted); background: rgba(255,255,255,.55); }
.inline-form { display: inline; margin: 0; }
.text-button { border: 0; padding: 4px; background: none; color: var(--green); font-weight: 700; cursor: pointer; text-decoration: none; }
.text-button:hover, .text-link:hover { text-decoration: underline; }
.text-button.danger { color: var(--error); }
.text-link, .back-link { color: var(--green); font-weight: 700; text-decoration: none; }
.back-link { display: block; font-size: .86rem; margin-bottom: 18px; }

.flash-stack { position: fixed; top: 86px; right: 20px; z-index: 50; display: grid; gap: 8px; width: min(390px, calc(100vw - 40px)); }
.flash { padding: 13px 16px; border-radius: 12px; background: var(--card); border-left: 4px solid var(--green); box-shadow: 0 12px 35px rgba(0,0,0,.13); animation: flash-in .25s ease-out; }
.flash-error { border-color: var(--error); }
.flash-success { border-color: #38805d; }
.flash-info { border-color: var(--gold); }
.flash.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity .25s ease, transform .25s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }

.eyebrow, .card-label, .story-kicker { display: block; margin-bottom: 9px; color: var(--coral); font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 46px; padding: 11px 20px; border: 1px solid transparent; border-radius: 999px; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .52; cursor: wait; transform: none; }
.button-primary { color: white; background: var(--green); box-shadow: 0 9px 24px rgba(35,75,61,.18); }
.button-primary:hover { background: #183a2f; box-shadow: 0 11px 29px rgba(35,75,61,.25); }
.button-secondary { color: var(--green); border-color: rgba(35,75,61,.22); background: var(--green-light); }
.button-danger { color: white; background: var(--error); box-shadow: 0 9px 24px rgba(168,63,54,.18); }
.button-danger:hover { background: #8f3029; box-shadow: 0 11px 29px rgba(168,63,54,.25); }
.button-wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); cursor: pointer; color: var(--green); font-weight: 800; }

.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-size: .8rem; color: var(--muted); font-weight: 700; }
label small { font-weight: 400; }
input, textarea, select { width: 100%; min-height: 47px; padding: 11px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.85); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35,75,61,.1); }

/* Login */
.login-page { background: var(--green); }
.login-page::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .13; background-image: radial-gradient(circle at 20% 30%, #f5d776 0 1px, transparent 2px), radial-gradient(circle at 80% 60%, #fff 0 1px, transparent 2px); background-size: 38px 38px, 53px 53px; }
.login-shell { width: min(1180px, calc(100% - 40px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(40px, 8vw, 120px); padding: 60px 0; position: relative; }
.login-story { color: white; }
.login-story h1 { max-width: 720px; font-size: clamp(3.2rem, 7vw, 6.7rem); }
.story-kicker { color: #efba83; }
.story-subtitle { max-width: 580px; color: #ebeee7; font-size: clamp(1.05rem, 2vw, 1.35rem); }
.story-copy { max-width: 570px; color: rgba(255,255,255,.72); line-height: 1.7; }
.route-line { display: flex; align-items: center; max-width: 460px; margin: 35px 0 28px; }
.route-line span { width: 12px; height: 12px; border: 2px solid #efba83; border-radius: 50%; }
.route-line i { flex: 1; border-top: 2px dashed rgba(239,186,131,.65); }
.route-line strong { color: #efba83; font-size: 2rem; line-height: 1; }
.login-card { padding: clamp(28px, 5vw, 52px); border-radius: 30px; background: var(--card); box-shadow: 0 35px 100px rgba(0,0,0,.28); }
.login-card h2 { margin-bottom: 28px; }
.login-note { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: .78rem; }

/* Hunt */
.hunt-page { background: linear-gradient(120deg, #e8e4d9, var(--paper) 55%); }
.hunt-layout { width: min(1160px, calc(100% - 36px)); margin: 50px auto 90px; display: grid; grid-template-columns: 245px minmax(0, 760px); justify-content: center; align-items: start; gap: clamp(32px, 6vw, 85px); }
.hunt-rail { position: sticky; top: 118px; padding-top: 12px; }
.progress-copy { font-family: "Playfair Display", serif; font-size: 1.55rem; font-weight: 700; }
.progress-track { height: 5px; margin: 20px 0 36px; overflow: hidden; border-radius: 5px; background: #d3d3c9; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--coral); }
.timer-block { padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.timer-block span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.timer-block strong { font-size: 1.75rem; letter-spacing: .05em; font-variant-numeric: tabular-nums; }
.score-block { display: flex; align-items: baseline; justify-content: space-between; padding: 17px 0; border-bottom: 1px solid var(--line); }
.score-block span { color: var(--muted); font-size: .75rem; }
.score-block strong { color: var(--coral); font-family: "Playfair Display", serif; font-size: 2rem; }
.sync-status { display: flex; align-items: center; gap: 8px; margin-top: 17px; color: var(--muted); font-size: .73rem; }
.sync-status i { width: 7px; height: 7px; border-radius: 50%; background: #3c9468; box-shadow: 0 0 0 4px rgba(60,148,104,.12); }
.sync-status.is-offline i { background: var(--error); }
.quest-card { padding: clamp(28px, 5vw, 60px); border: 1px solid rgba(35,75,61,.1); border-radius: 32px; background: var(--card); box-shadow: var(--shadow); }
.quest-heading { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 27px; }
.quest-heading h1 { font-size: clamp(2rem, 5vw, 3.6rem); margin: 0; }
.quest-number { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid rgba(218,107,81,.35); border-radius: 50%; color: var(--coral); font-family: "Playfair Display", serif; font-weight: 700; }
.quest-copy { color: #35413b; font-size: clamp(1.03rem, 2vw, 1.17rem); line-height: 1.85; }
.gallery { margin: 30px 0; }
.gallery-stage { position: relative; overflow: hidden; aspect-ratio: 16/10; border-radius: 18px; background: #e5e1d8; }
.gallery-stage img { display: none; width: 100%; height: 100%; object-fit: cover; }
.gallery-stage img.is-active { display: block; }
.gallery-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 12px; color: var(--muted); font-size: .8rem; }
audio { width: 100%; margin: 24px 0; }
.answer-form { display: grid; gap: 16px; margin-top: 34px; padding-top: 28px; border-top: 1px solid var(--line); }
.answer-form label { font-size: .85rem; }
.answer-form input[name="answer"] { min-height: 55px; font-size: 1rem; }
.wait-copy { margin: -6px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }
.ready-copy { margin: 0; color: var(--muted); text-align: center; }
.number-grid { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(35px, 54px)); gap: 8px; justify-content: center; margin: 4px 0 10px; }
.number-grid input { min-width: 0; height: 54px; padding: 5px; text-align: center; font-size: 1.3rem; font-weight: 700; }
.file-drop { position: relative; display: grid; place-items: center; min-height: 120px; padding: 25px; border: 1px dashed var(--green); border-radius: 15px; background: rgba(220,233,223,.35); color: var(--green); text-align: center; cursor: pointer; }
.file-drop small { color: var(--muted); }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.hint-panel { margin-top: 20px; }
.hint-content { margin-top: 14px; padding: 24px; border-radius: 15px; background: #f2e7d9; color: #593d2e; }
.hint-content p { margin-bottom: 15px; line-height: 1.65; }
.hint-content img { max-width: 100%; border-radius: 11px; margin-top: 10px; }
.skip-form { margin-top: 24px; text-align: center; }

/* Finish */
.finished-page { background: var(--green); color: white; }
.finish-shell { min-height: calc(100vh - 72px); width: min(720px, calc(100% - 36px)); margin: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 0; }
.finish-shell h1 { font-size: clamp(3rem, 9vw, 6rem); }
.finish-shell p { max-width: 580px; color: rgba(255,255,255,.72); font-size: 1.15rem; line-height: 1.7; }
.finish-mark { color: #efba83; font-family: "Playfair Display", serif; font-size: 5rem; }
.finish-stats { display: flex; gap: 50px; margin-top: 25px; }
.finish-stats div { display: grid; }
.finish-stats strong { color: #efba83; font-family: "Playfair Display", serif; font-size: 2.6rem; }
.finish-stats span { color: rgba(255,255,255,.62); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.simple-shell { width: min(700px, calc(100% - 36px)); min-height: calc(100vh - 72px); margin: auto; display: grid; place-content: center; justify-items: start; }

/* Admin */
.admin-page { background: #f1f3ef; }
.admin-shell { width: min(1320px, calc(100% - 40px)); margin: 48px auto 100px; }
.narrow-admin { width: min(980px, calc(100% - 40px)); }
.admin-title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.admin-title-row h1 { margin: 0; font-size: clamp(2.3rem, 5vw, 4.2rem); }
.admin-title-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.admin-metrics div { display: flex; align-items: baseline; gap: 9px; padding: 19px 22px; border-radius: 15px; color: white; background: var(--green); }
.admin-metrics strong { font-family: "Playfair Display", serif; font-size: 2rem; }
.admin-metrics span { color: rgba(255,255,255,.68); font-size: .75rem; }
.admin-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; align-items: start; }
.admin-card { padding: clamp(22px, 3vw, 34px); border: 1px solid rgba(35,75,61,.11); border-radius: var(--radius); background: var(--card); box-shadow: 0 12px 35px rgba(28,48,39,.06); }
.admin-card-wide { grid-row: span 2; }
.section-heading { display: flex; justify-content: space-between; margin-bottom: 22px; }
.admin-list { display: grid; }
.admin-list-row { display: flex; align-items: center; gap: 13px; min-height: 65px; padding: 12px 3px; border-top: 1px solid #ebe8df; }
.admin-list-row:first-child { border-top: 0; }
.admin-list-row.is-muted { opacity: .53; }
.admin-list-row small { display: block; margin-top: 4px; color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.order-pill { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; color: var(--green); background: var(--green-light); font-weight: 700; }
.status-dot { white-space: nowrap; color: var(--muted); font-size: .72rem; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #aaa; }
.status-dot.active::before { background: #3c9468; }
.team-row { color: inherit; text-decoration: none; border-radius: 9px; }
.team-row:hover { background: #f7f5ef; }
.team-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: white; background: var(--coral); font-weight: 700; }
.empty-state { padding: 35px; color: var(--muted); border: 1px dashed var(--line); border-radius: 13px; text-align: center; }
.compact-form { gap: 13px; }
.form-grid { display: grid; gap: 17px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-two { grid-column: 1 / -1; }
.check-row { display: flex; flex-wrap: wrap; gap: 28px; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--ink); cursor: pointer; }
.check-label input { width: 18px; min-height: 18px; accent-color: var(--green); }
.grid-answer-editor { display: grid; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #f8f7f2; }
.correct-grid { margin: 0; justify-content: start; }
.correct-grid input { width: 54px; min-height: 54px; background: white; }
.initial-media-fields { display: grid; gap: 18px; margin-top: 6px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #f8f7f2; }
.initial-media-fields h2 { margin-bottom: 5px; }
.initial-media-fields input[type="file"] { padding: 8px; background: white; }
.initial-media-fields label > small { min-height: 18px; color: var(--green); overflow-wrap: anywhere; }
.hint-settings { display: grid; gap: 16px; padding: 20px; border: 1px solid #dfcba5; border-radius: 14px; background: #fff8e5; }
.quest-editor { margin-bottom: 18px; }
.media-manager h3 { margin-top: 34px; font-size: 1rem; }
.muted-copy { color: var(--muted); line-height: 1.6; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.media-tile { position: relative; overflow: hidden; aspect-ratio: 4/3; border-radius: 12px; background: #ddd; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; }
.media-tile form { position: absolute; top: 7px; right: 7px; }
.media-tile button { display: grid; place-items: center; width: 29px; height: 29px; border: 0; border-radius: 50%; color: white; background: rgba(25,25,25,.72); cursor: pointer; }
.media-upload { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.media-upload input { flex: 1; }
.danger-zone { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 22px; padding: 22px; text-align: center; }
.notice-card { margin-bottom: 18px; padding: 17px 20px; border-left: 4px solid var(--gold); border-radius: 9px; background: #fff8e5; color: #6a5732; font-size: .87rem; }
.route-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.route-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.route-heading h2 { font-size: 1.25rem; margin: 0; }
.route-heading span { color: var(--muted); }
.sortable-list, .available-list { min-height: 180px; display: grid; align-content: start; gap: 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 13px; background: #f8f7f2; }
.sortable-item, .available-quest { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; text-align: left; }
.sortable-item { cursor: grab; }
.sortable-item.is-dragging { opacity: .4; }
.sortable-item div, .available-quest div { flex: 1; }
.sortable-item small, .available-quest small { display: block; color: var(--muted); font-size: .69rem; }
.drag-handle { color: #a5aaa6; font-size: 1.2rem; }
.available-quest { width: 100%; cursor: pointer; }
.available-quest:hover { border-color: var(--green); }
.available-quest > span { color: var(--green); font-size: 1.4rem; }
.crop-dialog { width: min(900px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 22px; background: var(--card); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.crop-dialog::backdrop { background: rgba(12,27,21,.75); backdrop-filter: blur(3px); }
.crop-dialog-head, .crop-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 20px 25px; }
.crop-dialog-head { border-bottom: 1px solid var(--line); }
.crop-dialog-head h2 { margin: 0; }
.crop-stage { height: min(58vh, 540px); background: #18241f; }
.crop-stage img { display: block; max-width: 100%; }
.crop-actions { justify-content: flex-end; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; gap: 35px; }
  .login-story h1 { font-size: clamp(3rem, 13vw, 5rem); }
  .hunt-layout { grid-template-columns: 1fr; margin-top: 24px; gap: 18px; }
  .hunt-rail { position: static; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 20px; padding: 14px; border-radius: 15px; background: rgba(255,255,255,.58); }
  .progress-track { grid-column: 1 / -1; grid-row: 2; margin: 5px 0; }
  .timer-block { padding: 0; border: 0; text-align: right; }
  .timer-block strong { font-size: 1.3rem; }
  .sync-status { grid-column: 1 / -1; margin: 5px 0 0; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-card-wide { grid-row: auto; }
  .route-builder { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-header { height: 62px; }
  .brand > span:last-child, .user-chip { display: none; }
  .login-shell { width: min(100% - 28px, 520px); padding: 35px 0; }
  .login-story h1 { font-size: 3rem; }
  .route-line { margin: 22px 0; }
  .login-card { padding: 27px 22px; border-radius: 22px; }
  .hunt-layout { width: min(100% - 20px, 760px); margin-bottom: 40px; }
  .hunt-rail { grid-template-columns: 1fr 125px; }
  .quest-card { padding: 26px 18px; border-radius: 22px; }
  .quest-heading { gap: 12px; }
  .quest-number { width: 40px; height: 40px; }
  .gallery-stage { aspect-ratio: 4/3; }
  .admin-shell, .narrow-admin { width: min(100% - 24px, 980px); margin-top: 28px; }
  .admin-title-row { align-items: flex-start; flex-direction: column; }
  .admin-metrics { grid-template-columns: 1fr; }
  .admin-metrics div { padding: 12px 18px; }
  .admin-card { padding: 20px 15px; }
  .admin-list-row { flex-wrap: wrap; }
  .admin-list-row .grow { min-width: calc(100% - 55px); }
  .two-cols, .three-cols { grid-template-columns: 1fr; }
  .media-upload { align-items: stretch; flex-direction: column; }
  .crop-actions { flex-wrap: wrap; }
  .crop-actions .button { flex: 1; }
}
