/* Soulsway Activity - game UI stylesheet.
 *
 * The whole app lives on a FIXED 1280x720 design stage (#stage) that
 * js/stage.js scales to fit the window (letterboxed, never a scrollbar).
 * Everything inside uses plain px - the stage transform handles sizing.
 */

:root {
  --bg: #131017;
  --panel: #221c2c;
  --panel-2: #1a1522;
  --edge: #4a3f5e;
  --line: #352c44;
  --ink: #e8ddc8;
  --dim: #9a8c96;
  --gold: #c9a45c;
  --gold-hi: #e8cd8f;
  --green: #3f7d4e;
  --good: #8fd08c;
  --alert: #e08278;
  --red: #a04138;
  --accent: #9b8ec4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden;
  user-select: none;
}

#fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

#boot {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  color: var(--dim); font-size: 18px; letter-spacing: 1px; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #1c1725, var(--bg));
}
#boot .err { color: #cf7a6e; margin-top: 12px; font-size: 14px; }

/* --- the scaled stage --------------------------------------------------- */

#viewport {
  position: fixed; inset: 0; z-index: 1; overflow: hidden;
}
/* Centering lives INSIDE the transform (translate(-50%,-50%) before the
   scale, anchored at 50%/50%): layout-based centering (grid/flex) sizes
   its track on the UNSCALED 1280x720 box and mis-centers as soon as the
   window is smaller than the design space. */
#stage {
  width: 1280px; height: 720px;
  position: absolute; left: 50%; top: 50%;
  display: flex; gap: 18px; padding: 22px;
  transform: translate(-50%, -50%);
}

/* --- game panels (double-edged, FF window feel) ------------------------- */

.panel {
  background: linear-gradient(168deg, #262033 0%, #191423 74%);
  border: 1px solid var(--edge);
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #0e0b14, inset 0 0 0 4px #3d3450,
              0 10px 40px #00000066;
}

/* --- menu sidebar ------------------------------------------------------- */

#menu-panel {
  width: 288px; flex: none;
  display: flex; flex-direction: column;
  padding: 22px 0 16px;
}
#menu-title {
  font-size: 15px; letter-spacing: 6px; color: var(--gold);
  text-align: center; font-weight: bold; margin-bottom: 14px;
}
#menu-title::after {
  content: ''; display: block; height: 1px; margin: 12px 26px 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .5;
}
#menu { flex: 1 1 0; min-height: 0; position: relative; }

/* CursorList (shared by menu / action bar / popovers) */
.clist { list-style: none; position: relative; }
.clist li {
  position: relative; cursor: pointer;
  color: var(--dim); white-space: nowrap;
}
.clist li.disabled { opacity: .4; cursor: default; }
.clist li .badge {
  display: inline-block; min-width: 20px; height: 20px; margin-left: 10px;
  border-radius: 10px; background: var(--gold); color: #1c1710;
  font-size: 12px; font-weight: bold; line-height: 20px; text-align: center;
  padding: 0 6px; vertical-align: 2px;
}
.clist li .badge.warn { background: var(--red); color: #f7e8e5; }

/* vertical flavor (the main menu) */
.clist.v li {
  padding: 11px 24px 11px 46px;
  font-size: 19px; letter-spacing: 2px; font-variant: small-caps;
}
.clist.v li.sel { color: var(--ink); }
.clist.v li.now { color: var(--gold); }
.clist.v li.found { color: #a9e0af; }
.clist.v li.danger { color: var(--alert); }

/* horizontal flavor (the action bar) */
.clist.h { display: flex; gap: 26px; flex-wrap: wrap; }
.clist.h li {
  padding: 8px 6px 8px 24px; font-size: 16px; letter-spacing: 1px;
}
.clist.h li.sel { color: var(--ink); }
.clist.h li.danger.sel { color: var(--alert); }
.clist.h li.success.sel { color: var(--good); }

/* The rotating cursor: spins around its POINTING axis (rotateX on a
   right-pointing arrow) - stays a readable right-arrow the whole turn,
   twisting like a spindle. No perspective: rotateY + perspective made it
   skew, mirror and vanish edge-on twice per turn. */
.cursor {
  position: absolute; left: 14px; width: 22px; height: 22px;
  pointer-events: none;
  transition: top .12s ease-out, left .12s ease-out;
  filter: drop-shadow(0 0 6px #c9a45c99);
  z-index: 2;
}
.cursor::before {
  content: ''; position: absolute; inset: 2px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #8a6c34);
  clip-path: polygon(6% 0%, 100% 50%, 6% 100%, 22% 50%);
  animation: cursor-spin 1.6s linear infinite;
}
.clist.h .cursor { left: auto; }
@keyframes cursor-spin {
  from { transform: rotateX(0deg); }
  to   { transform: rotateX(360deg); }
}
.clist:not(.active) .cursor { display: none; }
.clist:not(.active) li.sel { color: inherit; }
.clist.v:not(.active) li.now { color: var(--gold); }

/* party (religion) panel under the menu */
#party {
  margin: 14px 16px 0; padding: 14px 16px 12px;
  border-top: 1px solid var(--line);
}
#party .name {
  font-size: 18px; font-weight: bold; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#party .stage {
  font-size: 12px; letter-spacing: 2px; font-weight: bold;
  color: var(--accent); margin: 3px 0 10px;
}
#party .vitals { font-size: 13px; color: var(--dim); letter-spacing: 1px; }
#party .vitals b { color: var(--gold); }
#party .vitals.tick b { animation: vitals-flash .9s ease-out; }
@keyframes vitals-flash {
  0% { color: #fff; text-shadow: 0 0 12px var(--gold-hi); }
  100% { color: var(--gold); text-shadow: none; }
}
#party.empty .name { color: var(--dim); font-style: italic; font-weight: normal; }

/* --- screen panel ------------------------------------------------------- */

#screen-panel {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  border-left: 6px solid var(--accent);
  position: relative; overflow: hidden;
}
#screen {
  flex: 1 1 0; min-height: 0; overflow-y: auto;
  padding: 30px 34px 20px;
  scrollbar-width: none;
  mask-image: linear-gradient(180deg, transparent 0, #000 18px,
                              #000 calc(100% - 18px), transparent 100%);
}
#screen::-webkit-scrollbar { display: none; }
#screen.enter { animation: page-in .22s ease-out; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
#screen img.map {
  display: block; max-width: 100%; max-height: 100%;
  margin: 0 auto; border-radius: 8px; border: 1px solid var(--line);
}

