/* This Button Lies. Flat, loud, cheeky; coral ground, ink buttons. Design rules live in the repo's CLAUDE.md. */
:root { --coral: #f39a6b; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--coral); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body.m-select, body.m-ending { background: var(--cream); }
button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.screen { padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }

/* Title */
.title { min-height: 100vh; min-height: 100dvh; max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 20px; }
.title-devil { width: 128px; height: 128px; }
.title h1 { font-size: 64px; line-height: 0.95; }
.title h1 span { display: block; }
.tagline { font-size: 20px; font-weight: 700; margin: 0; }
.keys { font-size: 16px; margin: 0; max-width: 34em; }

/* Panels: puzzle select and the ending */
.panel-in { max-width: 880px; margin: 0 auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.pzs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
@media (max-width: 640px) { .pzs { grid-template-columns: repeat(4, 1fr); } }
.pz {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 64px; padding: 10px;
  background: var(--ink); color: var(--cream); border: 2px solid var(--ink); border-radius: 4px;
  font: 16px/1.2 var(--body); text-align: left; cursor: pointer;
}
.pz b { font: 20px/1 var(--display); font-weight: 400; }
.pz:hover:not(:disabled) { transform: translateY(-2px); }
.pz:disabled { background: transparent; color: rgba(26, 22, 18, 0.55); border: 2px dashed rgba(26, 22, 18, 0.35); cursor: default; }
.pz:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.sub { font-size: 20px; margin: 8px 0 24px; }
.stats { display: flex; flex-wrap: wrap; gap: 16px 40px; margin: 0 0 32px; }
.stats .wide { flex-basis: 100%; }
.stats dt { font-size: 16px; font-weight: 700; }
.stats dd { margin: 0; font: 32px/1.1 var(--display); }
.stats dd.small { font: 700 20px/1.3 var(--body); max-width: 30em; }

/* Play: header, the devil's line, the puzzle, then the footer at the bottom */
.play { min-height: 100vh; min-height: 100dvh; max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; padding-top: max(12px, env(safe-area-inset-top)); }
.bar { display: flex; align-items: center; gap: 16px; }
.num { display: flex; flex-direction: column; }
.lab { font-size: 16px; font-weight: 700; }
.lvlno { display: inline-block; align-self: flex-start; font: 64px/1 var(--display); position: relative; z-index: 2; }
.wrongs { margin: 0 auto 0 8px; font-size: 16px; font-weight: 700; align-self: flex-end; padding-bottom: 6px; }
.wrongs b { font: 20px/1 var(--display); font-weight: 400; }
.devilwrap { position: relative; width: 72px; height: 72px; flex: none; }
.devil { position: relative; z-index: 1; display: block; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 4px; background: var(--coral); cursor: pointer; }
.devil img { display: block; width: 72px; height: 72px; pointer-events: none; }
.devil:focus-visible, .w:focus-visible, .found:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.zzz { position: absolute; right: 64px; top: -4px; font: 20px/1 var(--display); transform: rotate(-12deg); }
/* the devil's line; no bar while he is quiet */
.line:empty { border-color: transparent; }
.line { min-height: 2.8em; margin: 8px 0 0; padding-left: 12px; border-left: 4px solid var(--ink); font-size: 20px; font-weight: 700; line-height: 1.4; }

.stage { position: relative; flex: 1 0 auto; display: flex; flex-direction: column; align-items: stretch; padding: 20px 0 24px; }
.stage > .qwrap { align-self: flex-start; }
.stage > .hintbtn { align-self: flex-start; }
.qwrap { position: relative; }
.q { position: relative; z-index: 1; display: inline-block; background: var(--coral); font-size: 32px; line-height: 1.15; overflow-wrap: break-word; }
.q .w { display: inline-block; }
.q .dot { padding: 0 10px 0 2px; margin-right: -10px; }
.extra { margin-top: 16px; }
.extra:empty { display: none; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.answers.one { grid-template-columns: 1fr; }
.cell { position: relative; display: flex; }
.ans { position: relative; z-index: 1; flex: 1; min-height: 64px; justify-content: center; text-align: center; overflow: hidden; white-space: normal; line-height: 1.1; }
.ans .lbl { position: relative; }
.cell.big { grid-column: 1 / -1; order: -1; }
.cell.big .ans { min-height: 140px; }
.cell.far { grid-column: 1 / -1; margin-top: 130vh; }
.answers.arena { display: block; position: relative; height: 280px; border: 3px dashed rgba(26, 22, 18, 0.35); border-radius: 4px; }
.arena .cell { position: absolute; left: 30%; top: 40%; width: 140px; }
.ans.ticked, .lvlno.ticked { text-decoration: line-through; text-decoration-thickness: 4px; }
.ans.ticked { background: transparent; color: var(--ink); }

/* Hold: the button fills with coral while held */
.bar-fill { position: absolute; inset: 0; background: var(--coral); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.holdable { touch-action: none; }

/* Dragging */
.grab { touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; position: relative; z-index: 3; }
.grab.dragging { cursor: grabbing; }
.found { position: absolute; z-index: 0; font-size: 16px; min-height: 36px; padding: 4px 10px; }
.qwrap > .found { left: 0; top: 0; }
.devilwrap > .found, .cell > .found { inset: 0; margin: auto; width: fit-content; height: fit-content; }
.devilwrap > .found { padding: 4px 6px; }

/* Typing */
.typed { display: flex; flex-wrap: wrap; gap: 12px; }
.typed input {
  flex: 1 1 200px; min-width: 0; min-height: 56px; padding: 8px 12px; font: 700 20px/1.2 var(--body); color: var(--ink);
  background: var(--cream); border: 3px solid var(--ink); border-radius: 4px;
}
.typed input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.devils { display: flex; align-items: flex-end; gap: 28px; padding-left: 8px; }
.mini { width: 40px; height: 40px; }
.mini.m1 { width: 28px; height: 28px; margin-bottom: 18px; }
.mini.m2 { width: 52px; height: 52px; }

.hintbtn { margin-top: 20px; }
.hinttext { margin: 16px 0 0; font-size: 20px; font-weight: 700; }
.stamp { margin: 0; padding: 4px 12px; font: 32px/1.1 var(--display); color: var(--cream); background: var(--ink); border-radius: 4px; transform: rotate(-4deg); pointer-events: none; }
.stage.done .answers, .stage.done .extra { opacity: 0.45; }

.foot { padding-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.foot .btn { font-size: 16px; min-height: 44px; padding: 8px 12px; }

/* A wrong answer shakes the puzzle (not with reduced motion; main.js skips it then too) */
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.stage.shake { animation: shake 0.3s linear; }

@media (max-width: 480px) {
  .title h1 { font-size: 48px; }
  .title-devil { width: 96px; height: 96px; }
  .lvlno { font-size: 44px; }
  .q { font-size: 24px; }
  .line { font-size: 18px; }
  .answers { margin-top: 24px; }
  .foot { gap: 6px; }
  .foot .btn { padding: 8px; }
  .stamp { font-size: 20px; padding: 4px 8px; }
}
/* Phones held upright: answers sit low, under the thumb */
@media (max-width: 480px) and (min-height: 600px) {
  .stage > .answers { margin-top: auto; padding-top: 24px; }
  .stage > .answers.arena { padding-top: 0; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .title { justify-content: flex-start; gap: 12px; }
  .title-devil { display: none; }
  .title h1 { font-size: 40px; }
  .title h1 span { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  .btn:hover, .btn:active, .pz:hover:not(:disabled) { transform: none; }
  .stage.shake { animation: none; }
}
/* Phones sideways: a smaller header and answers, so the question and its answers fit the 343px screen */
@media (max-height: 500px) and (orientation: landscape) {
  .play { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .lvlno { font-size: 40px; }
  .devilwrap, .devil, .devil img { width: 48px; height: 48px; }
  .zzz { right: 44px; }
  .line { font-size: 16px; min-height: 1.4em; margin-top: 4px; }
  .stage { padding: 8px 0 12px; }
  .q { font-size: 24px; }
  .extra { margin-top: 8px; }
  .answers { margin-top: 12px; gap: 8px; }
  .ans { min-height: 48px; }
  .cell.big .ans { min-height: 72px; }
  .answers.arena { height: 160px; }
  .stamp { font-size: 20px; padding: 4px 8px; }
}
