/* L'Amic Invisible — estil "noir": abric de tweed, venes, barret de feltre i ulleres fosques */
:root {
  --bg: #1b1916;          /* fons d'estudi en penombra */
  --bg2: #2c2824;
  --card: #ece4d3;        /* color de vena */
  --card2: #e3d9c5;
  --ink: #1e1b18;
  --muted: #6e6558;
  --red: #2b2724;         /* acció principal: feltre del barret */
  --red-d: #0f0d0c;
  --green: #4a3a2c;       /* guant de pell */
  --gold: #b79b67;        /* llautó envellit */
  --blood: #7d2a22;       /* errors i perills */
  --line: #cdbfa6;
  --radius: 6px;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --type: "Special Elite", "Courier New", ui-monospace, monospace;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .4 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  font-family: "Lora", Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(170,155,135,.22), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,.7), transparent 60%),
    var(--noise),
    linear-gradient(170deg, var(--bg2), var(--bg) 60%);
  background-attachment: fixed;
}
::selection { background: var(--ink); color: var(--card); }
a { color: inherit; text-underline-offset: 3px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 28px 16px 64px; }
header.top { text-align: center; color: var(--card); margin: 16px 0 30px; }
header.top .logo { font-size: 52px; line-height: 1; color: var(--card); filter: drop-shadow(0 6px 14px rgba(0,0,0,.6)); }
header.top .logo svg { width: 116px; height: auto; display: inline-block; }
header.top h1 {
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: clamp(34px, 7vw, 52px); margin: 12px 0 6px; letter-spacing: .3px;
  text-shadow: 0 3px 18px rgba(0,0,0,.6);
}
header.top p { margin: 0; color: rgba(236,228,211,.72); font-style: italic; }
header.top .badge { font-style: normal; }

.card {
  position: relative;
  background-color: var(--card);
  background-image:
    repeating-linear-gradient(112deg, rgba(110,90,60,.045) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(22deg, rgba(110,90,60,.03) 0 1px, transparent 1px 11px);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 18px 40px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3);
  margin-bottom: 20px;
}
.card h2 {
  margin: 0 0 14px; font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: .2px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
label {
  display: block; margin: 14px 0 6px;
  font-family: var(--type); font-weight: 400; font-size: 14px; letter-spacing: .6px; text-transform: uppercase; color: #4b4339;
}
label small { font-family: "Lora", Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--muted); }
textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f7f2e8; color: var(--ink); resize: vertical; }
textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30,27,24,.12); }
input, select {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f2e8;
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #a0957f; font-style: italic; }
input:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30,27,24,.12); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

