/* Fair Table P0 - Modern Craft: warm vector wood on a dark premium page. */
:root {
  --page: #17130f;
  --page-2: #211a13;
  --ink: #ece4d4;
  --ink-dim: #a89a80;
  --gold: #c9a227;
  --gold-bright: #ffd761;
  --wood: #c99b62;
  --wood-dark: #8a4b2a;
  --leather: #5d3b22;
  --felt: #2a2118;
  --btn: #33291d;
  --btn-edge: #57462e;
  --white-checker: #f3ead8;
  --black-checker: #2e2a26;
  font-size: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 6px;
}
.brand-name { font-weight: 800; letter-spacing: 0.4px; font-size: 1.05rem; color: var(--ink); }
.brand-name::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-left: 7px; vertical-align: 2px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--btn); color: var(--ink); border: 1px solid var(--btn-edge);
  border-radius: 10px; width: 38px; height: 34px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }
#btn-sound.muted .sound-waves { display: none; }
#btn-sound.muted { color: var(--ink-dim); }

#scorebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 14px 6px; gap: 8px;
}
.player { display: flex; align-items: center; gap: 7px; min-width: 0; }
.pname { font-size: 0.85rem; color: var(--ink-dim); }
.pscore { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.pmeta { font-size: 0.68rem; color: var(--ink-dim); white-space: nowrap; }
.chip { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.chip-white { background: var(--white-checker); border: 2px solid #cbb98f; }
.chip-black { background: var(--black-checker); border: 2px solid var(--gold); }
.cubebox {
  min-width: 34px; height: 34px; padding: 0 4px; border-radius: 7px; background: linear-gradient(145deg, #f5efdf, #d8cdb4);
  color: #2a2118; font-weight: 800; display: grid; place-items: center; font-size: 0.95rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.45); border: 1px solid #b7a97f;
}
.cubebox.hidden { visibility: hidden; }
.cubebox.pulse { animation: cubepulse 0.9s ease-in-out infinite; }
@keyframes cubepulse { 50% { transform: scale(1.12); box-shadow: 0 0 14px var(--gold-bright); } }
#matchbar { text-align: center; font-size: 0.72rem; color: var(--ink-dim); padding-bottom: 4px; }

#board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 6px; }
#board { width: 100%; height: auto; aspect-ratio: 1080 / 780; max-height: 100%; }

#controls { padding: 6px 12px calc(env(safe-area-inset-bottom, 0px) + 10px); }
#dice-tray {
  display: flex; align-items: center; gap: 10px; min-height: 46px;
  background: var(--page-2); border: 1px solid #3a2f20; border-radius: 12px; padding: 5px 12px;
}
.die {
  width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(145deg, #faf5e8, #ddd2b8);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 5px; gap: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5); flex: none;
}
.die .pip { width: 70%; height: 70%; place-self: center; border-radius: 50%; background: #241c12; }
.die.used { opacity: 0.35; }
.die.rolling { animation: diceshake 0.09s linear infinite; }
@keyframes diceshake { 25% { transform: rotate(7deg) translateY(-1px); } 75% { transform: rotate(-7deg) translateY(1px); } }
.shield-mini {
  background: none; border: none; color: var(--gold); width: 26px; height: 26px; padding: 0; cursor: pointer; flex: none;
  filter: drop-shadow(0 0 4px rgba(201,162,39,0.4));
}
#dice-note { font-size: 0.72rem; color: var(--ink-dim); margin-left: auto; text-align: right; }
#action-row { display: flex; gap: 8px; margin-top: 8px; }
.btn {
  flex: 1; padding: 12px 10px; border-radius: 12px; border: 1px solid var(--btn-edge);
  background: var(--btn); color: var(--ink); font-size: 1rem; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(160deg, #d8b13c, #a9821a); color: #241c08; border-color: #e8c85a; }
.btn[disabled] { opacity: 0.4; }
#hint { text-align: center; font-size: 0.78rem; color: var(--ink-dim); min-height: 1.2em; margin-top: 7px; }

#modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,7,4,0.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 20; padding: 18px;
}
#modal {
  background: var(--page-2); border: 1px solid #4a3b26; border-radius: 18px;
  padding: 22px 20px; max-width: 430px; width: 100%; max-height: 86dvh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6);
}
#modal h2 { margin: 0 0 6px; font-size: 1.3rem; }
#modal h3 { margin: 16px 0 6px; font-size: 0.85rem; color: var(--gold); text-transform: uppercase; letter-spacing: 0.6px; }
#modal p { margin: 6px 0; font-size: 0.92rem; line-height: 1.45; color: var(--ink); }
#modal .dim { color: var(--ink-dim); font-size: 0.8rem; }
#modal .btn { margin-top: 10px; }
.modal-actions { display: flex; gap: 8px; }
.hashbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.68rem; word-break: break-all;
  background: #120d08; border: 1px solid #3a2f20; border-radius: 8px; padding: 8px 10px; color: #d8c896;
}
.rollrow { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 3px 2px; border-bottom: 1px solid #2c2318; }
.rollrow .who { color: var(--ink-dim); }
.rollrow .vals { font-weight: 700; letter-spacing: 2px; }
.rollrow .chk { color: #7fc36a; }
.seg { display: flex; gap: 6px; margin: 10px 0 4px; }
.seg .btn { padding: 9px 6px; }
.seg .btn.sel { background: linear-gradient(160deg, #d8b13c, #a9821a); color: #241c08; border-color: #e8c85a; }
.big-emoji { font-size: 2.2rem; text-align: center; }
#modal-backdrop[hidden] { display: none; }
