/* ------------------------------------------------------------------
   style.css — warm stone and dusk. Two columns on a desktop, the
   shop slides up from the bottom on a phone.
------------------------------------------------------------------ */

:root {
  --ink:        #efe6d6;
  --ink-dim:    #a99f8f;
  --ink-faint:  #6f685e;
  --bg:         #100e16;
  --panel:      #1a1722;
  --panel-2:    #221d2c;
  --line:       #302a3c;
  --gold:       #e9b755;
  --ember:      #d9744a;
  --olive:      #97b06a;
  --sky:        #7fa8d0;
  --stone:      #a89f92;
  --danger:     #c9553f;
  --panel-w:    clamp(300px, 27vw, 372px);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { touch-action: manipulation; }

kbd {
  font-family: var(--mono);
  font-size: 0.86em;
  background: #2b2537;
  border: 1px solid #3d3550;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--ink);
}

/* ---------------- layout ------------------------------------------------ */
#app {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  height: 100%;
  width: 100%;
}

#stage {
  position: relative;
  overflow: hidden;
  background: #0b0a12;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ---------------- HUD --------------------------------------------------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top, 0px) + 10px) 18px
           max(16px, env(safe-area-inset-bottom, 0px) + 10px) 18px;
}

.hud-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hud-left { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-width: 0; }

.stat { min-width: 92px; text-shadow: 0 2px 10px rgba(0,0,0,.75); }
.stat.right { text-align: right; }

.stat-label {
  font-size: 10.5px;
  letter-spacing: .20em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 1px;
}

.stat-value {
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value.gold { color: var(--gold); }

.stat-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
}

.stat-stars {
  margin-top: 3px;
  font-size: 12px;
  color: #dcc8ff;
  letter-spacing: .08em;
}

.hud-centre {
  flex: 1;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#profile {
  width: 100%;
  height: 58px;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.6));
}

.phase {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 10.5px;
  letter-spacing: .22em;
  color: var(--ink-dim);
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
#phase-timer {
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

/* ---- feats ------------------------------------------------------------- */

#feat-toasts { display: flex; flex-direction: column; gap: 7px; }

.feat-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(280px, 46vw);
  padding: 8px 14px 8px 11px;
  border-radius: 10px;
  border: 1px solid rgba(233, 183, 85, .45);
  background: rgba(22, 18, 32, .82);
  box-shadow: 0 6px 22px rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  animation: feat-in .34s cubic-bezier(.2,.9,.3,1.2);
  transition: opacity .4s, transform .4s;
}
.feat-toast.going { opacity: 0; transform: translateX(-14px); }

.feat-toast-mark { color: var(--gold); font-size: 16px; line-height: 1; flex: none; }
.feat-toast-eyebrow {
  display: block;
  font-size: 9.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}
.feat-toast-name { display: block; font-size: 13px; color: var(--ink); line-height: 1.35; }

@keyframes feat-in {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: none; }
}

#modal-body .feat-count { margin-bottom: 14px; }   /* beats #modal-body p */

.feat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 0 7px;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--ink-dim);
  border-bottom: 1px solid #2b2538;
  padding-bottom: 5px;
}
.feat-head:first-of-type { margin-top: 4px; }
.feat-head em {
  font-style: normal;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.feat-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 0;
}
.feat-mark { color: var(--ink-faint); font-size: 13px; line-height: 1.3; text-align: center; }
.feat-row.on .feat-mark { color: var(--gold); }

.feat-body { min-width: 0; }
.feat-name { display: block; font-size: 13px; color: var(--ink-dim); }
.feat-row.on .feat-name { color: var(--ink); font-weight: 600; }
.feat-line {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
}
.feat-row.on .feat-line { color: var(--ink-dim); }

.feat-note {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* The summit quote. Two parts, faded on their own timers by UI.tick — the
   duration is set inline from CFG.quotes.fade so the tuning lives in one
   place, and the transition does the fading rather than a per-frame ramp. */
#banner {
  align-self: center;
  margin-bottom: 8vh;
  text-align: center;
  padding: 0 20px;
  max-width: min(760px, 92%);
}
#banner-quote {
  font-family: var(--serif);
  font-size: clamp(17px, 2.4vw, 27px);
  font-style: italic;
  line-height: 1.34;
  color: #f3e7cf;
  text-shadow: 0 3px 20px rgba(0,0,0,.9);
  white-space: pre-line;          /* a lyric keeps the breaks it was written with */
  transition: opacity .9s ease;
}
#banner-credit {
  margin-top: 10px;
  font-size: clamp(11px, 1.15vw, 14px);
  letter-spacing: .04em;
  color: #cdbfa6;
  text-shadow: 0 2px 14px rgba(0,0,0,.9);
  transition: opacity .9s ease;
}
#banner-attribution { font-weight: 600; color: #e6d7bb; }
#banner-source { font-style: italic; opacity: .82; }
/* No source on this one, so no separator either. */
#banner-source:not(:empty)::before { content: ', '; font-style: normal; opacity: .7; }

