/* Mar o Pelle — styles */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Lalezar';
  src: url('../fonts/lalezar-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
  font-display: swap;
}
@font-face {
  font-family: 'Lalezar';
  src: url('../fonts/lalezar-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-200B, U+2010-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Lalezar';
  src: url('../fonts/lalezar-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}

/* ---------- theme tokens ---------- */
:root {
  --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --title: 'Lalezar', 'Vazirmatn', Tahoma, sans-serif;
  --emoji: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  --r: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
:root[data-theme="jungle"] {
  --bg1: #0c4529; --bg2: #1b7a49; --bg3: #8fd15f;
  --panel: rgba(255, 253, 244, .95); --panel-2: #f1f6e5; --ink: #22301d; --muted: #61705a; --line: rgba(30, 50, 20, .13);
  --accent: #ff9f1c; --accent-hi: #ffc15e; --accent-dark: #c46b00; --accent-ink: #fff;
  --accent2: #20b2a4; --accent2-dark: #137a70; --chip: #e6f1d6; --title-shadow: #0a3a20;
  --topbar-ink: #fff;
}
:root[data-theme="candy"] {
  --bg1: #8a4fe0; --bg2: #ff6fb2; --bg3: #8fe6ff;
  --panel: rgba(255, 255, 255, .96); --panel-2: #fbf0ff; --ink: #3c2150; --muted: #7d6593; --line: rgba(80, 30, 110, .14);
  --accent: #ff4fa3; --accent-hi: #ff8cc5; --accent-dark: #b8236b; --accent-ink: #fff;
  --accent2: #7b5cff; --accent2-dark: #4f33cc; --chip: #f3e6ff; --title-shadow: #7a1f63;
  --topbar-ink: #fff;
}
:root[data-theme="night"] {
  --bg1: #050817; --bg2: #121a48; --bg3: #3a2f86;
  --panel: rgba(23, 29, 70, .94); --panel-2: #1d2660; --ink: #eef1ff; --muted: #a7b0dc; --line: rgba(255, 255, 255, .13);
  --accent: #ffd166; --accent-hi: #ffe39c; --accent-dark: #b98a1e; --accent-ink: #2a1f00;
  --accent2: #4cc9f0; --accent2-dark: #1f8db5; --chip: #262f72; --title-shadow: #000;
  --topbar-ink: #fff;
}
:root[data-theme="persian"] {
  --bg1: #08283e; --bg2: #11587a; --bg3: #e2ad4a;
  --panel: rgba(255, 250, 238, .96); --panel-2: #f6ecd6; --ink: #2a2116; --muted: #7b6647; --line: rgba(80, 50, 10, .15);
  --accent: #1b8ea3; --accent-hi: #45b6c9; --accent-dark: #0f5f6e; --accent-ink: #fff;
  --accent2: #c99a1a; --accent2-dark: #8f6a07; --chip: #efe2c4; --title-shadow: #062033;
  --topbar-ink: #fff;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg1); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: transparent;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }

#decor {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
  background:
    radial-gradient(1100px 650px at 85% -10%, var(--bg3) 0%, transparent 60%),
    radial-gradient(900px 700px at -15% 115%, var(--bg2) 0%, transparent 62%),
    linear-gradient(160deg, var(--bg2), var(--bg1));
}
#decor span {
  position: absolute; bottom: -12vh; font-family: var(--emoji); font-size: var(--s); opacity: .17;
  animation: drift var(--d) linear infinite; animation-delay: var(--dl);
}
@keyframes drift {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-125vh) rotate(var(--rot)); }
}
#app { position: relative; z-index: 1; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  color: var(--topbar-ink);
}
.bar-title { margin: 0 4px; font-family: var(--title); font-weight: 400; font-size: 26px; text-shadow: 0 2px 0 var(--title-shadow); white-space: nowrap; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 20px; font-family: var(--emoji); line-height: 1;
  color: #fff; background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  cursor: pointer; transition: transform .1s, background .2s;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.icon-btn:hover { background: rgba(255, 255, 255, .26); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.off { opacity: .5; text-decoration: line-through; }
[dir="rtl"] .flip { display: inline-block; transform: scaleX(-1); }
.badge { font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }

.lang-switch {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: rgba(0, 0, 0, .2); border: 1px solid rgba(255, 255, 255, .26);
}
.lang-switch button {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  font-weight: 800; font-size: 14px; padding: 6px 11px; border-radius: 999px; min-width: 40px;
}
.lang-switch button[aria-pressed="true"] { background: #fff; color: #1d1d1d; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.lang-switch button .fa { font-family: var(--font); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 16px; padding: 12px 18px;
  font-weight: 800; font-size: 17px; line-height: 1.3;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .12);
  cursor: pointer; transition: transform .08s, box-shadow .08s, filter .15s;
  -webkit-user-select: none; user-select: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18), 0 4px 10px rgba(0, 0, 0, .1); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; filter: grayscale(.3); }
