:root {
  --ink: #10243e;
  --ink-soft: #526071;
  --paper: #f7f1e7;
  --paper-deep: #eee4d3;
  --white: #fffdf9;
  --emerald: #08775f;
  --emerald-dark: #075d4c;
  --coral: #df6659;
  --line: #d8cdbc;
  --shadow: 0 20px 60px rgb(16 36 62 / 10%);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgb(223 102 89 / 7%) 0 1px, transparent 1.5px) 0 0 / 20px 20px,
    var(--paper);
  font-family: var(--sans);
  line-height: 1.55;
}
button, input { font: inherit; }
a { color: inherit; text-decoration-thickness: .08em; text-underline-offset: .18em; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 100; top: .75rem; left: .75rem; padding: .7rem 1rem; background: var(--ink); color: white; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header {
  width: min(calc(100% - 2rem), 1120px);
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; min-height: 44px; font: 700 1.35rem/1 var(--serif); text-decoration: none; }
.brand em { color: var(--coral); font-weight: 400; }
.brand-mark { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 4; }
.primary-nav { position: relative; display: flex; align-items: center; gap: .45rem; font-size: .9rem; font-weight: 700; }
.primary-nav > a, .menu-button { min-height: 44px; display: inline-flex; align-items: center; padding: 0 .75rem; border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: none; }
.menu-button::after { content: '↓'; margin-left: .4rem; transition: transform .18s ease; }
.menu-button[aria-expanded="true"]::after { transform: rotate(180deg); }
.menu-panel { position: absolute; z-index: 20; top: calc(100% + .35rem); right: 0; width: 180px; padding: .45rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.menu-panel a { display: flex; align-items: center; min-height: 44px; padding: .4rem .7rem; border-radius: 8px; text-decoration: none; }
.menu-panel a:hover { background: var(--paper); }

main { min-height: calc(100vh - 214px); }
.game-shell, .page-shell { width: min(calc(100% - 2rem), 720px); margin: clamp(2rem, 6vw, 4.5rem) auto; }
.game-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.eyebrow { display: block; margin-bottom: .35rem; color: var(--emerald-dark); font-size: .74rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { font-family: var(--serif); line-height: 1.05; }
h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.6rem); letter-spacing: -.035em; }
h2 { margin: 2rem 0 .55rem; font-size: 1.5rem; }
.game-meta { display: grid; justify-items: end; gap: .3rem; }
.game-heading time { color: var(--ink-soft); font-size: .86rem; font-weight: 650; }
.timer { color: var(--ink-soft); font-size: .76rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.timer strong { color: var(--ink); font-family: ui-monospace, 'Cascadia Mono', monospace; font-size: .92rem; }

.progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.progress li { min-width: 0; }
.progress button { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: .35rem; border: 0; border-bottom: 6px solid var(--line); background: transparent; color: var(--ink-soft); cursor: pointer; font-size: .75rem; font-weight: 800; }
.progress button:disabled { cursor: default; }
.progress .is-current button { border-bottom-color: var(--coral); color: var(--ink); }
.progress .is-solved button { border-bottom-color: var(--emerald); color: var(--emerald-dark); }
.progress .is-revealed button { border-bottom-color: #7b8490; color: var(--ink-soft); }
.progress .is-active:not(.is-current) button { border-bottom-color: var(--coral); }
.bridge-card { position: relative; overflow: hidden; padding: clamp(1.4rem, 5vw, 3rem); border: 1px solid var(--line); border-radius: 24px; background: rgb(255 253 249 / 92%); box-shadow: var(--shadow); text-align: center; }
.bridge-card.is-shaking { animation: shake .26s ease-in-out; }
.bridge-number { position: absolute; top: .75rem; right: 1rem; color: var(--paper-deep); font: 700 clamp(3rem, 10vw, 5rem)/1 var(--serif); }
.bridge-prompt { position: relative; margin: .25rem 0; font: 700 clamp(1.45rem, 6vw, 2.4rem)/1.2 var(--serif); letter-spacing: .015em; }
.bridge-prompt span { color: var(--coral); letter-spacing: .12em; }
.bridge-glyph { width: 72px; height: 34px; margin: .65rem 0; fill: none; stroke: var(--emerald); stroke-linecap: round; stroke-width: 2.5; }
.answer-form { margin-top: 2rem; text-align: left; }
.answer-form label { display: block; margin-bottom: .45rem; font-size: .85rem; font-weight: 750; }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: .6rem; }
.answer-row input { width: 100%; min-height: 52px; padding: 0 1rem; border: 1px solid #a99e8e; border-radius: 10px; background: white; color: var(--ink); text-transform: uppercase; }
.answer-row input::placeholder { color: #767d85; text-transform: none; }
.button, .icon-button, .text-button { min-height: 44px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; }
.button { padding: .65rem 1.1rem; }
.button-primary { min-height: 52px; background: var(--emerald); color: white; }
.button-primary:hover { background: var(--emerald-dark); }
.button-quiet { background: var(--paper-deep); color: var(--ink); }
.button-reward { background: var(--coral); color: white; }
.text-button { padding: .5rem; background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: .2rem; }
.status-message { min-height: 2.6em; margin: .55rem 0 0; color: var(--ink-soft); font-size: .84rem; }
.status-message[data-kind="success"] { color: var(--emerald-dark); font-weight: 700; }
.status-message[data-kind="error"] { color: #a13e35; font-weight: 700; }
.game-actions { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .8rem; }
.vibration-toggle { min-height: 44px; display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-soft); cursor: pointer; font-size: .78rem; font-weight: 700; }
.vibration-toggle input { width: 18px; height: 18px; accent-color: var(--emerald); }
.hint-pattern { margin: 1rem 0 0; color: var(--ink); font-family: var(--serif); font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; }
.resolution { margin-top: 1.8rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.resolution-state { display: block; margin-bottom: .25rem; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.resolution-state.is-solved { color: var(--emerald-dark); }
.resolution-state.is-revealed { color: var(--ink-soft); }
.resolution strong { display: block; font: 700 1.6rem/1.2 var(--serif); }
.resolution p { margin: .5rem auto 0; color: var(--ink-soft); font-size: .88rem; }
.bridge-navigation { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.8rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.icon-button { width: 44px; padding: 0; background: var(--paper-deep); color: var(--ink); font-size: 1.1rem; }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.ad-space { width: min(calc(100% - 2rem), 720px); min-height: 112px; margin: 0 auto 3rem; display: grid; place-items: center; border: 1px dashed #b9ae9e; color: #727982; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; }
.result-ad { min-height: 280px; margin: 1rem 0; }
.game-error, .result-card { padding: clamp(1.4rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.game-error h2, .result-card h2 { margin: 0 0 .7rem; }
.game-error p { color: var(--ink-soft); }
.result-card ul { margin: 1.5rem 0; padding: 0; display: grid; gap: .6rem; list-style: none; }
.result-card li { padding: .7rem .85rem; border-radius: 9px; background: var(--paper); font-weight: 700; }
.result-card li.is-solved { color: var(--emerald-dark); }
.result-card li.is-revealed { color: var(--ink-soft); }
.result-time { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-block: 1px solid var(--line); color: var(--ink-soft); font-size: .82rem; font-weight: 750; text-transform: uppercase; }
.result-time strong { color: var(--ink); font: 700 1.8rem/1 ui-monospace, 'Cascadia Mono', monospace; }
.result-actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.share-status { min-height: 1.5em; color: var(--ink-soft); font-size: .82rem; }
.countdown { margin-top: 1.25rem; padding: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-radius: 12px; background: var(--paper); color: var(--ink-soft); font-size: .82rem; font-weight: 750; text-transform: uppercase; }
.countdown strong { color: var(--emerald-dark); font: 700 1.15rem/1 ui-monospace, 'Cascadia Mono', monospace; }

@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.page-shell { min-height: 55vh; }
.page-narrow { max-width: 660px; }
.lead { max-width: 46ch; color: var(--ink-soft); font-size: 1.1rem; }
.archive-list { margin-top: 2rem; border-top: 1px solid var(--line); }
.archive-list a { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.archive-list a:hover { padding-inline: .5rem; background: rgb(255 253 249 / 55%); }
.archive-list strong { display: inline-block; min-width: 4rem; color: var(--emerald-dark); }
.prose { font-size: 1.02rem; }
.prose p, .prose li { max-width: 66ch; }
.prose li + li { margin-top: .5rem; }
.example { margin: 1.5rem 0; padding: 1.25rem; border-left: 4px solid var(--coral); background: var(--white); font-family: var(--serif); font-size: 1.15rem; }
.example span { display: block; }
.example strong { color: var(--emerald-dark); }
.legal-date, .legal-note { color: var(--ink-soft); font-size: .86rem; }
.legal-note { margin-top: 2.5rem; padding: 1rem; border: 1px solid var(--line); }

.site-footer { width: min(calc(100% - 2rem), 1120px); margin: 3rem auto 0; padding: 1.5rem 0 2rem; display: flex; justify-content: space-between; gap: 1.5rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .78rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.site-footer a { min-height: 44px; display: inline-flex; align-items: center; }
.footer-consent { min-height: 44px; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: .18em; }

.consent-banner { position: fixed; z-index: 80; right: 1rem; bottom: 1rem; left: 1rem; width: min(calc(100% - 2rem), 920px); margin: auto; padding: 1rem 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 18px 70px rgb(16 36 62 / 24%); }
.consent-banner p { max-width: 60ch; margin: .2rem 0 0; color: var(--ink-soft); font-size: .82rem; }
.consent-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.consent-dialog { width: min(calc(100% - 2rem), 580px); padding: 0 1.4rem 1.4rem; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 90px rgb(0 0 0 / 25%); }
.consent-dialog::backdrop { background: rgb(16 36 62 / 66%); }
.consent-choice { min-height: 72px; margin: .7rem 0; padding: .8rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.consent-choice span, .consent-choice small { display: block; }
.consent-choice small { color: var(--ink-soft); font-weight: 400; }
.consent-choice input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--emerald); }
.offline-shell { width: min(calc(100% - 2rem), 620px); min-height: 100vh; margin: auto; display: grid; align-content: center; justify-items: start; }
.offline-shell .brand-mark { width: 52px; height: 52px; margin-bottom: 1rem; }
.offline-shell p { max-width: 52ch; color: var(--ink-soft); }

.info-dialog { width: min(calc(100% - 2rem), 620px); max-height: min(80vh, 720px); padding: 0 1.5rem 2rem; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 90px rgb(0 0 0 / 25%); }
.info-dialog::backdrop { background: rgb(16 36 62 / 66%); backdrop-filter: blur(3px); }
.dialog-bar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 1rem 0 .5rem; background: var(--paper); }
.dialog-bar .eyebrow { margin: 0; }
.dialog-bar .icon-button { font-size: 1.5rem; }

@media (max-width: 560px) {
  .site-header { min-height: 68px; }
  .brand { font-size: 1.15rem; }
  .brand-mark { width: 30px; }
  .primary-nav > a { display: none; }
  .game-heading { align-items: start; flex-direction: column; gap: .25rem; }
  .game-meta { justify-items: start; }
  .bridge-card { border-radius: 18px; }
  .answer-row { grid-template-columns: 1fr; }
  .game-actions { flex-wrap: wrap; }
  .game-actions .button, .game-actions .text-button { flex: 1 1 44%; }
  .result-actions .button { flex: 1 1 100%; }
  .vibration-toggle { width: 100%; justify-content: center; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .consent-banner { align-items: stretch; flex-direction: column; }
  .consent-actions .button, .consent-actions .text-button { flex: 1 1 100%; }
  .button-primary { width: 100%; }
  .site-footer p { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Editorial admin */
.admin-body { background: #f4f1ea; }
.admin-header { width: min(calc(100% - 2rem), 1180px); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); }
.admin-nav { display: flex; align-items: center; gap: .3rem 1rem; font-size: .85rem; font-weight: 750; }
.admin-nav form { margin: 0; }
.admin-shell { width: min(calc(100% - 2rem), 1080px); margin: 2.5rem auto 5rem; }
.admin-shell h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
.admin-title-row, .admin-section-title { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.admin-section-title { margin-top: 2.5rem; margin-bottom: .5rem; }
.admin-section-title h2 { margin: 0; }
.admin-notice, .stock-alert { margin: 0 0 1.25rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.admin-notice ul { margin-bottom: 0; }
.admin-notice.is-success { border-color: var(--emerald); color: var(--emerald-dark); }
.admin-notice.is-error, .stock-alert { border-color: #bd3f35; background: #fff0ed; color: #822e28; }
.admin-notice.is-warning { border-color: #bc7a25; background: #fff8e8; color: #71470f; }
.admin-login { width: min(100%, 430px); margin: 9vh auto; padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.admin-login h1 { margin-bottom: .6rem; }
.admin-login form, .csv-upload, .emergency-panel form { display: grid; gap: 1rem; }
.admin-login label, .admin-editor label, .csv-upload label, .emergency-panel label { display: grid; gap: .35rem; color: var(--ink-soft); font-size: .8rem; font-weight: 750; }
.admin-login input, .admin-editor input, .admin-editor textarea, .csv-upload input, .emergency-panel input { width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid #aaa092; border-radius: 8px; background: white; color: var(--ink); }
.admin-editor textarea { resize: vertical; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.5rem 0 2.5rem; }
.admin-stats article { padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.admin-stats span, .admin-stats small { display: block; color: var(--ink-soft); font-size: .75rem; }
.admin-stats strong { display: block; margin: .25rem 0; font: 700 1.8rem/1 var(--serif); }
.admin-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: .45rem; }
.admin-calendar span { min-height: 58px; display: grid; place-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--white); text-align: center; font-weight: 800; }
.admin-calendar small { color: var(--ink-soft); font-size: .62rem; }
.admin-calendar .is-filled { border-color: var(--emerald); background: #e5f4ee; color: var(--emerald-dark); }
.admin-calendar .is-gap { border-color: #bd3f35; background: #fff0ed; color: #822e28; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th, .admin-table td { padding: .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { color: var(--ink-soft); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tr.has-error { background: #fff0ed; }
.status-pill { display: inline-flex; padding: .2rem .5rem; border-radius: 999px; background: var(--paper-deep); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.status-pill.is-published { background: #dcefe7; color: var(--emerald-dark); }
.admin-editor { display: grid; gap: 1rem; }
.admin-editor fieldset, .publish-panel, .emergency-panel { margin: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.admin-editor fieldset:disabled { opacity: .7; }
.admin-editor legend { padding: 0 .4rem; font: 700 1.1rem var(--serif); }
.admin-grid { display: grid; gap: 1rem; }
.admin-grid.two { grid-template-columns: repeat(2, 1fr); }
.admin-grid.three { grid-template-columns: repeat(3, 1fr); }
.admin-bridge { position: relative; margin-bottom: 1rem !important; }
.bridge-order { position: absolute; top: .5rem; right: .7rem; display: flex; gap: .3rem; }
.bridge-order .icon-button { width: 38px; min-height: 38px; }
.admin-editor label + label, .admin-editor .admin-grid + label { margin-top: .8rem; }
.publish-panel { margin-top: 2rem; }
.publish-panel h2 { margin-top: 0; }
.check-row { min-height: 38px; display: flex; align-items: center; gap: .6rem; }
.check-row input { width: 18px; height: 18px; accent-color: var(--emerald); }
.publish-panel button { margin-top: 1rem; }
.inline-danger { margin-top: 1rem; }
.emergency-panel { margin-top: 1rem; border-color: #bd3f35; }
.emergency-panel summary { cursor: pointer; color: #822e28; font-weight: 800; }
.emergency-panel form { margin-top: 1rem; }
.preview-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; padding: 0; list-style: none; }
.preview-progress li { height: 6px; background: var(--emerald); }
.admin-preview-list { display: grid; gap: 1rem; }
.admin-preview-card .resolution { max-width: 560px; margin-inline: auto; }
.csv-upload { grid-template-columns: 1fr auto; align-items: end; margin: 1.5rem 0 2rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.line-results { padding: 1rem 1rem 1rem 2.2rem; border: 1px solid var(--emerald); border-radius: 10px; background: #e5f4ee; }

@media (max-width: 700px) {
  .admin-header { align-items: flex-start; flex-direction: column; padding-block: .8rem; }
  .admin-nav { width: 100%; flex-wrap: wrap; }
  .admin-title-row { align-items: flex-start; flex-direction: column; }
  .admin-stats, .admin-grid.two, .admin-grid.three { grid-template-columns: 1fr; }
  .admin-calendar { grid-template-columns: repeat(3, 1fr); }
  .csv-upload { grid-template-columns: 1fr; }
}
