
@font-face {
  font-family: "Cinzel Decorative";
  src: url("assets/fonts/CinzelDecorative-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cinzel Decorative";
  src: url("assets/fonts/CinzelDecorative-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Crimson Text";
  src: url("assets/fonts/CrimsonText-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Crimson Text";
  src: url("assets/fonts/CrimsonText-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Crimson Text";
  src: url("assets/fonts/CrimsonText-Italic.ttf") format("truetype");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "IM Fell French Canon";
  src: url("assets/fonts/IMFellFrenchCanon-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}

/* Lobby — courtyard gate · merchant stall */
:root {
  --text: #f3e6d0;
  --muted: #c4a574;
  --ink: #2a1a0c;
  --gold: #f5c542;
  --good: #5ddea8;
  --warn: #f0c14a;
  --danger: #c44048;
  --radius: 10px;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  font-family: "Crimson Text", Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(120, 80, 36, 0.4) 0%, transparent 55%),
    linear-gradient(180deg, #2a1c12 0%, #1a120c 55%, #120c08 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
a { color: #e0b060; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 14px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.brand h1 {
  margin: 0;
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: 1.4rem;
  color: #f3e2b8;
  text-shadow: 0 2px 0 #3a2410, 0 0 18px rgba(255, 180, 60, 0.25);
}
.brand .tag {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.85rem;
  color: #c4a574;
}
.nav { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.92rem; }
.nav a { color: #b89868; }
.nav a.active { color: #f0e0c0; font-weight: 700; }

.pouch-hud, .wallet {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #5a3e28 0%, #3a2818 100%);
  border: 2px solid #8a6238;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 220, 160, 0.15);
}
@media (max-width: 640px) {
  .wallet { grid-template-columns: 1fr 1fr; }
}
.wallet-cell .label {
  display: block;
  font-size: 0.72rem;
  color: #d4b888;
}
.wallet-cell strong {
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 1.15rem;
  color: #f8ecd0;
}
.wallet-cell.gems strong { color: var(--gold); }
.wallet-cell.ok strong { color: var(--good); }

.solvency-strip, .parchment-stamp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 4px;
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(180deg, #d8c49a, #c4a878);
  border: 2px solid #6a4a28;
  color: #2a1a0c;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.solvency-strip.ok { color: #1a4a28; }
.solvency-strip.fail {
  color: #5a1010;
  background: linear-gradient(180deg, #e0b090, #c88868);
  border-color: #8a3030;
}
.solvency-strip .detail {
  font-family: "Crimson Text", Georgia, serif;
  font-weight: 400;
  font-size: 0.85rem;
  color: #4a3420;
}

/* Gate / courtyard */
.gate-scene {
  position: relative;
  min-height: min(58vh, 480px);
  margin: 0 -6px 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #5a3a1c;
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
  background: #1a1008;
}
.gate-bg {
  position: absolute;
  inset: 0;
  background: url("assets/town/rooms/room_lobby_gate_painted.png") center 45% / cover no-repeat;
  filter: saturate(1.08) contrast(1.04) brightness(1.05);
  transform: scale(1.02);
}
.gate-vignet {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(20,10,4,0.08) 0%, transparent 22%, transparent 68%, rgba(10,5,2,0.3) 100%);
}
.gate-sign {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 28px 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.gate-sign h2 {
  margin: 0;
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: #f3e2b8;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 #3a2410, 0 0 18px rgba(255,180,60,0.35), 0 8px 24px rgba(0,0,0,0.7);
}
.gate-mood {
  margin: 0 0 8px;
  max-width: 420px;
  font-style: italic;
  color: #d8c4a0;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.btn-enter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: min(280px, 86vw);
  padding: 12px 28px;
  margin: 4px 0;
  border-radius: 10px;
  border: 3px solid #c49048;
  background: linear-gradient(180deg, #8a6430, #5a3e18);
  color: #fff6e0 !important;
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none !important;
  box-shadow: 0 4px 0 #2a180c, 0 8px 24px rgba(0,0,0,0.45);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.btn-enter:hover { filter: brightness(1.08); }
.btn-enter:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a180c, 0 4px 12px rgba(0,0,0,0.4); }
.btn-enter.secondary {
  min-height: 44px;
  font-size: 0.95rem;
  background: linear-gradient(180deg, #4a3a6a, #2a1e40);
  border-color: #7a6aa0;
  box-shadow: 0 3px 0 #1a1028, 0 6px 16px rgba(0,0,0,0.4);
}
.cta-note {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #c4a574;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

/* Merchant stall */
.stall-section {
  position: relative;
  margin-bottom: 16px;
  padding: 16px 14px 18px;
  background:
    linear-gradient(165deg, rgba(74, 52, 32, 0.92), rgba(46, 28, 16, 0.95)),
    url("assets/town/rooms/room_store.png") center 30% / cover no-repeat;
  border: 2px solid #8a6238;
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stall-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(30,18,10,0.28), rgba(20,12,6,0.55));
  pointer-events: none;
}
.stall-section > * { position: relative; z-index: 1; }
.stall-head {
  text-align: center;
  margin-bottom: 12px;
}
.stall-head h2 {
  margin: 0;
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: 1.25rem;
  color: #f3e2b8;
}
.stall-head .sub {
  margin: 4px 0 0;
  font-style: italic;
  color: #c4a574;
  font-size: 0.9rem;
}

.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.card-btn, .pack-card, .sink-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  min-height: 120px;
  border-radius: 8px;
  border: 2px solid #6a4a28;
  background: linear-gradient(165deg, #e8d4a8, #c8a878);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  cursor: pointer;
  font: inherit;
}
.card-btn:hover, .pack-card:hover { filter: brightness(1.04); border-color: #c49048; }
.card-btn .name, .pack-card .name {
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
}
.card-btn .gems { color: #5a3a10; font-weight: 700; }
.card-btn .ada {
  font-family: "IM Fell French Canon", Georgia, serif;
  color: #3a2410;
  font-size: 1.05rem;
}
.card-btn .meta { font-size: 0.78rem; color: #5a4028; font-style: italic; }
.card-btn.featured, .pass-btn.featured {
  border-color: #c49048;
  box-shadow: 0 0 0 2px rgba(196, 144, 72, 0.35), 0 4px 12px rgba(0,0,0,0.3);
}
.card-btn .discount {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: #5a3a1c;
  color: #f0d78c;
  border-radius: 10px;
  font-size: 0.72rem;
}

.pass-status.parchment-plaque {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #d8c49a, #c4a878);
  border: 2px solid #6a4a28;
  border-radius: 4px;
  color: var(--ink);
}
@media (max-width: 640px) {
  .pass-status.parchment-plaque { grid-template-columns: 1fr 1fr; }
}
.pass-status .cell span {
  display: block;
  font-size: 0.72rem;
  color: #5a4028;
}
.pass-status .cell strong {
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 0.95rem;
}

.pass-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.primary-sm, .secondary-sm {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid #6a4a28;
  font-family: "IM Fell French Canon", Georgia, serif;
  font-weight: 700;
  box-shadow: 0 3px 0 #2a180c;
}
.primary-sm {
  background: linear-gradient(180deg, #8a6430, #5a3e18);
  border-color: #c49048;
  color: #fff6e0;
}
.secondary-sm {
  background: linear-gradient(180deg, #5a3e28, #3a2818);
  color: #f0e0c0;
}

.dev-drawer {
  margin: 8px 0 0;
  border: 1px dashed #5a4a38;
  border-radius: 8px;
  background: rgba(20, 12, 6, 0.85);
  color: #8a7048;
  font-size: 0.78rem;
}
.dev-drawer summary {
  cursor: pointer;
  padding: 6px 12px;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: #8a7048;
  list-style: none;
}
.dev-drawer summary::-webkit-details-marker { display: none; }
.dev-drawer[open] summary { border-bottom: 1px solid #4a3828; }
.dev-drawer-body { padding: 10px 12px 12px; }
.lab-note { margin: 0 0 8px; color: #8a7048; }
.muted-links a { color: #8a7048; margin-right: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  z-index: 80;
  max-width: min(420px, 92vw);
  padding: 12px 18px;
  background: linear-gradient(180deg, #5a3e28, #3a2818);
  border: 2px solid #c49048;
  border-radius: 8px;
  color: #f8ecd0;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  text-align: center;
  transition: transform 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #c44048; }

@media (max-width: 420px) {
  .gate-scene { min-height: 44vh; }
  .btn-enter { font-size: 1.05rem; min-width: 90vw; }
}
@media (min-width: 1100px) {
  .gate-scene { min-height: 400px; }
}


/* —— lobby4: painted gate + plain packs —— */
.gate-bg {
  background: url("assets/town/rooms/room_lobby_gate_painted.png") center 45% / cover no-repeat !important;
  filter: saturate(1.05) contrast(1.02) brightness(1.06) !important;
}
.gate-scene {
  min-height: min(56vh, 460px);
  margin: 0 -6px 14px;
  border-width: 2px;
  background: #1a1008;
}
.gate-vignet {
  background:
    linear-gradient(180deg, rgba(20,10,4,0.05) 0%, transparent 18%, transparent 62%, rgba(10,5,2,0.35) 100%) !important;
}
.gate-sign {
  padding: 20px 14px 22px;
  gap: 10px;
}
.gate-sign h2 {
  text-shadow:
    0 2px 0 #3a2410,
    0 0 18px rgba(255, 180, 60, 0.4),
    0 6px 18px rgba(0,0,0,0.85),
    0 1px 8px rgba(0,0,0,0.9);
}
.gate-mood.ribbon {
  display: inline-block;
  margin: 0 auto;
  max-width: min(360px, 92vw);
  padding: 8px 14px;
  font-style: italic;
  font-size: 0.95rem;
  color: #2a1a0c !important;
  background: linear-gradient(180deg, #f0e0c0, #d4b888);
  border: 2px solid #6a4a28;
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
  text-shadow: none !important;
}

/* kill empty dark boxes / leftover HUD */
.wallet, .solvency-strip, .parchment-stamp:empty, .gate-sign > div:empty {
  display: none !important;
}

.stall-section {
  background:
    linear-gradient(165deg, rgba(74, 52, 32, 0.72), rgba(46, 28, 16, 0.78)),
    url("assets/town/rooms/room_store.png") center 30% / cover no-repeat;
}
.stall-section::before {
  background: linear-gradient(180deg, rgba(30,18,10,0.2), rgba(20,12,6,0.45)) !important;
}

.pack-pouch {
  position: relative;
  padding-top: 16px;
  min-height: 168px;
  overflow: hidden;
}
.pack-pouch .pouch-art {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
}
.pack-pouch .ada {
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #3a2410;
}
.pack-pouch .usd {
  display: block;
  font-size: 0.78rem;
  color: #5a4028;
  font-style: italic;
}
.pack-pouch .meta { display: none; }
.best-ribbon {
  position: absolute;
  top: 10px;
  right: -28px;
  padding: 4px 32px;
  background: linear-gradient(180deg, #c44048, #8a2028);
  color: #fff6e0;
  font-family: "IM Fell French Canon", Georgia, serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transform: rotate(32deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  z-index: 2;
}
.pack-pouch.best-value {
  border-color: #c49048;
  box-shadow: 0 0 0 2px rgba(196, 144, 72, 0.35), 0 4px 12px rgba(0,0,0,0.3);
}

@media (max-width: 420px) {
  .gate-scene { min-height: 48vh; }
  .gate-bg { background-position: center 42% !important; }
}

/* —— night1: no page scroll. Gate strip + tab bar + one board that fills the rest —— */
html:has(body.lobby-page), body.lobby-page { height: 100%; overflow: hidden; }
body.lobby-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
body.lobby-page .app.lob-app {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(58px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
body.lobby-page .gate-scene { flex: 0 0 auto; min-height: 0 !important; height: clamp(104px, 20vh, 200px); margin: 0; }
body.lobby-page .gate-sign { height: 100%; padding: 8px 10px; gap: 6px; justify-content: center; }
body.lobby-page .gate-sign h2 { font-size: clamp(1.3rem, 4.2vh, 2rem); }
body.lobby-page .btn-enter { min-height: 48px; min-width: min(240px, 70vw); padding: 8px 22px; }
.lob-tabs { flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lob-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 52px; padding: 4px 2px; border-radius: 12px; border: 2px solid #8a6238;
  background: linear-gradient(180deg, #5a3e28, #3a2818); color: #f0e0c0; font-size: 1.25rem; line-height: 1.1;
  box-shadow: 0 3px 0 #2a180c;
}
.lob-tab span { font-family: "IM Fell French Canon", Georgia, serif; font-size: .9rem; font-weight: 700; }
.lob-tab.on { background: linear-gradient(180deg, #f0e0c0, #d4b888); color: #2a1a0c; border-color: #c49048; box-shadow: 0 0 0 2px rgba(196,144,72,.4), 0 3px 0 #6a4a28; }
.lob-panels { flex: 1 1 auto; min-height: 0; position: relative; }
.lob-panel { height: 100%; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.lob-panel[hidden], .lob-sub[hidden] { display: none !important; }
body.lobby-page .chal-card { margin: 0 !important; max-width: none !important; }
body.lobby-page .lob-panel > .chal-card, body.lobby-page .lob-sub { flex: 1 1 auto; min-height: 0; overflow: hidden; }
body.lobby-page .lob-panel > .lob-holdem { flex: 0 0 auto; }
/* Daily card, compact */
body.lobby-page #chalDaily { padding: 10px 12px; }
body.lobby-page #chalDaily .sub { margin: 0 0 4px; font-size: .85rem; }
body.lobby-page .dl-row { padding: 5px 0; }
body.lobby-page .chal-card .go { min-width: 84px; padding: 10px 12px; }
body.lobby-page .dl-you { margin: 4px 0; padding: 5px 8px; }

body.lobby-page .dl-mini li { padding: 2px 4px; }
body.lobby-page .chal-card .tiers { font-size: .8rem; margin: 4px 0 0; }
@media (max-height: 760px) { body.lobby-page .dl-mini li:nth-child(n+4) { display: none; } }
@media (max-height: 700px) { body.lobby-page .dl-mini { display: none; } }
/* Goals: segmented switch + compact rows */
.lob-seg { flex: 0 0 auto; display: flex; gap: 6px; justify-content: center; }
.lob-segb {
  flex: 1; max-width: 180px; min-height: 44px; border-radius: 22px; border: 2px solid #8a6238;
  background: rgba(40,24,12,.85); color: #f0e0c0; font-family: "IM Fell French Canon", Georgia, serif; font-weight: 700; font-size: 1rem;
}
.lob-segb.on { background: linear-gradient(180deg, #f0e0c0, #d4b888); color: #2a1a0c; border-color: #c49048; }
body.lobby-page #chalList { padding: 6px 10px; }
body.lobby-page #chalList h3 { display: none; }
body.lobby-page #chalList .goal-group { margin: 0; }
body.lobby-page .ch-row { grid-template-columns: 32px 1fr auto; padding: 6px 0; gap: 0 8px; }
body.lobby-page .ch-row .ic { font-size: 1.4rem; }
body.lobby-page .ch-row b { font-size: .95rem; line-height: 1.15; }
body.lobby-page .ch-row .meta { font-size: .8rem; gap: 4px 6px; }
body.lobby-page .ch-row .bar { display: none; }
/* Events */
body.lobby-page .won-list { padding: 8px 10px; }
body.lobby-page .won-list h3 { margin-bottom: 2px; }
body.lobby-page .won-grid { grid-template-columns: repeat(4, 1fr); gap: 22px 6px; padding: 4px 0 18px; }
body.lobby-page .won-item { padding: 6px 2px 6px; font-size: .78rem; line-height: 1.1; text-align: center; }
body.lobby-page .won-item .wi-ic { font-size: 1.5rem; }
.lob-holdem { display: flex; align-items: center; gap: 10px; padding: 8px 12px !important; }
.lob-holdem > div { flex: 1; display: flex; flex-direction: column; }
.lob-holdem b { font: 700 1.05rem Georgia, serif; color: #5a1a10; }
.lob-holdem span { font-size: .85rem; color: #5a4028; }
/* Shop */
body.lobby-page .lob-sub { display: flex; flex-direction: column; gap: 8px; }
body.lobby-page .card-row { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
body.lobby-page .card-btn { min-height: 0; padding: 10px 6px; }
body.lobby-page .pack-pouch { min-height: 0; padding-top: 10px; }
body.lobby-page .pack-pouch .pouch-art { width: 56px; height: 56px; }
body.lobby-page .card-btn .name { font-size: 1rem; }
.pass-line { margin: 0; padding: 8px 10px; border-radius: 8px; background: linear-gradient(180deg, #d8c49a, #c4a878); border: 2px solid #6a4a28; color: #2a1a0c; font-size: .9rem; text-align: center; }
body.lobby-page .pass-controls { margin-top: 0; }
.lob-note { margin: 0; text-align: center; font-size: .8rem; color: #f3e3bd; text-shadow: 0 1px 2px #000; }
body.lobby-page .dev-drawer { position: fixed; left: 4px; bottom: 4px; z-index: 40; max-width: 220px; opacity: .6; }
@media (min-width: 900px) { body.lobby-page .app.lob-app { max-width: 620px; } }
.lob-tab { position: relative; }
.lob-tab.has-ready::after { content: ""; position: absolute; top: 4px; right: 8px; width: 12px; height: 12px; border-radius: 50%; background: #e04040; border: 2px solid #fff1c2; }
