:root {
  --paper: #e8eee5; --paper-2: #dbe5d8; --ink: #1e2a47; --money: #2d6a4f; --gold: #b48a2c; --gold2: #e2c271;
  --red: #a3322c; --line: #b9c7bd; --muted: #5d6b64; --felt: #24543f; --felt2: #1d4634; --wood: #5a3a22;
  --font: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; color: var(--ink); font: 16px/1.4 var(--font); background: #1b1f1d; }
button, input, select { font: inherit; color: inherit; border-radius: 7px; border: 1.5px solid var(--ink); background: #fff; padding: 7px 11px; }
button { cursor: pointer; font-weight: 700; background: var(--ink); color: var(--paper); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ================= home e sala d'attesa ================= */
.screen { min-height: 100vh; padding: 16px; color: var(--paper);
  background: radial-gradient(circle at 50% 30%, #2f6a50, var(--felt2) 70%, #13261d); }
.screen .panel { background: rgba(232,238,229,.95); color: var(--ink); border-radius: 14px; padding: 18px; max-width: 440px; margin: 0 auto; display: grid; gap: 12px; }
.hero { text-align: center; padding: 36px 0 22px; }
.hero7 { height: 190px; filter: drop-shadow(0 12px 18px rgba(0,0,0,.55)); }
.hero .seven { font-size: clamp(7rem, 30vw, 12rem); font-weight: 800; line-height: .8; color: var(--gold2);
  text-shadow: 2px 2px 0 #9a7424, 4px 4px 0 #7c5c1a, 6px 6px 0 #5e4512, 8px 12px 14px rgba(0,0,0,.5); }
.hero h1 { margin: 6px 0 0; font-size: clamp(2.2rem, 9vw, 3.4rem); }
.hero p { max-width: 34ch; margin: 8px auto 0; opacity: .85; }
.screen input { width: 100%; }
.screen .row { display: flex; gap: 8px; }
.code { font-size: 3rem; font-weight: 800; letter-spacing: .12em; color: var(--money); text-align: center; }
.plist { display: grid; gap: 6px; }
.plist div { padding: 8px 12px; background: #fff; border-radius: 8px; border: 1.5px solid var(--line); display: flex; justify-content: space-between; }

/* ================= tavolo ================= */
#wrap { position: fixed; inset: 0; overflow: hidden; background: #1b1f1d; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: absolute; left: 50%; top: 50%; width: 1920px; height: 900px; transform-origin: 0 0;
  background: radial-gradient(circle at 50% 42%, #3b423e, #1d211f 78%); }
#stage.photo { background: linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,.35)), var(--bg) center / cover no-repeat; }
.abs { position: absolute; }
.table { position: absolute; left: 200px; top: 110px; width: 1200px; height: 600px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 45%, #2f6a50, var(--felt) 55%, var(--felt2));
  box-shadow: 0 0 0 20px var(--wood), 0 0 0 25px #3e2716, 0 30px 70px rgba(0,0,0,.65), inset 0 0 90px rgba(0,0,0,.45); }
.table::after { content: ""; position: absolute; inset: 26px; border-radius: 50%; border: 2px dashed rgba(232,238,229,.12); }
.topleft { position: absolute; left: 18px; top: 12px; color: var(--paper); z-index: 30; display: flex; gap: 10px; align-items: center; }
.topleft b { font-size: 26px; }
.topleft button { font-size: 13px; padding: 4px 10px; background: rgba(232,238,229,.15); border-color: rgba(232,238,229,.4); }

/* fiche */
.bank { display: flex; gap: 6px; align-items: flex-end; min-height: 62px; }
.stackcol { display: flex; flex-direction: column-reverse; align-items: center; position: relative; }
.chip { width: 34px; height: 9px; border-radius: 50%; margin-top: -4px; position: relative; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.chip::before { content: ""; position: absolute; inset: 1px 5px; border-radius: 50%; border: 1.5px dashed rgba(255,255,255,.75); }
.c1 { background: #f1efe6; } .c1::before { border-color: #7a7a7a; }
.c5 { background: #c0392b; } .c10 { background: #2a5db0; }
.stackcol .lbl { position: absolute; bottom: -17px; font-size: 11px; font-weight: 700; color: rgba(232,238,229,.85); white-space: nowrap; }
.fly { position: absolute; z-index: 70; width: 34px; height: 34px; border-radius: 50%; border: 4px dashed rgba(255,255,255,.8);
  box-shadow: 0 6px 12px rgba(0,0,0,.5); pointer-events: none; }
.fly.c1 { border-color: #8d8d8d; }
.none { font-size: 12px; color: rgba(232,238,229,.6); }
.total { font-weight: 800; font-variant-numeric: tabular-nums; }

/* Setteh fisici */
.sevens { display: flex; gap: 2px; align-items: flex-end; min-height: 34px; flex-wrap: wrap; max-width: 150px; }
.seven { font-weight: 800; font-size: 34px; line-height: 1; color: var(--gold2);
  text-shadow: 1px 1px 0 #9a7424, 2px 2px 0 #7c5c1a, 3px 3px 0 #5e4512, 4px 6px 6px rgba(0,0,0,.55); }
.seven.plus { color: #5fbf8f; text-shadow: 1px 1px 0 #2d6a4f, 2px 2px 0 #224f3b, 3px 3px 0 var(--gold), 4px 6px 6px rgba(0,0,0,.55); }
.seven.small { font-size: 26px; }

/* carte */
.back { width: 54px; height: 76px; border-radius: 6px; border: 2px solid var(--paper); position: relative; overflow: hidden;
  background: repeating-linear-gradient(45deg, #1e2a47 0 5px, #26355a 5px 10px); display: grid; place-items: center;
  color: var(--gold2); font-weight: 800; font-size: 22px; box-shadow: 0 3px 7px rgba(0,0,0,.45); flex: none; }
.back.mkt { background: repeating-linear-gradient(-45deg, #2d6a4f 0 5px, #357a5b 5px 10px); }
.back img, .face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fan { display: flex; }
.fan .back { margin-left: -26px; } .fan .back:first-child { margin-left: 0; }
.fan .back:nth-child(1) { transform: rotate(-9deg); } .fan .back:nth-child(3) { transform: rotate(9deg); }
.face { width: 82px; height: 115px; border-radius: 7px; background: #fff; border: 2px solid var(--ink); padding: 6px;
  font-size: 9.5px; line-height: 1.25; box-shadow: 0 6px 14px rgba(0,0,0,.5); position: relative; overflow: hidden; flex: none; }
.face b { display: block; font-size: 11px; margin-bottom: 3px; }
.face.mk { background: var(--ink); color: var(--paper); border-color: var(--gold); }
.face.mk b { color: var(--gold2); }
.face.hasimg { padding: 0; }
.face.hasimg .txt { display: none; }
.face .cap { position: absolute; left: 0; right: 0; bottom: 0; background: var(--red); color: #fff; font-size: 9px; text-align: center; padding: 1px; }
.face.law { width: 118px; height: 166px; font-size: 11.5px; padding: 8px; }
.face.law b { font-size: 13px; }
.face.law.hasimg { padding: 0; }
.face.last { box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0,0,0,.5); }
.flipin { animation: flipin .7s ease-out; }
@keyframes flipin { 0% { transform: perspective(600px) rotateY(180deg) scale(.7); filter: brightness(.3); }
  50% { filter: brightness(.3); } 51% { filter: none; } 100% { transform: perspective(600px) rotateY(0) scale(1); } }

/* posti */
.plate { position: absolute; transform: translate(-50%, -50%); background: rgba(20,28,24,.84); border: 2px solid rgba(232,238,229,.25);
  border-radius: 12px; padding: 8px 12px 18px; color: var(--paper); min-width: 200px; z-index: 6; }
.plate.turn { border-color: #7fd1a6; box-shadow: 0 0 0 4px rgba(127,209,166,.3); }
.plate.dead { opacity: .4; filter: grayscale(1); }
.plate.dead .nm { text-decoration: line-through; }
.plate .hd { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.plate .nm { font-weight: 800; font-size: 17px; }
.plate .row { display: flex; gap: 12px; align-items: flex-end; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; font-size: 11px; }
.badge { padding: 1px 7px; border-radius: 99px; background: rgba(232,238,229,.18); }
.tablecards { position: absolute; transform: translate(-50%, -50%); display: flex; gap: 8px; align-items: center; z-index: 5; }
.plate.market { background: linear-gradient(#2a3557, #1e2a47); border-color: var(--gold); min-width: 230px; }
.plate.market .nm { color: var(--gold2); }

/* dado */
.die { width: 58px; height: 58px; border-radius: 12px; background: #fdfbf4; border: 2px solid #cfc7b0; position: relative;
  box-shadow: 0 6px 12px rgba(0,0,0,.5); flex: none; }
.die i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); }
.die.seven-face i { background: var(--gold); }
.die.lg { width: 76px; height: 76px; }
.die.lg i { width: 13px; height: 13px; }
#flydie { position: absolute; z-index: 75; }

/* centro */
.pricecoin { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; font-size: 54px; font-weight: 800; color: var(--ink);
  background: repeating-conic-gradient(var(--gold) 0 6deg, #d9b45a 6deg 12deg); border: 4px solid var(--paper); box-shadow: 0 6px 14px rgba(0,0,0,.45); }
.capt { font-size: 13px; color: rgba(232,238,229,.85); text-align: center; margin-top: 4px; }
.info { color: var(--paper); display: grid; gap: 3px; font-size: 15px; }
.info b { font-size: 17px; }
.log { position: absolute; left: 800px; top: 505px; transform: translateX(-50%); width: 560px; text-align: center; color: rgba(232,238,229,.85);
  font-size: 14px; line-height: 1.55; z-index: 3; }
.log div:last-child { color: #fff; font-weight: 700; }

/* richiesta in corso */
.pending { position: absolute; left: 800px; top: 492px; transform: translateX(-50%); z-index: 40; background: #fffaf0; border: 2px solid var(--gold);
  border-radius: 14px; padding: 12px 16px; display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 26px rgba(0,0,0,.55); max-width: 760px; }
.pending h3 { margin: 0 0 2px; font-size: 18px; }
.pending p { margin: 2px 0; font-size: 14px; }
.pending .btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.pending .btns button { padding: 6px 14px; }
.pending .gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.pending .alt { background: #fff; color: var(--ink); }
.pending input { width: 80px; }
.secs { color: var(--muted); font-weight: 400; }

/* io */
.mine { position: absolute; left: 0; right: 0; bottom: 0; height: 210px; background: linear-gradient(transparent, rgba(0,0,0,.6) 35%); z-index: 20; }
.mybox { position: absolute; left: 22px; bottom: 16px; width: 320px; background: rgba(20,28,24,.9); border: 2px solid rgba(232,238,229,.25);
  border-radius: 14px; padding: 10px 14px 22px; color: var(--paper); }
.mybox.turn { border-color: #7fd1a6; box-shadow: 0 0 0 4px rgba(127,209,166,.3); }
.mybox .nm { font-size: 19px; font-weight: 800; }
.hand { position: absolute; left: 800px; bottom: 12px; transform: translateX(-50%); display: flex; gap: 12px; align-items: flex-end; }
.hcard { width: 124px; height: 174px; font-size: 12px; cursor: pointer; transition: transform .15s; }
.hcard b { font-size: 14px; }
.hcard:nth-child(1) { transform: rotate(-6deg) translateY(8px); } .hcard:nth-child(3) { transform: rotate(6deg) translateY(8px); }
.hcard:hover { transform: translateY(-14px); }
.hint { position: absolute; left: 800px; bottom: 196px; transform: translateX(-50%); color: rgba(232,238,229,.65); font-size: 13px; z-index: 21; white-space: nowrap; }
.acts { position: absolute; right: 22px; bottom: 16px; width: 340px; display: grid; gap: 6px; color: var(--paper); }
.acts h4 { margin: 0; font-size: 15px; }
.acts .r { display: flex; gap: 5px; align-items: center; }
.acts button { padding: 6px 8px; font-size: 13px; background: var(--paper); color: var(--ink); border-color: var(--paper); flex: 1; }
.acts button.dark { background: transparent; color: var(--paper); }
.acts button.red { background: var(--red); border-color: var(--red); color: #fff; }
.acts input, .acts select { padding: 5px 6px; font-size: 13px; border-color: var(--paper); background: #fff; color: var(--ink); }
.acts input { width: 58px; flex: none; }
.acts select { flex: 1; min-width: 0; }
.waiting { position: absolute; right: 22px; bottom: 26px; width: 340px; color: rgba(232,238,229,.75); font-size: 15px; text-align: right; }

/* zoom e finestre */
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,.62); display: grid; place-items: center; z-index: 90; }
.overlay .face { width: 300px; height: 420px; font-size: 20px; padding: 20px; border-width: 3px; }
.overlay .face b { font-size: 28px; margin-bottom: 12px; }
.overlay .face.hasimg { padding: 0; }
.zb { display: flex; gap: 10px; margin-top: 16px; justify-content: center; align-items: center; flex-wrap: wrap; max-width: 420px; }
.zb button { padding: 9px 18px; background: var(--paper); color: var(--ink); border-color: var(--paper); }
.zb button.dark { background: transparent; color: var(--paper); }
.zb select { padding: 8px; }
.zb .note { color: var(--paper); font-size: 15px; text-align: center; width: 100%; }
.loglist { background: var(--paper); border-radius: 12px; padding: 14px 18px; width: 640px; max-height: 640px; overflow: auto; font-size: 15px; }
.loglist div { padding: 3px 0; border-bottom: 1px solid var(--line); }
.winner { text-align: center; color: var(--paper); }
.winner .seven { font-size: 140px; }
.winner h2 { font-size: 40px; margin: 10px 0 20px; }

#toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--red); color: #fff; padding: 10px 16px; border-radius: 8px; max-width: 90vw; display: none; z-index: 200; }
#rotate { display: none; position: fixed; inset: 0; background: #1b1f1d; color: var(--paper); z-index: 150; place-items: center; text-align: center; padding: 30px; }
#rotate .ph { width: 70px; height: 120px; border: 4px solid var(--paper); border-radius: 14px; margin: 0 auto 20px; animation: rot 2s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 820px) { body.ingame #rotate { display: grid; } }
@media (prefers-reduced-motion: reduce) { .flipin, #rotate .ph { animation: none; } }

/* ================= immagini e nuova disposizione ================= */
.room { position: absolute; left: 0; top: 0; width: 1612px; height: 900px; background: center / cover no-repeat; }
.room::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(0,0,0,.55)); }
.mfig { position: absolute; left: 690px; top: 112px; width: 220px; z-index: 2; filter: drop-shadow(0 10px 18px rgba(0,0,0,.6)); pointer-events: none; }
.plate.market { min-width: 0; padding: 6px 12px; background: rgba(20,24,36,.72); z-index: 4; }

/* fiche: pile con il bordo a righe e la faccia della foto in cima */
.bank { min-height: 44px; gap: 4px; }
.stackcol { display: flex; flex-direction: column-reverse; align-items: center; }
.chip { width: 34px; height: 7px; margin-top: -2px; border-radius: 5px; box-shadow: 0 1px 0 rgba(0,0,0,.45); }
.chip::before { display: none; }
.c1 { background: repeating-linear-gradient(90deg, #f3f1ea 0 6px, #2a4fa8 6px 9px); }
.c5 { background: repeating-linear-gradient(90deg, #d8322b 0 6px, #f5f1e8 6px 9px); }
.c10 { background: repeating-linear-gradient(90deg, #2c3e8f 0 6px, #f5f1e8 6px 9px); }
.c25 { background: repeating-linear-gradient(90deg, #1e6b49 0 6px, #f5f1e8 6px 9px); }
.chiptop { width: 34px; height: 16px; margin-top: -9px; border-radius: 50%; object-fit: cover; box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.stackcol .lbl { display: none; }
img.fly { position: absolute; z-index: 70; width: 34px; height: 34px; border: 0; border-radius: 50%; box-shadow: 0 6px 12px rgba(0,0,0,.5); pointer-events: none; }

/* Setteh: 7 di bronzo distesi; i Setteh+ sono in piedi e verdi */
.sevens { display: flex; align-items: flex-end; gap: 0; max-width: 220px; flex-wrap: nowrap; min-height: 30px; }
.seven-lie { width: 54px; margin-left: -30px; filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.seven-lie:first-child, .seven-up + .seven-lie { margin-left: 0; }
.seven-up { height: 46px; margin-right: 2px; filter: hue-rotate(85deg) saturate(1.6) brightness(1.05) drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.sevens.small .seven-lie { width: 42px; margin-left: -24px; }
.sevens.small .seven-lie:first-child { margin-left: 0; }
.sevens.small .seven-up { height: 36px; }

/* la tua postazione: fiche, totale e Setteh sopra le carte in mano */
.myrow { position: absolute; left: 800px; top: 622px; transform: translateX(-50%); z-index: 21; display: flex; gap: 16px; align-items: flex-end;
  padding: 8px 16px; border-radius: 14px; background: rgba(12,16,14,.72); border: 2px solid rgba(232,238,229,.2); color: var(--paper); white-space: nowrap; }
.myrow.turn { border-color: #7fd1a6; box-shadow: 0 0 0 4px rgba(127,209,166,.3); }
.myrow.dead { opacity: .5; filter: grayscale(1); }
.mytotal { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; padding-bottom: 4px; }
.mine { height: 200px; pointer-events: none; }
.hand { z-index: 22; }

/* colonna laterale */
.side { position: absolute; left: 1612px; top: 0; width: 308px; height: 900px; z-index: 30; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(#141a17, #0e1210); border-left: 2px solid var(--gold); color: var(--paper); }
.sidehd { display: flex; flex-direction: column; }
.sidehd b { font-size: 26px; line-height: 1.1; }
.sidehd span { font-size: 13px; opacity: .7; }
.loglist { flex: 1; min-height: 120px; overflow-y: auto; font-size: 13.5px; line-height: 1.4; padding-right: 4px; }
.loglist div { padding: 4px 0; border-bottom: 1px solid rgba(232,238,229,.1); }
.loglist div:last-child { color: #fff; font-weight: 700; }
.side .pending { position: static; transform: none; max-width: none; flex-direction: column; align-items: stretch; gap: 8px; padding: 12px;
  background: #fffaf0; color: var(--ink); }
.side .pending .die.lg { align-self: center; }
.side .pending .face { align-self: center; }
.side .acts { position: static; width: auto; }
.side .waiting { position: static; width: auto; text-align: left; padding: 8px 0; }
.side .hint { position: static; transform: none; white-space: normal; font-size: 12px; text-align: left; }
.topleft { display: none; }

/* mano del Mercato che porta il dado */
#flyhand { position: absolute; z-index: 76; width: 180px; height: 145px; pointer-events: none; }
#flyhand img { width: 180px; transform: scaleY(-1); filter: drop-shadow(0 10px 14px rgba(0,0,0,.55)); }
#flyhand .die { position: absolute; left: calc(180px * .27 - 29px); top: calc(145px * .76 - 29px); }
.winner .hero7 { height: 170px; }
.side { overflow: hidden; }
.side .loglist { background: none; width: auto; max-height: none; border-radius: 0; padding: 0 4px 0 0; color: rgba(232,238,229,.85); font-size: 13.5px; }
.side .loglist div { border-bottom: 1px solid rgba(232,238,229,.1); }
.side .acts .r { flex-wrap: wrap; }
.side .acts .r > * { min-width: 0; }
.side .acts .r span { font-size: 12px; opacity: .8; }
.tablecards { z-index: 21; }
