/* «Пирамида» — оболочка полной версии: 3D-сцена на весь экран, прозрачный холст интерфейса, полоса кнопок сверху,
   листы (итоги, лестница, клуб) поверх. Те же пухлые кнопки с тёмной обводкой, что у соседей по «Норе». */
:root { --ink: #3a2418; --felt: #1f8a4a; --gold: #ffd36a; --wood: #7a3c18; --cream: #fff6e6; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1a1e; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
#ui { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

#bar { position: absolute; left: 0; right: 0; top: 0; height: 52px; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 8px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); pointer-events: none; }
#bar > * { pointer-events: auto; }
.grow { flex: 1; }
.chip { height: 38px; min-width: 38px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 999px; background: var(--cream);
  color: var(--ink); font: 800 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.chip.icon { padding: 0; justify-content: center; width: 38px; font-size: 18px; }
.chip.gold { background: var(--gold); }
.chip[aria-pressed="false"] { background: #bbb; text-decoration: line-through; }
.chip:focus-visible, .btn:focus-visible { outline: 3px solid #3c8ce0; outline-offset: 2px; }
.ico { font-size: 18px; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6c0, #f0b52a 60%, #b07a10); border: 2px solid var(--ink); }

#toast { position: absolute; left: 50%; bottom: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; width: max-content; transform: translateX(-50%); background: var(--ink); color: #fff;
  font-weight: 800; padding: 10px 16px; border-radius: 999px; z-index: 5; max-width: 92vw; text-align: center; pointer-events: none; box-shadow: 0 4px 0 rgba(0,0,0,.25); }

#foot { position: absolute; left: 0; right: 0; bottom: 4px; z-index: 2; text-align: center; font-size: 11px; color: rgba(255,240,220,.45); pointer-events: none; }
#foot a { color: inherit; pointer-events: auto; }
body.playing #foot { display: none; }

.sheet { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: rgba(30, 14, 10, .5); overflow-y: auto; }
.sheet[hidden] { display: none; }
.sheet.low { align-items: flex-end; background: linear-gradient(to bottom, rgba(30,14,10,0) 30%, rgba(30,14,10,.55)); }
.card { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; background: var(--cream); border: 4px solid var(--ink); border-radius: 24px;
  padding: 18px; box-shadow: 0 8px 0 rgba(0, 0, 0, .3); text-align: center; }
.sheet.low .card { max-height: 58%; }
.card.wide { max-width: 720px; text-align: left; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card h2 { margin: 0 0 6px; font-size: 27px; font-weight: 900; }
.x { width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink); }
.face { width: 96px; height: 96px; display: block; margin: -4px auto 4px; }
.quote { margin: 4px auto 10px; max-width: 340px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 12px; font-weight: 700; position: relative; }
.quote::before { content: ''; position: absolute; top: -12px; left: 50%; margin-left: -9px; border: 9px solid transparent; border-bottom-color: var(--ink); border-top: 0; }
.note { font-size: 15px; margin: 8px 0; }
.lines { list-style: none; padding: 0; margin: 8px 0; font-weight: 700; text-align: left; }
.lines li { padding: 5px 0; border-bottom: 2px dashed #ead9bf; display: flex; justify-content: space-between; gap: 8px; }
.lines li b { color: #b07a10; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn { min-height: 46px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); font: 800 16px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; cursor: pointer; padding: 6px 10px; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.btn.primary { grid-column: 1 / -1; background: var(--felt); color: #fff; font-size: 19px; min-height: 56px; }
.btn.ghost { background: #f1e6d4; }
.btn.glow { grid-column: 1 / -1; background: var(--gold); }
.btn[hidden] { display: none; }
.btn:disabled { opacity: .5; cursor: default; }

.ladder { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.rival { border: 3px solid var(--ink); border-radius: 18px; background: #fff; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; font: inherit; color: var(--ink); text-align: center; }
.rival canvas { width: 84px; height: 84px; }
.rival b { font-size: 15px; }
.rival small { font-size: 12px; color: #7a5a40; }
.rival .st { font-size: 12px; font-weight: 800; }
.rival.won { background: #eaf7e6; }
.rival.cur { background: var(--gold); }
.rival:disabled { background: #e8e0d4; color: #8a7a6a; cursor: default; }
.rival:disabled canvas { filter: grayscale(1) brightness(.6); }

.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.item { border: 3px solid var(--ink); border-radius: 16px; background: #fff; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; text-align: left; }
.item b { font-size: 15px; }
.item small { grid-column: 1; font-size: 12px; color: #7a5a40; }
.item button { grid-row: 1 / span 2; grid-column: 2; min-width: 86px; min-height: 40px; border: 3px solid var(--ink); border-radius: 12px; background: var(--gold); font: 800 15px system-ui, sans-serif; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; justify-content: center; }
.item button:disabled { background: #e8e0d4; cursor: default; }
.item.own { background: #eaf7e6; }
.item.own button { background: #fff; }

.ad { margin-top: 12px; min-height: 90px; }
.ad[hidden] { display: none; }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .sheet.low { justify-content: flex-end; align-items: stretch; background: linear-gradient(to right, rgba(30,14,10,0) 45%, rgba(30,14,10,.5)); }
  .sheet.low .card { max-height: 100%; max-width: 460px; }
  .sheet.low .items { grid-template-columns: 1fr; }
}
@media (min-width: 1100px) { #ad-side-ladder, #ad-side-club { float: right; width: 300px; } }

.chip.day { background: linear-gradient(90deg, #ffe7a3, #ffc0a0); }
@media (max-width: 400px) { .chip.day { padding: 0 8px; font-size: 13px; } #rival-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; } }
.bracket { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.bracket div { border: 3px solid var(--ink); border-radius: 14px; background: #fff; text-align: center; padding: 4px; font-size: 12px; font-weight: 800; }
.bracket div.done { background: #eaf7e6; }
.bracket div.now { background: var(--gold); }
.bracket canvas { width: 100%; max-width: 72px; aspect-ratio: 1; display: block; margin: 0 auto; }
.board { list-style: none; padding: 0; margin: 8px 0; max-height: 240px; overflow-y: auto; }
.board li { display: grid; grid-template-columns: 2.4em 1fr auto; gap: 6px; padding: 5px 8px; border-bottom: 2px dashed #ead9bf; font-weight: 700; }
.board li.me { background: var(--gold); border-radius: 10px; }
.board li b { font-variant-numeric: tabular-nums; }
