/* Reset margins/paddings */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body: full viewport, vertical layout, center horizontally */
body {
  display: flex;
  flex-direction: column;
  align-items: center;       /* center buttons + board horizontally */
  justify-content: flex-start;
  min-height: 100vh;
  min-width: 100vw;
  background: black;
  color: white;
  font-family: sans-serif;
  overflow-x: hidden;
}

/* UI buttons container */
#uiContainer {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

/* Button styling: uniform 14px font */
button {
  font-size: 14px;
  font-family: sans-serif;
  font-weight: normal;
  padding: 2px;
  border-radius: 8px;
}

/* Main game container - use grid for precise control */
#gameContainer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-start;
  width: 100%;
  margin: 20px auto;
  gap: 0 30px;
  padding: 0 20px;
  max-width: none;
  box-sizing: border-box;
}

/* Left column: holds canvas - place in middle grid cell (column 2) */
#leftColumn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
  grid-column: 2;
}

/* Canvas container: center canvas */
#canvasContainer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
  height: auto;
  /* Will be sized dynamically by JavaScript */
  flex-shrink: 0;
}

/* Canvas itself - remove all margin/padding */
#canvasContainer canvas {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  image-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Sidebar: positioned next to the board */
#sidebar {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: white;
  flex-shrink: 0;
  padding-top: 0;
  align-self: flex-start;  /* Align to top */
  margin-top: 60px;  /* Account for canvas title area (60px translate) */
  grid-column: 3;
}

/* Timer container */
#timerContainer {
  color: white;
  font-size: 14px;
  font-family: sans-serif;
  font-weight: normal;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

#timerText {
  width: 100%;
}

#timerContainer button {
  padding: 4px 10px;
  font-size: 12px;
  background-color: white;
  color: black;
  border: 1px solid black;
  border-radius: 8px;
  cursor: pointer;
  font-weight: normal;
}

/* Prediction container: keep centered inside sidebar */
#predictionContainer {
  width: 100%;
  text-align: center;
  font-size: 14px;
  font-family: sans-serif;
  font-weight: normal;
}

/* Score container: highscore, bottom of sidebar */
#scoreContainer {
  width: 100%;
  text-align: left;
  color: white;
  font-size: 14px;
  font-family: sans-serif;
  font-weight: normal;
}

/* Mobile responsiveness */
@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  #uiContainer {
    margin-top: 10px;
    flex-wrap: wrap;
    gap: 8px;
  }

  button {
    font-size: 13px;
    padding: 6px 10px;
  }

  #gameContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin: 10px auto;
    gap: 15px;
    padding: 0;
  }

  #leftColumn {
    width: 100%;
    align-items: center;
    grid-column: auto;
  }

  #canvasContainer {
    width: 100%;
    /* Hide board title on mobile by reducing top padding */
  }

  /* Hide the board title text by making canvas viewport smaller */
  #canvasContainer canvas {
    margin-top: -30px;
  }

  #sidebar {
    width: 100%;
    flex-direction: row;
    gap: 10px;
    text-align: center;
    margin-top: 0;
    grid-column: auto;
  }

  #timerContainer,
  #predictionContainer,
  #scoreContainer {
    flex: 1;
    font-size: 14px;
    text-align: center;
  }
}

/* Starting Image Overlay */
#startingImageOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgb(0, 0, 0);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100001;
  font-family: sans-serif;
  cursor: pointer;
  overflow: hidden;
}

#startingImageOverlay.hidden {
  display: none;
}

.starting-content {
  text-align: center;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 90%;
  max-height: 90vh;
}

.starting-content img {
  max-width: 90%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

.starting-text p {
  font-size: 12px;
  color: #aaa;
  max-width: 600px;
  margin-bottom: 8px;
}

/* Hard Mode Loading Overlay */
#hardModeLoadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100000;
  font-family: sans-serif;
  overflow: hidden;
}

#hardModeLoadingOverlay.hidden {
  display: none;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-content h2 {
  font-size: 24px;
  margin-bottom: 15px;
  font-weight: normal;
}

.loading-content p {
  font-size: 14px;
  margin-bottom: 30px;
  color: #aaa;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

