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

/* ONLY body is flex. html is just a full-viewport box — do not flex html. */
html {
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  background: #04180a;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  background: #04180a;
  font-family: Tahoma, "Trebuchet MS", Arial, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* User arcade PAE-MAN logo */
.title-logo {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  height: 48px;
  width: auto;
  max-width: min(72vw, 340px);
  object-fit: contain;
  z-index: 6;
  pointer-events: none;
  image-rendering: auto;
  border-radius: 4px;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.title-unused {

  position: absolute;
  top: 8px;
  left: 14px;
  font-size: clamp(18px, 3.2vw, 36px);
  font-style: italic;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffe14a;
  text-shadow:
    0 2px 0 #7a5200,
    0 0 18px rgba(0,0,0,.55),
    2px 3px 0 rgba(0,0,0,.45);
  pointer-events: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.pac-pie {
  display: inline-block;
  width: 0.78em;
  height: 0.78em;
  margin: 0 0.12em 0 0.14em;
  border-radius: 50%;
  background: conic-gradient(
    #ffe14a 0deg 38deg,
    transparent 38deg 82deg,
    #ffe14a 82deg 360deg
  );
  box-shadow: 0 2px 0 #7a5200;
  transform: rotate(-18deg);
  flex: 0 0 auto;
}

.fact-bug {
  position: absolute;
  top: 10px;
  right: 12px;
  left: auto;
  transform: none;
  background: linear-gradient(#0c2a12, #06180a);
  border: 2px solid #d4b14a;
  padding: 4px 16px 5px;
  font-size: clamp(12px, 2vw, 16px);
  letter-spacing: 2px;
  color: #f3e3a6;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
  white-space: nowrap;
}
.fact-bug strong {
  color: #fff;
  font-size: 1.15em;
  letter-spacing: 1px;
}
.fact-bug.cele {
  border-color: #ffe566;
  box-shadow: 0 0 18px rgba(255, 229, 102, .45), 0 4px 0 rgba(0,0,0,.35);
  color: #ffe566;
}

.hint {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 1.6px;
  color: rgba(255,255,255,.72);
  text-transform: uppercase;
  text-align: right;
  pointer-events: none;
  text-shadow: 0 1px 4px #000;
}

/* Leftover height ONLY after HUD + pad. flex-basis:0 is required. */
.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 56px 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.play {
  position: relative;
  line-height: 0;
  flex: 0 1 auto;
}
.play canvas {
  display: block;
  border-radius: 4px;
  box-shadow:
    0 0 0 3px #d4b14a,
    0 0 0 6px #3a2a08,
    8px 10px 0 rgba(0,0,0,.4);
  background: #000008;
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(180, 20, 20, 0);
  z-index: 8;
  border-radius: 4px;
}
.flash.go { animation: deathFlash 420ms ease-out; }
@keyframes deathFlash {
  0%   { background: rgba(255, 230, 180, .55); }
  28%  { background: rgba(180, 30, 20, .42); }
  100% { background: rgba(180, 20, 20, 0); }
}

.stamp {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(0.86);
  z-index: 9;
  font-size: clamp(22px, 4.4vw, 52px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 3px;
  color: #ffe566;
  text-shadow: 0 3px 0 #000, 0 0 18px rgba(0,0,0,.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}
.stamp.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.pad {
  display: none;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 4px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 6;
  pointer-events: auto;
  background: #04180a;
}
.pad-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.pad-spacer {
  width: 56px;
  height: 1px;
}
.pad button {
  min-width: 56px;
  min-height: 48px;
  padding: 0 12px;
  font-size: 22px;
  font-weight: 800;
  font-family: inherit;
  color: #f3e3a6;
  background: linear-gradient(#1a3a18, #0a1c0a);
  border: 2px solid #d4b14a;
  border-radius: 8px;
  box-shadow: 0 3px 0 #3a2a08, 2px 4px 0 rgba(0,0,0,.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
}
.pad button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a2a08;
}

/* Always visible bottom HUD — never shrinks, never absolute overlay */
.hud {
  flex: 0 0 auto;
  position: relative;
  z-index: 7;
  pointer-events: auto;
  padding: 6px 10px calc(4px + env(safe-area-inset-bottom));
  background: #04180a;
  border-top: 2px solid rgba(212, 177, 74, 0.35);
}

.talk-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  margin: 0 auto 6px;
  max-width: 980px;
  perspective: 920px;
}
.portrait-frame {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border: 3px solid #e6c35a;
  box-shadow: 0 0 0 2px #3a2a08, 4px 4px 0 rgba(0,0,0,.45);
  background: #2a1a10;
  position: relative;
  overflow: hidden;
}
.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}
.portrait-frame::after {
  content: "DR. TAON";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-align: center;
  background: rgba(0,0,0,.65);
  color: #f3e3a6;
  padding: 1px 0;
}
.dialogue {
  flex: 1;
  min-width: 0;
  background: linear-gradient(#16110a, #0a0806 55%, #120e08);
  border: 3px solid #d4b14a;
  border-radius: 4px;
  min-height: 72px;
  padding: 8px 12px;
  font-size: clamp(13px, 1.7vw, 17px);
  line-height: 1.32;
  color: #f4f0e4;
  overflow: visible;
  box-shadow:
    0 0 0 1px #3a2a08,
    4px 4px 0 rgba(0,0,0,.35),
    inset 0 0 0 1px rgba(212, 177, 74, 0.28);
  transform-origin: center center;
  backface-visibility: hidden;
}
.dialogue.flip { animation: cardFlip 450ms ease; }
@keyframes cardFlip {
  0%   { transform: rotateY(-88deg) scale(0.94); opacity: 0.35; }
  58%  { transform: rotateY(8deg) scale(1.02); opacity: 1; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.dialogue .q {
  color: #7ec8ff;
  font-weight: 700;
  margin-bottom: 4px;
}
.dialogue .a {
  color: #fff;
}

.statbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: linear-gradient(rgba(8,18,10,.88), rgba(4,10,6,.92));
  border: 2px solid rgba(0,0,0,.6);
  border-top: 2px solid rgba(255,255,255,.12);
  padding: 4px 12px;
  min-height: 38px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat .lbl {
  font-size: 10px;
  letter-spacing: 1.6px;
  color: #9aaa9a;
  text-transform: uppercase;
}
.stat .val {
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 1px;
  line-height: 1.05;
}
.stat .val.club { color: #3dff6a; text-shadow: 0 0 10px rgba(40,255,90,.35); }
.stat .val.pin { color: #ffe566; }
.stat .val.tip {
  color: #f3e3a6;
  font-size: clamp(12px, 1.6vw, 16px);
  letter-spacing: 1.4px;
}
.q-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background:
    #082010 url("assets/prostate-gold.png") center / 88% no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(230, 195, 90, .4),
    0 0 0 2px #222,
    0 0 10px rgba(255, 229, 102, .28);
  justify-self: center;
}

.disclaimer {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.8px;
  color: rgba(200, 210, 190, .55);
  padding: 3px 8px 1px;
}

@media (pointer: coarse), (hover: none), (max-width: 820px) {
  .pad { display: flex; flex-direction: column; }
  .hud { padding-bottom: 4px; }
  .hint { display: none; }
}

@media (max-width: 820px) {
  .title-logo { height: 36px; max-width: 70vw; }
  .stage { padding-top: 44px; }
  .portrait-frame { width: 64px; height: 64px; flex-basis: 64px; }
  .dialogue { min-height: 64px; font-size: 13px; padding: 6px 8px; }
  .stat .val { font-size: 15px; }
  .title { font-size: 18px; top: 6px; left: 8px; }
  .fact-bug { font-size: 11px; padding: 3px 10px 4px; top: 8px; }
  .statbar { grid-template-columns: 1fr 1fr auto 1fr; min-height: 32px; }
  .stat:last-child { display: none; }
  .pad button { min-width: 58px; min-height: 50px; font-size: 20px; }
  .pad-spacer { width: 58px; }
  .stage { padding: 40px 6px 4px; }
}

@media (max-height: 740px) {
  .portrait-frame { width: 56px; height: 56px; flex-basis: 56px; }
  .dialogue { min-height: 56px; font-size: 12px; padding: 5px 8px; }
  .statbar { min-height: 28px; padding: 2px 8px; }
  .stage { padding-top: 36px; padding-bottom: 2px; }
  .disclaimer { font-size: 9px; padding: 2px 8px 0; }
  .title { font-size: 16px; }
}

@media (max-height: 620px) {
  .fact-bug { display: none; }
  .stage { padding-top: 28px; }
  .pad button { min-width: 48px; min-height: 42px; font-size: 18px; }
  .pad-spacer { width: 48px; }
}
