:root {
  --ink: #20231f;
  --lcd-ink: #1b2924;
  --lcd-left: 21.42%;
  --lcd-top: 18.26%;
  --lcd-width: 58.2%;
  --lcd-height: 57.55%;
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: none;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    linear-gradient(rgba(255, 247, 230, .22), rgba(222, 241, 235, .18)),
    url("../game/page-check-bg.webp");
  background-size: auto, 360px 360px;
  background-position: center;
  background-repeat: repeat;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

body {
  min-height: 100svh;
}

button {
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
  outline: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button:focus,
button:focus-visible,
.screen:focus,
.screen:focus-visible,
canvas:focus,
canvas:focus-visible {
  outline: 0;
}

.game-app {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  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));
  opacity: 1;
  transition: opacity .18s ease;
}

.is-loading .game-app {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.handheld {
  position: relative;
  width: min(1536px, calc(100vw - 16px), calc((100svh - 16px) * 1.5));
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: clamp(22px, 4.2vw, 66px);
  filter: drop-shadow(0 26px 48px rgba(38, 34, 27, .22));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.shell-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen-bezel {
  position: absolute;
  left: var(--lcd-left);
  top: var(--lcd-top);
  z-index: 2;
  width: var(--lcd-width);
  height: var(--lcd-height);
  overflow: hidden;
  border-radius: clamp(5px, 1.15vw, 18px);
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  background:
    repeating-linear-gradient(0deg, rgba(23, 35, 31, .07) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(23, 35, 31, .05) 0 1px, transparent 1px 5px),
    #c6d0c3;
  filter: contrast(1.06) saturate(.78);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.screen:focus-visible,
.shell-hotspot:focus-visible {
  outline: 0;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    linear-gradient(rgba(255, 247, 230, .34), rgba(222, 241, 235, .22)),
    url("../game/page-check-bg.webp");
  background-size: auto, 360px 360px;
  color: #1e2722;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

.loading-screen__panel {
  width: min(380px, 100%);
  padding: 18px;
  border: 2px solid rgba(45, 57, 50, .72);
  border-radius: 8px;
  background: rgba(239, 230, 207, .92);
  box-shadow: 0 14px 26px rgba(26, 24, 18, .2);
  font-family: "Courier New", ui-monospace, monospace;
  text-align: center;
}

.loading-screen__title,
.loading-screen__count {
  margin: 0;
  font-weight: 900;
}

.loading-screen__title {
  font-size: 1rem;
  line-height: 1.2;
}

.loading-screen__count {
  margin-top: 10px;
  font-size: .86rem;
}

.loading-screen__bar {
  height: 14px;
  margin-top: 12px;
  overflow: hidden;
  border: 2px solid rgba(31, 39, 34, .72);
  border-radius: 999px;
  background: #c6d0c3;
}

.loading-screen__bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: #e7b957;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .36);
  transition: width .16s ease;
}

.game-app[data-state="gameover"] .handheld {
  animation: hit-shake .34s cubic-bezier(.36, .07, .19, .97) both;
}

.install-prompt {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(32, 35, 31, .18);
}

.install-prompt[hidden] {
  display: none;
}

.install-prompt__panel {
  justify-self: center;
  width: min(420px, 100%);
  padding: 14px;
  border: 2px solid rgba(45, 57, 50, .72);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 247, 230, .88), rgba(229, 239, 226, .9)),
    url("../game/page-check-bg.webp");
  background-size: auto, 220px 220px;
  box-shadow: 0 14px 26px rgba(26, 24, 18, .24);
  color: #1e2722;
  font-family: "Courier New", ui-monospace, monospace;
}

.install-prompt__title,
.install-prompt__text {
  margin: 0;
}

.install-prompt__title {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.install-prompt__text {
  margin-top: 7px;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
}

.install-prompt__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.install-prompt__button {
  min-width: 116px;
  min-height: 38px;
  padding: 8px 13px;
  border: 2px solid rgba(41, 48, 43, .7);
  border-radius: 999px;
  background: #e7b957;
  color: #29251d;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .46), 0 4px 0 rgba(89, 67, 32, .28);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 900;
}

.install-prompt__button--ghost {
  background: #9dc1ad;
}

@keyframes hit-shake {
  10%,
  90% {
    transform: translateX(-1px);
  }

  20%,
  80% {
    transform: translateX(2px);
  }

  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }

  40%,
  60% {
    transform: translateX(4px);
  }
}

@media (max-width: 540px) {
  .game-app {
    align-items: center;
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
