body,
html {
  margin: 0;
  background-color: #000;
  color: #444;
  width: 100%;
  height: 100%;
  border: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

::selection {
  color: white;
}

div {
  color: antiquewhite;
  touch-action: none;
}

h1,
p {
  margin: 0 0 1em;
}

.flex-container {
  display: flex;
  align-items: stretch;
  background-color: #2e9097;
}

.flex-container > div {
  background-color: #1c802d;
  border: 1px;
  color: grey;
}

#snookerScore {
  font-family: var(--font-family-primary);
  font-size: 32px;
  color: yellow;
  text-align: center;
  filter: drop-shadow(0.08em 0.08em black);
}

#snookerScoreOverlay {
  position: absolute;
  bottom: 10px;
  right: 80px;
}

.p1Score,
.p2Score {
  font-size: 12px;
}

.p1Score.is-active,
.p2Score.is-active {
  font-weight: 800;
  filter: brightness(1.2);
}

.breakScore {
  font-size: 32px;
  font-style: italic;
  color: yellow;
  text-align: center;
  margin-top: 0.2em;
}

.view3d {
  width: 100%;
  flex: 1;
  min-height: 0;
  cursor: none;
  caret-color: transparent;
  -webkit-user-drag: none;
  user-select: none;
  position: relative;
}

.view3d:focus {
  outline: none;
}

canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 5px;
  -webkit-user-drag: none;
  user-select: none;
}

.panel {
  width: 100%;
  height: 70px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0;
  padding: 0;
  background: linear-gradient(180deg, #1a2128 0%, #0c1014 100%);
  border-radius: 0;
  border-top: 2px solid rgba(31,138,76,0.55);
  box-sizing: border-box;
  position: relative;
}

.aimControlColumn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  position: relative;
}

.toggleButton {
  height: 100%;
  width: 20%;
  margin-right: 4px;
  aspect-ratio: 0.4;
  border-radius: 10px;
  border-width: 4px;
  padding: 0;
  max-width: 80px;
}

.toggleButton:active,
.menuButton:active {
  transform: scale(0.97);
}

a.pill {
  outline: none;
  background: rgb(0 0 0 / 40%);
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid rgb(255 255 255 / 15%);
  margin: 0;
  padding: 0 8px;
  font-size: 12px;
  height: 30px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

a {
  color: lightblue;
}

.constants {
  background: linear-gradient(#495155, #0b0b0e);
  border-radius: 5px;
  position: fixed;
  right: 0;
  top: 0;
  visibility: hidden;
  padding: 5px;
  border: double;
  max-width: 50%;
  font-size: 12px;
}

.nw {
  display: inline-block;
}

label {
  display: inline-block;
  width: 9ch;
}

/* Bot Debug Overlay */
#botDebugOverlay {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 320px;
  min-height: 30px;
  max-height: 400px;
  background: rgb(0 0 0 / 40%);
  border: 1px solid rgb(255 255 255 / 15%);
  border-radius: 8px;
  padding: 0 8px;
  font-family: var(--font-family-mono);
  font-size: 16px;
  color: #ccc;
  z-index: 2000;
  overflow: hidden;
  display: none;
  box-sizing: border-box;
  align-items: center;
  flex-direction: column;
}

#botDebugOverlay header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  min-height: 30px;
}

#botDebugOverlay header span#botDebugToggle {
  cursor: pointer;
}

#botDebugOverlay header button {
  background: transparent;
  border: 1px solid #666;
  color: #aaa;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
  height: 22px;
}

#botDebugOverlay header button:hover {
  background: #333;
  color: #fff;
}

#botDebugOverlay header div {
  display: flex;
  align-items: center;
  gap: 8px;
}

#botDebugLog {
  margin: 4px 0 0;
  padding: 0;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

#botDebugLog::-webkit-scrollbar {
  width: 8px;
}

#botDebugLog::-webkit-scrollbar-track {
  background: #222;
}

#botDebugLog::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

/* Compact mode */
#botDebugOverlay.compact {
  width: 50px;
  height: 30px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

#botDebugOverlay.compact #botDebugLog {
  max-height: 0;
  overflow: hidden;
}

#botDebugOverlay.compact #botDebugClear {
  display: none;
}

/* Lobster emoji in header */
#botDebugOverlay header > span {
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  position: relative;
  top: -2px;
}

#helpOverlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90%, 380px);
  height: min(90%, 620px);
  background: rgb(0 0 0 / 100%);
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 3000;
  box-shadow: 0 8px 16px rgb(0 0 0 / 75%);
}

#helpOverlay[hidden] {
  display: none !important;
}

#helpOverlay iframe {
  width: 100%;
  flex: 1;
  border: none;
  border-radius: 8px;
}

#analysisOverlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(95%, 820px);
  height: min(92%, 760px);
  background: rgb(0 0 0 / 100%);
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 3000;
  box-shadow: 0 8px 16px rgb(0 0 0 / 75%);
}

#analysisOverlay[hidden] {
  display: none !important;
}

#analysisOverlay iframe {
  width: 100%;
  flex: 1;
  border: none;
  border-radius: 8px;
}

.help-footer {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-top: 1px solid rgb(255 255 255 / 10%);
  justify-content: center;
  align-items: center;
}

.help-text {
  color: #ccc;
  font-size: 0.75rem;
}

.lobby-btn,
#helpClose,
#analysisClose {
  padding: 6px 6px;
  background: rgb(255 255 255 / 10%);
  color: white;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.lobby-btn:hover,
#helpClose:hover,
#analysisClose:hover {
  background: rgb(255 255 255 / 20%);
  border-color: rgb(255 255 255 / 40%);
}

#botDebugLog::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.drill-panel {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: auto;
}

.drill-panel-top {
  top: 10px;
  transform: none;
}

.drill-panel-right {
  left: auto;
  right: 10px;
  top: auto;
  /* .outerMenu (hamburger/camera buttons) overflows 39px above #panel's top
     edge, i.e. above #viewP1's bottom edge; clear that plus a small gap. */
  bottom: 49px;
  transform: none;
}

/* When the elevation panel is open the Hit button shifts up; the drill buttons
   are lifted above it. DrillPanel sets `bottom` inline at runtime by measuring
   the Hit button's actual top; here we just switch to bottom-anchoring. */
.drill-panel.elevation-open {
  top: auto;
  transform: none;
}

/* The 44px spacer aligns Preview with the Hit button when centered; it is not
   needed once the stack is lifted above the elevation panel. */
.drill-panel.elevation-open .drill-gap {
  height: 0;
}

.drill-gap {
  height: 44px;
}

.drill-btn {
  width: 90px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid rgb(255 255 255 / 25%);
  background: rgb(0 30 60 / 75%);
  color: antiquewhite;
  font-size: 13px;
  font-family: var(--font-family-primary, sans-serif);
  cursor: pointer;
  user-select: none;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.drill-btn:not(:disabled):hover {
  background: rgb(0 60 110 / 85%);
  border-color: rgb(255 255 255 / 50%);
}

.drill-btn:not(:disabled):active {
  transform: scale(0.96);
}

.drill-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
