/* Find The Cheese! -- presentation.
 *
 * The original opened in a 200x200 popup with no scrollbars and no resize handle.
 * Browsers block that now, so the game is embedded in a little window frame that
 * quotes the shape instead. The canvas is 198px drawn, doubled by CSS with
 * pixelated scaling so it stays chunky rather than going soft. */

.cheese-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  margin: 12px 0 18px;
}

/* the fake popup chrome */
.cheese-window {
  border: 2px solid #3301c3;
  background: #101018;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
}
.cheese-titlebar {
  background: #3301c3;
  color: #fff;
  font: bold 11px/1 Verdana, Geneva, sans-serif;
  padding: 5px 7px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.cheese-titlebar span:last-child { opacity: .65; letter-spacing: 1px; }

.cheese-board {
  display: block;
  width: 396px;         /* 198px drawn, doubled */
  height: 396px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #101018;
  transition: filter .25s;
}
.cheese-board.cheese-won { filter: brightness(1.35) saturate(1.4); }

/* The status bar, inside the frame the way a console game keeps everything on the
   one screen: where you are on the left, what you are carrying on the right. It is
   DOM rather than painted into the canvas so the label stays crisp at any scale. */
.cheese-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px;
  background: #15121f;
  border-top: 2px solid #3301c3;
}
.cheese-room {
  font: bold 11px/1 Verdana, Geneva, sans-serif;
  color: #c9c9d4;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cheese-slots { display: flex; gap: 5px; flex: none; }
.cheese-slot {
  /* 18px drawn, doubled -- the same exact 2x the board uses, so the key in the
     socket lands on the same pixel grid as the key lying on the floor */
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* the readouts that stay outside the 200px square */
.cheese-side { flex: 1 1 220px; min-width: 200px; }
.cheese-status {
  font: 11px/1.5 Verdana, Geneva, sans-serif;
  min-height: 2.6em;
  margin-bottom: 8px;
}
.cheese-restart {
  font: 11px Verdana, Geneva, sans-serif;
  padding: 4px 10px;
  cursor: pointer;
}
.cheese-howto {
  font: 11px/1.6 Verdana, Geneva, sans-serif;
  margin-top: 12px;
}
.cheese-howto b { color: #630096; }

.cheese-board { cursor: pointer; touch-action: manipulation; }

/* Touch gets the stick, pointers get the numpad. A fixed stick would mean looking
   away from the maze to find it, so this one materializes under the thumb. */
.cheese-stick { display: none; }
@media (hover: none) and (pointer: coarse) {
  .cheese-stick {
    display: block;
    position: relative;
    height: 148px;
    margin-top: 12px;
    border: 1px dashed #9c8fd0;
    background: rgba(51, 1, 195, .05);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
  }
  .cheese-keyonly { display: none; }
}
@media not all and (pointer: coarse) { .cheese-touchonly { display: none; } }

.cheese-stick-base, .cheese-stick-knob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
}
.cheese-stick-base {
  width: 104px; height: 104px;
  background: rgba(51, 1, 195, .12);
  border: 2px solid rgba(51, 1, 195, .45);
}
.cheese-stick-knob {
  width: 52px; height: 52px;
  background: #3301c3;
  border: 2px solid #ece9f6;
}
.cheese-stick.on .cheese-stick-base,
.cheese-stick.on .cheese-stick-knob { opacity: 1; }
.cheese-stick-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font: italic 11px Verdana, Geneva, sans-serif;
  color: #9c8fd0;
  pointer-events: none;
  transition: opacity .12s;
}
.cheese-stick.on .cheese-stick-hint { opacity: 0; }

/* the numpad, drawn as the compass the original used it as */
.cheese-pad {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 4px;
  margin-top: 12px;
}
.cheese-pad button {
  height: 38px;
  font: bold 13px Verdana, Geneva, sans-serif;
  cursor: pointer;
  background: #ece9f6;
  border: 1px solid #9c8fd0;
  color: #3301c3;
}
.cheese-pad button:active { background: #3301c3; color: #fff; }
.cheese-pad .cheese-pad-mid {
  border: none;
  background: none;
  cursor: default;
  color: #9c8fd0;
}

/* The stick replaces the numpad on touch. This has to come after the .cheese-pad
   rules above, not with the rest of the touch block -- same specificity, so source
   order decides and an earlier override would simply lose. */
@media (hover: none) and (pointer: coarse) {
  .cheese-pad { display: none; }
}

/* On a phone the maze and the stick have to share one screen -- a stick you have to
   scroll to is a stick you cannot use while walking. Capping the board against the
   viewport height keeps both in reach without shrinking it on a tablet. */
@media (max-width: 560px) {
  .cheese-wrap { gap: 10px; }
  .cheese-window { width: min(100%, 52vh); }
  .cheese-board { width: 100%; }
  .cheese-side { flex: 1 1 100%; }
  .cheese-status { min-height: 1.8em; margin-bottom: 6px; }
  .cheese-howto { margin-top: 10px; }
  .cheese-hud { padding: 4px 6px; }
  .cheese-room { font-size: 10px; }
  .cheese-slot { width: 26px; height: 26px; }

  /* Put the stick immediately under the board. "Start over" sitting between them
     pushes the control the player's thumb wants off the bottom of the screen. */
  .cheese-side { display: flex; flex-direction: column; }
  .cheese-status { order: 2; }
  .cheese-stick { order: 4; margin-top: 2px; }
  .cheese-restart { order: 5; align-self: flex-start; margin-top: 10px; }
  .cheese-howto { order: 6; }
}
@media (max-width: 560px) and (max-height: 700px) {
  .cheese-window { width: min(100%, 44vh); }
  .cheese-stick { height: 116px !important; }
}

/* .cheese-room is inside the game's own dark chrome now, so it does not follow the
   page skin -- the screen looks the same whichever era you are viewing the site as. */
[data-era="modern"] .cheese-howto b { color: #c9a6ff; }
[data-era="modern"] .cheese-pad button { background: #1c1830; border-color: #4a3f7a; color: #c9a6ff; }
[data-era="modern"] .cheese-restart {
  background: #1c1830; border: 1px solid #4a3f7a; color: #c9a6ff;
}
[data-era="modern"] .cheese-window { border-color: #4a3f7a; }
[data-era="modern"] .cheese-titlebar { background: #241d3f; }
[data-era="modern"] .cheese-stick { border-color: #4a3f7a; background: rgba(139,92,246,.06); }
[data-era="modern"] .cheese-stick-hint { color: #6f639c; }
[data-era="modern"] .cheese-stick-base { background: rgba(139,92,246,.16);
  border-color: rgba(139,92,246,.5); }
[data-era="modern"] .cheese-stick-knob { background: #6d47c4; border-color: #1c1830; }
