/* The tower stays vertical on phones as well as larger screens. */
.jokes-body {
  --joke-cream: #fff4d5;
  --joke-line: #31445f;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: radial-gradient(ellipse at 50% 0, #253d5c, #101b2e 64%);
  color: #f9f3e6;
}
.jokes-home-link {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, calc((100vw - 980px) / 2));
  z-index: 2;
  padding: 6px 10px;
  border: 1px solid #455976;
  border-radius: 9px;
  color: #d3dfef;
  background: #142239;
  text-decoration: none;
  font-size: 13px;
}
.jokes-shell {
  position: relative;
  width: min(calc(100% - 28px), 980px);
  margin: 0 auto;
  padding: calc(max(12px, env(safe-area-inset-top)) + 42px) 0 max(22px, env(safe-area-inset-bottom));
}
.joke-start-card,
.joke-end-card {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 20px;
  border: 1px solid var(--joke-line);
  border-radius: 20px;
  background: #15243a;
  text-align: center;
  box-shadow: 0 15px 45px #080e1d55;
}
.joke-start-scene,
.joke-end-scene {
  position: relative;
  height: clamp(160px, 31svh, 250px);
  margin: -8px -8px 18px;
  overflow: hidden;
  border: 2px solid #7e9ba3;
  border-radius: 12px;
  background: #39afe0;
}
.joke-start-scene img,
.joke-end-scene img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center bottom; image-rendering: pixelated; }
.joke-start-scene img { transform: scale(1.35); transform-origin: center bottom; }
.joke-end-scene img { object-position: center 43%; transform: scale(1.3); transform-origin: center 43%; }
.joke-kicker { color: #96d8d9; font: 800 10px/1.4 system-ui, sans-serif; letter-spacing: .14em; }
.joke-start-card h1,
.joke-end-card h1 { margin: 7px 0 9px; color: var(--joke-cream); font-size: clamp(29px, 6vw, 41px); line-height: 1.2; }
.joke-start-card > p,
#joke-end-copy { color: #c3d0df; font-size: 14px; line-height: 1.55; }
.joke-start-card > .joke-start-rule { margin-top: 10px; color: #93a9bd; font: 12px/1.6 system-ui, sans-serif; }
.joke-main-button {
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid #8cc3b6;
  border-radius: 10px;
  color: #f7fff8;
  background: #357b77;
  font: inherit;
  font-size: 16px;
  transition: filter .15s, transform .15s;
}
.joke-main-button:not(:disabled):hover { filter: brightness(1.12); }
.joke-main-button:not(:disabled):active { transform: translateY(1px); }
.joke-main-button:disabled { cursor: wait; opacity: .55; }
#joke-start-button { width: 100%; margin-top: 18px; }
.joke-message { min-height: 16px; margin-top: 8px; color: #ffbcb7; font: 12px/1.5 system-ui, sans-serif; }
.joke-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 9px 13px;
  border: 1px solid var(--joke-line);
  border-radius: 12px;
  background: #142237;
}
.joke-game-header > div { display: flex; align-items: center; gap: 10px; }
.joke-header-label { color: #a6bdd0; font: 11px system-ui, sans-serif; }
.joke-game-header strong { color: var(--joke-cream); font-size: 22px; }
.joke-give-up { min-height: 34px; padding: 6px 12px; border: 1px solid #71515f; border-radius: 8px; color: #efb8c4; background: #372637; font: inherit; font-size: 13px; }
.joke-give-up.armed { color: #fff; background: #923b56; }
.joke-give-up:disabled { opacity: .5; }
.joke-game-grid { display: grid; grid-template-columns: minmax(320px, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.joke-tower-panel {
  position: relative;
  height: 530px;
  min-width: 0;
  overflow: hidden;
  border: 2px solid #5790ad;
  border-radius: 14px;
  background: #28211d;
  scroll-margin-top: 12px;
}
.joke-scene { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; }
.joke-world { position: absolute; inset: 0; will-change: transform; }
.joke-stairs { display: block; width: 100%; height: 100%; overflow: visible; shape-rendering: crispEdges; image-rendering: pixelated; }
.joke-scene-actor {
  position: absolute;
  z-index: 1;
  width: 23%;
  aspect-ratio: 1;
  transform: translate(-56%, -100%);
  pointer-events: none;
}
.joke-walk-sprite {
  width: 100%;
  height: 100%;
  background: url('assets/jokes/adventurer-walk.png') 0 0 / 400% 200% no-repeat;
  image-rendering: pixelated;
  transform-origin: 56% 100%;
  transform: translateY(var(--sole-offset, 0%)) scaleX(var(--actor-facing, 1));
}
.joke-landmark {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  image-rendering: pixelated;
  transform: scale(1.3);
  transform-origin: center 42%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.joke-tower-panel[data-stage="summit"] .joke-landmark { opacity: 1; }
.joke-scene-floor,
.joke-scene-goal {
  position: absolute;
  top: 10px;
  z-index: 2;
  padding: 6px 9px;
  border: 1px solid #e2d6a9;
  border-radius: 6px;
  background: #fff4d5;
  color: #283a46;
  font: 800 12px/1.2 system-ui, sans-serif;
}
.joke-scene-floor { left: 10px; }
.joke-scene-goal { right: 10px; }
.joke-progressbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.joke-question-card { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 25px; border: 1px solid var(--joke-line); border-radius: 16px; background: #16263e; }
.joke-question-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#joke-floor-badge { padding: 5px 9px; border: 1px solid #7eaa9c; border-radius: 7px; color: #c2e1cd; background: #2b4c4c; font-size: 14px; }
#joke-question-count { color: #8fa6bf; font: 11px system-ui, sans-serif; }
#joke-question { min-height: 145px; padding: 24px 0; color: var(--joke-cream); font-size: clamp(23px, 3vw, 32px); line-height: 1.45; word-break: keep-all; overflow-wrap: anywhere; }
#joke-answer-form label,
.joke-record-form label { display: block; margin-bottom: 6px; color: #b2c6d8; font: 12px system-ui, sans-serif; }
.joke-answer-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; }
#joke-answer,
#joke-nickname { width: 100%; min-width: 0; height: 44px; padding: 0 11px; border: 1px solid #58728b; border-radius: 9px; outline: none; color: #fff9ee; background: #101d31; font: 16px system-ui, sans-serif; }
#joke-answer:focus,
#joke-nickname:focus { border-color: #a1d7be; box-shadow: 0 0 0 2px #a1d7be22; }
#joke-answer::placeholder,
#joke-nickname::placeholder { color: #7891a8; }
.joke-feedback { min-height: 20px; margin-top: 11px; color: #a0b6c9; font: 12px/1.5 system-ui, sans-serif; text-align: center; }
.joke-feedback.good { color: #a9dfbd; }
.joke-feedback.bad { color: #ffc0bc; }
.joke-shake { animation: joke-shake .35s ease; }
@keyframes joke-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.joke-end-badge { display: inline-block; padding: 5px 10px; border-radius: 6px; color: #58491e; background: var(--joke-cream); font-size: 12px; }
.joke-record-form { margin-top: 20px; text-align: left; }
.joke-record-form > div { display: grid; grid-template-columns: minmax(0, 1fr) 108px; gap: 8px; }
#joke-save-record { padding-inline: 8px; font-size: 14px; }
.joke-ranking { margin-top: 20px; text-align: left; }
.joke-ranking-status { padding: 9px; margin-bottom: 13px; border: 1px solid #538675; border-radius: 8px; color: #bfebce; background: #234c43; font: 12px/1.5 system-ui, sans-serif; text-align: center; }
.joke-ranking-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.joke-ranking-head h2 { font-size: 20px; }
.joke-ranking-head > span { color: #8da6bc; font: 11px system-ui, sans-serif; }
#joke-ranking-list { display: grid; gap: 7px; max-height: 300px; overflow-y: auto; list-style: none; }
#joke-ranking-list li { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 42px; padding: 7px 9px; border: 1px solid var(--joke-line); border-radius: 8px; background: #102036; }
#joke-ranking-list li.top-1 { border-color: #c5a968; }
#joke-ranking-list li.top-2 { border-color: #a0b5c6; }
#joke-ranking-list li.top-3 { border-color: #a37b5f; }
.joke-rank-number { color: #dbc48a; text-align: center; font: 800 12px system-ui, sans-serif; }
#joke-ranking-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.joke-rank-score { color: #a8bdd0; font: 11px system-ui, sans-serif; }
.joke-ranking-empty { grid-template-columns: 1fr !important; color: #8da6bc; text-align: center; font: 12px system-ui, sans-serif; }
#joke-restart { width: 100%; margin-top: 15px; }
#joke-offline { position: fixed; inset: 0 0 auto; z-index: 30; padding: calc(7px + env(safe-area-inset-top)) 12px 7px; background: #9b522e; color: #fff; text-align: center; font: 13px system-ui, sans-serif; }
.jokes-body button:focus-visible,
.jokes-body a:focus-visible { outline: 3px solid #f6d98a; outline-offset: 3px; }
@media (max-width: 760px) {
  .jokes-shell { width: min(calc(100% - 20px), 560px); }
  .joke-game-grid { grid-template-columns: 1fr; gap: 10px; }
  .joke-tower-panel { height: clamp(340px, 52svh, 460px); }
  .joke-question-card { padding: 14px; }
  #joke-question { min-height: 68px; padding: 13px 0; font-size: 20px; }
  .joke-game-header { padding: 7px 11px; }
  .joke-game-header strong { font-size: 20px; }
}
@media (max-width: 360px) {
  .joke-tower-panel { height: clamp(310px, 50svh, 420px); }
  .joke-scene-floor, .joke-scene-goal { font-size: 11px; padding: 5px 7px; }
  .joke-start-card,
  .joke-end-card { padding: 15px; }
  #joke-question { font-size: 18px; }
  .joke-record-form > div { grid-template-columns: minmax(0, 1fr) 100px; }
}
@media (min-width: 761px) and (max-height: 620px) {
  .joke-tower-panel { height: clamp(230px, 65svh, 360px); }
  .joke-question-card { padding: 17px; }
  #joke-question { min-height: 80px; padding: 15px 0; font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .joke-tower-panel *,
  .jokes-body button { animation: none !important; transition: none !important; }
  .joke-shake { animation: none; }
}
