/* Status panel (LED counters, inventory, hint box), D-pad and action
   buttons, plus the portrait / landscape / desktop arrangements of the
   play stage. */

.cc-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px 0;
  border-top: 2px solid var(--cc-dark);
}

.cc-panel {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
}

.cc-counters {
  display: flex;
  gap: 4px;
}

.cc-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  border: 1px solid #000000;
  box-shadow: var(--cc-raised);
}

.cc-counter-label {
  font-size: 0.6em;
  font-weight: 700;
  white-space: nowrap;
}

.cc-led,
.cc-inventory {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.cc-led {
  width: 51px;
  height: 28px;
}

.cc-inventory {
  width: 128px;
  height: 64px;
  border: 2px solid var(--cc-dark);
  border-right-color: #ffffff;
  border-bottom-color: #ffffff;
}

.cc-hint {
  width: 190px;
  max-height: 68px;
  overflow-y: auto;
  padding: 4px 6px;
  background: #000000;
  color: #00ffff;
  box-shadow: var(--cc-sunken);
  font-size: 0.68em;
  line-height: 1.3;
  text-align: left;
  touch-action: pan-y;
}

.cc-hint p {
  margin: 0;
}

.cc-hint-title {
  color: #ffff00;
  font-weight: 700;
}

.cc-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.cc-pad {
  --pad: 54px;
  display: grid;
  grid-template-columns: repeat(3, var(--pad));
  grid-template-rows: repeat(3, var(--pad));
  gap: 2px;
  touch-action: none;
}

.cc-pad-btn {
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: none;
}

.cc-pad-btn:active {
  padding: 2px 0 0 2px;
}

.cc-pad-up {
  grid-area: 1 / 2;
}

.cc-pad-left {
  grid-area: 2 / 1;
}

.cc-pad-center {
  grid-area: 2 / 2;
  background: var(--cc-grey);
  box-shadow: var(--cc-sunken);
}

.cc-pad-right {
  grid-area: 2 / 3;
}

.cc-pad-down {
  grid-area: 3 / 2;
}

.cc-arrow {
  width: 18px;
  height: 14px;
  background: #000000;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.cc-pad-left .cc-arrow {
  transform: rotate(-90deg);
}

.cc-pad-right .cc-arrow {
  transform: rotate(90deg);
}

.cc-pad-down .cc-arrow {
  transform: rotate(180deg);
}

.cc-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-actions .cc-btn {
  min-width: 8.75em;
}

/* Portrait tablets: room for full-size counters. */
@media (orientation: portrait) and (min-width: 600px) {
  .cc-led {
    width: 102px;
    height: 56px;
  }

  .cc-counter-label {
    font-size: 0.8em;
  }

  .cc-inventory {
    width: 192px;
    height: 96px;
  }

  .cc-hint {
    width: 330px;
    max-height: 100px;
    font-size: 0.85em;
  }
}

/* Landscape, tablets and desktop: Windows 3.1 layout, panel on the right. */
@media (orientation: landscape) and (min-width: 560px) {
  .cc-stage {
    flex-direction: row;
  }

  .cc-board-host {
    margin-inline: 0;
  }

  .cc-side {
    width: clamp(230px, 30vw, 300px);
    justify-content: center;
    gap: 12px;
    padding: 8px 0 0 8px;
    border-top: 0;
    border-left: 2px solid var(--cc-dark);
    overflow-y: auto;
  }

  .cc-panel {
    flex-direction: column;
    align-items: center;
  }

  .cc-counters {
    flex-direction: column;
    gap: 6px;
  }

  .cc-counter {
    flex-direction: row;
    justify-content: space-between;
    gap: 10px;
    min-width: 190px;
    padding: 4px 6px;
  }

  .cc-counter-label {
    font-size: 0.8em;
  }

  .cc-led {
    width: 102px;
    height: 56px;
  }

  .cc-hint {
    width: 200px;
    height: 198px;
    max-height: none;
    font-size: 0.8em;
  }

  .cc-inventory {
    width: 192px;
    height: 96px;
  }

  .cc-controls {
    flex-direction: column;
    gap: 10px;
  }

  .cc-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .cc-actions .cc-btn {
    min-width: 0;
  }
}

/* Short landscape screens (phones): two compact columns. */
@media (orientation: landscape) and (min-width: 560px) and (max-height: 560px) {
  .cc-side {
    width: auto;
    display: grid;
    grid-template-columns: auto auto;
    align-content: center;
    gap: 8px;
  }

  .cc-counter {
    min-width: 0;
    padding: 2px 4px;
  }

  .cc-counter-label {
    font-size: 0.6em;
  }

  .cc-led {
    width: 51px;
    height: 28px;
  }

  .cc-counters {
    gap: 3px;
  }

  .cc-hint {
    width: 128px;
    height: 112px;
    font-size: 0.65em;
  }

  .cc-inventory {
    width: 128px;
    height: 64px;
  }

  .cc-pad {
    --pad: 44px;
  }

  .cc-actions {
    flex-direction: column;
  }

  .cc-actions .cc-btn {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.75em;
  }

  /* Restart and Levels are in the pause menu: room for the D-pad. */
  [data-id="chips-restart-button"],
  [data-id="chips-levels-button"] {
    display: none;
  }
}

/* Desktop and TV: the panel grows with the screen height. */
@media (min-width: 960px) and (min-height: 500px) {
  .cc-side {
    width: max(300px, 30dvh);
    gap: 2dvh;
  }

  .cc-counter {
    min-width: max(190px, 19dvh);
  }

  .cc-led {
    width: max(102px, 9.6dvh);
    height: max(56px, 5.3dvh);
  }

  .cc-inventory {
    width: max(192px, 18dvh);
    height: max(96px, 9dvh);
  }

  .cc-hint {
    width: max(200px, 19dvh);
    height: max(198px, 18dvh);
  }

  .cc-pad {
    --pad: max(54px, 6dvh);
  }
}

/* Mouse and keyboard: no on-screen D-pad. */
@media (hover: hover) and (pointer: fine) {
  .cc-pad {
    display: none;
  }
}
