body{
  margin: 0;
  padding: 0;
  font-family: 'Rubik', sans-serif;
  overflow: hidden;
}

.center {
  margin: 0 auto;
  width: 80%;
}

.hide {
  display: none !important;
}

#gameHud {
  z-index: 2;
  position: absolute;
  width: 100%;
  height: 100%;
}

#playBtn{
  position: absolute;
  color: white;
  background-color: #123ecd;
  border-radius: 8px;
  border: none;
  padding: 10px;
  font-size: 30px;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
}

#playBtn:hover{
  border: 3px solid #fff;
}

#playBtn.small{
  font-size: 14px;
  padding: 6px 12px;
  bottom: auto;
  top: 10px;
  left: 10px;
  transform: none;
}

#modeBtn{
  position: absolute;
  color: white;
  background-color: #0a7d4f;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  top: 10px;
  left: 105px;
  z-index: 11;
}

#modeBtn:hover{
  border: 3px solid #fff;
}

#freecamBtn{
  position: absolute;
  color: white;
  background-color: #6a2fb5;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  top: 10px;
  left: 200px;
  z-index: 11;
}

#freecamBtn:hover{
  border: 3px solid #fff;
}

#freecamBtn.active{
  background-color: #9900aa;
}

#cueBtn{
  position: absolute;
  color: white;
  background-color: #b5541b;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  top: 10px;
  left: 295px;
  z-index: 11;
}

#cueBtn:hover{
  border: 3px solid #fff;
}

#cueBtn.active{
  background-color: #e07a2a;
}

/* Cue-stick mode settings: the two aim-line toggles and cue elevation. */
#cuePanel{
  position: absolute;
  top: 48px;
  left: 10px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 180px;
  padding: 10px;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.55);
  color: #dadada;
  font-size: 12px;
}

/* Drawer header: always visible, tap to expand/collapse the settings. */
#cuePanelToggle{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

#cuePanelBody{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#cuePanel.collapsed{
  width: auto;
}

#cuePanel.collapsed #cuePanelBody{
  display: none;
}

#cuePanel label{
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#elevLabel{
  margin-top: 2px;
}

#elevSlider{
  width: 100%;
  margin: 0;
}

/* Cue-ball spin selector, bottom-right during normal play. */
#spinControl {
  position: absolute;
  right: 14px;
  bottom: 84px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.4);
  touch-action: none;
}

#spinCanvas {
  width: 96px;
  height: 96px;
  cursor: crosshair;
  touch-action: none;
}

#spinPresets {
  display: flex;
  gap: 4px;
}

#spinPresets button {
  border: none;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  color: #fff;
  background-color: rgba(255, 255, 255, 0.16);
}

#spinPresets button:active {
  background-color: rgba(255, 255, 255, 0.35);
}

@media (max-width: 600px) {
  #spinControl { bottom: 130px; padding: 6px; }
  #spinCanvas { width: 76px; height: 76px; }
}

/* On-screen fly pad, shown only in free-cam mode. */
#freecamControls {
  position: absolute;
  bottom: 24px;
  right: 16px;
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 48px);
  gap: 6px;
  z-index: 11;
  touch-action: none;
}

/* ▲ back ▼ ◀ ▶  laid out as a d-pad, with +/- for altitude */
#fcForward { grid-column: 2; grid-row: 1; }
#fcLeft    { grid-column: 1; grid-row: 2; }
#fcBack    { grid-column: 2; grid-row: 2; }
#fcRight   { grid-column: 3; grid-row: 2; }
#fcUp      { grid-column: 3; grid-row: 1; }
#fcDown    { grid-column: 1; grid-row: 1; }

#freecamControls button {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: none;
  background-color: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  touch-action: none;
}

#freecamControls button:active {
  background-color: rgba(153, 0, 170, 0.85);
}

#help {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 280px;
  padding: 8px 12px;
  background-color: rgba(0, 0, 0, 0.55);
  color: #dadada;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #000;
  z-index: 5;
}

#help h5 {
  margin: 0 0 4px;
}

#help ul {
  margin: 0;
  padding-left: 16px;
}

#mobileControls {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 11;
  touch-action: manipulation;
}

#mobileControls button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
}

#mobileControls button:active {
  background-color: rgba(0, 0, 0, 0.8);
}

#cancelBtn {
  background-color: rgba(153, 0, 0, 0.75) !important;
}

