/* The player page: a handheld console drawn around the game screen. The screen zooms by
 * whole numbers (--z, set by player.js); everything else keeps a fixed size in CSS pixels. */
:root {
  --z: 2;
  --page: #16181d;
  --ink: #e9e6df;
  --muted: #9a978f;
  --shell: #4b3f72;
  --shell-light: #5d5089;
  --shell-dark: #382f57;
  --bezel: #2a2c33;
  --button: #2b2733;
  --ab: #8c1d3f;
  --ab-light: #b02a53;
  --bar: #23252c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

#stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
}

#console {
  position: relative;
  width: calc(160px * var(--z) + 36px);
  padding: 16px 8px 0;
  border-radius: 14px 14px 64px 14px;
  background: linear-gradient(160deg, var(--shell-light), var(--shell) 40%, var(--shell-dark));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.12);
}

#bezel {
  position: relative;
  padding: 10px 10px 30px;
  border-radius: 8px 8px 28px 8px;
  background: var(--bezel);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

#led {
  position: absolute;
  left: 3px;
  top: calc(10px + 72px * var(--z) - 3px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8413c;
  box-shadow: 0 0 6px #e8413c;
}

#screen {
  width: calc(160px * var(--z));
  height: calc(144px * var(--z));
  margin: 0 auto;
  background: #000;
}

#screen canvas {
  display: block;
  width: calc(160px * var(--z));
  height: calc(144px * var(--z));
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#screen:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000;
}

#screen:fullscreen canvas {
  width: calc(160px * var(--fz, 1));
  height: calc(144px * var(--fz, 1));
}

#wordmark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  text-align: center;
  font-weight: 800;
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: #c9c6d6;
}

#wordmark .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 50%;
  vertical-align: 1px;
}
.dot.borgo { background: #e8c020; }
.dot.cervara { background: #d0302a; }
.dot.piano { background: #2f5fc8; }
.dot.pisana { background: #2e9a48; }

#controller {
  position: relative;
  height: 196px;
}

#controller_dpad {
  position: absolute;
  left: 6px;
  top: 30px;
  width: 112px;
  height: 112px;
  touch-action: none;
}

#controller_up, #controller_down, #controller_left, #controller_right, #controller_hub {
  position: absolute;
  width: 36px;
  height: 36px;
  background: var(--button);
}
#controller_up { left: 38px; top: 2px; border-radius: 5px 5px 0 0; }
#controller_down { left: 38px; top: 74px; border-radius: 0 0 5px 5px; }
#controller_left { left: 2px; top: 38px; border-radius: 5px 0 0 5px; }
#controller_right { left: 74px; top: 38px; border-radius: 0 5px 5px 0; }
#controller_hub {
  left: 38px;
  top: 38px;
  background: radial-gradient(circle, #24212b 30%, var(--button) 32%);
}
#controller_dpad > div {
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
#controller_hub { box-shadow: none !important; }

.roundBtn {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.55);
  background: radial-gradient(circle at 40% 35%, var(--ab-light), var(--ab));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
#controller_b { right: 72px; top: 66px; }
#controller_a { right: 12px; top: 40px; }

.capsuleBtn {
  position: absolute;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9c6d6;
  cursor: pointer;
}
.capsuleBtn span {
  width: 40px;
  height: 11px;
  border-radius: 6px;
  background: var(--button);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
#controller_select { left: calc(50% - 52px); }
#controller_start { left: calc(50% + 6px); }

#controller_dpad, .roundBtn, .capsuleBtn { cursor: pointer; }

.btnPressed { filter: brightness(0.75); transform: translateY(2px); }

#speaker {
  position: absolute;
  right: 18px;
  bottom: 16px;
  display: flex;
  gap: 5px;
  transform: rotate(-28deg);
}
#speaker i {
  display: block;
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: var(--shell-dark);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

#bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  max-width: calc(160px * var(--z) + 36px);
  font-size: 13px;
}

#bar button {
  font: inherit;
  color: var(--ink);
  background: var(--bar);
  border: 1px solid #3a3d46;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
#bar button[aria-pressed="false"] { color: var(--muted); }

#volume-label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#volume { width: 90px; accent-color: var(--ab-light); }

#keys {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

body.touch #keys { display: none; }

/* too small even at the smallest zoom: let the page scroll */
html.tight, html.tight body { overflow: auto; touch-action: auto; }
html.tight #stage { height: auto; min-height: 100%; justify-content: flex-start; }

@media (max-width: 400px) {
  #stage { padding: 8px 0; }
  #console { width: calc(160px * var(--z) + 20px); padding: 12px 4px 0; }
  #bezel { padding: 6px 6px 26px; }
  #led { left: 1px; top: calc(6px + 72px * var(--z) - 3px); }
}