.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Nothing to manage while he is going on his own, so the breath bar makes way
   for his pace. Take over and it comes straight back — hence afk-auto rather
   than afk, which is only the mode. */
#app.afk-auto #stamina-track { display: none; }
#app.afk-auto #stamina-wrap { justify-content: center; }
#app.afk-auto #stamina-label {
  min-width: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: .02em;
  color: var(--ink);
}

.tool.mode { border-color: #4a3f63; color: var(--ink); }
.tool.mode.afk { border-color: var(--gold); color: var(--gold); }

.mode-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 13px 15px;
  margin-bottom: 9px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #211c2d;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mode-card:hover { border-color: #5b4d7a; background: #281f38; }
.mode-card.on { border-color: var(--gold); background: #2c2436; }

.mode-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 4px; }
.mode-name { font-size: 15px; font-weight: 600; }
.mode-tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-dim);
}
.mode-card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-dim); }
.mode-card.on .mode-name { color: var(--gold); }

#stamina-wrap {
  width: min(360px, 62%);
  display: flex;
  align-items: center;
  gap: 10px;
}

#stamina-track {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: rgba(12,10,18,.68);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10), 0 2px 10px rgba(0,0,0,.5);
  overflow: hidden;
}

#stamina-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  border-radius: 99px;
  background: linear-gradient(90deg, #6f9c6a, #a8c56f 60%, #d8dd8a);
  transition: background .25s;
}
#stamina-fill.low  { background: linear-gradient(90deg, #b8653a, #dd9146); }
#stamina-fill.empty{ background: linear-gradient(90deg, #8e3730, #b8493a); }

#stamina-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  min-width: 62px;
  text-align: right;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}

/* ---------------- panel ------------------------------------------------- */
#panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel) 220px);
  border-left: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}

#panel-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

#panel-head h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .06em;
  color: #f0e4cd;
}

/* Reset out from under the title's serif, weight and letter-spacing rather
   than just riding them at a smaller size — it should read as the same tiny
   grey aside `.fine` is everywhere else, not as part of "Sisyphus". */
#app-version {
  font-family: var(--font);
  font-weight: 400;
  letter-spacing: normal;
}

.tools { display: flex; gap: 6px; flex-wrap: wrap; }

.tool {
  font: inherit;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #241f30;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.tool:hover { background: #2e2740; color: var(--ink); border-color: #473c5e; }

/* ---- the opening choice, once, at the foot of the first hill ------------ */
#intro-tip {
  position: relative;
  margin-bottom: 15px;
  padding: 13px 15px 14px;
  border-radius: 11px;
  border: 1px solid #5a4a2c;
  background: linear-gradient(#262034, #211c2d);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .40);
  animation: intro-in .34s cubic-bezier(.24, .9, .36, 1) both;
}
/* The arrow sits over the left end of the tools row, which is where the Mode
   button is — it is first in the flex line, so this needs no measuring. */
#intro-tip::before,
#intro-tip::after {
  content: '';
  position: absolute;
  left: 22px;
  border: 8px solid transparent;
}
#intro-tip::before { bottom: -17px; border-top-color: #5a4a2c; }
#intro-tip::after { bottom: -15px; border-top-color: #211c2d; }

#intro-tip p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.55; color: var(--ink-dim); }
#intro-tip p:last-of-type { margin: 10px 0 0; }
#intro-tip b { color: var(--ink); font-weight: 600; }
#intro-tip .intro-lede {
  font-family: var(--serif);
  font-size: 14.5px;
  color: #f0e4cd;
}
#intro-tip .fine { font-size: 11.5px; color: var(--ink-faint); }
#intro-tip .fine b { color: var(--gold); }
.intro-acts { display: flex; gap: 7px; flex-wrap: wrap; }
.intro-acts .tool { padding: 6px 11px; }
#intro-afk { border-color: var(--gold); color: var(--gold); }
#intro-afk:hover { background: #33291a; border-color: var(--gold); color: var(--gold); }

@keyframes intro-in {
  from { opacity: 0; transform: translateY(-7px); }
  to { opacity: 1; transform: none; }
}

/* And the button it is pointing at, so the eye goes there first. */
.tool.calling {
  border-color: var(--gold);
  color: var(--gold);
  animation: calling 1.8s ease-in-out infinite;
}
@keyframes calling {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233, 183, 85, .40); }
  50% { box-shadow: 0 0 0 5px rgba(233, 183, 85, 0); }
}
.tool.off { color: var(--ink-faint); }
.tool.danger:hover { border-color: var(--danger); color: #f0a294; }

#shop-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: #3b3350 transparent;
}
#shop-list::-webkit-scrollbar { width: 9px; }
#shop-list::-webkit-scrollbar-thumb { background: #3b3350; border-radius: 9px; }

