* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-top: #1b1010;
  --bg-bottom: #090606;
  --panel: rgba(24, 14, 13, 0.86);
  --panel-soft: rgba(255, 238, 214, 0.08);
  --panel-line: rgba(255, 221, 175, 0.08);
  --ink: #f6e5c6;
  --muted: #c9b394;
  --accent: #c64b30;
  --accent-strong: #e57b42;
  --gold: #efc16e;
  --green: #3fad79;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
}

body {
  min-height: 100vh;
  font-family: Baskerville, "Palatino Linotype", "Book Antiqua", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(236, 184, 94, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(201, 75, 44, 0.1), transparent 22%),
    linear-gradient(180deg, var(--bg-top) 0%, #3b1f1a 40%, var(--bg-bottom) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 214, 149, 0.08), transparent 18%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 30%, rgba(0, 0, 0, 0.42));
}

.page-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 24px 16px 44px;
  display: grid;
  gap: 18px;
}

.top-copy,
.game-panel {
  position: relative;
  border-radius: 28px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.top-copy {
  padding: 24px;
  overflow: hidden;
}

.top-copy::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -24px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(239, 193, 110, 0.22), transparent 68%);
}

.game-panel {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(38px, 8vw, 72px);
  line-height: 0.92;
  margin-bottom: 12px;
}

h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.lead {
  max-width: 700px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(239, 193, 110, 0.18);
  background: rgba(255, 237, 208, 0.08);
  font-size: 13px;
}

.dice-counter {
  text-align: center;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 225, 184, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 241, 220, 0.08), rgba(255, 241, 220, 0.04)),
    rgba(255, 241, 220, 0.04);
}

.counter-label {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 10px;
}

.dice-display {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold), #bb7c2d);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.24);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.dot.inactive {
  opacity: 0.18;
  transform: scale(0.9);
}

.counter-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

.game-area {
  position: relative;
  height: clamp(620px, 82vh, 920px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(255, 225, 184, 0.08);
  background-image:
    linear-gradient(180deg, rgba(5, 4, 4, 0.48), rgba(5, 4, 4, 0.14), rgba(5, 4, 4, 0.24)),
    url("pikken/template-bar.jpg");
  background-size: cover;
  background-position: center 18%;
}

.game-area::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 58%, rgba(255, 74, 128, 0.16), transparent 18%),
    radial-gradient(circle at 56% 24%, rgba(255, 206, 118, 0.1), transparent 20%),
    radial-gradient(circle at 84% 28%, rgba(100, 167, 255, 0.12), transparent 18%);
}

.coordinate-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.coordinate-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      to right,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) calc(2cm - 1px),
      rgba(255, 255, 255, 0.18) calc(2cm - 1px),
      rgba(255, 255, 255, 0.18) 2cm
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) calc(2cm - 1px),
      rgba(255, 255, 255, 0.18) calc(2cm - 1px),
      rgba(255, 255, 255, 0.18) 2cm
    );
}

.coordinate-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.coordinate-label {
  position: absolute;
  font-size: 12px;
  line-height: 1;
  color: rgba(255, 247, 232, 0.88);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.72);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.coordinate-labels-x .coordinate-label {
  top: 8px;
  transform: translateX(-50%);
}

.coordinate-labels-y .coordinate-label {
  left: 8px;
  transform: translateY(-50%);
}

.coordinate-readout {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 236, 199, 0.22);
  background: rgba(17, 10, 9, 0.76);
  color: #fff2d8;
  font-size: 13px;
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.bar-dice {
  position: absolute;
  bottom: clamp(6px, 2.8vw, 38px);
  left: 50%;
  transform: translateX(-50%);
  --die-size: 27px;
  --half-die: 13.5px;
  --face-overlap: 1.4px;
  --face-push: 0.7px;
  width: min(360px, 74vw);
  height: min(210px, 36vw);
  z-index: 6;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.dice-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
  cursor: inherit;
}

