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

html {
  width: 100%;
  height: 100%;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
  background: #04180a;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  height: 100%;
  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);
}

.title {
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: clamp(26px, 4.2vw, 50px);
  font-style: italic;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow:
    0 2px 0 #0a3a14,
    0 0 18px rgba(0,0,0,.55),
    2px 3px 0 rgba(0,0,0,.45);
  pointer-events: none;
  z-index: 5;
}

.fact-bug {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(#0c2a12, #06180a);
  border: 2px solid #d4b14a;
  padding: 5px 20px 6px;
  font-size: clamp(14px, 2.2vw, 18px);
  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: 18px;
  right: 16px;
  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;
  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: #062010;
}

.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(28px, 5.2vw, 62px);
  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 8px;
  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(6px + 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: 104px;
  height: 104px;
  flex: 0 0 104px;
  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;
  image-rendering: auto;
}
.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: 104px;
  padding: 10px 14px 10px 16px;
  font-size: clamp(16px, 2.1vw, 20px);
  line-height: 1.38;
  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: 6px;
}
.dialogue .a { color: #fff; }

.statbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1.1fr 1.4fr;
  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: 6px 14px 5px;
  min-height: 48px;
}
.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(18px, 2.4vw, 24px);
  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(13px, 1.8vw, 18px);
  letter-spacing: 1.4px;
}
.q-icon {
  width: 36px;
  height: 36px;
  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: 11px;
  letter-spacing: 0.8px;
  color: rgba(200, 210, 190, .55);
  padding: 4px 8px 2px;
}

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

@media (max-width: 820px) {
  .title { font-size: 22px; top: 8px; left: 10px; }
  .stage { padding: 44px 6px 4px; }
  .portrait-frame { width: 64px; height: 64px; flex-basis: 64px; }
  .dialogue { min-height: 64px; font-size: 13px; padding: 6px 8px; }
  .stat .val { font-size: 15px; }
  .fact-bug { font-size: 13px; padding: 4px 12px 5px; }
  .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; }
}

@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; }
}
