/* Moving Target. The SoSmarty look (base.css) on a rose ground; design rules live in the repo's CLAUDE.md. */
:root { --rose: #f0a3bd; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--rose); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body.m-select, body.m-ending { background: var(--cream); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.screen {
  max-width: 720px; margin: 0 auto;
  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: stands still */
.title { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 16px; }
.title-devil { width: 112px; height: 112px; }
.title h1 { font-size: 64px; line-height: 0.95; }
.title h1 span { display: block; }
.tagline { margin: 0; font-size: 20px; font-weight: 700; }
.blurb { margin: 0 0 8px; max-width: 34em; }
.keys { margin: 0; font-size: 16px; }
body.touch .keys { display: none; }

/* Rounds list and the ending, on cream */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rrow {
  width: 100%; display: grid; grid-template-columns: 2.2em 1fr auto 6.5em; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 14px; text-align: left; cursor: pointer;
  background: var(--ink); color: var(--cream); border: 3px solid var(--ink); border-radius: 4px; font: 700 16px/1.2 var(--body);
}
.rrow b { font: 20px/1 var(--display); font-weight: 400; }
.rrow .nm { font-size: 18px; }
.rrow .pat { font: 16px/1 var(--display); letter-spacing: 0.08em; white-space: nowrap; }
.rrow .st { text-align: right; }
.rrow.clean { background: var(--rose); color: var(--ink); }
.rrow:disabled { background: transparent; color: rgba(26, 22, 18, 0.55); border-style: dashed; border-color: rgba(26, 22, 18, 0.4); cursor: default; }
.rrow:hover:not(:disabled) { transform: translateY(-2px); }
.rrow:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.sub { margin: 8px 0 24px; font-size: 20px; }
.tally { display: grid; grid-template-columns: repeat(auto-fit, minmax(9em, 1fr)); gap: 16px 32px; margin: 0 0 28px; }
.tally dt { font-size: 16px; font-weight: 700; }
.tally dd { margin: 0; font: 32px/1.1 var(--display); }
.tally dd.small { font: 700 18px/1.3 var(--body); }

/* Play */
.play { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding-top: max(14px, env(safe-area-inset-top)); }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.rnd, .left { margin: 0; }
.rnd b { display: block; font: 32px/1 var(--display); font-weight: 400; }
.rnd span { font-size: 18px; font-weight: 700; }
.left { text-align: right; }
.lab { display: block; font-size: 16px; font-weight: 700; }
.left b { display: inline-block; font: 32px/1 var(--display); font-weight: 400; }
.talk { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.talk img { width: 48px; height: 48px; flex: none; }
#line { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; }

/* The fuse burns from the left toward the bomb; one segment per miss allowed */
.fuse { display: flex; align-items: center; height: 56px; }
.segs { flex: 1; display: flex; gap: 4px; align-items: center; }
.seg { flex: 1; height: 8px; background: var(--ink); border-radius: 4px; position: relative; }
.seg.burnt { background: transparent; border-top: 3px dotted rgba(26, 22, 18, 0.4); height: 0; border-radius: 0; }
.seg.lit::before {
  content: ''; position: absolute; left: -12px; top: -10px; width: 28px; height: 28px; background: var(--cream);
  clip-path: polygon(50% 0, 62% 34%, 100% 30%, 70% 55%, 88% 100%, 50% 72%, 12% 100%, 30% 55%, 0 30%, 38% 34%);
}
.bomb { position: relative; flex: none; width: 52px; height: 52px; margin-left: 2px; background: var(--ink); border-radius: 50%; }
.bomb::before { content: ''; position: absolute; left: -8px; top: 18px; width: 14px; height: 14px; background: var(--ink); border-radius: 3px; }
.bomb::after { content: ''; position: absolute; left: 12px; top: 10px; width: 10px; height: 10px; background: var(--cream); border-radius: 50%; }
.bang {
  display: none; position: absolute; right: -6px; top: 50%; translate: 0 -50%; padding: 26px 22px; z-index: 1;
  background: var(--cream); color: var(--ink); font: 20px/1 var(--display); text-transform: uppercase;
  clip-path: polygon(50% 0, 60% 22%, 86% 6%, 80% 34%, 100% 46%, 80% 60%, 92% 92%, 62% 78%, 50% 100%, 38% 78%, 8% 92%, 20% 60%, 0 46%, 20% 34%, 14% 6%, 40% 22%);
}
.fuse.blown .bomb { background: transparent; }
.fuse.blown .bomb::before, .fuse.blown .bomb::after { display: none; }
.fuse.blown .bang { display: block; }

/* The word: one slot per letter */
.word { display: flex; justify-content: center; gap: 8px; margin: 4px 0; min-height: 64px; }
.slot {
  width: 56px; height: 64px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px;
  border-bottom: 6px solid var(--ink); font: 40px/1 var(--display); text-transform: uppercase;
}
.slot.told { background: var(--cream); border-radius: 4px 4px 0 0; }

/* Letter keys */
.kb { display: grid; gap: 6px; }
.kbrow { display: flex; justify-content: center; gap: 6px; }
.key {
  flex: 0 1 52px; min-width: 0; height: 52px; padding: 0; cursor: pointer;
  background: var(--ink); color: var(--cream); border: 3px solid var(--ink); border-radius: 4px;
  font: 20px/1 var(--display); text-transform: uppercase;
}
.key:hover:not(:disabled) { transform: translateY(-2px); }
.key:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.key.hit { background: var(--cream); color: var(--ink); cursor: default; }
.key.miss { background: transparent; color: rgba(26, 22, 18, 0.45); border-color: rgba(26, 22, 18, 0.3); text-decoration: line-through; text-decoration-thickness: 3px; cursor: default; }
.key:disabled:not(.hit):not(.miss) { cursor: default; }

.wordform { display: flex; flex-wrap: wrap; gap: 10px; }
.wordform input {
  flex: 1 1 180px; min-width: 0; min-height: 52px; padding: 8px 12px; color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); border-radius: 4px; font: 24px/1 var(--display); text-transform: uppercase; letter-spacing: 0.1em;
}
.wordform input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.after { display: flex; gap: 10px; }
.after .btn { flex: 1; min-height: 64px; font-size: 24px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.tools .btn { font-size: 16px; min-height: 44px; padding: 8px 12px; }

/* State changes get a small kick; reduced motion turns them off */
@keyframes pop { 0% { transform: scale(1.25); } 100% { transform: none; } }
@keyframes say { 0% { transform: translateX(-6px); opacity: 0.3; } 100% { transform: none; opacity: 1; } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.left b.pop { animation: pop 0.25s ease-out; }
#line.pop { animation: say 0.2s ease-out; }
.shake { animation: shake 0.3s linear; }
@media (prefers-reduced-motion: reduce) {
  .left b.pop, #line.pop, .shake { animation: none; }
  .btn:hover, .btn:active, .key:hover:not(:disabled), .rrow:hover:not(:disabled) { transform: none; }
}

/* Phones upright: smaller slots and keys, keys low under the thumb */
@media (max-width: 480px) {
  .title h1 { font-size: 48px; }
  .title-devil { width: 88px; height: 88px; }
  .play { gap: 10px; }
  .word { gap: 5px; min-height: 52px; }
  .slot { width: 36px; height: 52px; font-size: 28px; border-bottom-width: 5px; padding-bottom: 4px; }
  .kb, .kbrow { gap: 4px; }
  .key { height: 48px; font-size: 18px; border-width: 2px; }
  .rrow { grid-template-columns: 1.8em 1fr auto; gap: 10px; padding: 8px 10px; }
  .rrow .pat { display: none; }
}
@media (max-width: 480px) and (min-height: 600px) {
  .play { justify-content: flex-start; }
  .word { margin-top: auto; }
  .kb, .after { margin-top: auto; }
}

/* Phones sideways: the word on the left, the keys on the right */
@media (max-height: 500px) and (orientation: landscape) {
  .title { justify-content: flex-start; gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); }
  .title-devil, .blurb { display: none; }
  .title h1 { font-size: 40px; }
  .title h1 span { display: inline; }
  .play {
    max-width: none; display: grid; grid-template-columns: 1fr 1.15fr; grid-template-rows: auto auto auto 1fr;
    column-gap: 20px; row-gap: 6px; align-content: start; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px;
  }
  .play > * { grid-column: 1; }
  .top { grid-row: 1; }
  .talk { grid-row: 2; min-height: 44px; }
  .talk img { width: 36px; height: 36px; }
  #line { font-size: 16px; }
  .fuse { grid-row: 3; height: 44px; }
  .bomb { width: 40px; height: 40px; }
  .bomb::before { top: 13px; }
  .bomb::after { left: 9px; top: 8px; width: 8px; height: 8px; }
  .word { grid-row: 4; align-self: start; }
  .slot { width: 32px; height: 44px; font-size: 24px; }
  .kb, .wordform, .after { grid-column: 2; grid-row: 1 / 4; align-self: start; }
  .tools { grid-column: 2; grid-row: 4; align-self: end; }
  .key { height: 42px; font-size: 16px; border-width: 2px; }
  .kb, .kbrow { gap: 4px; }
}
