/* base.css — shared look: painted wood, parchment and polished brass, like a handmade tabletop miniature. */
:root {
  --font: "Trebuchet MS", sans-serif;
  --ink: #3a2414; --cream: #fff3d6; --parch: #f3e3c0; --brass: #d9a441; --brass-d: #8a5a1c;
  --moss: #5b7a3a; --moss-d: #2f4a22; --lav: #b7a6d9; --cyan: #74e6ec; --red: #e0644a;
  --outline: 0 0 0 transparent;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1a24; color: var(--ink); font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#tilt { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .5s; }
#tilt.on { opacity: 1; }
#tilt::before, #tilt::after { content: ""; position: absolute; left: 0; right: 0; height: 22%; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#tilt::before { top: 0; -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }
#tilt::after { bottom: 0; -webkit-mask-image: linear-gradient(transparent, #000); mask-image: linear-gradient(transparent, #000); }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(30, 18, 40, .45) 100%); }
#ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--font); text-wrap: pretty; line-break: strict; }
#ui > * { pointer-events: auto; }
/* text that only shows (banners, toasts, subtitles, a closing dialogue box) never takes a tap or a click */
#ui > .banner, #ui > .toast, #ui > .subtitle, #ui > .dialog.out, #ui > .modal.closing { pointer-events: none; }
.screen { position: absolute; inset: 0; overflow: hidden; animation: screenIn .28s ease-out; }
.screen.passthrough { pointer-events: none; }
.screen.passthrough button, .screen.passthrough .pe { pointer-events: auto; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }

/* outlined display text */
.otext, .btn-label, .title-text, .banner span, .dialog-name, .chip b, .stars, .mcard-name {
  font-weight: 900; paint-order: stroke fill; -webkit-text-stroke: 4px var(--ink); color: var(--cream);
  text-shadow: 0 3px 0 var(--ink);
}
.title-text { font-size: 26px; letter-spacing: .02em; }

/* panel: 9-slice parchment + brass */
.panel {
  border-style: solid; border-width: 22px; border-image: url("../assets/ui-panel.webp") 12% fill / 22px stretch;
  color: var(--ink); filter: drop-shadow(0 6px 8px rgba(20, 10, 30, .35));
}
.panel .otext { -webkit-text-stroke: 3px var(--ink); }

/* buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; min-width: 52px; padding: 6px 18px; margin: 0; cursor: pointer; background: none; color: var(--cream);
  font-family: var(--font); font-size: 18px; border-style: solid; border-width: 12px 16px;
  border-image: url("../assets/ui-button.webp") 22% 9% fill / 12px 16px stretch;
  filter: drop-shadow(0 4px 0 rgba(40, 22, 10, .55)); transition: transform .12s, filter .12s;
}
.btn .btn-label { -webkit-text-stroke: 3.5px var(--moss-d); text-shadow: 0 2px 0 var(--moss-d); line-height: 1.1; }
.btn.primary { min-height: 60px; font-size: 22px; filter: drop-shadow(0 5px 0 rgba(40, 22, 10, .6)) saturate(1.15) brightness(1.08) hue-rotate(-18deg); }
.btn.small { min-height: 44px; font-size: 15px; padding: 2px 10px; border-width: 9px 12px; border-image-width: 9px 12px; }
.btn .btn-icon { width: 28px; height: 28px; object-fit: contain; }
.btn.small .btn-icon { width: 22px; height: 22px; }
.btn:hover, .btn.focused { transform: scale(1.05); filter: drop-shadow(0 4px 0 rgba(40, 22, 10, .55)) brightness(1.15); }
.btn.focused { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 10px; }
.btn.pressed { animation: squash .22s ease-out; }
.btn.disabled { filter: grayscale(.8) brightness(.8); }
@keyframes squash { 0% { transform: scale(.9, .86); } 60% { transform: scale(1.06, 1.04); } 100% { transform: scale(1); } }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.btn-row.col { flex-direction: column; align-items: stretch; }
.icon-btn {
  width: 48px; height: 48px; padding: 0; border: 0; cursor: pointer; background: url("../assets/ui-pause.webp") center / 100% 100% no-repeat;
  display: inline-flex; align-items: center; justify-content: center; filter: drop-shadow(0 3px 0 rgba(40, 22, 10, .5));
}
.icon-btn img { width: 62%; height: 62%; object-fit: contain; }
.icon-btn:hover, .icon-btn.focused { transform: scale(1.08); }
.icon-btn.focused { outline: 3px solid var(--cyan); border-radius: 10px; }
.icon-btn.plain { background: none; }

/* chips, stars, badges */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 4px; border-radius: 999px; background: rgba(42, 26, 18, .62); border: 2px solid var(--brass); }
.chip img { width: 26px; height: 26px; object-fit: contain; }
.chip b { font-size: 17px; -webkit-text-stroke: 3px var(--ink); }
.stars { font-size: 14px; letter-spacing: 1px; color: #ffe08a; -webkit-text-stroke: 2.5px var(--ink); text-shadow: 0 1px 0 var(--ink); }
.stars.r4 { color: #ffb8f0; } .stars.r5 { color: #8ff4ff; }
.el-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px 1px 2px; border-radius: 999px; background: color-mix(in srgb, var(--el) 35%, #2a1a12); color: var(--cream); font-weight: 800; font-size: 13px; border: 2px solid var(--el); }
.el-badge img { width: 20px; height: 20px; }
.hearts { color: #ff7f9e; font-size: 13px; letter-spacing: 1px; text-shadow: 0 1px 0 var(--ink); }

/* monster card */
.mcard {
  position: relative; display: flex; gap: 8px; align-items: center; width: 100%; padding: 6px; cursor: pointer; text-align: left;
  font-family: var(--font); background: linear-gradient(#fff6df, #eedcb4); border: 3px solid var(--brass); border-radius: 14px;
  box-shadow: 0 3px 0 var(--brass-d), inset 0 0 0 2px rgba(255, 255, 255, .5); color: var(--ink); transition: transform .12s;
}
.mcard.r4 { border-color: #e59adf; } .mcard.r5 { border-color: #5fe0ec; box-shadow: 0 3px 0 #2c8e98, 0 0 12px rgba(95, 224, 236, .6); }
.mcard.selected { background: linear-gradient(#e9ffd9, #c9e7a8); transform: scale(1.02); outline: 3px solid var(--moss); }
.mcard.focused { outline: 3px solid var(--cyan); }
.mcard-art { flex: 0 0 auto; width: 60px; height: 60px; border-radius: 12px; background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--el) 45%, #fff), #d9c79c); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mcard-art img { width: 100%; height: 100%; object-fit: contain; }
.mcard.compact .mcard-art { width: 48px; height: 48px; }
/* hand-drawn monsters (their art is a data: PNG of the strokes only): no box behind them, a paper rim around the strokes */
.mcard-art:has(> img[src^="data:"]), .co-pv-art:has(> img[src^="data:"]), .co-big:has(> img[src^="data:"]) { background: transparent !important; box-shadow: none !important; }
.mcard-art > img[src^="data:"], .co-pv-art > img[src^="data:"], .co-big > img[src^="data:"], .co-mini img.pa[src^="data:"], .ba-pport > img[src^="data:"] {
  filter: drop-shadow(0 0 1px #fbf1d8) drop-shadow(0 0 1px #fbf1d8) drop-shadow(0 0 1.2px #3a2414);
}
.mcard-info { flex: 1; min-width: 0; }
.mcard-name { font-size: 15px; -webkit-text-stroke: 3px var(--ink); line-height: 1.15; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.mcard-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.mcard-el { width: 20px; height: 20px; }
.mcard-lv { font-weight: 800; font-size: 13px; }
.mcard-evo { position: absolute; top: 2px; left: 4px; color: #fff4a0; font-size: 16px; text-shadow: 0 0 4px #ffb400, 0 1px 0 var(--ink); }
.mcard-badge { position: absolute; top: -8px; right: -6px; background: var(--moss); color: var(--cream); font-weight: 900; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--brass); }

/* modal */
.modal { position: absolute; inset: 0; background: rgba(28, 16, 36, .55); display: flex; align-items: center; justify-content: center; z-index: 40; animation: fadeIn .18s; }
.modal-box { width: min(92%, 380px); max-height: 86%; overflow-y: auto; animation: pop .26s cubic-bezier(.3, 1.6, .5, 1); }
.modal.closing { animation: fadeOut .16s forwards; }
.confirm-text { font-size: 17px; font-weight: 700; text-align: center; margin: 6px 4px 4px; line-height: 1.45; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }

/* toast / banner */
.toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); z-index: 60; background: rgba(42, 26, 18, .85); color: var(--cream); font-weight: 800; font-size: 16px; padding: 10px 18px; border-radius: 14px; border: 2px solid var(--brass); animation: pop .22s; max-width: 86%; text-align: center; pointer-events: none; }
.toast.out { opacity: 0; transition: opacity .35s; }
.banner { position: absolute; left: 0; right: 0; top: 39%; z-index: 55; display: flex; justify-content: center; pointer-events: none; animation: slam .42s cubic-bezier(.2, 1.7, .4, 1); }
.banner span { font-size: 44px; padding: 8px 30px; background: linear-gradient(90deg, transparent, rgba(58, 36, 20, .75) 15%, rgba(58, 36, 20, .75) 85%, transparent); color: #ffe7a0; -webkit-text-stroke: 5px var(--ink); }
.banner.lose span { color: #d9c9ff; }
.banner.out { opacity: 0; transform: scale(1.15); transition: all .45s; }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* story dialogue */
.dialog { position: absolute; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0 10px 22px; background: linear-gradient(transparent 55%, rgba(28, 16, 36, .5)); animation: fadeIn .2s; }
.dialog.out { animation: fadeOut .18s forwards; }
/* a story scene takes the stage: the screen under it steps aside so no text shows through around the box */
#ui:has(> .dialog:not(.out)) > .screen { opacity: 0; pointer-events: none; transition: opacity .2s; }
.dialog-portrait { position: absolute; bottom: 150px; left: 8px; width: 42%; max-width: 190px; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .4)); animation: slideUp .3s ease-out; pointer-events: none; }
.dialog.who-greyplume .dialog-portrait { left: auto; right: 8px; }
.dialog-box { position: relative; width: 100%; max-width: 420px; min-height: 130px; padding: 2px 6px; }
.dialog-name { font-size: 18px; margin-bottom: 4px; color: #ffe39a; }
.dialog-text { font-size: 17px; line-height: 1.5; font-weight: 700; min-height: 52px; padding-right: 18px; }
.dialog-text + .dialog-next, .dialog-next { bottom: -14px; }
.dialog-next { position: absolute; right: 4px; bottom: -6px; color: var(--brass-d); animation: bob 0.8s infinite alternate; }
@keyframes bob { to { transform: translateY(4px); } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } }

.hidden { display: none !important; }
.subtitle {
  position: absolute; left: 50%; top: 26%; transform: translateX(-50%); z-index: 40; pointer-events: none;
  max-width: 86%; padding: 8px 14px; border-radius: 12px; background: rgba(28, 18, 10, 0.72);
  color: var(--cream); font-size: 16px; font-weight: 700; text-align: center; line-height: 1.4;
  text-shadow: 0 2px 0 #000; border: 1px solid rgba(217, 164, 65, 0.5);
}
.howto { max-height: 52vh; overflow-y: auto; text-align: left; color: var(--ink); font-size: 15px; line-height: 1.5; padding: 0 4px; }
.howto p { margin: 0 0 8px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.scroll::-webkit-scrollbar { width: 0; }
