:root { color-scheme: light; font-family: system-ui, sans-serif; color: #16253f; background: #132d4f; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.handheld { width: min(100%, 580px); margin: auto; padding: 13px clamp(10px, 3vw, 18px) 12px; border: 2px solid #c6bba8; border-radius: 22px 22px 44px 22px; background: linear-gradient(145deg, #f7f0e3, #ddd2bf); box-shadow: inset 0 1px 2px #fff, 0 8px 22px #06152a99; }
header { display: flex; align-items: center; gap: 8px; font-weight: 850; font-size: 1.2rem; padding-bottom: 8px; margin-bottom: 9px; border-bottom: 3px solid #8a2549; box-shadow: 0 2px #447ba2; }
header img { width: 27px; height: 27px; object-fit: contain; }
.screen { width: 100%; max-width: 480px; margin-inline: auto; padding: 6px; border: 1px solid #080e17; border-radius: 11px; background: #293141; box-shadow: inset 0 2px 8px #101522; }
.menu { min-height: 0; padding: 13px; color: #25351e; background: #bccc8e; border: 2px solid #677b4d; border-radius: 5px; }
h1 { margin: 0 0 10px; font-size: 1.25rem; }
button, a { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid #2766a4; outline-offset: 2px; }
.game { display: grid; width: 100%; padding: 0; overflow: hidden; color: #fff; background: #253a27; border: 2px solid #253a27; border-radius: 7px; text-align: left; }
.game img { display: block; width: 100%; max-height: clamp(85px, 21svh, 150px); object-fit: cover; }
.game strong { padding: 9px 10px; }
iframe { width: 100%; height: clamp(190px, 40dvh, 340px); border: 0; border-radius: 5px; background: #132d4f; }
iframe:not([hidden]) { display: block; }
.status { margin: 9px 0 14px; font-size: .8rem; text-align: center; }
.controls { display: flex; justify-content: space-between; max-width: 480px; margin-inline: auto; gap: 12px; align-items: center; padding-inline: clamp(2px, 1.5vw, 10px); }
.pad { display: grid; --pad-size: clamp(44px, 12vw, 54px); grid-template-columns: repeat(3, var(--pad-size)); grid-template-rows: repeat(3, var(--pad-size)); gap: 4px; }
.pad button { color: #f2f0e9; background: linear-gradient(#384151, #181e2a); border: 1px solid #111723; border-radius: 9px; padding: 0; box-shadow: 0 2px 0 #111723; }
.pad button:nth-child(1) { grid-area: 1 / 2; }
.pad button:nth-child(2) { grid-area: 2 / 1; }
.pad button:nth-child(3) { grid-area: 2 / 3; }
.pad button:nth-child(4) { grid-area: 3 / 2; }
.pad::after { content: ''; grid-area: 2 / 2; place-self: center; width: 70%; height: 70%; background: #222a37; border-radius: 8px; pointer-events: none; }
.actions { display: flex; gap: clamp(12px, 4vw, 24px); align-items: center; }
.actions button { width: clamp(46px, 14vw, 60px); padding: 0; aspect-ratio: 1; border-radius: 50%; border: 2px solid #511c31; color: #fff; background: radial-gradient(at 30% 20%, #a74365, #711e39); box-shadow: 0 3px 0 #501a31; font-size: 1.1rem; font-weight: 850; }
.actions button:first-child { order: 2; transform: translateY(-12px); }
[data-control] { touch-action: none; user-select: none; }
[data-control][data-held] { filter: brightness(1.28); }
footer { display: flex; justify-content: center; gap: clamp(8px, 3vw, 16px); margin-top: 18px; }
footer a, footer button { display: grid; place-items: center; min-width: 44px; padding-inline: 11px; min-height: 44px; color: #fff; background: #46566d; border: 1px solid #2e3949; border-radius: 999px; font-size: .8rem; text-decoration: none; }

#next { background: #23466e; border-color: #142d4f; font-weight: 750; min-width: 86px; }
[hidden] { display: none !important; }
#install { margin-top: 12px; text-align: center; }
#install-app { min-height: 44px; padding: 6px 18px; border: 1px solid #162f50; border-radius: 999px; color: #fff; background: #23466e; font-size: .875rem; font-weight: 750; }
#install-help { max-width: 36ch; margin: 8px auto 0; font-size: .875rem; }
.build { margin-block: 10px 0; text-align: center; font-size: .75rem; }
@media (orientation: landscape) and (max-height: 650px) and (min-width: 540px) {
  .handheld { width: min(100%, 1050px); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 14px; color: #fff; background: linear-gradient(150deg,#313744,#171b25); border-color: #090d17; }
  header, .status, footer, #install, .build { grid-column: 1 / -1; }
  .screen { grid-area: 1 / 2; max-width: none; margin: 0; align-self: center; }
  .menu { min-height: 0; }
  .game img { max-height: 27svh; }
  iframe { height: clamp(150px, calc(100dvh - 130px), 350px); }
  .controls { display: contents; }
  .pad { --pad-size: clamp(44px, 7dvh, 50px); grid-area: 1 / 1; align-self: center; }
  .actions { grid-area: 1 / 3; align-self: center; }
}
footer { flex-wrap: wrap; }
#fullscreen { min-width: 44px; font-size: 1.2rem; }
iframe[data-loading] { visibility: hidden; }
.handheld:is(:fullscreen, :-webkit-full-screen) { width: 100%; height: 100%; max-width: none; border-radius: 0; overflow: auto; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
@media (max-width: 355px) {
  .handheld { padding-inline: 8px; }
  .controls { padding-inline: 0; gap: 8px; }
  .actions { gap: 8px; }
  .actions button { width: 44px; }
  footer { gap: 4px; }
  footer a, footer button { padding-inline: 7px; }
  #next { min-width: 76px; }
}

@media (orientation: portrait) and (max-height: 560px) {
  iframe { height: clamp(160px, calc(100dvh - 285px), 220px); }
}

@media (orientation: portrait) and (max-width: 600px) {
  .status { margin-bottom: clamp(14px, calc(12dvh - 50px), 42px); }
  .pad { gap: 6px; }
  .actions { gap: clamp(12px, 5vw, 26px); }
  footer { margin-top: clamp(18px, calc(7dvh - 20px), 32px); }
}
