:root {
  --ink: #fff1c4;
  --muted: #d8c48e;
  --night: #071912;
  --night-2: #102b1d;
  --leaf: #194d31;
  --stone: #cab67c;
  --stone-hi: #f2dea0;
  --stone-low: #6d5734;
  --gold: #e7af35;
  --gold-hi: #ffe27b;
  --terracotta: #c85b40;
  --jade: #3ea47d;
  --ochre: #daa536;
  --indigo: #6266b7;
  --line: #342515;
  --panel: rgba(15, 39, 26, .96);
  --shadow: 0 18px 0 rgba(24, 16, 8, .3), 0 28px 70px rgba(0, 0, 0, .56);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  font-size: 16px;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { -webkit-user-drag: none; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  background: var(--night);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hidden { display: none !important; }

.menu-screen {
  display: grid;
  place-items: center;
  padding: 36px;
  background:
    linear-gradient(180deg, rgba(5, 16, 19, .08), rgba(1, 9, 7, .28)),
    url("./assets/menu-jungle-retro.png") center / cover no-repeat;
}

.menu-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 43%, rgba(255, 195, 64, .12), transparent 28%),
    radial-gradient(ellipse at center, transparent 42%, rgba(2, 10, 7, .54) 112%);
}

.title-lockup {
  position: relative;
  width: min(610px, 57vw);
  padding: 28px 46px 34px;
  text-align: center;
  border: 4px solid #6f5226;
  border-radius: 24px 24px 30px 30px;
  background:
    linear-gradient(180deg, rgba(25, 69, 43, .93), rgba(8, 35, 24, .97)),
    repeating-linear-gradient(90deg, transparent 0 29px, rgba(255,255,255,.035) 30px 31px);
  box-shadow:
    inset 0 0 0 3px rgba(245, 206, 110, .18),
    inset 0 -16px 28px rgba(0,0,0,.2),
    0 7px 0 #302116,
    0 18px 45px rgba(0,0,0,.5);
  animation: rise-in .68s cubic-bezier(.2,.8,.2,1) both;
}

.title-lockup::before,
.title-lockup::after {
  content: "";
  position: absolute;
  top: 29px;
  width: 64px;
  height: 16px;
  border-top: 4px solid #c89a43;
  border-bottom: 2px solid #8a632c;
}
.title-lockup::before { left: 32px; }
.title-lockup::after { right: 32px; }

.title-emblem {
  width: 70px;
  height: 70px;
  margin: -8px auto 13px;
  display: grid;
  place-items: center;
  border: 4px solid #7b5b2a;
  border-radius: 50%;
  color: var(--gold-hi);
  box-shadow: inset 0 0 0 5px #1c5a38, 0 5px 0 #20170e;
  background: #d8a946;
}

