/* The setup and tile-picker screens inherit the exact visual language of choix.css. */
.nomon-explanation {
  position: relative;
  width: min(760px, calc(100vw - 40px));
  max-height: min(82vh, 760px);
  margin: auto;
  padding: 24px 30px;
  overflow-y: auto;
  color: #333;
  text-align: left;
  background: #fff;
  border: 5px solid #009688;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.nomon-explanation h3 { margin: 0 0 5px; color: #00796b; }
.nomon-explanation p { margin: 10px 0 0; line-height: 1.4; }
.nomon-explanation h3 + p { margin-top: 0; }
.nomon-source-link a { color: #00796b; font-weight: bold; text-decoration: underline; }
.explanation-button { display: block; min-width: 240px; margin: 16px auto; padding: 14px 32px; font-size: 20px; font-weight: bold; }
.explanation-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .78);
  box-sizing: border-box;
}
.explanation-overlay[hidden] { display: none !important; }
.explanation-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 42px;
  height: 42px;
  color: #fff;
  background: #00796b;
  border: 0;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.nomon-options { justify-content: center !important; }
.nomon-options #game-options-controls { min-width: 150px; flex-direction: column; }
#category-filter, #control-panel-instructions { margin: 10px 0; }
.source-select { min-width: 150px; padding: 6px; border: 2px solid #009688; border-radius: 6px; }
.source-import-controls { width: 100%; margin: 4px 0 12px; text-align: center; }
.nomon-options [hidden], .source-import-controls[hidden] { display: none !important; }
#youtube-import-controls { align-items: center; justify-content: center; gap: 8px; }
#youtube-import-controls .control-panel-input { max-width: 520px; }

#nomon-game {
  width: 100vw;
  height: 100vh;
  padding: 18px;
  background: #000;
  box-sizing: border-box;
  overflow: hidden;
}
#nomon-game[hidden] { display: none; }

#video-grid {
  --grid-gap: clamp(12px, 2vw, 28px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  justify-content: center;
  gap: var(--grid-gap);
  width: 100%;
  height: 100%;
  max-width: 1500px;
  min-height: 0;
  margin: auto;
  box-sizing: border-box;
}
#video-grid.count-3 {
  --grid-gap: clamp(28px, 5vw, 80px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  max-width: 1050px;
}
#video-grid.count-3 .nomon-tile { grid-column: span 2; }
#video-grid.count-3 .nomon-tile:nth-child(3) { grid-column: 2 / span 2; }
#video-grid.count-4 {
  --grid-gap: clamp(28px, 5vw, 80px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  max-width: 1050px;
}
#video-grid.count-5, #video-grid.count-6 {
  --grid-gap: clamp(24px, 4vw, 65px);
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  max-width: 1250px;
}
#video-grid.count-5 .nomon-tile, #video-grid.count-6 .nomon-tile { grid-column: span 2; }
#video-grid.count-5 .nomon-tile:nth-child(4) { grid-column: 2 / span 2; }
#video-grid.count-5 .nomon-tile:nth-child(5) { grid-column: 4 / span 2; }
#video-grid.count-7, #video-grid.count-8 {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
#video-grid.count-7 .nomon-tile, #video-grid.count-8 .nomon-tile { grid-column: span 2; }
#video-grid.count-7 .nomon-tile:nth-child(5) { grid-column: 2 / span 2; }
#video-grid.count-7 .nomon-tile:nth-child(6) { grid-column: 4 / span 2; }
#video-grid.count-7 .nomon-tile:nth-child(7) { grid-column: 6 / span 2; }
#video-grid.count-9 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  max-width: 1250px;
}
#video-grid.count-10, #video-grid.count-11 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
#video-grid.count-10 .nomon-tile, #video-grid.count-11 .nomon-tile { grid-column: span 2; }
#video-grid.count-10 .nomon-tile:nth-child(9) { grid-column: 3 / span 2; }
#video-grid.count-10 .nomon-tile:nth-child(10) { grid-column: 5 / span 2; }
#video-grid.count-11 .nomon-tile:nth-child(9) { grid-column: 2 / span 2; }
#video-grid.count-11 .nomon-tile:nth-child(10) { grid-column: 4 / span 2; }
#video-grid.count-11 .nomon-tile:nth-child(11) { grid-column: 6 / span 2; }