#action-bar {
  flex: none; padding: 10px 26px 14px; position: relative;
  border-top: 1px solid var(--line);
  min-height: 56px;
}
#action-bar:empty { display: none; }

#busy {
  position: absolute; top: 14px; right: 20px; width: 20px; height: 20px;
  border: 3px solid #3d3450; border-top-color: var(--gold);
  border-radius: 50%; animation: busy-spin .8s linear infinite; z-index: 5;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }

/* --- toast (the note) --------------------------------------------------- */

#toast {
  position: absolute; top: 34px; right: 40px; max-width: 520px; z-index: 8;
  background: #241d31ee; border: 1px solid var(--gold);
  border-left-width: 4px; border-radius: 8px;
  padding: 12px 18px; font-size: 15px; line-height: 1.45;
  box-shadow: 0 8px 30px #000a; cursor: pointer;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}
#toast.fade { opacity: 0; transition: opacity .5s; }

/* --- screen blocks ------------------------------------------------------ */

.blk { margin-bottom: 20px; }
.b-label {
  font-size: 13px; letter-spacing: 3px; color: var(--dim);
  font-weight: bold; margin-bottom: 4px;
}
.b-title { display: flex; align-items: flex-start; gap: 12px; }
.b-title h1 {
  font-size: 38px; font-weight: bold; color: var(--ink);
  line-height: 1.12; flex: 1; text-shadow: 0 2px 12px #0008;
}
.b-title .chip {
  flex: none; background: #30293c; color: var(--accent);
  font-size: 12px; font-weight: bold; letter-spacing: 1px;
  padding: 6px 14px; border-radius: 14px; margin-top: 8px;
}
.b-title .sub {
  font-size: 14px; letter-spacing: 3px; font-weight: bold;
  color: var(--accent); margin-top: 6px;
}
.b-text { font-size: 16px; color: #c4bcd2; line-height: 1.5; }
.b-text.quote { font-style: italic; font-size: 18px; color: #d6d0e2; }
.b-text.muted { color: var(--dim); font-size: 14px; letter-spacing: 1px; }
.b-text.gold { color: var(--gold); font-weight: bold; }
.b-text.good { color: var(--good); font-weight: bold; }
.b-text.alert {
  display: inline-block; background: #422024; color: var(--alert);
  font-weight: bold; letter-spacing: 1px; font-size: 14px;
  padding: 10px 16px; border-radius: 8px;
}
.b-text.label {
  font-size: 13px; letter-spacing: 3px; color: var(--dim);
  font-weight: bold; margin-bottom: -8px;
}
.b-text.accent { color: var(--accent); }

.b-stats { display: flex; flex-wrap: wrap; gap: 10px 46px; }
.b-stats .item .l {
  font-size: 12px; letter-spacing: 2px; color: var(--dim); font-weight: bold;
}
.b-stats .item .v { font-size: 28px; font-weight: bold; margin-top: 3px; }
.b-stats .item .v.gold { color: var(--gold); }
.b-stats .item .v.good { color: var(--good); }
.b-stats .item .v.alert { color: var(--alert); }

.b-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.b-bar .l {
  font-size: 12px; letter-spacing: 2px; color: var(--dim);
  font-weight: bold; min-width: 52px;
}
.b-bar .l.gold { color: var(--gold); }
.b-bar .name { font-size: 16px; font-weight: bold; }
.b-bar .track {
  flex: 1 1 160px; height: 15px; background: #302a3c; border-radius: 8px;
  overflow: hidden; min-width: 120px;
  box-shadow: inset 0 1px 4px #0007;
}
.b-bar .fill {
  height: 100%; border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
  transition: width .5s ease-out;
}
.b-bar .fill.gold {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.b-bar .right { font-size: 14px; font-weight: bold; }
.b-bar .note { flex-basis: 100%; font-size: 14px; color: var(--dim); }

.b-tidings .t {
  display: flex; gap: 12px; align-items: baseline;
  margin-bottom: 8px; font-size: 15px;
}
.b-tidings .t::before {
  content: '\25c6'; color: var(--gold); font-size: 10px;
  position: relative; top: -2px;
}
.b-tidings .t.alert { color: var(--alert); font-weight: bold; }
.b-tidings .t.alert::before { color: var(--alert); }
.b-tidings .t.gold { color: var(--gold); font-weight: bold; }

.b-rows .heading {
  font-size: 13px; letter-spacing: 3px; color: var(--accent);
  font-weight: bold; margin: 14px 0 8px;
}
.b-rows .r {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px;
  font-size: 16px; flex-wrap: wrap;
}
.b-rows .dot {
  flex: none; width: 11px; height: 11px; border-radius: 6px;
  background: #6e667c; position: relative; top: 1px;
}
.b-rows .dot.ready { background: #96d28c; box-shadow: 0 0 8px #96d28c66; }
.b-rows .dot.established { background: var(--gold); }
.b-rows .name { font-weight: bold; }
.b-rows .tag { color: var(--dim); font-size: 13px; }
.b-rows .desc { color: var(--dim); font-size: 13px; flex-basis: 100%;
                padding-left: 21px; }

.b-ranks .r { display: flex; align-items: center; gap: 14px; margin-bottom: 11px; }
.b-ranks .rank { min-width: 26px; font-size: 17px; font-weight: bold;
                 color: var(--dim); }
.b-ranks .rank.top { color: var(--gold); }
.b-ranks .name { flex: 0 1 210px; font-size: 16px; font-weight: bold;
                 overflow: hidden; text-overflow: ellipsis; }
.b-ranks .track { flex: 1 1 120px; height: 15px; background: #302a3c;
                  border-radius: 8px; overflow: hidden;
                  box-shadow: inset 0 1px 4px #0007; }
.b-ranks .fill { height: 100%; border-radius: 8px; }
.b-ranks .value { min-width: 64px; text-align: right; font-size: 14px;
                  font-weight: bold; }

.b-seals .lodges { display: flex; align-items: center; gap: 10px;
                   margin-bottom: 14px; }
.b-seals .lodge { width: 50px; height: 42px; border-radius: 9px;
                  border: 2px solid #46405230; position: relative; }
.b-seals .lodge.built { border-color: var(--gold); background: #3a3128; }
.b-seals .lodge.built::before {
  content: '\2302'; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: var(--gold);
  font-size: 22px;
}
.b-seals .lcount { font-size: 12px; letter-spacing: 2px; color: var(--dim);
                   font-weight: bold; }
.b-seals .wall { display: grid; gap: 13px;
                 grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.b-seals .tile {
  background: #262133; border: 1px solid #423a4e; border-radius: 10px;
  padding: 14px 10px; text-align: center;
}
.b-seals .tile.equipped { border: 2px solid var(--gold);
                          box-shadow: 0 0 22px #c9a45c33; }
.b-seals .hanzi { font-size: 40px; color: #c4bcd2; line-height: 1.2;
                  font-family: 'KaiTi', 'SimSun', Georgia, serif; }
.b-seals .tile.equipped .hanzi { color: var(--ink); }
.b-seals .pips { color: var(--gold); font-size: 11px; letter-spacing: 3px;
                 margin: 6px 0; min-height: 13px; }
.b-seals .plus { color: var(--good); font-size: 12px; font-weight: bold; }
.b-seals .minus { color: var(--alert); font-size: 12px; font-weight: bold; }

.b-vigil .haunt { font-size: 14px; letter-spacing: 3px; color: var(--dim);
                  font-weight: bold; }
.b-vigil h1 { font-size: 34px; margin: 4px 0 14px; }
.b-vigil .tell { font-style: italic; font-size: 17px; color: #cac2da;
                 line-height: 1.55; max-width: 620px; }
.b-vigil .meta { display: flex; gap: 44px; margin: 18px 0 10px; }
.b-vigil .meta .l { font-size: 12px; letter-spacing: 2px; color: var(--dim);
                    font-weight: bold; }
.b-vigil .meta .v { font-size: 26px; font-weight: bold; }
.b-vigil .meta .v.pot { color: var(--gold); }
.b-vigil .statusline { font-size: 22px; font-weight: bold; margin: 8px 0; }
.b-vigil .candles { display: flex; align-items: flex-end; gap: 26px;
                    margin: 18px 0 8px; min-height: 90px; }
.candle { width: 17px; border-radius: 4px; background: #d6cab2;
          position: relative; box-shadow: inset -3px 0 6px #0004; }
.candle.burned { background: #786e60; }
.candle .flame {
  position: absolute; left: 50%; top: -17px; transform: translateX(-50%);
  width: 10px; height: 15px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 65%, #fff0c8, #ffbe5a 60%, #ff9a3c);
  box-shadow: 0 0 18px 6px #ffbe5a55;
  animation: flicker 1.3s infinite alternate;
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-52%) scale(.86); }
}
.b-vigil .cracks { color: #c85a50; font-size: 14px; letter-spacing: 4px; }
.b-vigil .reveal { text-align: center; margin: 8px 0; }
.b-vigil .reveal .hanzi {
  font-size: 78px; color: #d64e42; text-shadow: 0 0 34px #96282855;
  font-family: 'KaiTi', 'SimSun', serif;
}
.b-vigil .reveal .epithet { color: var(--dim); font-size: 13px; }

/* --- popover (select options as a cursor list) -------------------------- */

#popover-wrap {
  position: absolute; inset: 0; z-index: 9;
  background: #00000055;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 0 40px 90px 0;
}
#popover {
  min-width: 340px; max-width: 560px; padding: 16px 0 10px;
}
#popover .ptitle {
  font-size: 13px; letter-spacing: 2px; color: var(--gold);
  font-weight: bold; padding: 0 24px 10px;
}
#popover .plist { max-height: 380px; overflow-y: auto; position: relative;
                  scrollbar-width: none; }
#popover .plist::-webkit-scrollbar { display: none; }
#popover .clist.v li { font-size: 16px; font-variant: normal;
                       letter-spacing: .5px; padding: 9px 22px 9px 44px;
                       white-space: normal; }
#popover .clist.v li .sub { display: block; font-size: 12.5px;
                            color: var(--dim); }

/* --- modal (found / edit forms) ----------------------------------------- */

#overlay {
  position: absolute; inset: 0; z-index: 10;
  background: #00000077;
  display: flex; align-items: center; justify-content: center;
}
#overlay form {
  width: 480px; padding: 24px 26px 20px;
  display: flex; flex-direction: column; gap: 10px;
  user-select: text;
}
#overlay h2 {
  font-size: 17px; color: var(--gold); font-weight: bold;
  letter-spacing: 2px; font-variant: small-caps; margin-bottom: 4px;
}
#overlay label { font-size: 13px; color: var(--dim); letter-spacing: 1px; }
#overlay input, #overlay textarea {
  width: 100%; padding: 9px 12px; font-family: inherit; font-size: 15px;
  background: #141020; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; outline: none;
}
#overlay input:focus, #overlay textarea:focus { border-color: var(--gold); }
#overlay textarea { min-height: 88px; resize: vertical; }
#overlay .btns { display: flex; gap: 10px; justify-content: flex-end;
                 margin-top: 6px; }
#overlay .btns button {
  padding: 9px 20px; cursor: pointer; font-family: inherit; font-size: 14px;
  border-radius: 6px; border: 1px solid var(--line);
  background: #141020; color: var(--ink); letter-spacing: 1px;
}
#overlay .btns button[type=submit] {
  background: var(--green); border-color: var(--green); color: #eaf5ec;
}
#overlay .btns button:hover { filter: brightness(1.2); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .cursor::before, .candle .flame, #busy { animation: none; }
  #screen.enter, #toast { animation: none; }
  .cursor { transition: none; }
}
