/* ---------- Header ---------- */

.dice-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 1.5rem 0.5rem;
}

.dice-header h1 {
  font-family: 'MedievalSharp', cursive;
  color: var(--ale-gold);
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  margin: 0.4rem 0 0.2rem;
  text-shadow: 0 0 12px rgba(255, 184, 77, 0.5), 0 2px 2px rgba(0, 0, 0, 0.6);
}

.dice-header .tagline {
  color: var(--parchment-edge);
  font-style: italic;
  margin: 0;
}

.back-link {
  display: inline-block;
  color: var(--parchment-edge);
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
}

.back-link:hover {
  border-bottom-color: var(--parchment-edge);
}

/* ---------- Setup screen ---------- */

.setup-screen {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
}

.setup-card {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-edge));
  border: 3px solid var(--wood-dark);
  border-radius: 10px;
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.setup-card h2 {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-warm);
  text-align: center;
  margin-top: 0;
}

.setup-group {
  margin-bottom: 1.4rem;
}

.setup-label {
  display: block;
  font-weight: 600;
  color: var(--text-warm);
  margin-bottom: 0.5rem;
}

.choice-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.choice-btn {
  flex: 1;
  min-width: 60px;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.5rem;
  border: 2px solid var(--wood-dark);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.35);
  color: var(--text-warm);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.6);
}

.choice-btn.selected {
  background: linear-gradient(180deg, var(--ember), #8f2e07);
  color: var(--parchment);
  border-color: var(--wood-dark);
}

.name-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.name-list input {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--wood-dark);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-dark);
}

.start-btn {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 1.1rem;
}

/* ---------- Game screen layout ---------- */

.game-screen {
  position: relative;
  z-index: 1;
  padding: 1.5rem 1.5rem 3rem;
}

.game-layout {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

/* ---------- Scoreboard ---------- */

.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.player-tile {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-edge));
  border: 3px solid var(--wood-dark);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.player-tile.active {
  border-color: var(--ale-gold);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), 0 0 16px rgba(255, 184, 77, 0.6);
  transform: translateY(-2px);
}

.player-tile .p-name {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-warm);
  font-size: 1.05rem;
  display: block;
}

.player-tile .p-score {
  color: var(--ember);
  font-weight: 600;
  font-size: 1.3rem;
}

/* ---------- Table area ---------- */

.table-area {
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.turn-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  justify-content: center;
  align-items: baseline;
  color: var(--parchment);
  width: 100%;
}

#current-player-label {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.3rem;
  color: var(--ale-gold);
}

.turn-score strong {
  color: var(--parchment);
  font-size: 1.15rem;
}

.dice-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  min-height: 84px;
}

.die {
  width: 68px;
  height: 68px;
  background: linear-gradient(180deg, var(--parchment), var(--parchment-edge));
  border: 2px solid var(--wood-dark);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.die.not-selectable {
  cursor: default;
}

.die:hover:not(.not-selectable) {
  transform: translateY(-3px);
}

.die.selected {
  border-color: var(--ale-gold);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 184, 77, 0.7);
}

.die.rolling {
  animation: dice-tumble 0.28s ease-in-out infinite;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55);
}

.die.settle {
  animation: dice-settle 0.2s ease-out;
}

@keyframes dice-tumble {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  25% { transform: translateY(-6px) rotate(-18deg) scale(1.06); }
  50% { transform: translateY(0) rotate(12deg) scale(0.94); }
  75% { transform: translateY(-3px) rotate(-10deg) scale(1.03); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes dice-settle {
  0% { transform: scale(1.2) rotate(8deg); }
  60% { transform: scale(0.94) rotate(-4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.die .pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dark);
  justify-self: center;
  align-self: center;
  opacity: 0;
}

.die[data-value="1"] .pip:nth-child(5) { opacity: 1; }
.die[data-value="2"] .pip:nth-child(1),
.die[data-value="2"] .pip:nth-child(9) { opacity: 1; }
.die[data-value="3"] .pip:nth-child(1),
.die[data-value="3"] .pip:nth-child(5),
.die[data-value="3"] .pip:nth-child(9) { opacity: 1; }
.die[data-value="4"] .pip:nth-child(1),
.die[data-value="4"] .pip:nth-child(3),
.die[data-value="4"] .pip:nth-child(7),
.die[data-value="4"] .pip:nth-child(9) { opacity: 1; }
.die[data-value="5"] .pip:nth-child(1),
.die[data-value="5"] .pip:nth-child(3),
.die[data-value="5"] .pip:nth-child(5),
.die[data-value="5"] .pip:nth-child(7),
.die[data-value="5"] .pip:nth-child(9) { opacity: 1; }
.die[data-value="6"] .pip:nth-child(1),
.die[data-value="6"] .pip:nth-child(3),
.die[data-value="6"] .pip:nth-child(4),
.die[data-value="6"] .pip:nth-child(6),
.die[data-value="6"] .pip:nth-child(7),
.die[data-value="6"] .pip:nth-child(9) { opacity: 1; }

.dice-message {
  color: var(--ale-gold);
  font-weight: 600;
  min-height: 1.4em;
  text-align: center;
}

.turn-log {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.9rem;
  color: var(--parchment-edge);
  min-height: 1.2em;
  text-align: center;
}

.action-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.secondary-btn {
  background: linear-gradient(180deg, var(--wood-light), var(--wood-mid));
}

.secondary-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #8a6039, var(--wood-light));
}

/* ---------- Rules card ---------- */

.rules-card {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-edge));
  border: 3px solid var(--wood-dark);
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  color: var(--text-warm);
  font-size: 0.9rem;
}

.rules-card h2 {
  font-family: 'MedievalSharp', cursive;
  margin-top: 0;
  font-size: 1.15rem;
}

.rules-card ul {
  padding-left: 1.1rem;
  margin: 0;
  line-height: 1.5;
}

.rules-card li {
  margin-bottom: 0.6rem;
}

/* ---------- Pass / winner overlays ---------- */

.pass-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 3, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1rem;
}

.pass-overlay.open {
  display: flex;
}

.pass-card {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-edge));
  border: 4px double var(--wood-dark);
  border-radius: 8px;
  max-width: 420px;
  width: 100%;
  padding: 2.2rem 1.8rem;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

.pass-card h2 {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-warm);
  margin-top: 0;
}

.pass-card p {
  color: var(--text-warm);
}

.winner-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
