/* =====================================================================================================================
   The finish: one layer over everything above that tidies the basics into one consistent, polished feel. Same goblin
   look; calmer surfaces, crisper controls, softer motion, readable text. (Later rules here win over the ones above.)
   ===================================================================================================================== */
:root {
  --surface: linear-gradient(180deg, rgba(36, 50, 24, 0.96), rgba(13, 19, 9, 0.98));
  --surface-2: rgba(255, 255, 255, 0.035);
  --surface-3: rgba(0, 0, 0, 0.28);
  --line: rgba(242, 182, 50, 0.22);
  --line-soft: rgba(240, 236, 224, 0.09);
  --line-strong: rgba(242, 182, 50, 0.5);
  --glow: 0 0 0 1px rgba(242, 182, 50, 0.08), 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.04) inset;
  --lift: 0 6px 18px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ink-soft: rgba(240, 236, 224, 0.72);
}
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
::selection { background: rgba(242, 182, 50, 0.35); color: #fff; }

/* windows: one surface, a soft entrance, a proper close button */
.shopcard {
  border-radius: 22px; border: 1px solid var(--line); background: var(--surface), #0d1309;
  box-shadow: var(--glow); padding: 28px 26px 30px;
}
.shopcard::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(120% 60% at 50% 0%, rgba(242, 182, 50, 0.07), transparent 60%); }
.shopcard h2 { letter-spacing: 0.01em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 24px rgba(242, 182, 50, 0.18); }
.open > .shopcard, .open > .bellcard, .open > .gmwcard { animation: winin 0.26s var(--ease) both; }
@keyframes winin { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.gamewin.open, #shop.open, #inventory.open, #trade.open, #duel.open, #roulette.open, #challenges.open, #catpick.open, #skills.open, #blackjack.open, #poker.open, #market.open, #econ.open, #loanwin.open { animation: dimin 0.2s ease-out both; }
@keyframes dimin { from { background-color: rgba(0, 0, 0, 0); } }
.shopclose {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; line-height: 1; color: var(--ink-soft);
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-soft); transition: transform 0.2s var(--ease), color 0.2s, border-color 0.2s, background 0.2s; z-index: 2;
}
.shopclose:hover { color: var(--gold); border-color: var(--line-strong); background: rgba(242, 182, 50, 0.08); transform: rotate(90deg); }

