html, body {
  margin: 0;
  height: 100%;
  background: #120c18;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

canvas#game {
  position: fixed;
  inset: 0;
  display: block;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- touch controls ---------- */
#touch { display: none; }
body.touch[data-state="play"] #touch { display: block; }

.pad {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
}
.pad.left {
  left: calc(14px + env(safe-area-inset-left));
  display: flex;
  gap: 12px;
}
.pad.right {
  right: calc(14px + env(safe-area-inset-right));
  width: 250px;
  height: 196px;
}

.tbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: rgba(20, 14, 30, 0.42);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  touch-action: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.05s, background 0.05s;
}
.tbtn.active {
  background: rgba(255, 210, 90, 0.55);
  transform: scale(0.92);
}
.tbtn.dir { width: 82px; height: 82px; font-size: 32px; }
.tbtn.duck { width: 60px; height: 60px; font-size: 30px; align-self: flex-end; }
.tbtn.big {
  position: absolute; right: 0; bottom: 0;
  width: 100px; height: 100px; font-size: 42px;
  background: rgba(200, 60, 40, 0.5);
}
.tbtn.mid { position: absolute; width: 70px; height: 70px; }
.tbtn.small { position: absolute; width: 52px; height: 52px; font-size: 22px; }
.tbtn[data-action="jump"]    { right: 110px; bottom: 0; }
.tbtn[data-action="block"]   { right: 16px;  bottom: 110px; }
.tbtn[data-action="swap"]    { right: 118px; bottom: 86px; }
.tbtn[data-action="special"] { right: 178px; bottom: 132px; background: rgba(255, 200, 60, 0.35); }

/* ---------- pause / sound buttons ---------- */
#sys {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
#sys button {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(20, 14, 30, 0.5);
  color: #fff;
  font-size: 20px;
  padding: 0;
}
body[data-state="title"] #btnPause,
body[data-state="victory"] #btnPause { display: none; }

/* ---------- rotate-device prompt ---------- */
#rotate {
  display: none;
  position: fixed; inset: 0;
  background: #120c18;
  color: #ffd76a;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
  z-index: 10;
}
body.touch.portrait #rotate { display: flex; }

/* smaller controls on short (landscape phone) screens */
@media (max-height: 440px) {
  .pad.right { width: 196px; height: 156px; }
  .tbtn.dir { width: 62px; height: 62px; font-size: 26px; }
  .tbtn.big { width: 80px; height: 80px; font-size: 34px; }
  .tbtn.mid { width: 56px; height: 56px; font-size: 22px; }
  .tbtn.small { width: 44px; height: 44px; font-size: 18px; }
  .tbtn[data-action="jump"]    { right: 88px; bottom: 0; }
  .tbtn[data-action="block"]   { right: 12px; bottom: 88px; }
  .tbtn[data-action="swap"]    { right: 94px; bottom: 68px; }
  .tbtn[data-action="special"] { right: 142px; bottom: 106px; }
  #sys button { width: 38px; height: 38px; font-size: 17px; }
}
.tbtn { background: rgba(20, 14, 30, 0.32); }

/* The bundled policy is available from the title screen, including offline. */
#privacy {
  display: none;
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 11;
  padding: 10px 14px;
  border-radius: 8px;
  background: #21172c;
  color: #ffe7a3;
  font-size: 14px;
  touch-action: manipulation;
}
body[data-state="title"] #privacy { display: block; }

#shop {
  box-sizing: border-box;
  width: min(580px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 24px;
  border: 2px solid #c89a42;
  border-radius: 20px;
  background: #21172f;
  color: #f9f0df;
  overflow-y: auto;
  touch-action: pan-y;
  font-size: 16px;
}
#shop::backdrop { background: rgba(8, 5, 16, .78); }
#shop header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: sticky; top: 0; z-index: 1; background: #21172f; padding-bottom: 8px; }
#shop h1 { font-size: 28px; margin: 0 0 12px; color: #ffe099; }
#shop .eyebrow { font-size: 10px; letter-spacing: .16em; color: #c9b2d7; margin: 0 0 7px; }
#shop button { min-height: 44px; border: 1px solid #c89a42; border-radius: 9px; background: #ffd76a; color: #21172f; font-weight: 800; padding: 8px 14px; touch-action: manipulation; }
#shop button:disabled { background: #40324c; color: #c5b7ce; border-color: #6c567c; cursor: default; }
#shop button:focus-visible { outline: 3px solid white; outline-offset: 3px; }
#shopBalance { color: #ffe099; font-weight: 800; margin: 0; }
.shop-intro, .shop-note { color: #d5c7df; line-height: 1.5; }
.shop-note { font-size: 12px; margin-bottom: 0; }
.shop-good { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid #57405f; }
.shop-good strong { color: #ffe099; }
.shop-good p { font-size: 13px; line-height: 1.45; margin: 5px 0 0; }
.shop-good button { flex-shrink: 0; }
#shopMessage { min-height: 24px; color: #b8f3c2; }
@media (max-height: 440px) {
  .pad.left { gap: 8px; }
  .tbtn.duck { width: 46px; height: 46px; font-size: 24px; }
  #shop { padding: 16px 22px; }
}
