/* The Aurelious Quest — styled like the interior pages of Marcos Garcia's Stoic books: cream paper, sepia ink, gold rules */
:root {
  --paper: #efe6cf; --paper-2: #f6efdc; --ink: #2b1d10; --ink-soft: #5a4630; --gold: #a8842a; --gold-2: #c9a227;
  --navy: #0b1720; --teal: #2f6f7a; --line: rgba(168, 132, 42, 0.55);
  --serif: "Cormorant Garamond", Georgia, serif; --body: "Literata", Georgia, serif; --mono: "Space Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #e4d8bb; color: var(--ink); }
body { font: 400 1.04rem/1.6 var(--body); -webkit-font-smoothing: antialiased;
  background: radial-gradient(120vmax 80vmax at 50% 30%, #efe6cf 40%, #d9caa6 100%); }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; }
[hidden] { display: none !important; }

.stage { max-width: 1060px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 30px max(12px, env(safe-area-inset-left)); min-height: 100vh; display: flex; }
.screen { width: 100%; align-self: center; animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* book page */
.page { max-width: 820px; margin: 0 auto; padding: clamp(22px, 5vw, 54px); text-align: center; background: var(--paper-2); border: 1px solid var(--line);
  box-shadow: 0 1px 0 #fff inset, 0 24px 60px rgba(60, 40, 15, .22); outline: 1px solid var(--line); outline-offset: -10px; }
.eyebrow { font: 700 .72rem/1.4 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--teal); margin: 0 0 1rem; }
.pre { font: italic 500 1.35rem/1 var(--serif); color: var(--ink-soft); margin: 0 0 .2rem; }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.02; margin: 0 0 .5rem; color: var(--ink); }
h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); letter-spacing: .01em; }
h2 { font-size: clamp(2rem, 4.5vw, 3rem); }
.sub { font: italic 500 1.2rem/1.3 var(--serif); color: var(--ink-soft); margin: 0; }
.rule { display: flex; align-items: center; gap: .8rem; margin: 1.1rem auto 1.3rem; max-width: 360px; color: var(--gold); }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--gold); box-shadow: 0 3px 0 rgba(168, 132, 42, .5); }
.rule.small { max-width: 220px; margin: .6rem auto .9rem; }
.plate { margin: 0 auto 1.3rem; padding: 8px; background: #fff; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(60, 40, 15, .2); max-width: 640px; }
.plate.small { max-width: 220px; }
.lede { max-width: 38rem; margin: 0 auto 1.3rem; color: var(--ink-soft); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; margin-bottom: 1.4rem; }
.box { border: 1px solid var(--line); background: rgba(239, 230, 207, .6); padding: 14px 16px; outline: 1px solid var(--line); outline-offset: -5px; }
.box-h { font: 700 .74rem var(--serif); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin: 0 0 .5rem; text-align: center; }
.box ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; color: var(--ink-soft); font-size: .97rem; }
.box li::before { content: "✦ "; color: var(--gold); }
.box b { color: var(--ink); font-weight: 600; }
.box ul.keys li::before { content: ""; }
kbd { display: inline-block; min-width: 1.7em; padding: .02rem .35rem; margin-right: .2rem; border: 1px solid var(--ink-soft); border-bottom-width: 2px; font: 700 .72rem var(--mono); color: var(--ink); text-align: center; background: #fff8e8; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }
.best { font: .8rem var(--mono); color: var(--teal); margin: 1rem 0 0; }
.links { margin: 1.2rem 0 0; font: .8rem var(--mono); color: var(--ink-soft); }
.links a { color: var(--ink-soft); }
.links a:hover { color: var(--gold); }
.quote { max-width: 34rem; margin: 1.4rem auto 0; padding: 0 1rem; font: italic 500 1.3rem/1.4 var(--serif); color: var(--ink); }
.quote cite { display: block; margin-top: .4rem; font: 700 .7rem var(--serif); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-style: normal; }
.final-stats { list-style: none; padding: 0; margin: 0 auto; display: inline-grid; gap: .3rem; font: .86rem var(--mono); color: var(--ink-soft); text-align: left; }
.final-stats b { color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .7rem 1.4rem; border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font: 700 .8rem/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; text-decoration: none; cursor: pointer; transition: transform .15s, background .2s; }
.btn:hover { transform: translateY(-1px); background: rgba(168, 132, 42, .12); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.btn-gold { background: linear-gradient(135deg, #a8842a, #d9b45a); color: #1e1406; border-color: #6b5214; box-shadow: 0 8px 22px rgba(120, 90, 20, .3); }
.btn-gold:hover { background: linear-gradient(135deg, #b8922e, #e5c36a); }
.btn-big { min-height: 58px; padding: 1rem 2rem; font-size: .9rem; }
.btn-sm { min-height: 38px; padding: .4rem .9rem; font-size: .7rem; }

/* game */
.screen-game { align-self: flex-start; }
.game-wrap { position: relative; width: 100%; border: 1px solid var(--gold); outline: 1px solid var(--line); outline-offset: 4px; background: var(--paper); box-shadow: 0 24px 60px rgba(60, 40, 15, .3); touch-action: none; user-select: none; -webkit-user-select: none; }
#cv { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; }
.game-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .9rem; }
.rotate { display: none; font: .72rem var(--mono); color: var(--ink-soft); }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(43, 29, 16, .45); padding: 12px; }
.ov-card { display: flex; gap: 22px; align-items: center; max-width: 700px; text-align: left; background: var(--paper-2); border: 1px solid var(--gold); outline: 1px solid var(--line); outline-offset: -7px; padding: clamp(14px, 3vw, 28px); box-shadow: 0 20px 50px rgba(30, 20, 5, .4); animation: rise .35s ease both; }
.ov-img { width: 150px; flex: none; border: 1px solid var(--line); padding: 5px; background: #fff; }
.ov-kicker { font: 700 .8rem var(--serif); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); margin: 0 0 .3rem; }
.ov-card h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); }
.ov-card .rule.small { margin-left: 0; }
.ov-text { color: var(--ink-soft); margin: 0 0 1.1rem; font-size: .98rem; }

.touch { display: none; position: absolute; inset: auto 0 0 0; padding: 8px; justify-content: space-between; pointer-events: none; }
.touch div { display: flex; gap: 10px; pointer-events: auto; }
.touch button { width: 62px; height: 62px; border-radius: 50%; border: 2px solid var(--gold); background: rgba(246, 239, 220, .55); color: var(--ink); font-size: 1.5rem; line-height: 1; touch-action: none; }
.touch button.on { background: rgba(201, 162, 39, .5); }
.touch .jmp { width: 72px; height: 72px; }
body.touchy .touch { display: flex; }
body.touchy .rotate { display: inline; }

@media (max-width: 700px) {
  .cols { grid-template-columns: 1fr; }
  .ov-card { flex-direction: column; text-align: center; }
  .ov-card .rule.small { margin-left: auto; }
  .ov-img { width: 90px; }
}
@media (orientation: portrait) { body.touchy .touch { position: static; padding: 12px 6px 4px; background: var(--paper); } }
@media (orientation: landscape) and (max-height: 520px) {
  .stage { padding-top: 4px; padding-bottom: 4px; }
  #cv { max-height: calc(100vh - 60px); width: auto; margin: 0 auto; }
  body.touchy .rotate { display: none; }
  .touch button { width: 54px; height: 54px; } .touch .jmp { width: 62px; height: 62px; }
  .ov-img { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.cast { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 0 0 1.4rem; align-items: end; }
.cast figure { margin: 0; text-align: center; }
.cast img { height: 96px; width: auto; margin: 0 auto .3rem; image-rendering: auto; filter: drop-shadow(0 4px 6px rgba(60,40,15,.25)); }
.cast figcaption { font: 600 .95rem/1.1 var(--serif); color: var(--ink); }
.cast small { display: block; font: italic 400 .78rem var(--serif); color: var(--ink-soft); margin-top: .1rem; }
@media (max-width: 700px) { .cast { grid-template-columns: repeat(3, 1fr); row-gap: 14px; } }
.touch .thr { width: 52px; height: 52px; font-size: 1.3rem; align-self: flex-end; }
@media (orientation: portrait) { body.touchy .touch { gap: 6px; } body.touchy .touch div { gap: 8px; } body.touchy .touch button { width: 64px; height: 64px; } body.touchy .touch .jmp { width: 72px; height: 72px; } body.touchy .touch .thr { width: 52px; height: 52px; } }
.chapters { margin: 1rem auto 0; max-width: 420px; }
.chap-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chap-row .btn { min-width: 52px; font-family: var(--serif); font-size: 1rem; letter-spacing: .05em; }
.chap-row .btn:disabled { opacity: .35; cursor: not-allowed; }

/* safety: no double-tap zoom on controls, pinch zoom still allowed on the page */
html { touch-action: manipulation; }
#cv, .touch, .touch button { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.safety { max-width: 760px; margin: 14px auto 0; padding: 10px 14px; border: 1px solid var(--gold); background: rgba(246, 239, 220, .7); font-size: 14px; line-height: 1.45; color: var(--ink); }

/* settings: one gear button over the game instead of a row of buttons */
.gear { position: absolute; top: 4px; right: 6px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--gold); background: rgba(246, 239, 220, .9); color: var(--ink); font-size: 1.35rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.gear:hover, .gear[aria-expanded="true"] { background: var(--gold-2); }
.settings { position: absolute; top: 50px; right: 6px; z-index: 4; display: flex; flex-direction: column; gap: 8px; min-width: 210px; padding: 14px; background: var(--paper-2); border: 1px solid var(--gold); outline: 1px solid var(--line); outline-offset: -6px; box-shadow: 0 16px 40px rgba(30, 20, 5, .4); }
.settings[hidden] { display: none; }
.settings .btn { width: 100%; }
.set-h { margin: 0 0 2px; font: 700 .8rem var(--serif); letter-spacing: .3em; text-transform: uppercase; color: var(--gold); text-align: center; }
.set-note { margin: 0; font: .7rem var(--mono); color: var(--ink-soft); text-align: center; }
body:not(.touchy) .set-note { display: none; }
/* touch buttons always fit the width of the phone */
@media (orientation: portrait) {
  body.touchy .touch { padding: 8px 4px 4px; gap: 4px; }
  body.touchy .touch div { gap: 6px; }
  body.touchy .touch button { width: min(64px, 16vw); height: min(64px, 16vw); font-size: 1.35rem; }
  body.touchy .touch .jmp { width: min(72px, 18vw); height: min(72px, 18vw); }
  body.touchy .touch .thr { width: min(52px, 13vw); height: min(52px, 13vw); }
  body.touchy .stage { padding-top: 6px; }
}
.overlay:not([hidden]) ~ .gear, .overlay:not([hidden]) ~ .settings { display: none; }

/* desktop: the game fills the window; JS sets the exact width */
.screen-game { max-width: none; }
body:has(#s-game:not([hidden])) .stage { max-width: none; padding-top: 12px; padding-bottom: 12px; }
#game-wrap { margin: 0 auto; }
@media (orientation: portrait) and (max-width: 760px) { #game-wrap { width: 100% !important; } }
.screen-game { margin: 0 auto; }

/* Return to the author page: a book-plate in ink on paper, with twinkling stars and a pencil underline that draws itself on hover. It sits in the page flow, so it never covers text. */
.home-row { margin: 1.4rem 0 .4rem; }
.home { display: inline-flex; align-items: center; gap: .7rem; min-height: 48px; padding: .65rem 1.4rem; text-decoration: none; color: var(--ink);
  font: 600 1.15rem/1.2 var(--serif); letter-spacing: .06em; background: var(--paper-2); border: 1px solid var(--gold); outline: 1px solid var(--line); outline-offset: -6px;
  box-shadow: 0 6px 18px rgba(60, 40, 15, .18); transition: transform .15s, box-shadow .2s; }
.home span { background: linear-gradient(var(--ink-soft), var(--ink-soft)) left bottom / 0 1px no-repeat; transition: background-size .45s ease-out; padding-bottom: 1px; }
.home i { font-style: normal; color: var(--gold); display: inline-block; animation: home-twinkle 3s ease-in-out infinite; }
.home i:last-child { animation-delay: 1.5s; }
.home:hover { transform: translateY(-2px) rotate(-.4deg); box-shadow: 0 10px 24px rgba(60, 40, 15, .26); }
.home:hover span, .home:focus-visible span { background-size: 100% 1px; }
.home:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
@keyframes home-twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: .7; } 50% { transform: scale(1.3) rotate(45deg); opacity: 1; } }
.settings a.btn { text-decoration: none; }
@media (max-width: 520px) { .home { font-size: 1rem; gap: .45rem; padding: .6rem 1rem; } }
@media (max-height: 520px) { .settings { gap: 5px; padding: 10px 12px; max-height: calc(100vh - 60px); overflow-y: auto; } .settings .btn { min-height: 32px; padding: .3rem .8rem; } .settings .set-h { margin: 0; } }