.nomon-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #111 center / cover no-repeat;
  border: 4px solid #fff;
  border-radius: 8px;
  transition: opacity .2s, border-color .2s, transform .2s;
}
.nomon-tile .caption {
  position: absolute;
  inset: auto 0 0;
  min-height: 45px;
  padding: 8px 62px 8px 10px;
  color: #fff;
  background: rgba(0, 0, 0, .72);
  font-size: clamp(.72rem, 1.15vw, 1rem);
  font-weight: bold;
}
.nomon-tile.shortlisted { border-color: #ffeb3b; box-shadow: inset 0 0 0 3px #ffeb3b; z-index: 2; }
.nomon-tile.eliminated { opacity: .22; filter: grayscale(1); }
.nomon-tile.confirmed { border-color: #00e5c3; box-shadow: inset 0 0 0 4px #00e5c3; }

.nomon-clock {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: clamp(60px, 5.5vw, 82px);
  height: clamp(60px, 5.5vw, 82px);
  background: #fff;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #111, 0 3px 9px #000;
}
.nomon-clock::before { content: ""; position: absolute; z-index: 1; top: -4px; bottom: auto; left: 50%; width: 4px; height: calc(50% + 4px); background: #111; border-radius: 4px 4px 0 0; transform: translateX(-50%); }
.clock-hand { position: absolute; z-index: 2; bottom: 50%; left: calc(50% - 2px); width: 4px; height: 38%; background: #e53935; border-radius: 4px; transform-origin: 50% 100%; }
.clock-pin { position: absolute; z-index: 3; top: calc(50% - 5px); left: calc(50% - 5px); width: 10px; height: 10px; background: #111; border-radius: 50%; }

#video-container[hidden] { display: none; }
#youtube-player { width: 100vw; height: 100vh; border: 0; }
#youtube-player[hidden], #video-player[hidden] { display: none !important; }
#close-video { position: absolute; z-index: 10001; top: 14px; right: 18px; width: 50px; height: 50px; color: #fff; background: #0009; border: 2px solid #fff; border-radius: 50%; font-size: 2rem; }

@media (max-width: 800px) {
  #nomon-game { padding-inline: 10px; }
  #video-grid { --grid-gap: 10px; }
  #video-grid.count-7, #video-grid.count-8 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
  #video-grid.count-7 .nomon-tile:nth-child(5),
  #video-grid.count-7 .nomon-tile:nth-child(6) { grid-column: span 2; }
  #video-grid.count-7 .nomon-tile:nth-child(7) { grid-column: 3 / span 2; }
  #video-grid.count-8 .nomon-tile:nth-child(7) { grid-column: 2 / span 2; }
  #video-grid.count-8 .nomon-tile:nth-child(8) { grid-column: 4 / span 2; }
  #video-grid.count-10, #video-grid.count-11, #video-grid.count-12 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }
  #video-grid.count-10 .nomon-tile,
  #video-grid.count-11 .nomon-tile,
  #video-grid.count-12 .nomon-tile { grid-column: span 2; }
  #video-grid.count-10 .nomon-tile:nth-child(9) { grid-column: span 2; }
  #video-grid.count-10 .nomon-tile:nth-child(10) { grid-column: 3 / span 2; }
  #video-grid.count-11 .nomon-tile:nth-child(9) { grid-column: span 2; }
  #video-grid.count-11 .nomon-tile:nth-child(10) { grid-column: 2 / span 2; }
  #video-grid.count-11 .nomon-tile:nth-child(11) { grid-column: 4 / span 2; }
}
@media (max-width: 520px) {
  .nomon-tile .caption { min-height: 38px; padding: 5px 68px 5px 6px; font-size: 10px; }
  .nomon-clock { right: 5px; bottom: 5px; }
}