/* ---------------- upgrade rows ------------------------------------------ */
.up {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  font: inherit;
  color: var(--ink);
  padding: 9px 11px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1e1a28;
  cursor: pointer;
  opacity: .62;
  transition: opacity .15s, background .15s, border-color .15s, transform .08s;
}
.up:hover { background: #262034; }
.up.afford { opacity: 1; border-color: #4a3f63; background: #241f33; }
.up.afford:hover { border-color: var(--gold); background: #2b2438; }
.up.afford:active { transform: translateY(1px); }
.up.maxed { opacity: .5; cursor: default; border-style: dashed; }

.up-glyph {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 16px;
  background: #2a2438;
  color: var(--stone);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.tone-ember { color: var(--ember); background: #35212099; }
.tone-olive { color: var(--olive); background: #24301f99; }
.tone-sky   { color: var(--sky);   background: #1f2a3899; }
.tone-gold  { color: var(--gold);  background: #352c1a99; }
.tone-stone { color: var(--stone); background: #2b2a2e99; }

.up-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.up-head { display: flex; align-items: baseline; gap: 7px; }
.up-name { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.up-lv {
  font-size: 10px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.up-blurb {
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
}

.up-detail {
  margin-top: 2px;
  font-size: 10.5px;
  font-family: var(--mono);
  color: #8e86a6;
  letter-spacing: -.01em;
}

.up-cost { text-align: right; min-width: 46px; }
.up-cost-n {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.up.afford .up-cost-n { color: var(--gold); }
.up-cost-l {
  display: block;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------------- prestige ---------------------------------------------- */
#prestige-card {
  margin: 4px 10px 10px;
  padding: 11px 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1d1a29;
  transition: border-color .2s, background .2s;
}
#prestige-card.ready {
  border-color: #6a5a94;
  background: linear-gradient(160deg, #262041, #1d1a29);
}
#prestige-card.hidden { display: none; }

.pres-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.pres-glyph { color: #c9b3ff; font-size: 15px; }
.pres-title { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
#prestige-info {
  margin: 0 0 9px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
}

#panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.fine { font-size: 10px; color: var(--ink-faint); }

/* ---------------- buttons ----------------------------------------------- */
.btn {
  font: inherit;
  font-size: 12.5px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #272134;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #322a44; border-color: #4d4169; }
.btn.wide { width: 100%; }
.btn.primary { background: #4a3c22; border-color: var(--gold); color: #f7e3b6; }
.btn.primary:hover { background: #5b4a29; }
.btn.danger { background: #3d1f1c; border-color: var(--danger); color: #f2b3a7; }
.btn.danger:hover { background: #4e2724; }

.float-btn {
  display: none;
  position: absolute;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  font: inherit;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 99px;
  border: 1px solid #5a4b78;
  background: rgba(34,28,46,.92);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}

/* ---------------- modal ------------------------------------------------- */
#modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8,6,14,.74);
  backdrop-filter: blur(4px);
}
#modal.hidden { display: none; }

#modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(84vh, 720px);
  overflow-y: auto;
  padding: 26px 28px 22px;
  border-radius: 14px;
  border: 1px solid #3c3450;
  background: linear-gradient(170deg, #241f31, #191622);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}

#modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
#modal-close:hover { background: #2e2740; color: var(--ink); }

#modal-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: .02em;
}

#modal-body { font-size: 13.5px; line-height: 1.62; color: #cdc4b5; }
#modal-body p { margin: 0 0 11px; }
#modal-body b { color: var(--ink); font-weight: 600; }
#modal-body .lede {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15.5px;
  color: #e6d9c2;
  margin-bottom: 15px;
}
#modal-body .fine { display: block; font-size: 11.5px; color: var(--ink-faint); line-height: 1.6; }

.keys { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; }
.keys dt { color: var(--ink); font-weight: 600; white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-dim); }

.stats { width: 100%; border-collapse: collapse; }
.stats th {
  text-align: left;
  font-weight: 400;
  color: var(--ink-dim);
  padding: 7px 0;
  border-bottom: 1px solid #2b2538;
}
.stats td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 7px 0;
  border-bottom: 1px solid #2b2538;
}

#modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.hidden { display: none; }

/* ---------------- narrow screens ---------------------------------------- */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr; }

  .float-btn { display: block; }

  #panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: min(74vh, 560px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(102%);
    transition: transform .28s cubic-bezier(.3,.8,.35,1);
    box-shadow: 0 -12px 40px rgba(0,0,0,.55);
    z-index: 10;
  }
  #app.shop-open #panel { transform: translateY(0); }
  #app.shop-open .float-btn { bottom: calc(min(74vh, 560px) + 12px); }
  .float-btn { right: 12px; }

  #panel-head { padding-top: 14px; }
  /* desktop-only, not merely styled down — a phone never sees it */
  #app-version { display: none; }
  #hud { padding-left: 12px; padding-right: 12px; }
  .hud-centre { max-width: 190px; }
  #profile { height: 44px; }
  #stamina-wrap { width: min(340px, 86%); }
  .hud-bottom { padding-bottom: 58px; }
}

@media (max-width: 520px) {
  .hud-centre { display: none; }
  .stat-value { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
