/* Phone / touch layout. Loaded after style.css; overrides its fixed 140px side panels. */

html, body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#menuToggle, #panButton {
  font-size: 13px;
}

/* Tool categories (all screen sizes) */
#controls { height: auto; }
#toolCats { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px 5px; }
.toolCat {
  width: auto; height: auto; min-width: 0;
  flex: 1 1 auto; font-size: 12px; padding: 3px 4px;
  border: 1px solid #888; border-radius: 5px; background: #eee; color: #222;
}
.toolCat.active { background: #1b2a3a; color: #fff; border-color: #1b2a3a; }

/* Colours for the new tool buttons */
#hospitalButton { background-color: #ffe4e4; }
#churchButton { background-color: #f3eee0; }
#windButton { background-color: #e8f8ff; }
#solarButton { background-color: #3a5bd6; color: white; }
#schoolButton { background-color: #c8553a; color: white; }
#libraryButton { background-color: wheat; }
#recyclingButton { background-color: seagreen; color: white; }
#metroButton { background-color: royalblue; color: white; }
#forestButton { background-color: forestgreen; color: white; }
#waterButton { background-color: deepskyblue; }
#landfillButton { background-color: peru; color: white; }

@media (pointer: coarse), (max-width: 900px) {
  #header, #footer, #tooSmall, #debug { display: none !important; }
  #wrapper { top: 0 !important; }
  #canvasContainer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }

  /* Status strip across the top */
  #infobar {
    position: absolute !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    width: auto !important; height: auto !important;
    padding: 2px 8px !important;
    font-size: 12px; line-height: 18px;
    background: rgba(245, 255, 250, 0.9);
    text-align: left !important;
  }
  #infobar .inner { display: flex; flex-wrap: wrap; gap: 0 14px; }
  #infobar .inner > div { display: inline-block; margin: 0 !important; padding: 0 !important; border: 0 !important; }
  #infobar br { display: none; }

  /* RCI demand bars: hidden from the map, opened from Menu > Demand. Kept laid out (visibility, not
     display) because rci.js sizes its canvas from this box on every update. */
  #RCIContainer {
    position: fixed !important;
    top: calc((100% - 84px) / 2 + 12px) !important; left: 50% !important; right: auto !important;
    width: 120px !important; height: 150px !important; padding: 0 !important;
    transform: translate(-50%, -50%) scale(1.2);
    visibility: hidden; z-index: 40;
    border: 2px solid #1b2a3a; border-radius: 8px;
  }
  #rciLabel { display: none; }
  body.rciOpen #RCIContainer { visibility: visible; }
  body.rciOpen #rciLabel {
    display: block; position: fixed; top: calc((100% - 84px) / 2 + 12px); left: 50%; z-index: 41;
    transform: translate(-50%, -118px);
    background: #1b2a3a; color: #fff; font-size: 13px; padding: 3px 10px; border-radius: 6px;
  }
  #rciRequest { display: block !important; background: #2e7d32; color: #fff; }

  /* Menu button + slide-in menu */
  #menuToggle {
    position: absolute; left: 6px; bottom: 90px;
    width: auto !important; height: 40px; padding: 0 12px;
    border-radius: 8px; border: 1px solid #333; background: #1b2a3a; color: #fff;
  }
  #miscButtons {
    display: none !important;
    position: fixed !important;
    top: 28px !important; left: 6px !important; bottom: 136px !important;
    width: 170px !important; overflow-y: auto; padding: 6px !important;
    z-index: 30;
  }
  body.menuOpen #miscButtons { display: block !important; }
  #miscButtons button { width: 100%; height: 38px; margin: 3px 0; font-size: 14px; }

  /* Tool palette: one scrolling row along the bottom */
  #controls {
    position: fixed !important;
    top: auto !important; bottom: 0 !important; left: 0 !important; right: 0 !important;
    width: auto !important; height: 84px !important;
    padding: 0 0 3px !important;
    overflow: hidden;
  }
  #toolCats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 3px 4px; height: 30px; box-sizing: border-box; }
  #toolCats::-webkit-scrollbar { display: none; }
  #toolCats .toolCat { flex: 1 0 auto; font-size: 12px; padding: 2px 10px; height: 24px; }
  #buttons { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #toolInfo { display: none; }
  #buttons { display: flex; flex-wrap: nowrap; gap: 4px; padding: 0 4px; height: 46px; }
  #buttons button {
    flex: 0 0 auto;
    width: 74px !important; margin: 0 !important; padding: 2px !important;
    height: 46px; font-size: 11px; line-height: 13px;
    white-space: normal; overflow-wrap: anywhere;
    border: 1px solid #666; border-radius: 6px;
  }
  #buttons button.selected { border: 3px solid #000; font-weight: bold; }
  #panButton { background: #e0e0e0; color: #000; }

  #notifications {
    top: 28px !important; bottom: auto !important;
    left: 50% !important; right: auto !important;
    transform: translateX(-50%) !important;
    max-width: 60vw;
  }

  /* Dialogs must fit a phone screen */
  .modal, #splash, #start {
    max-width: 96vw !important; max-height: 94vh !important; overflow: auto;
  }
  .modal button, #splash button, #start input[type=submit] { min-height: 40px; }

  /* Query window: two columns that fit the screen instead of a fixed 620px list */
  .queryList { width: auto !important; padding: 0 12px !important; }
  .queryList dt.queryItem { width: 30%; vertical-align: top; }
  .queryList dd.queryItem { width: 66%; margin: 0; vertical-align: top; }
}

