* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #cfcbbf;
  font-family: system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 148px 1fr 148px;
  grid-template-areas: "left mid right";
  align-items: center;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

#left { grid-area: left; }
#mid { grid-area: mid; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#right { grid-area: right; }
.side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; height: 100%; }

#bezel {
  background: #3a3c48;
  padding: 4px;
  border-radius: 8px;
  line-height: 0;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #f6e7c1;
  display: block;
  border-radius: 4px;
}

/* Krzyżak */
#dpad {
  position: relative;
  width: 132px;
  height: 132px;
  touch-action: none;
}
#dpad .arm {
  position: absolute;
  background: #2e2f36;
  border-radius: 6px;
  box-shadow: 0 3px 0 #1b1c20;
}
#dpad .arm.h { left: 0; right: 0; top: 44px; height: 44px; }
#dpad .arm.v { top: 0; bottom: 0; left: 44px; width: 44px; }
#dpad .hub {
  position: absolute; left: 56px; top: 56px; width: 20px; height: 20px;
  border-radius: 50%; background: #25262b;
}
#dpad[data-dir~="left"]  .arm.h { background: linear-gradient(90deg, #4a4c57 0 33%, #2e2f36 33%); }
#dpad[data-dir~="right"] .arm.h { background: linear-gradient(270deg, #4a4c57 0 33%, #2e2f36 33%); }
#dpad[data-dir~="up"]    .arm.v { background: linear-gradient(180deg, #4a4c57 0 33%, #2e2f36 33%); }
#dpad[data-dir~="down"]  .arm.v { background: linear-gradient(0deg, #4a4c57 0 33%, #2e2f36 33%); }

/* Przyciski A / B */
#ab {
  display: flex;
  gap: 10px;
  align-items: center;
  transform: rotate(-20deg);
}
#ab button {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: none;
  background: #9c2459;
  color: #e9c3d3;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 0 #641338;
  touch-action: none;
}
#ab button.on { transform: translateY(3px); box-shadow: 0 1px 0 #641338; background: #b43a70; }
#btn-a { margin-top: -20px; }
#btn-b { margin-top: 20px; }

#btn-start {
  border: none;
  background: #8a8c96;
  color: #3a3b42;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 22px;
  border-radius: 10px;
  box-shadow: 0 2px 0 #5d5f68;
  touch-action: none;
}
#btn-start.on { transform: translateY(2px); box-shadow: none; }

@media (orientation: portrait) {
  #shell {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "mid mid" "left right";
  }
  #mid { padding-top: 10px; }
  .side { justify-content: flex-start; padding-top: 12%; }
}