.bar-dice.dragging {
  cursor: grabbing;
}

.game-area.dragging {
  cursor: grabbing;
}

.bar-dice::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: 72%;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.05) 55%, rgba(0, 0, 0, 0) 100%);
  filter: blur(3px);
  z-index: 0;
}

.cup {
  position: absolute;
  bottom: -52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  cursor: pointer;
  transition: transform 0.26s ease;
}

.cup:not(.lifted):hover {
  transform: translateX(-50%) scale(1.02);
}

.cup.lifted {
  transform: translateX(-50%) translateY(-560px);
}

.cup-image {
  position: relative;
  z-index: 1;
  height: clamp(780px, 96vh, 1020px);
  filter: drop-shadow(0 22px 38px rgba(0, 0, 0, 0.38));
  transform-origin: center bottom;
  transition: transform 0.26s ease, filter 0.2s ease;
}

.cup.shaking .cup-image {
  animation: cup-shake 0.9s ease-in-out;
}

.cup.throwing .cup-image {
  animation: cup-throw 0.45s ease-out forwards;
}

@keyframes cup-shake {
  0% { transform: rotate(0deg) translateX(0); }
  15% { transform: rotate(-11deg) translateX(-8px); }
  30% { transform: rotate(11deg) translateX(8px); }
  45% { transform: rotate(-9deg) translateX(-6px); }
  60% { transform: rotate(9deg) translateX(6px); }
  75% { transform: rotate(-6deg) translateX(-4px); }
  100% { transform: rotate(0deg) translateX(0); }
}

@keyframes cup-throw {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  40% { transform: translateY(-36px) rotate(6deg) scale(1.03); }
  80% { transform: translateY(6px) rotate(-2deg) scale(0.99); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.result-box {
  text-align: center;
  padding: 18px;
  border-radius: 20px;
  background: rgba(245, 195, 93, 0.1);
  border: 1px solid rgba(245, 195, 93, 0.18);
  min-height: 98px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.result-box p:first-child {
  color: var(--muted);
}

.result-box.win {
  background: rgba(63, 173, 121, 0.12);
  border-color: rgba(63, 173, 121, 0.24);
}

.result-box.game-over {
  background: rgba(198, 75, 48, 0.12);
  border-color: rgba(198, 75, 48, 0.24);
}

.dice-results {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
}

.die-result {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 243, 224, 0.2), rgba(255, 243, 224, 0.1));
  color: var(--ink);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.05em;
  font-weight: bold;
  border: 1px solid rgba(255, 225, 184, 0.14);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.18);
}

.die-result.pik {
  background: linear-gradient(180deg, rgba(29, 25, 24, 0.92), rgba(15, 12, 12, 0.96));
  color: #f6d18f;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn {
  padding: 13px 18px;
  font-size: 0.98em;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.22s ease;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(198, 75, 48, 0.28);
}

.btn-secondary {
  background: rgba(255, 240, 215, 0.1);
  color: var(--ink);
  border: 1px solid rgba(255, 225, 184, 0.12);
}

.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 240, 215, 0.16);
}

.btn-ghost {
  background: rgba(255, 240, 215, 0.06);
  color: var(--muted);
  border: 1px solid rgba(255, 225, 184, 0.08);
}

#peekBtn:disabled {
  background: rgba(255, 240, 215, 0.04);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.template-notes {
  display: grid;
  gap: 12px;
}

.note-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 225, 184, 0.08);
  background: var(--panel-soft);
}

.note-card p,
.note-card li {
  color: var(--muted);
  line-height: 1.55;
}

.note-card ul {
  list-style: none;
  display: grid;
  gap: 8px;
}

.note-card li::before {
  content: "▸";
  color: var(--gold);
  margin-right: 8px;
}

.bar-die {
  position: absolute;
  width: var(--die-size);
  height: var(--die-size);
  transform: translate(-50%, -50%) rotate(var(--die-rot, 0deg));
  transform-style: preserve-3d;
  display: none;
}

