/* LAST SONG - arcade cabinet shell. The game itself is drawn on the canvas. */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #07040c;
  color: #cfc6e6;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  font-family: "Courier New", Courier, monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #24103a 0%, #0c0616 55%, #050308 100%);
}

#cabinet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Bezel around the screen */
#screen {
  position: relative;
  line-height: 0;
  border: 6px solid #17111f;
  border-radius: 10px;
  background: #000;
  box-shadow:
    0 0 0 2px #3a2850,
    0 0 26px rgba(255, 46, 136, 0.35),
    0 0 70px rgba(40, 220, 255, 0.12);
}

#game {
  display: block;
  width: 480px;
  height: 270px;
  background: #000;
  border-radius: 4px;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* CRT scanlines + vignette */
#crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 4px;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.16) 3px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, 0.42) 100%);
}

#legend {
  margin: 0;
  font-size: 12px;
  letter-spacing: 1px;
  color: #7d6f9c;
  text-align: center;
}
#legend b { color: #ffe14a; font-weight: normal; }

/* Sound toggle */
#mute {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 5;
  padding: 6px 9px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 1px;
  color: #28dcff;
  background: rgba(12, 6, 22, 0.75);
  border: 1px solid #28dcff;
  border-radius: 4px;
  cursor: pointer;
}
#mute.off { color: #7d6f9c; border-color: #4a3d66; }

/* ---------- Touch controls ---------- */
#touch { display: none; }

body.touch #legend { display: none; }
body.touch #screen { border-width: 2px; }
body.touch #touch {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
body.touch #touch > * { pointer-events: auto; }

#pad {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.07);
}
#stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

#actions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  /* Three columns: SOLO and JUMP on top, BLOCK / KICK / PUNCH below (the thumb rests on PUNCH). */
  grid-template-columns: repeat(3, 66px);
  gap: 8px;
}
.tbtn.solo { grid-column: 2; grid-row: 1; }
.tbtn.jump { grid-column: 3; grid-row: 1; }
.tbtn.block { grid-column: 1; grid-row: 2; }
.tbtn.kick { grid-column: 2; grid-row: 2; }
.tbtn.punch { grid-column: 3; grid-row: 2; }
.tbtn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  font: inherit;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
}
.tbtn.punch { background: rgba(255, 46, 136, 0.5); }
.tbtn.jump { background: rgba(46, 232, 106, 0.4); }
.tbtn.solo { background: rgba(255, 225, 74, 0.4); }
.tbtn.kick { background: rgba(40, 220, 255, 0.42); }
.tbtn.block { background: rgba(176, 77, 255, 0.45); }
.tbtn:active, .sbtn:active { filter: brightness(1.5); }

#sys {
  position: absolute;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
.sbtn {
  padding: 8px 12px;
  font: inherit;
  font-size: 11px;
  color: #ffe14a;
  background: rgba(12, 6, 22, 0.7);
  border: 1px solid rgba(255, 225, 74, 0.7);
  border-radius: 14px;
}

/* Portrait phones: screen on top, controls below */
@media (orientation: portrait) {
  body.touch { align-items: flex-start; padding-top: 44px; }
}

/* Narrow phones: smaller action buttons so the 3-column grid clears the virtual stick */
@media (max-width: 400px) {
  #actions { grid-template-columns: repeat(3, 54px); gap: 6px; }
  .tbtn { width: 54px; height: 54px; font-size: 10px; }
}

@media (max-height: 380px) {
  #legend { display: none; }
  #screen { border-width: 2px; }
}
