/* ── Xahtzee dice animation variants (each die rolls differently) ── */
.y-die-wrap:nth-child(1) .dice.animate { animation: rotate  3.0s cubic-bezier(0.22, 0.61, 0.36, 1); }
.y-die-wrap:nth-child(2) .dice.animate { animation: rotate2 3.5s cubic-bezier(0.16, 1, 0.3, 1); }
.y-die-wrap:nth-child(3) .dice.animate { animation: rotate  2.9s cubic-bezier(0.22, 0.61, 0.36, 1); }
.y-die-wrap:nth-child(4) .dice.animate { animation: rotate2 3.3s cubic-bezier(0.16, 1, 0.3, 1); }
.y-die-wrap:nth-child(5) .dice.animate { animation: rotate  3.6s cubic-bezier(0.22, 0.61, 0.36, 1); }

/* ── Layout ── */
.y-game-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.y-dice-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 2rem 0.5rem 1rem;
  flex-wrap: wrap;
}

.y-die-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.y-die-wrap.held .dice {
  outline: 3px solid #c9a84c;
  outline-offset: 4px;
  border-radius: 5px;
}

/* ── Hold label ── */
.hold-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  font-size: 0.65rem;
  color: #888;
  user-select: none;
  font-family: Arial, sans-serif;
}

.hold-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: #c9a84c;
  width: 15px;
  height: 15px;
}

.hold-label input:disabled,
.hold-label input:disabled + span {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Roll controls ── */
.y-roll-area {
  text-align: center;
  padding: 0.5rem 0 1.5rem;
}

.y-rolls-left {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #666;
  font-family: Arial, sans-serif;
  margin-bottom: 0;
}

/* ── Player indicator ── */
.y-player-indicator {
  text-align: center;
  font-size: 0.95rem;
  color: #8b1a2d;
  font-weight: 700;
  padding: 0.5rem 0;
  letter-spacing: 0.04em;
}

/* ── Scoreboard table ── */
.y-scoreboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.y-scoreboard thead th {
  background: #8b1a2d;
  color: #f5e8d0;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-family: 'Russo One', Arial, sans-serif;
}

.y-scoreboard th.active-player {
  color: #c9a84c;
}

.y-scoreboard td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #e8d5b0;
  font-family: Arial, sans-serif;
  vertical-align: middle;
}

.y-cat-cell {
  font-size: 0.78rem;
  color: #444;
  white-space: nowrap;
}

.y-scoreboard tr.section-header td {
  background: #f5e8d0;
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8b1a2d;
  padding: 0.45rem 0.75rem;
  font-family: Arial, sans-serif;
}

/* Position thumbnail — no filter, black icon */
.y-pos-thumb {
  width: 26px;
  height: 26px;
  display: block;
  object-fit: contain;
  border-radius: 3px;
  padding: 2px;
  background: transparent;
  border: 1px solid rgba(139, 26, 45, 0.15);
  transition: background 0.15s, border-color 0.15s;
}

/* Gold background when scored successfully */
.y-img-cell.scored:not(.failed) .y-pos-thumb {
  background: rgba(201, 168, 76, 0.35);
  border-color: #c9a84c;
}

/* Image column — narrow, centered */
.y-img-cell {
  width: 36px;
  padding: 0.2rem 0.25rem;
  text-align: center;
  vertical-align: middle;
  position: relative;
}

/* Cross overlay for failed scores */
.y-img-cell.failed .y-pos-thumb {
  opacity: 0.35;
}

.y-img-cell.failed::before,
.y-img-cell.failed::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 2px;
  background: #8b1a2d;
  border-radius: 1px;
  pointer-events: none;
}

.y-img-cell.failed::before { transform: translate(-50%, -50%) rotate(45deg); }
.y-img-cell.failed::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* Value column — compact */
.y-val-cell {
  padding: 0.2rem 0.5rem 0.2rem 0.15rem;
  min-width: 2rem;
  vertical-align: middle;
  font-size: 0.82rem;
  font-family: Arial, sans-serif;
}

/* Upcoming: fully visible */
.y-img-cell.upcoming  { opacity: 1; }
.y-val-cell.upcoming  { opacity: 1; }

/* Potential: gold highlight, clickable */
.y-img-cell.potential,
.y-val-cell.potential {
  background: rgba(201, 168, 76, 0.15);
  cursor: pointer;
  transition: background 0.12s;
}

.y-img-cell.potential:hover,
.y-val-cell.potential:hover {
  background: rgba(201, 168, 76, 0.45);
}

.y-img-cell.potential .y-pos-thumb {
  outline: 2px solid #c9a84c;
  outline-offset: 1px;
}

.y-pot-val {
  font-weight: 700;
  color: #8b1a2d;
}

/* Scored */
.y-val-cell.scored {
  font-weight: 600;
  color: #333;
}

.y-val-cell.failed {
  color: #bbb;
  text-decoration: line-through;
}

.y-scoreboard td.empty {
  color: #ccc;
}

.y-scoreboard tr.bonus-row td {
  font-size: 0.73rem;
  color: #999;
  background: #fdf6ee;
  font-style: italic;
}

.y-scoreboard .progress {
  color: #c9a84c;
}

.y-scoreboard tr.total-row td {
  background: #12080a;
  color: #f5e8d0;
  padding: 0.65rem 0.75rem;
  border-bottom: none;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: 'Russo One', Arial, sans-serif;
}