.btn .ico { font-family: var(--emoji); font-size: 1.1em; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 5px 0 var(--accent-dark), 0 10px 22px rgba(0, 0, 0, .2);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--accent-dark), 0 5px 12px rgba(0, 0, 0, .2); }
.btn-accent2 {
  background: linear-gradient(180deg, var(--accent2), var(--accent2-dark));
  color: #fff; box-shadow: 0 5px 0 var(--accent2-dark), 0 10px 22px rgba(0, 0, 0, .2);
}
.btn-xl { font-size: 21px; padding: 16px 24px; border-radius: 20px; }
.btn-small { font-size: 14px; padding: 8px 12px; border-radius: 12px; }

/* ---------- menu ---------- */
.menu-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 16px 28px; gap: 18px; }
.menu-hero { text-align: center; color: #fff; }
.logo { width: min(300px, 70vw); height: auto; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .3)); overflow: visible; }
.logo-head { animation: headBob 2.4s ease-in-out infinite; transform-box: fill-box; }
.logo-tongue { animation: tongue 2.4s ease-in-out infinite; }
.logo-die { animation: dieWobble 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes headBob { 0%, 100% { translate: 0 0; } 50% { translate: 2px -4px; } }
@keyframes tongue { 0%, 70%, 100% { opacity: 0; } 76%, 90% { opacity: 1; } }
@keyframes dieWobble { 0%, 100% { rotate: 0deg; } 50% { rotate: 12deg; } }
.title {
  margin: 4px 0 0; font-family: var(--title); font-weight: 400;
  font-size: clamp(46px, 11vw, 92px); line-height: 1.05;
  color: #fff; text-shadow: 0 5px 0 var(--title-shadow), 0 12px 28px rgba(0, 0, 0, .35);
}
.tagline { margin: 6px 0 0; font-size: clamp(15px, 3.6vw, 19px); font-weight: 600; opacity: .92; }
.menu-buttons { width: min(430px, 100%); display: flex; flex-direction: column; gap: 12px; }
.menu-buttons .row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.menu-buttons .row2 .btn { padding-inline: 10px; font-size: 16px; gap: 8px; }
.about { margin: 4px 0 0; color: rgba(255, 255, 255, .75); font-size: 13px; text-align: center; }

/* ---------- setup ---------- */
.setup-grid {
  width: 100%; max-width: 1220px; margin: 0 auto; padding: 4px 14px 120px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start;
}
.card { background: var(--panel); border-radius: 24px; padding: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 19px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { font-family: var(--emoji); }
.presets { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: #fff; }
.presets .lbl { font-weight: 800; margin-inline-end: 4px; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.chip {
  border: 2px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .15); color: #fff;
  border-radius: 99px; padding: 7px 14px; font-weight: 800; cursor: pointer;
}
.chip.on { background: #fff; color: var(--ink); border-color: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.chip .ico { font-family: var(--emoji); }

.plist { display: flex; flex-direction: column; gap: 10px; }
.prow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 10px; align-items: center;
  padding: 10px; border-radius: 18px; background: var(--panel-2);
  border-inline-start: 7px solid var(--pc);
}
.prow-opts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.prow-opts .ptype { flex: none; }
.avatar-btn {
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  font-family: var(--emoji); font-size: 30px; line-height: 1;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc) 75%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2); display: grid; place-items: center;
}
.prow input {
  width: 100%; min-width: 0; font: inherit; font-weight: 700; font-size: 16px;
  padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink);
}
.prow input:focus { border-color: var(--accent2); outline: none; }
.prow .colors { display: flex; gap: 7px; flex-wrap: wrap; padding-inline-start: 2px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; padding: 0;
  background: var(--sw); box-shadow: 0 0 0 1px var(--line), 0 2px 5px rgba(0, 0, 0, .15);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.12); }