#rciRequest { display: none; }

/* Pinch zoom stretches the map canvas; up to a pixel can poke past the edge */
#canvasContainer { overflow: hidden; }

/* Buildings the city hasn't unlocked yet */
.toolButton.locked { opacity: 0.5; filter: grayscale(0.8); }
.lockLabel { display: none; pointer-events: none; font-size: 9px; line-height: 11px; white-space: nowrap; }
.toolButton.locked .lockLabel { display: block; }
.congratsExtra { margin-top: 8px; font-weight: bold; }
#gameVersion { font-size: 11px; color: #555; margin-top: 6px; }
#autosaveNote { font-size: 11px; color: #2e7d32; margin-top: 6px; }
#updateBanner {
  position: fixed; top: 30px; left: 50%; transform: translateX(-50%); z-index: 300;
  width: auto; height: auto; padding: 10px 16px; font-size: 14px;
  background: #ffcc00; color: #000; border: 2px solid #000; border-radius: 8px;
}

.transferButton { background: #546e7a; color: #fff; }
#getApp { display: block; text-align: center; line-height: 38px; height: 38px; margin: 3px 0; border-radius: 3px; background: #3ddc84; color: #073042; font-weight: bold; text-decoration: none; font-size: 14px; }

/* Portrait phones: stack the opening screens vertically */
@media (orientation: portrait) and (max-width: 600px) {
  #splash, #start { width: 92vw !important; height: auto !important; box-sizing: border-box; }
  #splashContainer, #splashButtonContainer, #splashButtons { position: static !important; }
  #splashContainer { width: 100%; margin: 8px 0; }
  #SplashCanvas { width: 100%; height: auto; display: block; }
  #splashButtons { display: flex; gap: 6px; }
  #splashButtons .splashButton { flex: 1 1 0; width: auto !important; margin: 0 !important; height: 48px; font-size: 13px; }
  #start label, #start input[type=radio] { font-size: 16px; }

  /* In-game: the status strip wraps to two lines, so start panels below it; fit all six tabs */
  #miscButtons { top: 46px !important; height: auto !important; max-height: calc(100% - 190px) !important; }
  #toolCats .toolCat { padding: 2px 5px !important; font-size: 12px; }
}