.bar-dice.fallback-dice .bar-die {
  display: block;
}

.bar-die::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 92%;
  width: calc(var(--die-size) * 0.78);
  height: calc(var(--die-size) * 0.18);
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0.04) 70%, rgba(0, 0, 0, 0) 100%);
  filter: blur(3px);
  opacity: var(--shadow-opa, 0.32);
  z-index: 0;
}

.flat-die {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: #f7f7f7;
  border: 1px solid #bdbdbd;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  display: none;
}

.flat-die::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 58%);
  pointer-events: none;
}

.die-scene {
  position: relative;
  z-index: 1;
  width: var(--die-size);
  height: var(--die-size);
  perspective: 800px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  display: block;
}

.die-scene::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -3px;
  height: 42%;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  transform: skewY(-18deg);
  opacity: 0.32;
  pointer-events: none;
  z-index: -1;
}

.die-cube {
  width: var(--die-size);
  height: var(--die-size);
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-30deg) rotateY(25deg);
  transition: transform 0.5s ease;
  background: #f6f8fb;
  border-radius: 8px;
}

.die-face {
  position: absolute;
  width: calc(var(--die-size) + var(--face-overlap));
  height: calc(var(--die-size) + var(--face-overlap));
  top: calc(var(--face-overlap) / -2);
  left: calc(var(--face-overlap) / -2);
  border-radius: 8px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid #c5cdd7;
  background-color: #f6f8fb;
  background-clip: border-box;
  overflow: hidden;
  box-shadow:
    inset 0 1px 3px rgba(255, 255, 255, 0.85),
    inset -1px -2px 4px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.12);
}

.die-face::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 6px;
  background: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.25), transparent 60%);
  pointer-events: none;
}

.die-face::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 6px;
  background: radial-gradient(circle at 75% 75%, rgba(0, 0, 0, 0.06), transparent 60%);
  pointer-events: none;
}

.die-face-top {
  transform: rotateX(90deg) translateZ(calc(var(--half-die) + var(--face-push)));
}

.die-face-bottom {
  transform: rotateX(-90deg) translateZ(calc(var(--half-die) + var(--face-push)));
}

.die-face-front {
  transform: translateZ(calc(var(--half-die) + var(--face-push)));
}

.die-face-back {
  transform: rotateY(180deg) translateZ(calc(var(--half-die) + var(--face-push)));
}

.die-face-left {
  transform: rotateY(-90deg) translateZ(calc(var(--half-die) + var(--face-push)));
}

.die-face-right {
  transform: rotateY(90deg) translateZ(calc(var(--half-die) + var(--face-push)));
}

.pips {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 4px;
}

.pip {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 40%, #111 0%, #000 75%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18);
}

.pip::after {
  content: "";
  position: absolute;
  top: 25%;
  left: 25%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

@media (max-width: 720px) {
  .page-shell {
    padding: 16px 12px 34px;
  }

  .top-copy,
  .game-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .game-area {
    height: 760px;
  }

  .cup.lifted {
    transform: translateX(-50%) translateY(-448px);
  }

  .cup-image {
    height: 820px;
  }

  .bar-dice {
    bottom: 40px;
    width: 300px;
    height: 176px;
  }

  .coordinate-label {
    font-size: 11px;
  }

  .coordinate-readout {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }

  .controls {
    justify-content: stretch;
  }

  .btn {
    flex: 1 1 calc(50% - 12px);
  }
}

[hidden]{display:none!important}.game-nav{display:flex;flex-wrap:wrap;gap:20px;margin-bottom:26px;font:16px/1.5 system-ui,sans-serif}.game-nav a{color:var(--ink);text-underline-offset:4px}.game-nav a:focus-visible{outline:3px solid var(--gold);outline-offset:5px}

.bar-dice{visibility:hidden}