.icon-mini {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; font-weight: 900;
  background: rgba(220, 50, 50, .12); color: #c0392b;
}
.add-player { margin-top: 10px; width: 100%; border: 2px dashed var(--line); background: transparent; box-shadow: none; color: var(--muted); }

.field { margin: 12px 0 0; }
.field:first-of-type { margin-top: 0; }
.field .lbl { display: block; font-weight: 800; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px; border-radius: 15px; background: var(--chip); }
.seg button {
  flex: 1 1 auto; min-width: 58px; border: 0; background: transparent; cursor: pointer;
  font-weight: 800; font-size: 15px; padding: 8px 10px; border-radius: 11px; color: var(--ink);
}
.seg button[aria-pressed="true"] { background: var(--accent2); color: #fff; box-shadow: 0 3px 0 var(--accent2-dark); }
.seg button:disabled { opacity: .38; cursor: not-allowed; }
.seg.col { flex-direction: column; }
.seg.col button { text-align: start; }
.seg.small button { min-width: 0; padding: 6px 9px; font-size: 14px; }
.seg .ico { font-family: var(--emoji); }
.note { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }

.toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 4px; border: 0; border-bottom: 1px dashed var(--line); background: none; cursor: pointer;
  font-weight: 700; font-size: 15.5px; text-align: start; color: var(--ink);
}
.toggle:last-child { border-bottom: 0; }
.toggle:disabled { opacity: .4; cursor: not-allowed; }
.switch { position: relative; flex: none; width: 50px; height: 29px; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch::after {
  content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 23px; height: 23px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: inset-inline-start .2s;
}
.toggle[aria-checked="true"] .switch { background: var(--accent2); }
.toggle[aria-checked="true"] .switch::after { inset-inline-start: 24px; }

.code-row { display: flex; gap: 8px; align-items: center; }
.code-row input {
  flex: 1; min-width: 0; font: inherit; font-weight: 900; letter-spacing: 3px; text-transform: uppercase;
  font-family: ui-monospace, Consolas, monospace; font-size: 17px; direction: ltr; text-align: center;
  padding: 9px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--ink);
}
.code-row input:disabled { opacity: .5; }
.preview-wrap { margin-top: 14px; display: flex; justify-content: center; }
.preview { width: min(100%, 360px); display: block; border-radius: 16px; box-shadow: 0 10px 22px rgba(0, 0, 0, .2); }

.setup-grid.single { max-width: 760px; grid-template-columns: 1fr; }
.stepper { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; }
.stepper button {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, .4); background: rgba(255, 255, 255, .14); color: #fff;
  font-weight: 800; font-size: 15px; padding: 7px 14px 7px 10px; border-radius: 99px;
}
.stepper button.on { background: #fff; color: var(--ink); border-color: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.stepper .num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 14px;
}
.stepper .line { flex: 0 1 50px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .45); }
.code-note { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.code-note.err { color: #d62839; font-weight: 800; }

.mode-opts { display: grid; gap: 12px; }
.mode-opt {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; text-align: start;
  padding: 16px; border-radius: 22px; border: 3px solid transparent; cursor: pointer;
  background: var(--panel-2); color: var(--ink); box-shadow: 0 5px 0 rgba(0, 0, 0, .12);
  transition: transform .08s, border-color .2s;
}
.mode-opt:hover { border-color: var(--accent2); }
.mode-opt:active { transform: translateY(3px); }
.mode-opt .big {
  grid-row: span 2; width: 66px; height: 66px; border-radius: 20px; display: grid; place-items: center;
  font-family: var(--emoji); font-size: 38px; background: var(--chip);
}
.mode-opt b { font-size: 20px; font-weight: 900; }
.mode-opt .sub { font-size: 14px; color: var(--muted); line-height: 1.55; }
.mode-opt.primary { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); box-shadow: 0 5px 0 var(--accent-dark); }
.mode-opt.primary .sub { color: inherit; opacity: .92; }
.mode-opt.primary .big { background: rgba(255, 255, 255, .28); }

.count-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.count-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; cursor: pointer;
  border-radius: 20px; border: 3px solid transparent; background: var(--panel-2); color: var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .12); transition: transform .08s, border-color .2s;
}
.count-grid button:hover { border-color: var(--accent2); }
.count-grid button:active { transform: translateY(3px); }
.count-grid .n { font-family: var(--title); font-size: 40px; line-height: 1; }
.count-grid .ppl { font-family: var(--emoji); font-size: 17px; line-height: 1; }
.count-grid .lbl { font-weight: 800; font-size: 14px; color: var(--muted); }
.count-grid .solo {
  grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 14px; padding: 16px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink);
  box-shadow: 0 5px 0 var(--accent-dark); font-weight: 900; font-size: 19px;
}
.count-grid .solo .ppl { font-size: 28px; white-space: nowrap; }