button, .btn {
  font-family: var(--type); font-size: 16px; font-weight: 400; letter-spacing: .5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border: 0; border-radius: var(--radius);
  background: var(--red); color: var(--card);
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
  cursor: pointer; text-decoration: none;
  transition: transform .08s, background .15s, color .15s;
}
button:hover, .btn:hover { background: var(--red-d); }
button:active, .btn:active { transform: translateY(1px); box-shadow: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button:disabled { background: #a59a89; color: #ece4d3; cursor: not-allowed; box-shadow: none; }
button.secondary, .btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px #8f8270; }
button.secondary:hover, .btn.secondary:hover { background: rgba(30,27,24,.07); }
button.green, .btn.green { background: var(--green); color: var(--card); }
button.green:hover, .btn.green:hover { background: #33271d; }
button.small, .btn.small { padding: 7px 11px; font-size: 14px; }
button.big, .btn.big { width: 100%; padding: 16px; font-size: 19px; margin-top: 18px; }
.muted { color: var(--muted); }
.note {
  background: rgba(183,155,103,.18); border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 14px; font-size: 14px; margin-top: 12px;
}
.err { color: var(--blood); font-weight: 700; min-height: 1.2em; margin-top: 10px; }

.plist { list-style: none; padding: 0; margin: 0; }
.plist li { border-top: 1px dashed var(--line); padding: 13px 0; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.plist li:first-child { border-top: 0; }
.plist .name { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.plist .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.plist .extra { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.plist .extra select { padding: 6px 8px; width: auto; font-size: 14px; }

.badge {
  display: inline-block; font-family: var(--type); font-size: 12px; font-weight: 400; letter-spacing: .4px;
  padding: 2px 8px; border-radius: 3px; margin-left: 6px; vertical-align: middle;
  border: 1px solid currentColor;
}
.badge.ok { color: #3d4a2f; background: rgba(61,74,47,.08); }
.badge.wait { color: #7a5a2a; background: rgba(122,90,42,.08); }
.badge.seen { color: #2e2a26; background: rgba(46,42,38,.06); }
header.top .badge.seen { color: var(--card); background: rgba(0,0,0,.25); }

.progress { height: 6px; background: rgba(30,27,24,.12); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .4s; }

.preview { font-size: 15px; background: #f7f2e8; border: 1px dashed #a89a82; border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; }
.big-emoji { font-size: 72px; text-align: center; margin: 6px 0; }
.center { text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: #141210; color: var(--card); padding: 12px 18px; border-radius: var(--radius);
  font-family: var(--type); letter-spacing: .3px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  border-left: 3px solid var(--gold);
  transition: transform .25s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.wrap.wide { max-width: 960px; }
.tabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.tabs button { background: rgba(236,228,211,.08); color: var(--card); flex: 1 1 auto; box-shadow: inset 0 0 0 1px rgba(236,228,211,.18); }
.tabs button:hover { background: rgba(236,228,211,.16); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: none; }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: #f5efe3; }
.item .grid { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.item .grid.two { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.item label { margin: 0 0 3px; font-size: 12px; color: var(--muted); }
.item input { padding: 8px 10px; }
.item .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.item .full { margin-top: 8px; }
.ph { display: inline-block; font-family: var(--type); font-size: 13px; background: rgba(30,27,24,.08); border-radius: 3px; padding: 2px 6px; margin: 2px; cursor: pointer; }
.savebar { position: sticky; bottom: 12px; display: flex; gap: 10px; justify-content: flex-end; background: var(--card); padding: 12px; border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.45); z-index: 5; flex-wrap: wrap; }
.vslot { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; border-top: 1px dashed var(--line); padding: 14px 0; }
.vslot:first-of-type { border-top: 0; }
.vslot video, .vslot .novideo { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius); background: #141210; }
.vslot .novideo { display: grid; place-items: center; color: #9a8f7e; font-size: 13px; font-family: var(--type); }
.vslot h3 { margin: 0 0 4px; font-size: 17px; font-family: var(--serif); }
.vslot textarea { font-size: 14px; margin-top: 6px; }
.vslot .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.upbar { height: 6px; background: rgba(30,27,24,.12); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.upbar > div { height: 100%; width: 0; background: var(--green); transition: width .2s; }
.spoiler { text-align: center; padding: 18px; background: rgba(183,155,103,.18); border-radius: var(--radius); }
@media (max-width: 640px) { .vslot { grid-template-columns: 1fr; } .item .grid.two { grid-template-columns: 1fr; } }
footer { text-align: center; color: rgba(236,228,211,.5); font-size: 13px; margin-top: 28px; font-family: var(--type); letter-spacing: .4px; }
@media (max-width: 480px) {
  .plist li { grid-template-columns: 1fr; }
  .plist .actions { justify-content: flex-start; }
}

button.green:disabled, button.secondary:disabled { background: #a59a89; color: #ece4d3; box-shadow: none; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Emojis apagats, com en una foto antiga */
.card h2, .big-emoji, footer, .scene .em, #start .em { filter: grayscale(.85) sepia(.3); }

/* Diàleg de confirmació (confirmBox) */
.cbox-back { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(8, 6, 5, .72); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s; }
.cbox-back.show { opacity: 1; }
.cbox { width: 100%; max-width: 420px; margin: 0; text-align: center; transform: translateY(12px) scale(.97);
  transition: transform .18s; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.cbox-back.show .cbox { transform: none; }
.cbox h2 { border: 0; padding: 0; margin: 6px 0 8px; }
.cbox p { margin: 0 0 18px; }
.cbox-emoji { font-size: 46px; line-height: 1; }
.cbox-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cbox-btns button { flex: 1 1 140px; }
a.btn.disabled { opacity: .55; pointer-events: none; filter: grayscale(.6); }

/* Selector d'idioma */
.langsw { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0,0,0,.35); }
.langsw button { background: transparent; color: var(--card); padding: 4px 10px; font-size: 13px; letter-spacing: .08em;
  border-radius: 999px; box-shadow: none; min-height: 0; }
.langsw button.on { background: var(--gold); color: #14110f; }
.langbar { display: flex; justify-content: flex-end; margin-bottom: -18px; }

.paytable { width: 100%; border-collapse: collapse; font-size: 14px; }
.paytable th, .paytable td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.paytable th { font-family: var(--type); font-weight: normal; color: var(--muted); }