.pyramid-mark {
  position: relative;
  width: 43px;
  height: 39px;
  background: linear-gradient(145deg, #fff0a6, #b56f1b);
  clip-path: polygon(42% 4%,58% 4%,58% 20%,68% 20%,68% 37%,79% 37%,79% 55%,90% 55%,100% 91%,0 91%,10% 55%,21% 55%,21% 37%,32% 37%,32% 20%,42% 20%);
  filter: drop-shadow(0 3px 0 #5b3b18);
}

.pyramid-mark::after {
  content: "";
  position: absolute;
  left: 41%;
  bottom: 9%;
  width: 18%;
  height: 27%;
  background: #18442d;
}

.game-title {
  margin: 0;
  font: 900 clamp(2.9rem, 5vw, 5.2rem)/.88 Georgia, "Palatino Linotype", serif;
  letter-spacing: .025em;
  text-transform: uppercase;
  color: #f7d767;
  -webkit-text-stroke: 1px #513417;
  text-shadow: 0 3px 0 #7d4d19, 0 6px 0 #24180e, 0 11px 18px rgba(0,0,0,.46);
}

.game-title span {
  display: block;
  margin-top: 15px;
  color: #f8edc4;
  font: 900 .28em "Trebuchet MS", sans-serif;
  letter-spacing: .34em;
  text-indent: .34em;
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 0 #4a321b;
}

.menu-actions {
  width: min(390px, 42vw);
  margin: 28px auto 0;
  display: grid;
  gap: 10px;
}

.stone-button, .ghost-button, .icon-button, .choice-card, .color-chip {
  border: 0;
  cursor: pointer;
  color: var(--ink);
}

.stone-button {
  position: relative;
  min-height: 52px;
  padding: 12px 22px;
  border: 3px solid #5c3d1d;
  border-radius: 10px;
  background: linear-gradient(180deg, #d19a3d 0 48%, #a66b25 49% 100%);
  box-shadow: inset 0 2px rgba(255,240,178,.35), 0 5px 0 #3c2818, 0 10px 20px rgba(0,0,0,.32);
  color: #2a1b0f;
  font-weight: 900;
  letter-spacing: .075em;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(255,236,170,.38);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

.stone-button:hover { filter: brightness(1.1) saturate(1.08); transform: translateY(-2px); }
.stone-button:active { transform: translateY(3px); box-shadow: inset 0 2px rgba(255,240,178,.25), 0 2px 0 #3c2818; }
.stone-button.secondary { background: linear-gradient(180deg, #9db587 0 48%, #657c59 49% 100%); border-color: #33472f; color: #142215; box-shadow: inset 0 2px rgba(255,255,255,.25), 0 5px 0 #1d2b1d, 0 10px 20px rgba(0,0,0,.28); }
.stone-button.danger { background: linear-gradient(180deg, #c76b4c 0 48%, #8c3c2e 49% 100%); }
.stone-button:disabled { opacity: .45; cursor: default; filter: grayscale(.5); transform: none; }

.ghost-button {
  min-height: 44px;
  padding: 9px 17px;
  border: 2px solid #83662e;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(29,86,53,.98), rgba(12,54,35,.98));
  box-shadow: inset 0 1px rgba(255,255,255,.12), 0 3px 0 #1c291c;
  color: #f7e8bb;
  font-weight: 900;
  letter-spacing: .035em;
  transition: filter .13s ease, transform .13s ease;
}
.ghost-button:hover { filter: brightness(1.18); transform: translateY(-1px); }

.menu-button {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  text-align: center;
}
.menu-button > span:last-child { grid-column: 2; }
.menu-icon { grid-column: 1; display: grid; place-items: center; }
.menu-icon .ui-icon { width: 24px; height: 24px; stroke-width: 2.3; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--gold-hi);
  outline-offset: 3px;
}

.corner-credit {
  position: absolute;
  right: 20px;
  bottom: 15px;
  color: rgba(255,240,197,.72);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  text-shadow: 0 2px 3px #000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(3, 15, 10, .72);
  backdrop-filter: blur(3px);
  animation: fade-in .18s ease both;
}

.modal {
  width: min(900px, 90vw);
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
  border: 5px solid #755627;
  border-radius: 15px;
  background:
    linear-gradient(150deg, rgba(30,82,51,.99), rgba(9,43,29,.99)),
    var(--panel);
  box-shadow: inset 0 0 0 3px rgba(243,208,117,.18), var(--shadow);
  animation: modal-in .26s cubic-bezier(.2,.8,.2,1) both;
}

.modal.compact { width: min(570px, 88vw); }
.modal.wide { width: min(1040px, 94vw); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(230,177,58,.33);
}

.modal h2, .modal h3 { margin: 0; font-family: Georgia, "Palatino Linotype", serif; }
.modal h2 { color: var(--gold-hi); font-size: 2rem; text-shadow: 0 2px #432c15; }
.modal p { color: #ddcfab; line-height: 1.5; }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 3px solid #5a421f;
  border-radius: 9px;
  background: linear-gradient(#d3a64f, #8f6628);
  color: #2c2012;
  box-shadow: inset 0 2px rgba(255,255,255,.22), 0 3px 0 #2f2215;
}
.icon-button:hover { filter: brightness(1.12); }
.icon-button .ui-icon { width: 23px; height: 23px; stroke-width: 2.4; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0 25px;
}

.choice-card {
  min-height: 106px;
  padding: 15px 10px;
  border: 3px solid #355b3e;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(69,121,75,.55), rgba(17,62,40,.68));
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 4px 0 rgba(13,27,17,.8);
  text-align: center;
  transition: border-color .14s, filter .14s, transform .14s;
}
.choice-card:hover { transform: translateY(-2px); filter: brightness(1.12); }
.choice-card.active { border-color: var(--gold); background: linear-gradient(180deg, rgba(199,147,47,.42), rgba(62,93,49,.72)); box-shadow: inset 0 0 0 2px rgba(255,229,132,.18), 0 4px 0 #453019, 0 0 18px rgba(232,181,62,.22); }
.choice-card strong { display: block; margin-top: 11px; color: #fff0c0; font-size: .95rem; }
.mode-icon { min-height: 33px; display: grid; place-items: center; }

.player-dots { display: flex; align-items: center; justify-content: center; gap: 7px; }
.player-dots i, .versus-icon i {
  width: 18px;
  height: 18px;
  display: block;
  border: 3px solid #3c2b18;
  border-radius: 50%;
  background: #efc75b;
  box-shadow: inset 0 2px rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.35);
}
.versus-icon { display: flex; align-items: center; justify-content: center; gap: 8px; }
.versus-icon b { padding: 4px 6px; border: 2px solid #3c2b18; border-radius: 5px; color: #2a1d10; background: #7eb59a; font-size: .75rem; }

.setup-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 25px; }
.setup-panel { padding: 20px; border: 3px solid #365b3f; border-radius: 12px; background: rgba(4,25,16,.36); box-shadow: inset 0 2px 12px rgba(0,0,0,.18); }
.setup-panel h3 { margin-bottom: 14px; color: #f4df9d; }

.player-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid rgba(243,218,147,.14);
}
.player-row:last-child { border-bottom: 0; }
.player-number { color: var(--gold-hi); font: 900 1.12rem Georgia, serif; text-align: center; }
.player-name {
  width: 100%;
  padding: 10px 12px;
  border: 3px solid #42634a;
  border-radius: 7px;
  background: #0c2e20;
  color: #fff1c8;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.24);
}
.player-name:disabled { color: #b7ac8b; }
.color-list { display: flex; gap: 7px; }
.color-chip { width: 28px; height: 28px; border: 3px solid #2b2618; border-radius: 50%; box-shadow: inset 0 2px rgba(255,255,255,.28), 0 2px 0 rgba(0,0,0,.38); }
.color-chip.active { outline: 3px solid #fff0a5; outline-offset: 2px; }

.field { margin: 16px 0; }
.field label, .field .label { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 8px; color: #efe1ba; font-weight: 900; }
.field input[type="range"] { width: 100%; accent-color: var(--gold); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented button { min-height: 40px; border: 2px solid #3e6547; border-radius: 7px; color: #efdfb4; background: #123d29; cursor: pointer; font-weight: 800; }
.segmented button.active { border-color: var(--gold); background: #765b27; color: #fff1b4; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 14px 0; color: #f0e2bd; font-weight: 800; }
.switch { position: relative; width: 52px; height: 29px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border: 2px solid #263c2c; border-radius: 20px; background: #496251; cursor: pointer; transition: .16s; }
.switch span::after { content: ""; position: absolute; width: 21px; height: 21px; left: 2px; top: 2px; border: 2px solid #57452b; border-radius: 50%; background: #d9cfaa; transition: .16s; }
.switch input:checked + span { background: #a67c28; }
.switch input:checked + span::after { transform: translateX(23px); background: #ffeb9b; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.rules-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rule-card { padding: 18px; border: 3px solid #355940; border-radius: 10px; background: rgba(5,31,20,.43); }
.rule-card .rule-icon { min-height: 33px; color: var(--gold-hi); }
.rule-svg { width: 34px; height: 34px; stroke-width: 1.8; }
.golden-glyph { font-size: 2rem; }
.rule-card h3 { margin: 9px 0 6px; color: #f6e4ab; font-size: 1.05rem; }
.rule-card p { margin: 0; color: #cfbf98; font-size: .9rem; }

.game-screen { display: flex; flex-direction: column; background: #0b2418; }

.topbar {
  position: relative;
  z-index: 60;
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 9px 20px;
  border-bottom: 5px solid #6d4b23;
  background:
    linear-gradient(180deg, rgba(40,99,58,.98), rgba(13,55,35,.98)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(255,255,255,.035) 35px 36px);
  box-shadow: inset 0 -3px rgba(0,0,0,.18), 0 8px 20px rgba(0,0,0,.35);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -5px;
  height: 5px;
  background: linear-gradient(90deg, transparent, var(--active-color, var(--gold)) 24% 76%, transparent);
  filter: drop-shadow(0 0 7px var(--active-color, var(--gold)));
  pointer-events: none;
}

.mini-title { font: 900 1.02rem Georgia, serif; letter-spacing: .08em; text-transform: uppercase; color: #f7e7b1; text-shadow: 0 2px #1a2c1e; }
.mini-title span { color: var(--gold-hi); }
.turn-readout { min-width: 340px; padding: 4px 26px; text-align: center; border-left: 2px solid rgba(226,177,67,.3); border-right: 2px solid rgba(226,177,67,.3); }
.turn-name { font: 900 1.18rem Georgia, serif; text-shadow: 0 2px #132418; }
.turn-instruction { margin-top: 2px; color: #dfd0a8; font-size: .82rem; font-weight: 700; }
.top-actions { display: flex; justify-content: flex-end; gap: 8px; }
.top-actions .icon-button { width: 42px; height: 42px; }

.game-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #153b27;
}

.game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 58px rgba(2, 13, 8, .26);
}

.scene-plane {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 100%;
  aspect-ratio: 1672 / 941;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.scene-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.temple-shell {
  position: absolute;
  z-index: 8;
  left: 33.2536%;
  top: 20.6164%;
  width: 33.4928%;
  height: 52.6036%;
}

.board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: .5%;
  padding: .65%;
  border: 0;
  background: transparent;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: #4f4631;
  border-radius: 5px;
  box-shadow: inset 0 3px 6px rgba(0,0,0,.64), 0 1px rgba(255,255,255,.22);
  overflow: visible;
}

.tile:hover:not(:disabled) { z-index: 9; }
.tile:hover:not(:disabled) .lid { filter: brightness(1.1); transform: translateY(-2px) scale(1.025); }
.tile:disabled { cursor: default; }
.tile.selectable::after {
  content: "";
  position: absolute;
  inset: -3px;
  z-index: 7;
  border: 2px solid rgba(255, 218, 104, .78);
  border-radius: 7px;
  opacity: 0;
  box-shadow: 0 0 9px rgba(255,205,65,.45);
  transition: opacity .12s;
  pointer-events: none;
}
.tile.selectable:hover::after { opacity: 1; }

.well {
  position: absolute;
  inset: 7%;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: radial-gradient(circle at 50% 38%, #625a41, #28291f 82%);
  box-shadow: inset 0 5px 9px rgba(0,0,0,.72), inset 0 0 0 2px #716344;
}

.artifact-img {
  width: 94%;
  height: 94%;
  object-fit: contain;
  transform: scale(.95);
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.5));
  user-select: none;
  pointer-events: none;
}

.lid {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: 2px solid #67573a;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.24), transparent 33%),
    linear-gradient(145deg, #d4c28e, #9f8c5f 68%, #776642);
  box-shadow: inset 0 0 0 2px rgba(246,229,177,.32), 0 3px 2px rgba(29,25,16,.55);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .22s ease, filter .12s ease;
}

.lid::before, .lid::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(91,74,44,.66);
  background: linear-gradient(145deg, #cdbc87, #8e7a50);
  box-shadow: 1px 2px 1px rgba(0,0,0,.3), inset 1px 1px rgba(255,255,255,.28);
}
.lid::before { width: 58%; height: 58%; }
.lid::after { width: 27%; height: 27%; background: linear-gradient(145deg, #c4b27b, #77653f); }

.tile.revealed .lid { transform: translate(62%, -58%) rotate(10deg) scale(.82); opacity: .16; pointer-events: none; }
.tile.peeked .lid { opacity: .28; filter: sepia(.2) brightness(1.32); transform: translate(8%, -5%) rotate(2deg); }
.tile.collected .lid { opacity: 0; transform: translate(82%, -95%) rotate(30deg) scale(.54); }
.tile.collected .well { background: radial-gradient(circle at center, #4d4935, #27281f); }
.tile.collected .artifact-img { opacity: 0; }
.tile.shake-near { animation: lid-rattle .18s linear 7; }
.tile.shake-direct { animation: direct-hit .28s ease 4; z-index: 10; }

.chests-layer { position: absolute; inset: 0; z-index: 18; pointer-events: none; }
.player-chest {
  --player-color: var(--terracotta);
  position: absolute;
  width: clamp(155px, 13vw, 205px);
  height: clamp(132px, 17vh, 178px);
  pointer-events: auto;
  transition: transform .25s ease, filter .25s ease;
  filter: saturate(.84) drop-shadow(0 9px 7px rgba(0,0,0,.42));
}
.player-chest.p0 { left: 3.2%; bottom: 6.2%; --lid-x: -62%; --lid-y: 10%; --lid-r: -8deg; }
.player-chest.p1 { right: 3.2%; bottom: 6.2%; --lid-x: 62%; --lid-y: 10%; --lid-r: 8deg; }
.player-chest.p2 { right: 3.2%; top: 4.2%; --lid-x: 62%; --lid-y: -12%; --lid-r: -8deg; }
.player-chest.p3 { left: 3.2%; top: 4.2%; --lid-x: -62%; --lid-y: -12%; --lid-r: 8deg; }
.player-chest.active { transform: translateY(-5px) scale(1.04); filter: saturate(1.08) drop-shadow(0 0 10px var(--player-color)) drop-shadow(0 10px 8px rgba(0,0,0,.48)); }

.chest-visual { position: absolute; left: 4%; right: 4%; top: 0; height: calc(100% - 35px); }
.chest-body, .chest-lid { position: absolute; left: 50%; width: 100%; height: auto; transform: translateX(-50%); pointer-events: none; }
.chest-body { top: 0; z-index: 1; }
.chest-lid { top: 2%; z-index: 3; width: 93%; transition: transform .46s cubic-bezier(.2,.75,.2,1), filter .3s ease; }
.player-chest.open .chest-lid { transform: translate(calc(-50% + var(--lid-x)), var(--lid-y)) rotate(var(--lid-r)); filter: drop-shadow(0 8px 6px rgba(0,0,0,.38)); }

.chest-glow { position: absolute; z-index: 2; left: 12%; right: 12%; top: 5%; height: 65%; opacity: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255,236,124,.96), rgba(255,166,31,.36) 38%, transparent 70%); pointer-events: none; }
.player-chest.burst .chest-glow { animation: chest-burst .85s ease-out; }

.chest-medallion {
  position: absolute;
  z-index: 5;
  width: 35px;
  height: 35px;
  left: 50%;
  top: 38%;
  display: grid;
  place-items: center;
  transform: translate(-50%,-50%);
  border: 3px solid #4f351b;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 11px var(--player-color), inset 0 2px rgba(255,255,255,.28), 0 3px 0 rgba(0,0,0,.38);
  color: #fff4cf;
  font: 900 1rem Georgia, serif;
  text-shadow: 0 2px 2px rgba(0,0,0,.55);
}

.chest-label {
  position: absolute;
  left: 1%;
  right: 1%;
  bottom: 0;
  min-height: 36px;
  display: grid;
  align-items: center;
  padding: 5px 11px;
  border: 3px solid color-mix(in srgb, var(--player-color) 55%, #47321a 45%);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(27,75,47,.96), rgba(9,38,26,.97));
  box-shadow: 0 4px 0 rgba(23,19,11,.75), inset 0 1px rgba(255,255,255,.1);
}
.chest-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: color-mix(in srgb, var(--player-color) 50%, #fff4d0 50%); font-size: .88rem; font-weight: 900; text-shadow: 0 2px #132116; }
.special-pips { position: absolute; right: 7px; top: -12px; display: flex; gap: 3px; }
.special-pip { width: 9px; height: 9px; border: 2px solid #47351c; border-radius: 50%; background: #465447; }
.special-pip.on { background: var(--gold); box-shadow: 0 0 7px var(--gold-hi); }
.player-symbol { margin-right: 5px; }

.bonus-token {
  position: absolute;
  z-index: 8;
  right: -8px;
  bottom: 29px;
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border: 3px solid #68451d;
  border-radius: 50%;
  color: #4c2d0c;
  background: radial-gradient(circle at 35% 28%, #ffef9a, #d99f2c 65%, #855a18);
  box-shadow: 0 5px 0 rgba(44,28,13,.72), inset 0 0 0 3px rgba(255,245,190,.34);
  font: 900 1.1rem Georgia, serif;
  animation: token-arrive .4s ease both;
}
.bonus-token.using { animation: token-use .65s ease forwards; }

.turn-controls {
  position: absolute;
  left: 50%;
  bottom: 2.4%;
  z-index: 32;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 13px;
  border: 4px solid #60461f;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(30,84,51,.97), rgba(8,42,27,.98));
  box-shadow: inset 0 2px rgba(255,255,255,.09), 0 5px 0 #241b10, 0 13px 25px rgba(0,0,0,.42);
}
.turn-controls .stone-button { min-height: 43px; padding: 9px 17px; font-size: .78rem; }
.turn-controls .roll-dice-button {
  min-width: 176px;
  min-height: 58px;
  padding: 13px 25px;
  font-size: 1rem;
  letter-spacing: .07em;
  box-shadow: inset 0 2px rgba(255,255,255,.18), 0 5px 0 #583c18, 0 0 16px rgba(234,179,59,.22);
}
.turn-controls .skip-dice-button { min-width: 102px; }
.shortcut { opacity: .58; margin-left: 6px; font-size: .72rem; }

.die-roll-overlay {
  position: absolute;
  inset: 0;
  z-index: 74;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,217,110,.16), transparent 24%);
  animation: fade-in .14s ease both;
}
.die-roll-overlay.leaving { opacity: 0; transition: opacity .18s; }
.stone-d4 {
  width: 138px;
  height: 116px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 5px solid #665535;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,.28), transparent 30%),
    linear-gradient(145deg, #d3c18c, #927d52);
  box-shadow: inset 0 0 0 4px rgba(244,226,169,.3), 0 14px 0 rgba(54,39,20,.48), 0 24px 35px rgba(0,0,0,.5);
  color: #3f2c17;
  transform: rotate(-4deg) scale(.94);
}
.stone-d4.toss-0 { animation: d4-toss-a .17s ease; }
.stone-d4.toss-1 { animation: d4-toss-b .2s ease; }
.stone-d4.toss-2 { animation: d4-toss-c .22s ease; }
.stone-d4.final { transform: rotate(0) scale(1.04); border-color: #8a682c; box-shadow: inset 0 0 0 4px rgba(255,235,149,.42), 0 13px 0 rgba(67,43,19,.55), 0 0 28px rgba(255,202,66,.42), 0 25px 38px rgba(0,0,0,.52); transition: transform .22s ease, box-shadow .22s ease; }
.stone-d4.result-x { color: #7c2f22; }
.stone-d4.result-detect { color: #3f4d36; }
.d4-symbol { display: grid; place-items: center; height: 50px; }
.d4-symbol .die-glyph { width: 47px; height: 47px; stroke-width: 1.35; }
.detect-die-icon {
  display: block;
  width: 45px;
  height: 50px;
  background: currentColor;
  -webkit-mask: url("./assets/detect-die-glyph.png") center / contain no-repeat;
  mask: url("./assets/detect-die-glyph.png") center / contain no-repeat;
}
.stone-d4 strong { font-size: .83rem; letter-spacing: .1em; }

.detector-mode, .detector-mode .tile { cursor: none !important; }
.detector-tool {
  --meter-angle: -32deg;
  position: absolute;
  z-index: 55;
  width: 132px;
  height: 158px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -94%);
  filter: drop-shadow(0 10px 7px rgba(0,0,0,.46));
  transition: opacity .08s ease;
}
.detector-tool.visible { opacity: 1; }
.detector-tool img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.detector-meter {
  position: absolute;
  left: 57.8%;
  top: 26.5%;
  width: 18%;
  height: 13%;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: inset 0 0 7px rgba(255,190,36,.5);
}
.detector-meter i { position: absolute; left: 50%; bottom: 0; width: 2px; height: 82%; background: #542514; transform: rotate(var(--meter-angle)); transform-origin: 50% 100%; transition: transform .28s ease; }
.detector-led { position: absolute; left: 57%; top: 39.2%; width: 8px; height: 8px; border-radius: 50%; background: #8b5428; }
.detector-tool.locked.near { --meter-angle: 0deg; animation: detector-shiver .16s linear 9; filter: drop-shadow(0 0 10px #f19a2e) drop-shadow(0 10px 7px rgba(0,0,0,.46)); }
.detector-tool.locked.direct { --meter-angle: 30deg; animation: detector-shiver .09s linear 17; filter: drop-shadow(0 0 13px #ec3d2b) drop-shadow(0 10px 7px rgba(0,0,0,.46)); }
.detector-tool.locked.miss { --meter-angle: -30deg; }
.detector-tool.near .detector-led { background: #f39a28; box-shadow: 0 0 8px #ffb23c; }
.detector-tool.direct .detector-led { background: #ee3929; box-shadow: 0 0 10px #ff3825; }

.artifact-focus {
  position: absolute;
  inset: 0;
  z-index: 76;
  display: grid;
  place-items: center;
  pointer-events: auto;
  background: radial-gradient(circle at center, rgba(255,213,92,.1), rgba(3,14,9,.64));
  animation: fade-in .16s ease both;
}
.artifact-focus-card {
  position: relative;
  width: min(36vh, 390px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,235,157,.26) 0 43%, rgba(240,183,48,.13) 55%, transparent 70%);
  filter: drop-shadow(0 28px 22px rgba(0,0,0,.56));
  animation: artifact-rise .34s cubic-bezier(.2,.8,.2,1) both;
}
.artifact-focus-card::before { content: ""; position: absolute; inset: 4%; border: 3px solid rgba(255,221,112,.45); border-radius: 50%; box-shadow: 0 0 18px rgba(255,199,55,.22); animation: slow-spin 15s linear infinite; }
.artifact-focus img { width: 86%; height: 86%; object-fit: contain; filter: drop-shadow(0 15px 10px rgba(0,0,0,.48)); }
.skip-hint { position: absolute; bottom: 7%; padding: 7px 12px; border-radius: 7px; color: rgba(255,244,206,.8); background: rgba(6,31,20,.68); font-size: .8rem; letter-spacing: .05em; }
.artifact-focus.special .artifact-focus-card { background: radial-gradient(circle, rgba(255,239,145,.48) 0 42%, rgba(244,172,30,.24) 52%, transparent 71%); }

.flying-artifact {
  position: fixed;
  z-index: 120;
  width: 100px;
  height: 100px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 7px rgba(0,0,0,.46));
  transition: left .72s cubic-bezier(.35,.03,.35,1), top .72s cubic-bezier(.35,.03,.35,1), transform .72s ease, opacity .65s ease;
}

.toast-stack { position: absolute; z-index: 92; top: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 290px; padding: 11px 20px; border: 3px solid #775827; border-radius: 9px; background: linear-gradient(180deg, rgba(31,87,53,.97), rgba(9,43,29,.98)); color: #f8e8b7; text-align: center; font-weight: 800; box-shadow: 0 5px 0 rgba(29,21,12,.76), 0 12px 24px rgba(0,0,0,.38); animation: toast-in 2.2s ease both; }

.turn-banner { position: absolute; z-index: 70; top: 15%; left: 50%; transform: translateX(-50%); padding: 13px 31px; border: 4px solid var(--banner-color, var(--gold)); border-radius: 11px; background: linear-gradient(180deg, rgba(31,85,52,.98), rgba(8,42,27,.98)); box-shadow: 0 5px 0 #241b10, 0 13px 28px rgba(0,0,0,.42), 0 0 18px color-mix(in srgb, var(--banner-color) 42%, transparent); font: 900 1.3rem Georgia, serif; color: #fff1c4; animation: banner-pass 1.1s ease both; pointer-events: none; }

.privacy-card { text-align: center; }
.privacy-eye { width: 76px; height: 48px; margin: 0 auto 18px; border: 4px solid var(--gold); border-radius: 70% 15%; transform: rotate(45deg); display: grid; place-items: center; }
.privacy-eye::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--gold-hi); box-shadow: 0 0 13px var(--gold); }

.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 20px 0; }
.result-player { --player-color: var(--gold); padding: 18px; border: 3px solid color-mix(in srgb, var(--player-color) 55%, #3c2e19 45%); border-radius: 10px; background: rgba(4,29,18,.38); text-align: center; }
.result-player.winner { box-shadow: 0 0 24px color-mix(in srgb, var(--player-color) 55%, transparent); background: rgba(232,181,59,.12); transform: translateY(-4px); }
.result-player h3 { color: color-mix(in srgb, var(--player-color) 55%, white 45%); }
.result-score { margin: 9px 0; font: 900 2.4rem Georgia, serif; color: var(--gold-hi); }
.result-breakdown { color: #d5c49b; font-size: .88rem; line-height: 1.55; }
.winner-title { text-align: center; font: 900 2.5rem Georgia, serif; color: var(--gold-hi); text-shadow: 0 3px #513517, 0 0 20px rgba(242,192,71,.4); }

.hint-card { position: absolute; z-index: 72; right: 22px; top: 18px; width: 300px; padding: 17px; border: 4px solid #6d5125; border-radius: 11px; background: linear-gradient(180deg, rgba(31,86,52,.98), rgba(8,43,28,.98)); box-shadow: 0 5px 0 #251b10, 0 15px 32px rgba(0,0,0,.42); animation: hint-in .35s ease both; }
.hint-card h3 { margin: 0 0 5px; color: var(--gold-hi); font-family: Georgia, serif; }
.hint-card p { margin: 0 0 12px; color: #d8c9a3; font-size: .9rem; line-height: 1.4; }
.hint-card button { width: 100%; }

@keyframes rise-in { from { opacity: 0; transform: translateY(22px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(10px); } }
@keyframes artifact-rise { from { opacity: 0; transform: translateY(34px) scale(.62) rotate(-5deg); } }
@keyframes slow-spin { to { transform: rotate(360deg); } }
@keyframes lid-rattle { 0%,100% { transform: translate(0); } 25% { transform: translate(-2px,1px) rotate(-1deg); } 75% { transform: translate(2px,-1px) rotate(1deg); } }
@keyframes direct-hit { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-6px) rotate(2deg); } }
@keyframes chest-burst { 0% { opacity: 0; transform: scale(.45); } 32% { opacity: 1; } 100% { opacity: 0; transform: scale(1.55); } }
@keyframes token-arrive { from { opacity: 0; transform: translateY(-30px) rotate(-100deg) scale(.5); } }
@keyframes token-use { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35) rotate(15deg); filter: brightness(1.8); } 100% { transform: scale(.1) rotate(80deg); opacity: 0; } }
@keyframes d4-toss-a { 0% { transform: translate(-22px,-30px) rotate(-18deg) scale(.74); opacity: .4; } 100% { transform: translate(0) rotate(5deg) scale(.96); opacity: 1; } }
@keyframes d4-toss-b { 0% { transform: translate(19px,-18px) rotate(16deg) scale(.8); } 100% { transform: translate(0) rotate(-5deg) scale(.98); } }
@keyframes d4-toss-c { 0% { transform: translate(-8px,14px) rotate(-10deg) scale(.86); } 100% { transform: translate(0) rotate(3deg) scale(1); } }
@keyframes detector-shiver { 0%,100% { transform: translate(-50%,-94%) rotate(0); } 50% { transform: translate(calc(-50% + 2px),-94%) rotate(1deg); } }
@keyframes toast-in { 0% { opacity: 0; transform: translateY(-9px); } 12%,75% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-5px); } }
@keyframes banner-pass { 0% { opacity: 0; transform: translate(-50%,-12px) scale(.9); } 20%,72% { opacity: 1; transform: translate(-50%,0) scale(1); } 100% { opacity: 0; transform: translate(-50%,8px) scale(.96); } }
@keyframes hint-in { from { opacity: 0; transform: translateX(20px); } }

@media (max-height: 820px) {
  .topbar { min-height: 62px; padding-block: 6px; }
  .player-chest { width: 155px; height: 132px; }
  .turn-controls { bottom: 1.4%; transform: translateX(-50%) scale(.9); }
  .title-lockup { transform: scale(.9); }
}

@media (max-width: 1280px) {
  .player-chest { width: 150px; height: 128px; }
  .player-chest.p0, .player-chest.p3 { left: 1.5%; }
  .player-chest.p1, .player-chest.p2 { right: 1.5%; }
  .chest-label { font-size: .78rem; }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(145px, 1fr) minmax(260px, 1.2fr) auto;
    gap: 8px;
    padding-inline: 10px;
  }
  .mini-title {
    min-width: 0;
    overflow: hidden;
    font-size: .82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .turn-readout { min-width: 0; padding-inline: 10px; }
  .turn-name { font-size: 1rem; }
  .turn-instruction { font-size: .72rem; }
  .top-actions .icon-button { width: 36px; height: 36px; padding: 0; }
  .top-actions .icon-button .ui-icon { display: block; width: 23px; min-width: 23px; height: 23px; min-height: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