.setup-footer {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 5;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; justify-content: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, .35));
  pointer-events: none;
}
.setup-footer .btn { width: min(430px, 100%); pointer-events: auto; }

/* ---------- game ---------- */
#scr-game { height: 100dvh; min-height: 0; }
.game-main {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 370px); gap: 14px;
  padding: 2px 14px max(14px, env(safe-area-inset-bottom));
}
#board-box { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { display: block; border-radius: 22px; filter: drop-shadow(0 16px 28px rgba(0, 0, 0, .38)); touch-action: manipulation; }
#side { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
#panel { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 2px 6px; scrollbar-width: thin; }

.turn-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 22px;
  background: var(--panel); box-shadow: var(--shadow); border: 3px solid var(--pc, transparent);
  transition: border-color .3s;
}
.turn-avatar {
  width: 60px; height: 60px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--emoji); font-size: 34px; border: 3px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc, #ccc) 75%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .2);
}
.turn-avatar.bounce { animation: bounceIn .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes bounceIn { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
.turn-name { font-size: 21px; font-weight: 900; line-height: 1.3; }
.turn-hint { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* dice and roll button: their own dock at the bottom of the side column */
.dice-dock {
  flex: none; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 24px;
  background: var(--panel); border: 3px solid var(--pc, transparent);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28); transition: border-color .3s;
}
.dice-stage {
  --ds: 66px; display: flex; gap: 14px; padding: 6px 4px; border: 0; background: none; cursor: pointer;
  perspective: 700px; flex: none;
}
.dice-stage:disabled { cursor: default; }
.die-wrap { display: block; width: var(--ds); height: var(--ds); transform-style: preserve-3d; transform: rotateX(-16deg) rotateY(20deg); }
.dice-stage.rolling .die-wrap { animation: tumble .8s ease-out; }
@keyframes tumble {
  0% { translate: 0 0; } 25% { translate: 0 -30px; } 55% { translate: 0 3px; } 72% { translate: 0 -9px; } 100% { translate: 0 0; }
}
.die { display: block; position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 1s cubic-bezier(.18, .85, .3, 1.08); }
.face {
  position: absolute; inset: 0; border-radius: 22%;
  background: radial-gradient(circle at 30% 25%, #ffffff, #f4f4f4 55%, #dcdcdc);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .08), inset -5px -7px 12px rgba(0, 0, 0, .1);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 15%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.f1 { transform: translateZ(calc(var(--ds) / 2)); }
.f6 { transform: rotateY(180deg) translateZ(calc(var(--ds) / 2)); }
.f3 { transform: rotateY(90deg) translateZ(calc(var(--ds) / 2)); }
.f4 { transform: rotateY(-90deg) translateZ(calc(var(--ds) / 2)); }
.f2 { transform: rotateX(90deg) translateZ(calc(var(--ds) / 2)); }
.f5 { transform: rotateX(-90deg) translateZ(calc(var(--ds) / 2)); }
.pip {
  width: 78%; height: 78%; place-self: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .35), transparent 45%), var(--pip, #2b2b2b);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .45);
}
.btn-roll { flex: 1; font-size: 24px; padding: 18px 12px; font-family: var(--title); font-weight: 400; letter-spacing: .5px; }
.btn-roll.pulse:not([disabled]) { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { scale: 1; } 50% { scale: 1.04; } }

.msg {
  min-height: 54px; padding: 12px 16px; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow);
  font-weight: 800; font-size: 16.5px; line-height: 1.5; display: flex; align-items: center;
}
.msg.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(.96); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

.players { display: grid; gap: 8px; }
.pcard {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 9px 12px; border-radius: 18px; background: var(--panel); box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
  border: 2px solid transparent; transition: border-color .25s, transform .25s;
}
.pcard.active { border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 30%, transparent), 0 6px 16px rgba(0, 0, 0, .15); }
.pcard.done { opacity: .85; }
.pav {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--emoji); font-size: 24px; border: 2px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc) 75%);
}
.pname { font-weight: 900; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: 13px; color: var(--muted); font-weight: 700; }
.pbar { height: 6px; border-radius: 99px; background: var(--line); margin-top: 5px; overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 99px; background: var(--pc); transition: width .3s; }
.pbadges { font-family: var(--emoji); font-size: 18px; }

