body {
  background: #1a1a2e;
  transition: background 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  font-family: sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
button {
  padding: 8px 24px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background: #3a3a5c;
  color: #fff;
  touch-action: manipulation; /* suppress double-tap-to-zoom when tapping options quickly */
}
button:hover {
  background: #4a4a7c;
}

.hidden {
  display: none !important;
}

#homePage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#homeBtn {
  position: fixed;
  top: 12px;
  left: 12px;
  font-size: 28px;
  color: #aaa;
  text-decoration: none;
  line-height: 1;
  z-index: 10;
}
#homeBtn:hover {
  color: #fff;
}

body.player-b {
  background: #230913;
}

body.clue-choice-mode {
  background: #230913;
}

body.player-b.clue-choice-mode {
  background: #1a1a2e;
}

#timerDisplay {
  font-family: monospace;
  color: #888;
  text-align: center;
  cursor: pointer;
  margin-top: 8px;
  font-size: 16px;
  user-select: none;
}

/* Popup */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.popup-overlay.hidden {
  display: none;
}
.popup {
  background: rgba(42, 42, 74, 0.82);
  border-radius: 10px;
  padding: 24px;
  min-width: 260px;
  color: #fff;
}
.popup h3 {
  margin: 0 0 16px;
  text-align: center;
}
.input-mode-toggle {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  background: #1f1f3a;
  border-radius: 6px;
  padding: 3px;
}
.input-mode-btn {
  flex: 1;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #aaa;
  cursor: pointer;
}
.input-mode-btn.active {
  background: #3a3a6a;
  color: #fff;
}
.popup-section {
  margin-bottom: 16px;
}
.popup-section label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: #aaa;
}
.digit-picker {
  display: flex;
  gap: 8px;
}
.digit-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: #3a3a5c;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
}
.digit-btn.selected {
  border-color: #fff;
}
.color-picker {
  display: flex;
  gap: 8px;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.clear-btn {
  font-size: 18px;
  color: #aaa;
}
.color-swatch.selected {
  border-color: #fff;
}
.popup-error {
  color: #ff6b6b;
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
}
.popup-error.hidden {
  display: none;
}
.popup-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
#popupOk {
  width: 145px;
}
#popupOk.solve-mode {
  background: #2563eb;
}
#popupOk.solve-mode:hover {
  background: #1d4ed8;
}
.clear-action-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.invisible {
  visibility: hidden;
}
#confirmAccept {
  background: #8a3a3a;
}
#confirmAccept:hover {
  background: #6a2a2a;
}

/* Fixture list */
.fixture-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.fixture-list button {
  text-align: left;
  padding: 8px 12px;
  font-size: 14px;
}

select {
  padding: 8px 12px;
  font-size: 16px;
  border: none;
  border-radius: 6px;
  background: #3a3a5c;
  color: #fff;
  cursor: pointer;
}

#gamePage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100vh;
  padding: 0 8px;
  box-sizing: border-box;
}

#board {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

#board svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Clickable tiles */
.hex-tile {
  cursor: pointer;
}
.hex-tile:hover {
  opacity: 0.85;
}

#belowBoardContainer {
  min-height: 140px;
}

#messageContainer {
  margin-top: 48px;
  margin-bottom: 24px;
  height: 70px;
}

/* Hint button */
#hintBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  font-size: 24px;
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  padding: 0;
}
#hintBtn:hover {
  color: #fff;
}

/* Hint mode */
body.hint-mode {
  background: #2a1f1a;
}

#hintPanel {
  text-align: center;
  margin: 5px;
  width: 300px;
  max-width: 100%;
}
#hintPanel button:not(.hint-candidate-btn) {
  padding: 8px 12px;
  white-space: nowrap;
}
.hint-button-row {
  display: flex;
  margin-top: 8px;
}
.hint-right-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.hint-action-slot {
  width: 96px;
  display: flex;
}
.hint-action-slot button {
  flex: 1;
}

.hint-info {
  font-size: 14px;
  color: #ddd;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 4px 0 8px;
  line-height: 1.8;
}

.hint-candidate-btn {
  display: inline-block;
  min-width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid #555;
  background: #3a3a5c;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 4px;
  margin: 0 2px;
  vertical-align: middle;
}
.hint-candidate-btn:hover {
  opacity: 0.75;
}

#manualBtn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a6a3a;
}
#manualBtn:hover {
  background: #2a5a2a;
}

/* Manual page */
body.manual {
  justify-content: flex-start;
  padding: 24px 24px 96px;
  box-sizing: border-box;
}
.manual-container {
  max-width: 600px;
  width: 100%;
  color: #fff;
}
.manual-page img {
  max-width: 100%;
  max-height: 55vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  margin: 16px auto;
  display: block;
}
.manual-nav-row {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 600px;
  align-items: center;
  margin-top: 0;
  background: #1a1a2e;
}
.manual-close {
  padding: 8px 24px;
  font-size: 16px;
  border-radius: 6px;
  background: #3a3a5c;
  color: #fff;
  text-decoration: none;
  display: inline-block;
}
.manual-close:hover {
  background: #4a4a7c;
}
.manual-page-indicator {
  flex: 1;
  text-align: center;
  color: #aaa;
  font-size: 14px;
}

/* Mode selector buttons */
.mode-btn {
  padding: 8px 20px;
  font-size: 14px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: #3a3a5c;
  color: #aaa;
}
.mode-btn-active {
  border-color: #6af;
  color: #fff;
  background: #3a3a6a;
}

/* Rotate-to-portrait overlay (browser fallback; manifest handles installed PWA) */
#rotateOverlay {
  display: none;
}
@media (max-width: 900px) and (orientation: landscape) {
  #rotateOverlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
    background: #1a1a2e;
    color: #fff;
    font-size: 18px;
  }
  #rotateOverlay .rotate-icon {
    font-size: 64px;
    animation: rotate-hint 1.6s ease-in-out infinite;
  }
}
@keyframes rotate-hint {
  0%, 40% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}