/* small buttons: crisp, consistent, with a little lift */
.chip {
  border-radius: 11px; border: 1px solid rgba(154, 168, 184, 0.32); padding: 7px 13px; line-height: 1.15;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 60%), rgba(0, 0, 0, 0.34);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s var(--ease), border-color 0.15s, box-shadow 0.15s, background 0.15s, filter 0.15s;
}
.chip:not(.locked):not(:disabled):hover { filter: none; border-color: rgba(242, 182, 50, 0.55); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 6px 14px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(242, 182, 50, 0.06); }
.chip:not(.locked):not(:disabled):active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) inset; }
.chip:disabled { opacity: 0.42; cursor: not-allowed; }
.chip.on { background: linear-gradient(180deg, #ffe08a, var(--gold)); color: #2b1d02; border-color: #ffe08a; }
button:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* the segmented tabs used across windows */
.mkttabs, .htabs { gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-soft); width: fit-content; max-width: 100%; margin-left: auto; margin-right: auto; }
.mkttabs button, .htabs .chip { border: 1px solid transparent; background: transparent; box-shadow: none; border-radius: 10px; transition: background 0.18s, color 0.18s, box-shadow 0.18s; }
.mkttabs button:hover, .htabs .chip:hover { background: rgba(255, 255, 255, 0.05); transform: none; box-shadow: none; }
.mkttabs button.on, .htabs .chip.on { background: linear-gradient(180deg, #ffe08a, var(--gold)); color: #2b1d02; box-shadow: 0 2px 8px rgba(242, 182, 50, 0.25); }

/* fields */
input[type="number"], input[type="text"]:not(#search), select, textarea {
  border-radius: 10px; border: 1px solid rgba(242, 182, 50, 0.32); background: rgba(0, 0, 0, 0.42); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="number"]:focus, input[type="text"]:not(#search):focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 182, 50, 0.15); }

/* reading: notes a touch brighter, roomier and not too wide */
.hnote, .vmeta, .aucsub, .folkhome, .enote { line-height: 1.45; }
.hnote { color: var(--ink-soft); }
#aucbody > .hnote, #folkbody > .hnote, #hallbody > p, #caulbody > .hnote, #loans > .hnote { max-width: 72ch; margin-left: auto; margin-right: auto; }
.shopcard h4, #vilpanel h4 { letter-spacing: 0.02em; }

/* cards: one family */
.auccard, .folkcard, .loancard, .bankoffer, .hallgrid div, .hallvote, .folkdetail, .hrow, #vilpanel .vcard, .stock, .prstat {
  border-radius: 14px; border: 1px solid var(--line-soft); background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 40%), rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.auccard, .folkcard, .stock { transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s; }
.auccard:hover, .folkcard:hover { transform: translateY(-2px); border-color: rgba(242, 182, 50, 0.35); box-shadow: var(--lift); }
.auccard.focus, .folkcard.sel { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(242, 182, 50, 0.12), var(--lift); }
.auccard.leading { border-color: rgba(126, 224, 122, 0.6); }
.hallvote { background: linear-gradient(180deg, rgba(199, 125, 255, 0.12), rgba(199, 125, 255, 0.03)); border-color: rgba(199, 125, 255, 0.35); }
.hallgrid div.bad, .folkcard.homeless { border-color: rgba(255, 140, 120, 0.4); }
#vilpanel .vcard { border-color: var(--line); }
#vilpanel .vcard.hint { border-style: dashed; }

/* scrollbars inside windows and panels: thin and quiet, but there (long lists need them) */
.shopcard *, #vilpanel, #housepanel, .folklist, .aucstash, #belllist { scrollbar-width: thin; scrollbar-color: rgba(242, 182, 50, 0.3) transparent; }
.shopcard *::-webkit-scrollbar, #vilpanel::-webkit-scrollbar, #housepanel::-webkit-scrollbar, .folklist::-webkit-scrollbar, #belllist::-webkit-scrollbar { display: block; width: 8px; height: 8px; }
.shopcard *::-webkit-scrollbar-thumb, #vilpanel::-webkit-scrollbar-thumb, #housepanel::-webkit-scrollbar-thumb, .folklist::-webkit-scrollbar-thumb, #belllist::-webkit-scrollbar-thumb { background: rgba(242, 182, 50, 0.28); border-radius: 8px; }
.shopcard *::-webkit-scrollbar-track, #vilpanel::-webkit-scrollbar-track, .folklist::-webkit-scrollbar-track { background: transparent; }

/* the toast: a calm card that slides up, in sentence case */
#toast {
  text-transform: none; border-radius: 16px; border: 1px solid rgba(122, 255, 42, 0.45); padding: 13px 20px 13px 18px;
  background: linear-gradient(180deg, rgba(42, 61, 16, 0.97), rgba(15, 23, 11, 0.98)); color: #f4f7c8; font-size: 15px; letter-spacing: 0.01em;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03) inset, 0 0 30px rgba(122, 255, 42, 0.16);
  transform: translate(-50%, 140%); transition: transform 0.38s var(--ease), opacity 0.25s;
}
#toast.show { transform: translate(-50%, 0); }
#toast::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--skin); }
#toast small { font-size: 15px; line-height: 1.35; color: var(--ink-soft); margin-top: 3px; }

/* full-screen places (the village, a house): a clean toolbar along the top */
.vtop { background: linear-gradient(180deg, rgba(20, 30, 13, 0.96), rgba(12, 18, 9, 0.9)); border-bottom: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); position: relative; z-index: 2; }
.vtop .chip { padding: 7px 12px; }
#vilpanel { background: linear-gradient(180deg, rgba(14, 20, 10, 0.97), rgba(9, 13, 7, 0.97)); border-left: 1px solid var(--line-soft); }
#vilpanel h3 { letter-spacing: 0.01em; }

@media (prefers-reduced-motion: reduce) {
  .open > .shopcard, .open > .bellcard, .open > .gmwcard, .gamewin.open { animation: none; }
  .chip, .shopclose, .auccard, .folkcard { transition: none; }
}
.dogkit .vactions { flex-direction: row !important; flex-wrap: wrap; }
/* windows always finish opening, even while the page is resting (unfocused pages pause their other animations) */
body.idle .open > .shopcard, body.idle .open > .bellcard, body.idle .open > .gmwcard, body.idle .gamewin.open,
body.idle #shop.open, body.idle #inventory.open, body.idle #trade.open, body.idle #duel.open, body.idle #roulette.open, body.idle #challenges.open,
body.idle #catpick.open, body.idle #skills.open, body.idle #blackjack.open, body.idle #poker.open, body.idle #market.open, body.idle #econ.open, body.idle #loanwin.open { animation-play-state: running !important; }
/* toasts sit above any open window */
#toast { z-index: 130; }
/* the coin icon stays on the line with its number */
.aucfacts span.cur-i, .hallgrid span.cur-i, .folkt span.cur-i, .prstat span.cur-i { display: inline-block !important; }

/* banners drop in under the timers, never over them (placebanners() works out where) */
#mythbanner, #challenge { top: var(--below-clock, 12px); }
header { transition: padding-top 0.25s var(--ease); }
/* hidden, they tuck right up out of sight (they sit lower now, under the timers) */
#challenge:not(.show) { transform: translate(-50%, calc(-100% - var(--below-clock, 16px) - 40px)); }
#mythbanner:not(.show) { transform: translate(-50%, calc(-100% - var(--below-clock, 12px) - 40px)); }
/* the raid banner keeps to one line where there's room, rather than squeezing into half the width */
#raidbanner { width: max-content; }

/* newcomers waiting at the gate */
.hallvote.gate { background: linear-gradient(180deg, rgba(154, 168, 184, 0.14), rgba(154, 168, 184, 0.03)); border-color: rgba(154, 168, 184, 0.45); }
.hallvote.gate.closed { opacity: 0.7; }
.gatefolk { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.gateone { display: inline-flex; flex-direction: column; align-items: center; min-width: 74px; padding: 6px 8px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-soft); }
.gateone b { font-family: var(--f-ui); font-weight: 400; font-size: 11px; color: var(--gold); }
.gateone small { font-size: 12px; color: var(--ink-dim); }

/* faiths and visitors */
.faithcard { margin: 8px 0; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(242, 182, 50, 0.18); text-align: left; font-size: 14px; line-height: 1.45; }
.faithcard h3 { margin: 0 0 6px; }
.faithcard h4 { margin: 10px 0 6px; }
.faithcard.mine { border-color: rgba(242, 182, 50, 0.55); box-shadow: 0 0 18px rgba(242, 182, 50, 0.08) inset; }
.faithcard .aucform { margin: 8px 0; }
.faithsyms { margin: 4px 0 8px; }
.faithsyms .coopt { font-size: 20px; width: 40px; height: 40px; line-height: 1; }
.faithroster { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px; }
.faithone { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); min-width: 0; }
.faithone svg { flex: none; }
.faithone b { flex: 1; min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.faithone small { opacity: 0.75; white-space: nowrap; font-size: 12px; }
.faithone button { flex: none; padding: 3px 8px; font-size: 12px; }
.avrace { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.avrace small { font-size: 11px; line-height: 1.2; color: var(--text, #f4ecd6); opacity: 0.9; }
#avraces .coopt { width: auto; height: auto; padding: 4px 6px 3px; line-height: 1; min-width: 52px; }
.avraceblurb { margin: 2px 0 8px; }
.folkkid { font-size: 0.85em; }
.faithcard .aucform input { flex: 1; min-width: 200px; }
.faithcard .aucform select { max-width: 100%; }

/* a raid on: the edges of the village glow red */
#village.raiding::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5; box-shadow: inset 0 0 140px rgba(255, 30, 10, 0.5); animation: raidglow 1.6s ease-in-out infinite; }
@keyframes raidglow { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
body.idle #village.raiding::after { animation-play-state: running !important; }
.vbubble { font-weight: normal; }

/* the live auction: a card that sits over everything while it's on */
#liveauc { display: none; }
#liveauc.open { display: block; position: fixed; left: 16px; bottom: 16px; z-index: 135; width: min(340px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(40, 30, 12, 0.97), rgba(22, 16, 8, 0.97)); border: 2px solid #f2b632; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 22px rgba(242, 182, 50, 0.25); color: #f4ecd6; }
#liveauc.on { animation: lapulse 1.4s ease-in-out infinite; }
@keyframes lapulse { 50% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 34px rgba(242, 182, 50, 0.55); } }
body.idle #liveauc.on { animation-play-state: running !important; }
#liveauc .lahead { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
#liveauc .lahead b { color: #f2b632; font-family: var(--f-ui); white-space: nowrap; }
#liveauc .lahead span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#liveauc .laclose { background: none; border: 0; color: inherit; cursor: pointer; }
#liveauc .laprice { font-family: var(--f-ui); font-size: 28px; color: #ffd23c; text-align: center; margin: 4px 0; }
#liveauc .lameta { font-size: 13px; margin: 3px 0; }
#liveauc .lameta.dim { opacity: 0.7; }
#liveauc .labar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; margin: 6px 0 2px; }
#liveauc .labar i { display: block; height: 100%; transition: width 0.1s linear, background 0.3s; }
#liveauc button.hoard { width: 100%; margin-top: 8px; }
#liveauc .laresult { font-size: 15px; margin-top: 4px; }

/* the call to a live auction: a popup in the middle of whatever you're doing */
#livecall { position: fixed; inset: 0; z-index: 140; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.45); }
#livecall .lccard { width: min(400px, 100%); padding: 18px 20px; border-radius: 16px; text-align: center; color: #f4ecd6;
  background: linear-gradient(180deg, rgba(48, 36, 14, 0.98), rgba(24, 18, 8, 0.98)); border: 2px solid #f2b632; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(242, 182, 50, 0.35); animation: lcpop 0.35s ease-out; }
@keyframes lcpop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#livecall .lcbig { font-size: 42px; line-height: 1; margin-bottom: 4px; }
#livecall h3 { margin: 4px 0 8px; color: #ffd23c; }
#livecall p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
#livecall .lcacts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.livecard { margin: 10px 0; padding: 12px 14px; border-radius: 14px; border: 2px solid #f2b632; background: rgba(0, 0, 0, 0.3); }
.livecard .lahead { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.livecard .lahead b { color: #f2b632; font-family: var(--f-ui); }
.livecard .laprice { font-family: var(--f-ui); font-size: 30px; color: #ffd23c; text-align: center; margin: 4px 0; }
.livecard .lameta { font-size: 13px; margin: 3px 0; }
.livecard .lameta.dim { opacity: 0.7; }
.livecard .labar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; margin: 6px 0 2px; }
.livecard .labar i { display: block; height: 100%; transition: width 0.1s linear, background 0.3s; }
.livecard button.hoard { width: 100%; margin-top: 8px; }
.livelist { display: grid; gap: 6px; }
.liverow { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.liverow b { white-space: nowrap; }
.liverow span { flex: 1; min-width: 0; opacity: 0.8; font-size: 13px; }
body.idle #livecall .lccard { animation-play-state: running !important; }

.lalot { display: flex; gap: 10px; align-items: center; margin: 6px 0 8px; padding: 6px 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); text-align: left; }
.lalot .aucplot { width: 70px; height: 50px; flex: none; }
.lalot b { display: block; font-size: 14px; }
.lalot .lameta { font-size: 12px; margin: 2px 0; }
.lalot .lawatch { margin-top: 4px; padding: 3px 8px; font-size: 12px; }
#livecall .lalot { margin: 0 0 10px; }
#liveauc .laprice.small, .livecard .laprice.small { font-size: 18px; }

.lalot.compact { padding: 4px 6px; margin: 4px 0 6px; }
.lalot.compact .aucplot { width: 44px; height: 32px; }
.lalot.compact b { font-size: 13px; }