/* ── End-game overlay ── */
.y-endgame-box {
  max-height: 85vh;
  overflow-y: auto;
  max-width: 480px;
}

.y-endgame-score {
  color: #666;
  font-size: 0.9rem;
  font-family: Arial, sans-serif;
  margin-bottom: 0.25rem;
}

.y-endgame-reward {
  color: #8b1a2d;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  font-family: 'Russo One', Arial, sans-serif;
}

.y-endgame-positions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.y-endgame-pos-btn {
  background: transparent;
  border: 1px solid rgba(139, 26, 45, 0.2);
  border-radius: 5px;
  padding: 3px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.y-endgame-pos-btn:hover {
  background: rgba(201, 168, 76, 0.2);
  border-color: #c9a84c;
}

.y-endgame-pos-btn.selected {
  background: rgba(201, 168, 76, 0.4);
  border-color: #c9a84c;
}

.y-endgame-chosen {
  display: none;
  margin-bottom: 1.25rem;
}

.y-endgame-chosen-name {
  font-weight: 700;
  color: #8b1a2d;
  margin-top: 0.6rem;
  font-family: 'Russo One', Arial, sans-serif;
  font-size: 1rem;
}

/* ── Result overlay box ── */
.result-box {
  background: #fdf6ee;
  border: 2px solid #c9a84c;
  border-radius: 12px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
}

.result-box h2 {
  color: #8b1a2d;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.result-box .score-overlay-m {
  color: #333;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  font-family: Arial, sans-serif;
}

/* ── Clock inside position modal ── */
.y-modal-clock {
  padding: 0.5rem 0 !important;
}

/* ── Position reveal modal ── */
.y-pos-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(18, 8, 10, 0.88);
  z-index: 1000;
}

.y-pos-box {
  background: #fdf6ee;
  border: 2px solid #c9a84c;
  border-radius: 14px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.y-pos-failed {
  font-size: 1.2rem;
  font-weight: 700;
  color: #8b1a2d;
  font-family: 'Russo One', Arial, sans-serif;
  letter-spacing: 0.04em;
  margin: 0.5rem 0;
  display: none;
}

/* Wrapper carries the dark red bg; filter only on the <img> */
.y-pos-img-wrap {
  background: #8b1a2d;
  border-radius: 10px;
  padding: 1.25rem;
  display: inline-block;
}

.y-pos-img-wrap img {
  width: 140px;
  height: 140px;
  display: block;
  object-fit: contain;
  filter: brightness(0) invert(0.88) sepia(0.15);
}


/* ── Mobile: sticky dice bar ── */
@media (max-width: 767.98px) {
  /* Collapse .y-left's own box so .y-sticky-top becomes a direct
     flex child of .y-game-layout — which is tall enough for sticky */
  .y-left {
    display: contents;
  }

  .y-sticky-top {
    position: sticky;
    top: 3rem;
    z-index: 10;
    background: #f5ede0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    padding-bottom: 0.25rem;
  }

  /* Dice row + roll button side by side */
  .y-dice-controls {
    display: flex;
    align-items: center;
  }

  .y-dice-row {
    flex: 1;
    padding: 0.5rem 0.25rem 0.3rem;
    gap: 0.35rem;
  }

  .y-roll-area {
    flex: 0 0 auto;
    padding: 0 0.75rem 0 0;
    text-align: center;
  }

  #rollBtn {
    font-size: 0.78rem;
    padding: 0.3rem 0.9rem;
    border-radius: 1.5rem;
    white-space: nowrap;
  }

  .y-rolls-left {
    margin-top: 0.3rem;
    font-size: 0.65rem;
  }

  .y-player-indicator {
    font-size: 0.8rem;
    padding: 0.3rem 0;
  }
}

/* ── Desktop: side-by-side layout ── */
@media (min-width: 768px) {
  .y-game-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .y-left {
    flex: 0 0 280px;
  }

  .y-right {
    flex: 1;
  }
}

/* ── Large screens: bigger dice ── */
@media (min-width: 900px) {
  .y-dice-row .dice {
    width: 60px;
    height: 60px;
  }
  .y-dice-row .one  { transform: translateZ(30px); }
  .y-dice-row .two  { transform: translateX(-30px) rotateY(-90deg); }
  .y-dice-row .three { transform: translateY(30px) rotateX(90deg); }
  .y-dice-row .four  { transform: translateY(-30px) rotateX(90deg); }
  .y-dice-row .five  { transform: translateX(30px) rotateY(90deg); }
  .y-dice-row .six   { transform: translateZ(-30px); }

  .y-dice-row .two::before  { box-shadow: #000 -15px -15px 0 0, #000 15px 15px 0 0; }
  .y-dice-row .three::before { box-shadow: #000 -15px 15px 0 0, #000 15px -15px 0 0; }
  .y-dice-row .four::before  { background: transparent; box-shadow: #000 -15px 15px 0 0, #000 -15px -15px 0 0, #000 15px 15px 0 0, #000 15px -15px 0 0; }
  .y-dice-row .five::before  { box-shadow: #000 -15px -15px 0 0, #000 -15px 15px 0 0, #000 15px -15px 0 0, #000 15px 15px 0 0; }
  .y-dice-row .six::before   { background: transparent; box-shadow: #000 -15px -15px 0 0, #000 -15px 0 0, #000 -15px 15px 0 0, #000 15px -15px 0 0, #000 15px 0 0, #000 15px 15px 0 0; }

  .y-left {
    flex: 0 0 340px;
  }
}
