/* The cabinet around the canvas. Every ornament here is a CSS shape. */

:root {
  --ink: #ffffff;
  --dim: #ffb8ae;
  --blue: #2121de;
  --yellow: #ffff00;
  --bg: #000000;
  --font: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.cabinet {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 6px;
  width: min(100vw, 560px);
  height: 100dvh;
  max-height: 100dvh;
  padding: 6px 10px 10px;
}

.panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.readout { display: flex; flex-direction: column; line-height: 1.25; }
.readout .label { font-size: 10px; color: var(--dim); }
.readout .value { font-size: 17px; color: var(--ink); }
.readout:nth-child(2) { text-align: center; align-items: center; }
.readout:nth-child(3) { text-align: right; align-items: flex-end; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

canvas#screen {
  display: block;
  image-rendering: auto;
  border-radius: 4px;
}

.bottom { align-items: flex-end; }

/* A life is a yellow disc with a wedge cut out of it. */
.lives { display: flex; gap: 6px; min-height: 18px; }
.life {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(from 120deg,
              var(--yellow) 0 300deg, transparent 300deg 360deg);
}

.fruits { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; }
.fruits canvas { width: 22px; height: 22px; }

.buttons { display: flex; gap: 6px; }
.buttons button {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--dim);
  background: transparent;
  border: 2px solid var(--blue);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.buttons button:hover { color: var(--ink); border-color: var(--yellow); }
.buttons button:active { transform: translateY(1px); }

/* Thumb pad: only worth showing where there is no keyboard. */
.pad {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 48px);
  justify-content: center;
  gap: 6px;
}
.pad button {
  font-size: 18px;
  color: var(--yellow);
  background: #0a0a18;
  border: 2px solid var(--blue);
  border-radius: 10px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.pad button:active { background: var(--blue); }
.pad [data-dir="up"]    { grid-area: 1 / 2; }
.pad [data-dir="left"]  { grid-area: 2 / 1; }
.pad [data-dir="down"]  { grid-area: 2 / 2; }
.pad [data-dir="right"] { grid-area: 2 / 3; }

.hint {
  margin: 0;
  text-align: center;
  font-size: 10px;
  color: #6b6b8a;
  letter-spacing: 1px;
}

@media (hover: none) and (pointer: coarse) {
  .pad { display: grid; }
  .hint { display: none; }
}

@media (max-width: 420px) {
  .readout .value { font-size: 14px; }
  .fruits canvas { width: 18px; height: 18px; }
}
