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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  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;
}

.title {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: clamp(18px, 3.2vw, 36px);
  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: 10px;
  left: 50%;
  transform: translateX(-50%);
  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;
}

/* Well gets ONLY leftover height after HUD. flex-basis:0 is required. */
.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 48px 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  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;
}

.next-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.next-lbl {
  font-size: clamp(11px, 1.5vw, 14px);
  font-weight: 800;
  letter-spacing: 3px;
  color: #f3e3a6;
  text-shadow: 0 1px 0 #000;
}
.next-box {
  background: #062010;
  border: 3px solid #d4b14a;
  border-radius: 4px;
  padding: 6px;
  box-shadow:
    0 0 0 2px #3a2a08,
    6px 8px 0 rgba(0,0,0,.4);
}
.next-box canvas { display: block; }

.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;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 6px;
  z-index: 6;
  pointer-events: auto;
  background: #04180a;
}
.pad button {
  min-width: 52px;
  min-height: 44px;
  padding: 0 10px;
  font-size: 20px;
  font-weight: 800;
  font-family: inherit;
  color: #f3e3a6;
  background: linear-gradient(#1a3a18, #0a1c0a);
  border: 2px solid #d4b14a;
  border-radius: 6px;
  box-shadow: 0 3px 0 #3a2a08, 2px 4px 0 rgba(0,0,0,.35);
  cursor: pointer;
  touch-action: manipulation;
}
.pad button[data-act="hard"] {
  font-size: 12px;
  letter-spacing: 1.4px;
  min-width: 68px;
}
.pad button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a2a08;
}

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

.talk-row {
  display: flex;
  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: 84px;
  max-height: 84px;
  padding: 8px 12px;
  font-size: clamp(14px, 1.8vw, 18px);
  line-height: 1.3;
  color: #f4f0e4;
  overflow: hidden;
  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;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialogue .a {
  color: #fff;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.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: 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), (max-width: 720px) {
  .pad { display: flex; }
}

@media (max-width: 720px) {
  .portrait-frame { width: 72px; height: 72px; flex-basis: 72px; }
  .dialogue { min-height: 72px; max-height: 72px; font-size: 13px; padding: 6px 8px; }
  .stat .val { font-size: 15px; }
  .title { font-size: 20px; top: 6px; left: 8px; }
  .hint { display: none; }
  .fact-bug { font-size: 12px; padding: 3px 10px 4px; }
  .statbar { grid-template-columns: 1fr 1fr auto 1fr; }
  .stat:last-child { display: none; }
  .pad button { min-width: 46px; min-height: 42px; font-size: 17px; }
  .stage { padding-top: 42px; }
}

@media (max-height: 700px) {
  .portrait-frame { width: 64px; height: 64px; flex-basis: 64px; }
  .dialogue { min-height: 64px; max-height: 64px; font-size: 12px; padding: 5px 8px; }
  .statbar { min-height: 32px; padding: 2px 8px; }
  .stage { padding-top: 40px; padding-bottom: 4px; }
  .disclaimer { font-size: 9px; padding: 2px 8px 0; }
}
