/* Real keys occupy the fixed coral housing published by the mobile scene. */
.app-viewport > .typewriter-keyboard {
  display: none;
}
/* A small reading aid above the finger, independent of the retained key DOM.
   It is decoration only and cannot steal the input focus or another tap. */
.app-viewport > .typewriter-key-preview {
  position: absolute;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #315D75;
  background: #FFF4DC;
  color: #263E44;
  box-shadow: 0 3px 0 #213D43;
  font: 400 30px/1 "VT323",monospace;
  pointer-events: none;
  user-select: none;
  box-sizing: border-box;
}
.app-viewport > .typewriter-key-preview[hidden] { display: none; }
.app-viewport[data-category=english][data-typewriter-keyboard=true] > .typewriter-keyboard:not([hidden]) {
  position: absolute;
  z-index: 4;
  left: var(--typewriter-keys-left,12px);
  top: var(--typewriter-keys-top,50%);
  width: var(--typewriter-keys-width,calc(100% - 24px));
  height: 188px;
  display: grid;
  grid-template-rows: repeat(4,44px);
  gap: 4px;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.typewriter-keyboard .typewriter-keyboard-row {
  display: grid;
  grid-template-columns: repeat(12,minmax(0,1fr));
  /* Adjacent rectangular hit areas share the row's width. The smaller painted
     caps keep their breathing room without leaving untappable 2px gutters. */
  gap: 0;
  min-width: 0;
  height: 44px;
}
.typewriter-keyboard .typewriter-keyboard-row[data-row="1"] {
  grid-template-columns: repeat(11,minmax(0,1fr));
  margin-inline: calc(100%/24);
}
.typewriter-keyboard .typewriter-keyboard-row[data-row="2"] {
  grid-template-columns: repeat(10,minmax(0,1fr));
  margin-inline: calc(100%/12);
}
.typewriter-keyboard .typewriter-keyboard-row[data-row="3"] {
  grid-template-columns: 1.7fr 5fr 1.7fr;
  gap: 4px;
}
.typewriter-keyboard .typewriter-key {
  /* The small stepped cap is paint only: the real rectangular button keeps
     its full 44px height and the complete column width. A 12-key Turkish row
     cannot provide 44px widths on a narrow phone. Both icon pseudos stay free. */
  --typewriter-keycap-size: clamp(18px,calc((var(--typewriter-keys-width,280px) - 46px)/12),28px);
  --typewriter-keycap-width: min(var(--typewriter-keycap-size),calc(100% - 2px));
  --typewriter-keycap-height: var(--typewriter-keycap-size);
  --typewriter-keycap-face: #FFF3D9;
  --typewriter-keycap-light: #FFFAEA;
  --typewriter-keycap-rim: #D0C7A9;
  --typewriter-keycap-shadow: #213D43;
  --typewriter-keycap-paint: linear-gradient(to bottom,
    var(--typewriter-keycap-light) 0 1px,
    var(--typewriter-keycap-face) 1px calc(100% - 2px),
    var(--typewriter-keycap-rim) calc(100% - 2px));
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  height: 44px;
  min-height: 44px;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 2px 1px;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image:
    var(--typewriter-keycap-paint),var(--typewriter-keycap-paint),var(--typewriter-keycap-paint),
    linear-gradient(var(--typewriter-keycap-shadow),var(--typewriter-keycap-shadow)),
    linear-gradient(var(--typewriter-keycap-shadow),var(--typewriter-keycap-shadow)),
    linear-gradient(var(--typewriter-keycap-shadow),var(--typewriter-keycap-shadow));
  background-size:
    calc(var(--typewriter-keycap-width) - 8px) var(--typewriter-keycap-height),
    calc(var(--typewriter-keycap-width) - 4px) calc(var(--typewriter-keycap-height) - 4px),
    var(--typewriter-keycap-width) calc(var(--typewriter-keycap-height) - 12px),
    calc(var(--typewriter-keycap-width) - 8px) var(--typewriter-keycap-height),
    calc(var(--typewriter-keycap-width) - 4px) calc(var(--typewriter-keycap-height) - 4px),
    var(--typewriter-keycap-width) calc(var(--typewriter-keycap-height) - 12px);
  background-position: center,center,center,center calc(50% + 2px),center calc(50% + 2px),center calc(50% + 2px);
  background-repeat: no-repeat;
  color: #263E44;
  box-shadow: none;
  font: 400 22px/1 "VT323",monospace;
  text-align: center;
  letter-spacing: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.typewriter-keyboard .typewriter-key:focus-visible {
  outline: 2px solid #315D75;
  outline-offset: -4px;
}
.typewriter-keyboard .typewriter-key:is(.is-pressed,[data-pressed=true],:active):not(:disabled) {
  --typewriter-keycap-face: #DEC59C;
  --typewriter-keycap-light: #F0DDBB;
  --typewriter-keycap-rim: #BFAE8E;
  --typewriter-keycap-shadow: transparent;
  transform: translateY(2px);
}
.typewriter-keyboard .typewriter-key:disabled {
  --typewriter-keycap-face: #E8DFCA;
  --typewriter-keycap-light: #F4EDDB;
  --typewriter-keycap-rim: #BDB79E;
  cursor: default;
  opacity: 1;
  color: #66766D;
}
.typewriter-keyboard .typewriter-key:is([data-key-kind=mode],[data-key-kind=enter]) {
  --typewriter-keycap-width: min(64px,calc(100% - 8px));
  --typewriter-keycap-height: 28px;
}
.typewriter-keyboard .typewriter-key[data-key-kind=mode] {
  font-size: 15px;
  line-height: .95;
  white-space: normal;
}
.typewriter-keyboard .typewriter-key[data-key-kind=space] {
  --typewriter-keycap-width: calc(100% - 12px);
  --typewriter-keycap-height: 22px;
  font-size: 20px;
  letter-spacing: .04em;
}
.typewriter-keyboard .typewriter-key:is([data-key-kind=backspace],[data-key-kind=enter]) {
  position: relative;
  font-size: 0;
}
.typewriter-keyboard .typewriter-key[data-key-kind=backspace]::before {
  content: "";
  grid-area: 1 / 1;
  width: 16px;
  height: 11px;
  background: currentColor;
  clip-path: polygon(28% 0,100% 0,100% 100%,28% 100%,0 50%);
}
.typewriter-keyboard .typewriter-key[data-key-kind=backspace]::after {
  content: "×";
  grid-area: 1 / 1;
  margin-left: 3px;
  color: var(--typewriter-keycap-face);
  font: 12px/1 Arial,sans-serif;
}
.typewriter-keyboard .typewriter-key[data-key-kind=enter]::before {
  content: "";
  grid-area: 1 / 1;
  width: 17px;
  height: 12px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  box-sizing: border-box;
}
.typewriter-keyboard .typewriter-key[data-key-kind=enter]::after {
  content: "";
  position: absolute;
  left: calc(50% - 13px);
  top: calc(50% + 1px);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid currentColor;
}
.app-viewport > .typewriter-cat-overlay {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  image-rendering: pixelated;
}
.app-viewport[data-category=english][data-typewriter-keyboard=true] > .typewriter-cat-overlay:not([hidden]) {
  display: block;
}
/* Closed native/software-keyboard selectors must not displace this sheet. */
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .question-panel {
  position: absolute;
  grid-column: auto;
  grid-row: auto;
  left: var(--ios-paper-question-left);
  top: var(--ios-paper-question-top);
  width: var(--ios-paper-question-width);
  min-width: 0;
  min-height: 0;
  max-height: var(--ios-paper-question-height);
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  clip-path: none;
  transform: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  z-index: 6;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .question-panel h1 {
  font: 400 22px/1.12 "VT323",monospace;
  color: #263E44;
  letter-spacing: 0;
  overflow-wrap: break-word;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .question-panel .question-condition {
  display: block;
  margin: 0 0 2px;
  font: 400 16px/1.05 "VT323",monospace;
  color: #49605F;
  letter-spacing: 0;
}
@container (max-width:350px) {
  html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .question-panel h1 {
    font-size: 21px;
  }
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .question-eyebrow {
  display: none;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .answer-input {
  background: #FFF4DC;
  color: #263E44;
  border: 1px solid #B9AA88;
  box-shadow: inset 0 2px 0 #E8DABD;
  caret-color: #315D75;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true] .game-ui .answer-input:focus {
  border-color: #315D75;
  outline: 2px solid #315D75;
  outline-offset: -2px;
}
/* This two-line result fits the 52px prompt reserved on a short phone with
   a notice above its composer. Long answers keep the existing inner scroll. */
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true][data-typewriter-paper-density=tight] .ios-answer-card.ios-answer-paper-result {
  --ios-result-answer: 22px;
  --ios-result-points: 24px;
  --ios-result-title: 16px;
  padding: 2px;
  overflow: auto;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true][data-typewriter-paper-density=tight] .ios-answer-paper-result .ios-answer-text {
  line-height: 1.1;
}
html #review-main .app-viewport[data-category=english][data-typewriter-keyboard=true][data-typewriter-paper-density=tight] .ios-answer-paper-result .ios-answer-tier {
  margin-top: 2px;
  line-height: 1.1;
}
@media (prefers-reduced-motion: reduce) {
  .typewriter-keyboard .typewriter-key { transition: none; }
}