.log-box { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 14px; }
.log-box summary { cursor: pointer; font-weight: 900; }
.log-box ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.log-box li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.log-box li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--pc, #999); flex: none; transform: translateY(-1px); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 12, 24, .55); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fadeIn .2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(580px, 100%); max-height: min(90dvh, 960px); overflow: auto;
  background: var(--panel); color: var(--ink); border-radius: 28px; padding: 22px 20px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45); animation: popIn .3s cubic-bezier(.2, 1.2, .35, 1);
}
@keyframes popIn { from { transform: scale(.85) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-x {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--chip); cursor: pointer; font-size: 16px; font-weight: 900;
}
.modal-card h2 { margin: 0 0 14px; font-family: var(--title); font-weight: 400; font-size: 34px; line-height: 1.2; padding-inline-end: 40px; }
.modal-card h3 { margin: 18px 0 8px; font-size: 17px; font-weight: 900; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1 1 150px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.help-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.help-item:last-child { border-bottom: 0; }
.help-item b { display: block; font-size: 16px; margin-bottom: 3px; }
.help-item p { margin: 0; line-height: 1.7; color: var(--ink); }
.legend { display: grid; gap: 8px; }
.legend div { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--panel-2); border-radius: 12px; font-weight: 700; }
.legend .ico { font-family: var(--emoji); font-size: 22px; }

.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 10px; }
.avatar-grid button {
  aspect-ratio: 1; border-radius: 18px; border: 3px solid transparent; background: var(--panel-2);
  font-family: var(--emoji); font-size: 34px; cursor: pointer;
}
.avatar-grid button[aria-pressed="true"] { border-color: var(--accent2); background: var(--chip); }
.avatar-grid button.taken { opacity: .45; }

.lang-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lang-big button { padding: 12px 6px; border-radius: 14px; border: 3px solid transparent; background: var(--panel-2); font-weight: 900; font-size: 17px; cursor: pointer; }
.lang-big button[aria-pressed="true"] { border-color: var(--accent2); background: var(--chip); }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-grid button {
  border: 3px solid transparent; border-radius: 16px; padding: 10px; cursor: pointer; background: var(--panel-2);
  font-weight: 800; display: flex; flex-direction: column; gap: 8px; align-items: stretch; color: var(--ink);
}
.theme-grid button[aria-pressed="true"] { border-color: var(--accent2); }
.theme-swatch { height: 38px; border-radius: 10px; display: grid; grid-template-columns: repeat(5, 1fr); overflow: hidden; border: 4px solid var(--fr); }
.theme-swatch i { display: block; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent2); height: 28px; }
.slider-row .val { width: 46px; text-align: center; font-weight: 800; color: var(--muted); }