@media (max-width: 600px) {
  #help {
    top: 45px;
    left: 10px;
    right: 10px;
    width: auto;
    font-size: 11px;
  }

  #cuePanel {
    width: 150px;
    font-size: 11px;
    padding: 8px;
  }

  /* When the cue-stick panel is open (and expanded) it owns the top-left
     corner — slide the help sheet down so the two don't stack on each other. */
  #cuePanel:not(.hide):not(.collapsed) ~ #help {
    top: 185px;
  }
}

/* Touch button bar is only useful without a keyboard — hide past tablet width. */
@media (min-width: 1025px) {
  #mobileControls {
    display: none !important;
  }
}

#message {
  position: absolute;
  padding-top: 15%;
  width: 100%;
  background-color: rgba(13, 198, 18, 0.5);
  z-index: 10;
  height: 100%;
  text-align: center;
  color: #eaeaea;
}

/* breaks accessibility but these look ugly */
* {
  outline: none !important;
}

.player {
  padding-top: 1rem;
  border-radius: 5px;
  border: 1px solid #000;
  display: block;
  position: absolute;
  width: 200px;
  top: 5px;
  text-align: center;
  background-color: rgba(128, 128, 128, 0.75);
  border-color: rgb(128, 128, 128);
}

.player ul {
  display: inline-block;
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.player ul li {
  float: left;
  padding: 0;
  margin: 0 3px;
  width: 20px;
  height: 22px;
  text-align: center;
  display: block;
  border-radius: 20px;
}

.player ul li.pocketed {
  background-color: #3d3d3d;
}

.player1 {
  left: 5px;
  background-color: #0055cc;
}

.player.active {
  background-color: rgba(152, 251, 152, 0.75);
  border-color: rgb(152, 251, 152);
}

.player2 {
  right: 5px;
  background-color: #ffa500;
}

.player h5 {
  margin: 0;
  padding: 0;
  margin-top: 2px;
  margin-left: 3px;
  margin-bottom: 3px;
  color: #eaeaea;
}

.gamelog {
  padding: 0 10px;
  margin: 0;
  margin-left: 10px;
  color: #dadada;
  background-color: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  border: 1px solid #000;
  display: block;
  position: absolute;
  width: 300px;
  height: 20px;
  bottom: 10px;
  left: 5px;
  text-align: left;
  z-index: 2;
}

.gamelog:hover {
  height: 130px;
}

.gamelog li {
  display: none;
}

.gamelog li:nth-last-child(-n+1) {
  display: block;
}

.gamelog:hover li:nth-last-child(-n+6) {
  display: block;
}

.gamelog li {
  margin: 0;
  padding: 0;
  margin-top: 0px;
}

.timer {
  background-color: rgba(255, 255, 255, 0.75);
  border-radius: 3px;
  border: 1px solid #000;
  display: block;
  position: absolute;
  width: 50px;
  height: 50px;
  bottom: 10px;
  right: 10px;
  text-align: center;
  font-size: 36px;
  z-index: 1;
}

.player.solid span:before {
  content: 'Solid';
}

.player.striped span:before {
  content: 'Striped';
}
.player.unknown span:before {
  content: '?';
}

.player ul li {
  font-size: 10px;
  line-height: 19px;
  text-align: center;
}

.player ul li::after {
  display: block;
  background-color: white;
  width: 12px;
  height: 12px;
  border-radius: 12px;
  margin-top: -15px;
  content: '';
  margin-left: 4px;
  z-index: 10;
}

.player.striped ul li::before {
  background-image: linear-gradient(#fff 13%, transparent 13%, transparent 87%, #fff 13%);
}

.player.solid ul li::before {
  background-image: none;
}

.player ul li::before {
  display: block;
  border: 1px solid #000;
  width: 20px;
  height: 20px;
  border-radius: 20px;
  margin-top: 0;
  content: '';
  margin-bottom: -20px;
}

.player ul li:nth-child(1) {
  background-color: #f5c61f;
}

.player ul li:nth-child(2) {
  background-color: #123ecd;
}

.player ul li:nth-child(3) {
  background-color: #cd1b12;
}

.player ul li:nth-child(4) {
  background-color: #8412cd;
}

.player ul li:nth-child(5) {
  background-color: #ff7f00;
}

.player ul li:nth-child(6) {
  background-color: #269c0f;
}

.player ul li:nth-child(7) {
  background-color: #a20000;
}

.player ul li.pocketed {
  opacity: 0.5;
}

.player.unknown ul li {
  background-color: #3d3d3d;
}
