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

:root {
  --head-h: 40px;   /* header with the paccastudio menu item */
  --foot-h: 32px;   /* footer with the paccastudio link */
  --ink: #0c0f18;
  --line: #1f2638;
  --muted: #6a7494;
  --text: #c8cde0;
  --sun: #f8d840;
}

html, body { height: 100%; }

body {
  background: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Header and footer: thin bars in the colours of the game */
.page-bar {
  flex: none;
  height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
}
.page-bar.foot {
  height: var(--foot-h);
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: #3e4660;
}
.game-name { color: var(--sun); font-weight: bold; letter-spacing: 4px; }
.page-bar nav { display: flex; align-items: center; gap: 8px; }
.page-bar a { color: #9aa4cc; text-decoration: none; }
.page-bar a:hover, .page-bar a:focus-visible { color: #eef0fa; }
.pacca {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #2c3450;
  border-radius: 6px;
  letter-spacing: 1px;
}
.pacca img { display: block; border-radius: 4px; }
.pacca:hover { border-color: var(--muted); }
.tool {
  height: 30px;
  min-width: 34px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #9aa4cc;
  border: 1px solid #2c3450;
  border-radius: 6px;
  font: bold 12px 'Courier New', monospace;
  letter-spacing: 1px;
  cursor: pointer;
}
.tool:hover, .tool:focus-visible { color: #eef0fa; border-color: var(--muted); }
.tool .mute { display: none; }
.tool.off .wave { display: none; }
.tool.off .mute { display: inline; }

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

#wrap {
  position: relative;
  line-height: 0;
}

#game {
  display: block;
  background: #101820;
  cursor: pointer;
  /* 16:9, as large as fits between header and footer */
  width:  min(100vw, calc((100vh - var(--head-h) - var(--foot-h)) * 16 / 9));
  height: min(calc(100vh - var(--head-h) - var(--foot-h)), calc(100vw * 9 / 16));
}
@supports (height: 100dvh) {
  #game {
    width:  min(100vw, calc((100dvh - var(--head-h) - var(--foot-h)) * 16 / 9));
    height: min(calc(100dvh - var(--head-h) - var(--foot-h)), calc(100vw * 9 / 16));
  }
}

/* Phones held upright: the game sits at the top, with a hint to turn the phone */
.rotate { display: none; }
@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .stage { flex-direction: column; justify-content: flex-start; padding-top: 16px; gap: 14px; }
  .rotate { display: block; color: var(--muted); font-size: 12px; letter-spacing: 1px; text-align: center; padding: 0 16px; }
}

/* Touch controls in the bands beside the 16:9 game (phones held sideways have them), over its
   edges where the screen is narrower */
#touch[hidden] { display: none; }
.stage { position: relative; }
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  line-height: normal;
}
#stick {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: 12px;
  width: min(36vh, 140px);
  height: min(36vh, 140px);
  border-radius: 50%;
  background: rgba(20, 26, 44, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.22);
  pointer-events: auto;
  touch-action: none;
}
#knob {
  position: absolute;
  left: 30%;
  top: 30%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(248, 216, 64, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.5);
}
#touch .btns {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}
#touch .btns button, #t-pause {
  pointer-events: auto;
  touch-action: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font: bold 12px 'Courier New', monospace;
  letter-spacing: 1px;
}
#t-throw { width: min(30vh, 104px); height: min(30vh, 104px); background: rgba(220, 70, 60, 0.6); }
#t-jump { width: min(23vh, 80px); height: min(23vh, 80px); background: rgba(64, 140, 220, 0.55); margin-right: 18px; }
#t-pause {
  position: absolute;
  top: 8px;
  left: max(10px, env(safe-area-inset-left));
  width: 40px;
  height: 40px;
  background: rgba(20, 26, 44, 0.6);
  border-radius: 8px;
}

/* Short screens (phones held sideways): thinner bars, more room for the game */
@media (max-height: 520px) {
  :root { --head-h: 30px; --foot-h: 22px; }
  .page-bar { font-size: 11px; }
  .page-bar.foot { font-size: 10px; }
  .tool { height: 24px; min-width: 28px; }
  .pacca { padding: 3px 8px; }
}