/* win */
.win { text-align: center; }
.win h2 { padding: 0; margin-top: 4px; }
.win-avatar {
  width: 110px; height: 110px; margin: 4px auto 6px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--emoji); font-size: 64px; border: 5px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc) 75%);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--pc) 30%, transparent), 0 14px 30px rgba(0, 0, 0, .3);
  animation: winBounce 1.2s ease-in-out infinite;
}
@keyframes winBounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 18px 0 6px; direction: ltr; }
.podium .step { width: 31%; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium .pa {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-family: var(--emoji); font-size: 30px;
  border: 3px solid #fff; background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc) 75%); box-shadow: 0 4px 10px rgba(0, 0, 0, .2);
}
.podium .nm { font-weight: 900; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .block { width: 100%; border-radius: 14px 14px 6px 6px; display: grid; place-items: center; color: #fff; font-family: var(--title); font-size: 34px; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.podium .r1 .block { height: 112px; background: linear-gradient(#ffe066, #e9a300); }
.podium .r2 .block { height: 82px; background: linear-gradient(#e9eef5, #9aa6b8); }
.podium .r3 .block { height: 62px; background: linear-gradient(#f0b27a, #b86b2c); }
.table-wrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stats th { font-size: 12.5px; color: var(--muted); font-weight: 800; padding: 6px 4px; white-space: nowrap; }
table.stats td { padding: 8px 4px; border-top: 1px dashed var(--line); font-weight: 700; white-space: nowrap; }
table.stats td:first-child { text-align: start; }
table.stats small { color: var(--muted); }
table.stats .em { font-family: var(--emoji); }

/* ---------- online room ---------- */
#lobby-body { padding-bottom: 16px; }
.lobby-chat-wrap { padding-top: 0; }
.room-top { display: flex; gap: 16px; align-items: center; }
.room-qr { flex: none; width: 150px; padding: 6px; background: #fff; border-radius: 16px; box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.room-qr svg { display: block; width: 100%; height: auto; }
.room-info { min-width: 0; }
.room-label { font-weight: 800; color: var(--muted); font-size: 14px; }
.room-code { font-family: var(--title); font-size: 64px; line-height: 1; letter-spacing: 4px; color: var(--accent); text-shadow: 0 3px 0 var(--accent-dark); margin: 4px 0 6px; }
.room-info p { margin: 0; line-height: 1.6; font-size: 14px; }
.room-link {
  margin-top: 12px; padding: 8px 12px; border-radius: 12px; background: var(--chip); color: var(--muted);
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; text-align: left;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.seg.vis button { display: flex; flex-direction: column; gap: 2px; align-items: center; padding: 10px 8px; }
.seg.vis small { font-weight: 600; font-size: 12px; opacity: .85; }
.lseats { display: flex; flex-direction: column; gap: 8px; }
.lseat {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 16px; background: var(--panel-2); border-inline-start: 6px solid var(--pc);
}
.lseat.me { box-shadow: 0 0 0 2px var(--pc) inset; }
.lname { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.lname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--chip); color: var(--muted); }
.tag.host { background: #ffe9a8; color: #6b4b00; }
.pres { width: 12px; height: 12px; border-radius: 50%; background: #b9b9b9; box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); }
.pres.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.icon-mini.edit { background: var(--chip); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip-l { border: 2px solid var(--line); background: var(--panel-2); color: var(--ink); border-radius: 99px; padding: 7px 13px; font-weight: 800; cursor: pointer; }
.chip-l.on { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.chip-l .ico { font-family: var(--emoji); }
.summary { margin: 0; font-weight: 800; color: var(--muted); }
/* guests see the room's settings read-only: chosen options stay clear, the rest fades */
.room-cfg .seg button:disabled { opacity: 1; cursor: default; }
.room-cfg .seg button:disabled:not([aria-pressed="true"]) { opacity: .4; }
.room-cfg .toggle:disabled { opacity: 1; cursor: default; }
.room-cfg .toggle:disabled[aria-checked="false"] { opacity: .55; }
.wait-pill {
  pointer-events: auto; padding: 14px 22px; border-radius: 99px; background: var(--panel); color: var(--ink);
  font-weight: 800; box-shadow: var(--shadow); text-align: center;
}
.public-list { display: flex; flex-direction: column; gap: 8px; }
.pub-room {
  display: grid; grid-template-columns: auto auto 1fr auto; gap: 4px 12px; align-items: center; text-align: start;
  padding: 10px 12px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer;
}
.pub-room:hover { border-color: var(--accent2); }
.pub-room b { font-family: var(--title); font-size: 26px; font-weight: 400; color: var(--accent); }
.pub-room span:nth-child(4) { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.pub-room .go { grid-row: 1 / 3; grid-column: 4; font-weight: 900; color: var(--accent2); }
.pub-room .pav { grid-row: 1 / 3; }
.join-row { display: flex; gap: 8px; }
.join-row input, .text-in {
  flex: 1; min-width: 0; font: inherit; font-weight: 900; font-size: 20px; padding: 10px 12px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
}
.join-row input { letter-spacing: 4px; text-transform: uppercase; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.text-in { width: 100%; font-weight: 700; font-size: 17px; }
.colors { display: flex; gap: 7px; flex-wrap: wrap; }

/* chat */
.chat-card { padding: 14px; }
.chat-card h3 { margin-bottom: 8px; }
.chat-list { max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 6px; }
.chat-item { display: flex; gap: 8px; align-items: flex-end; }
.chat-item.mine { flex-direction: row-reverse; }
.cav {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--emoji); font-size: 17px;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--pc) 80%);
}
.cbubble {
  max-width: 78%; padding: 7px 11px; border-radius: 16px; background: var(--panel-2); border: 2px solid color-mix(in srgb, var(--pc) 35%, transparent);
  display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere;
}
.chat-item.mine .cbubble { background: color-mix(in srgb, var(--pc) 16%, var(--panel)); }
.cbubble b { font-size: 12px; color: var(--muted); }
.cbubble .q { font-size: 18px; font-weight: 800; }
.voice-btn { border: 0; border-radius: 99px; padding: 6px 12px; background: var(--accent2); color: #fff; font-weight: 800; cursor: pointer; }
.quick-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.qbtn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); border-radius: 99px;
  padding: 5px 10px; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.qbtn:active { transform: scale(.94); }
.chat-form { display: flex; gap: 6px; }
.chat-input { flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 9px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--ink); }
.mic { touch-action: none; -webkit-user-select: none; user-select: none; }
.mic.rec { background: #e53950; color: #fff; animation: pulse 0.9s ease-in-out infinite; }

/* settings: songs */
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.track-grid button {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; border: 3px solid transparent;
  background: var(--panel-2); color: var(--ink); font-weight: 800; font-size: 14px; cursor: pointer; text-align: start;
}
.track-grid button[aria-pressed="true"] { border-color: var(--accent2); background: var(--chip); }
.track-grid .ico { font-family: var(--emoji); font-size: 20px; }

.net-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  padding: 8px 16px; border-radius: 99px; background: #e53950; color: #fff; font-weight: 800; box-shadow: var(--shadow);
}
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 70; max-width: min(520px, 92vw);
  padding: 10px 18px; border-radius: 16px; background: rgba(20, 24, 40, .92); color: #fff; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); text-align: center; overflow-wrap: anywhere;
}
.toast.show { animation: popIn .25s ease-out; }

/* ---------- responsive ---------- */
/* phones held sideways: keep board and panel side by side, make the panel compact */
@media (max-height: 540px) and (min-aspect-ratio: 1/1) {
  .topbar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 4px; gap: 6px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .bar-title { font-size: 20px; }
  .lang-switch button { padding: 4px 8px; min-width: 32px; font-size: 13px; }
  .game-main { grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  #side, #panel { gap: 8px; }
  .turn-card { padding: 7px 10px; border-width: 2px; }
  .turn-avatar { width: 40px; height: 40px; font-size: 22px; }
  .turn-name { font-size: 16px; }
  .turn-hint { display: none; }
  .dice-dock { padding: 8px 10px; gap: 10px; border-width: 2px; }
  .dice-stage { --ds: 46px; gap: 8px; }
  .btn-roll { font-size: 19px; padding: 11px 8px; }
  .msg { min-height: 40px; font-size: 14px; padding: 8px 12px; }
  .pcard { padding: 5px 10px; }
  .pav { width: 32px; height: 32px; font-size: 18px; }
  .pbar { margin-top: 3px; }
}
@media (max-width: 880px) and (max-aspect-ratio: 1/1), (max-aspect-ratio: 5/6) {
  #scr-game { height: auto; min-height: 100dvh; }
  .game-main { grid-template-columns: 1fr; gap: 10px; padding-inline: 10px; padding-bottom: 0; }
  #board-box { height: min(calc((100vw - 20px) * 1.07), 62dvh); }
  #panel { overflow: visible; }
  .players { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
  /* upright phones and tablets: the dock becomes a bar fixed to the bottom of the screen */
  .dice-dock {
    position: sticky; bottom: 0; z-index: 4; margin-inline: -10px;
    border-radius: 24px 24px 0 0; border-width: 3px 0 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .28);
  }
}
@media (max-width: 520px) {
  .topbar { gap: 6px; padding-inline: 10px; }
  .icon-btn { width: 40px; height: 40px; font-size: 18px; }
  .bar-title { font-size: 21px; }
  .game-title { display: none; }
  .hide-narrow { display: none; }
  .lang-switch button { padding: 5px 8px; min-width: 34px; font-size: 13px; }
  .dice-stage { --ds: 56px; gap: 10px; }
  .btn-roll { font-size: 21px; padding: 15px 10px; }
  .setup-grid { grid-template-columns: 1fr; padding-inline: 10px; }
  .swatch { width: 25px; height: 25px; }
  .room-top { flex-direction: column; }
  .room-qr { width: 190px; }
  .room-info { text-align: center; }
  .modal-card { padding: 18px 14px 16px; border-radius: 22px; }
  .modal-card h2 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  #decor span, .logo-head, .logo-die, .logo-tongue, .btn-roll.pulse, .win-avatar { animation: none !important; }
}
