/* === General Styles === */
body {
  font-family: 'Lora', serif;
  background: #fffdf0;
  padding: 20px;
  text-align: center;
}

h1 {
  font-family: 'Great Vibes', cursive;
  font-size: 4rem;
  margin-top: 2px;
  margin-bottom: 30px;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.8);
  transform-origin: top center;
  width: 100%;
}

#panel-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(1.2);
  transform-origin: top center;
  width: 100%;
}

#box-wrapper {
  transform: scale(1.2);
}

.board {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 2px;
  margin: 0 auto;
  width: fit-content;
}

/* === Track & Cell Styles === */
.track {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  gap: 0;
}

.cell {
  width: 75px;
  height: 60px;
  border: 1px solid #aa6640;
  box-sizing: border-box;
  position: relative;
}

.cell.light { background-color: #fcc598; }
.cell.dark  { background-color: #f79951; }

.finish-line-marker {
  width: 75px;
  height: 8px;
  background-color: #fff;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.85) 100%),
    linear-gradient(-45deg, #000 25%, transparent 25%),
    linear-gradient(-135deg, #000 25%, transparent 25%),
    linear-gradient(-45deg, transparent 75%, #000 75%),
    linear-gradient(-135deg, transparent 75%, #000 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0;
  background-blend-mode: multiply;
  border: 1px solid #aa6640;
  box-sizing: border-box;
}

/* === Horse image === */
.race-number {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin-top: 10px;
  margin-bottom: 5px;
}

/* === Tokens === */
.tokens {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.token {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  position: absolute;
  transition: top 0.3s ease, left 0.3s ease;
  border: 2.9px solid black;
}

/* Player colors */
.token.p1 { background-color: #ff5c5c; }
.token.p2 { background-color: #2ec46c; }
.token.p3 { background-color: #42b0f5; }
.token.p4 { background-color: #ffcc4d; }

.player-label.p1 { color: #ff5c5c; }
.player-label.p2 { color: #2ec46c; }
.player-label.p3 { color: #42b0f5; }
.player-label.p4 { color: #ffcc4d; }

/* === Button Styles === */
#roll-btn,
.combo-btn {
  font-family: 'Lora', serif;
  font-size: 1.25rem;
  padding: 12px 24px;
  border-radius: 8px;
  background-color: #ffb070;
  color: #fffdf0;
  border: 2px solid #aa6640;
  cursor: pointer;
  margin-bottom: 15px;
  transition: background-color 0.3s ease;
}

#roll-btn:hover,
.combo-btn:hover {
  background-color: #ffa057;
  color: #333;
}

#restart-btn {
font-family: 'Lora', serif;
  font-size: 1.25rem;
  padding: 12px 24px;
  border-radius: 8px;
  background-color: #fffdf0;
  color: #aa6640;
  border: 2px solid #ffb070;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background-color 0.3s ease;
}


.combo-btn {
  margin: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  font-size: 1rem;
  border-radius: 6px;
  font-weight: bold;
  flex-shrink: 0;   
  flex-grow: 0;  
  box-sizing: border-box;
  display: inline-block;
  vertical-align: middle;
}

.combo-btn:active,
.combo-btn:focus {
  transform: none !important;
  padding: 6px 12px;
  border: 2px solid #aa6640; 
  outline: none;           
  box-shadow: none;         
  background-color: #ffb070; 
  color: #fffdf0;
}


button.combo-btn.disabled-combo {
  background-color: #ccc;
  color: #666;
  cursor: not-allowed;
}

/* === Dice === */
.dice-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.die {
  width: 48px;
  height: 48px;
  background-color: #fffdf0;
  border: 2px solid #aa6640;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: bold;
  margin-top: 10px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lora', serif;
  animation: roll 0.4s ease-in-out;
}

@keyframes roll {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(90deg); }
  50%  { transform: rotate(180deg); }
  75%  { transform: rotate(270deg); }
  100% { transform: rotate(360deg); }
}

/* === Turn / Output === */
#race-output, #dice-output {
  display: block;
  margin: 0 auto;
  text-align: center;
  margin-bottom: 10px;
}

.no-combos-msg {
  margin-top: 10px;
  font-style: italic;
  color: #555;
}

/* === Highlight Completed Race === */
.cells.completed {
  position: relative;
  border-radius: 4px;
  overflow: visible;
  transition: background-color 0.3s ease;
  outline: 6px solid;
  outline-offset: -2px;
  /* outline-color: black !important; */
}


.game-over-banner {
  font-family: 'Lora', serif;
  background-color: #ffb070;
  color: #fffdf0;
  border: 2px solid #aa6640;
  padding: 14px 24px;
  margin-top: 20px;
  font-size: 1.5rem;
  font-weight: bold;
  border-radius: 10px;
  display: inline-block;
  animation: fadeIn 0.5s ease-out;
}

@keyframes token-glow {
  0% {
    box-shadow: 0 0 3px 2px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
  }
  100% {
    box-shadow: none;
    transform: scale(1);
  }
}

.token.glow {
  animation: token-glow 0.4s ease-out;
  z-index: 3000;
}


select#player-count {
  font-family: 'Lora', serif;
  padding: 1px;
  border: 2px solid #aa6640;
  border-radius: 6px;
  background-color: #fffdf0;
  color: #333;
  font-size: 1rem;
  width: 55px;
  text-align: center; 
  text-align-last: center;
  margin-bottom: 10px;
}

select#player-select {
  font-family: 'Lora', serif;
  padding: 1px;
  border: 2px solid #aa6640;
  border-radius: 6px;
  background-color: #fffdf0;
  color: #333;
  font-size: 1rem;
  margin-top: 10px;
  margin-bottom: 10px;
  width: 80px;
  text-align: center;
  text-align-last: center;
}


/* === Scoreboard === */
.score-label {
  font-family: 'Great Vibes', cursive;
  font-size: 1.5rem;
  color: #333;
  font-weight: bold;
  margin-bottom: 4px;
  text-align: center;
}

.final-score-content {
  background: #fffdf0;
  border: 0px solid #333;
  box-shadow: 0 4px 25px rgba(0,0,0,0.2);
  padding: 30px 45px;
  border-radius: 10px;
  text-align: left;
  font-family: 'Lora', serif;
  max-width: 450px;
  width: 90%;
  animation: popIn 0.4s ease;
}

.final-score-content h2 {
  text-align: center; 
}

#final-score-overlay {
  position: fixed; 
  inset: 0; 
  min-height: 100%; 
  min-width: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}


#final-score-overlay.hidden {
  display: none;
}

.score-breakdown {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-family: 'Lora', serif;
}

.score-breakdown th,
.score-breakdown td {
  border: 1px solid #999;
  padding: 6px 12px;
  text-align: center;
}

.score-breakdown th {
  background: #f0e6d6;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

.ai-turn .combo-button {
    pointer-events: none; 
    cursor: default;
}

.ai-turn .combo-button:hover {
    background-color: inherit;
    color: inherit;
}

#bottom-panel {
  max-width: 900px;      
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  gap: 100px;
  box-sizing: border-box;
  align-items: center;
}


/* INITIAL LAYOUT: two columns, left and center only */
#bottom-panel.initial {
  justify-content: center;
}

#bottom-panel.initial .left-side,
#bottom-panel.initial .center-side {
  flex: 1;  /* keep equal widths here since right-side is hidden */
  display: block;
}

#bottom-panel.initial .right-side {
  display: none;
}


/* POST-CLICK layout */
#bottom-panel.post-click .left-side {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}


#bottom-panel.post-click .left-side > div {
  display: flex;          
  align-items: center;
  gap: 8px;               
  white-space: nowrap;    
}

#bottom-panel.post-click .left-side label {
  min-width: 50px;       
  font-size: 14px;
  color: #444;
}

#bottom-panel.post-click .left-side select {
  flex-shrink: 0;
}

#bottom-panel.post-click .center-side {
  flex: 0 0 180px;         
  display: flex;
  justify-content: center; 
  align-items: center;
  gap: 12px;               
  box-sizing: border-box;
  min-width: 160px;        
}

#bottom-panel.post-click .right-side {
  flex: 0 0 220px;         
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

/* MISC */
#roll-btn, #restart-btn {
  width: 160px;           
  min-width: 160px;
  box-sizing: border-box;
  flex-shrink: 0;          
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Keep buttons vertically aligned and avoid unexpected margin/padding jumps */
#roll-btn, #restart-btn, .combo-btn {
  display: inline-block;   
  vertical-align: middle;
}

/* Fix bottom panel container so its size doesn't change */
#bottom-panel {
  min-height: 60px;        
}

/* Optional: Keep dice-container stable size */
.dice-container {
  min-width: 160px;
  min-height: 56px;       
}

/* Prevent buttons from growing unexpectedly on hover or active */
#roll-btn:hover,
.combo-btn:hover,
#restart-btn:hover {
  background-color: #ffa057;
  color: #333;
  transform: none;
}

/* Avoid transform scale or padding changes on active states */
button:active {
  transform: none;
  padding: inherit;
}
