:root {
  --frame-ratio: 941 / 1672;
  --cream: #fff3d1;
  --gold: #ffc83d;
  --cyan: #44dbff;
  --ink: #150905;
  --font-ko-pixel: "Mulmaru";
  --font-code-pixel: "Mulmaru", "Courier New", monospace;
  --font-ui: "Arial Black", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

@font-face {
  font-family: "Mulmaru";
  src: url("./assets/fonts/Mulmaru.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #020610;
  color: var(--cream);
  font-family: var(--font-ko-pixel), var(--font-ui);
  touch-action: manipulation;
  user-select: none;
}

button {
  font: inherit;
}

.pixel-img,
.screen-bg,
.pixel-btn,
.hud-card,
.fever-row,
.input-board,
.keyboard,
.slot,
.key,
.rules-card,
.result-panel,
.pay-box,
.rank-box,
.speech-bubble,
.screen-tab,
.best-strip,
.sound-toggle {
  image-rendering: pixelated;
}

.game-frame {
  position: relative;
  width: min(100vw, calc(100vh * var(--frame-ratio)), 560px);
  aspect-ratio: var(--frame-ratio);
  overflow: hidden;
  background: #061226;
  isolation: isolate;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.screen.is-active {
  display: block;
}

.screen-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.sound-toggle {
  position: absolute;
  top: 1.2%;
  right: 2%;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 8.5%;
  aspect-ratio: 1;
  border: 0;
  background: url("./assets/generated/icon-trophy.png") center / contain no-repeat;
  color: #fff7c8;
  cursor: pointer;
  font-size: clamp(17px, 4.8vw, 30px);
  line-height: 1;
  text-shadow:
    0.18vw 0 #251006,
    -0.18vw 0 #251006,
    0 0.18vw #251006,
    0 -0.18vw #251006;
  filter: drop-shadow(0 0.4vw 0 #03040a);
}

.sound-toggle.is-off {
  filter: grayscale(0.8) brightness(0.75) drop-shadow(0 0.4vw 0 #03040a);
}

.title-logo {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 3.6%;
  width: 86%;
  height: auto;
  filter: drop-shadow(0 2.2vw 0 rgba(0, 0, 0, 0.55));
}

.title-parcel {
  position: absolute;
  left: 10%;
  top: 48%;
  width: 80%;
  height: auto;
  filter: drop-shadow(0 2vw 0 rgba(0, 0, 0, 0.48));
}

.speech-bubble {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 2.4% 6% 5%;
  background: url("./assets/generated/speech-bubble.png") center / 100% 100% no-repeat;
  color: #12234a;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(16px, 4.4vw, 27px);
  line-height: 1.15;
  text-align: center;
  text-shadow: none;
  white-space: nowrap;
}

.title-speech {
  left: 14%;
  right: 14%;
  bottom: 23.2%;
  min-height: 8%;
}

.title-links {
  position: absolute;
  left: 15%;
  right: 15%;
  top: 39.2%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3%;
  z-index: 2;
}

.title-link {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: clamp(24px, 6vw, 38px);
  padding: 0 5%;
  background: url("./assets/generated/panel-hud.png") center / 100% 100% no-repeat;
  color: #8cf2ff;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(10px, 2.85vw, 18px);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 0.25vw 0 #00132b;
  white-space: nowrap;
  overflow: hidden;
}

.pixel-btn {
  position: absolute;
  display: grid;
  place-items: center;
  min-height: 8%;
  border: 0;
  background-color: transparent;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  color: #160805;
  cursor: pointer;
  font-family: var(--font-ko-pixel), var(--font-ui);
  text-align: center;
  text-shadow:
    0 0.22vw 0 #fff2b6,
    0.18vw 0.18vw 0 rgba(75, 33, 4, 0.35);
}

.pixel-btn span {
  display: block;
  padding-bottom: 0.6%;
  line-height: 0.92;
  white-space: nowrap;
  letter-spacing: 0;
}

.pixel-btn-gold {
  background-image: url("./assets/generated/button-gold.png");
}

.pixel-btn-green {
  background-image: url("./assets/generated/button-green.png");
}

.pixel-btn-blue {
  background-image: url("./assets/generated/button-blue.png");
}

.title-start {
  left: 20%;
  right: 20%;
  bottom: 12.2%;
  font-size: clamp(24px, 6.6vw, 42px);
}

.rules-start {
  left: 20%;
  right: 20%;
  bottom: 5.5%;
  font-size: clamp(24px, 6.6vw, 42px);
}

.game-title-btn {
  left: 35%;
  right: 35%;
  top: 0.6%;
  width: auto;
  min-height: 3%;
  z-index: 3;
  font-size: clamp(8px, 2.35vw, 15px);
}

.result-title-btn {
  left: 36%;
  right: 36%;
  top: 1.4%;
  z-index: 4;
  min-height: 4.2%;
  font-size: clamp(10px, 2.9vw, 18px);
}

.best-strip {
  position: absolute;
  left: 17%;
  right: 17%;
  bottom: 2.5%;
  display: grid;
  grid-template-columns: 12% 0.8fr minmax(0, 1.9fr);
  align-items: center;
  gap: 2%;
  min-height: 6.5%;
  padding: 1.2% 5%;
  background: url("./assets/generated/panel-hud.png") center / 100% 100% no-repeat;
  color: #fff7e8;
  font-size: clamp(17px, 4.6vw, 29px);
  overflow: hidden;
}

.best-strip img {
  width: 100%;
}

.best-strip span {
  color: #60eaff;
}

.best-strip strong {
  justify-self: end;
  font-family: var(--font-ko-pixel), var(--font-ui);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
  font-size: clamp(13px, 3.6vw, 23px);
  line-height: 1;
}

.screen-tab {
  position: absolute;
  left: 27%;
  right: 27%;
  top: 2.2%;
  display: grid;
  place-items: center;
  min-height: 5.5%;
  background: url("./assets/generated/panel-hud.png") center / 100% 100% no-repeat;
  color: #dceeff;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(15px, 4.2vw, 27px);
  text-shadow: 0 0.28vw 0 #000;
}

.rules-card {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 8%;
  bottom: 14%;
  padding: 8% 8% 5%;
  background: url("./assets/generated/panel-rules-paper.png") center / 100% 100% no-repeat;
  color: #1b0b04;
}

.rules-card h1 {
  margin: 0 0 2.2%;
  color: #ffc83d;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(28px, 8vw, 50px);
  line-height: 1;
  text-align: center;
  text-shadow:
    0.22vw 0 #271006,
    -0.22vw 0 #271006,
    0 0.22vw #271006,
    0 0.65vw 0 #5b2504;
}

.rule-example {
  display: grid;
  grid-template-columns: 34% 1fr;
  align-items: center;
  gap: 3%;
  margin-top: 1%;
}

.rule-example img {
  width: 100%;
}

.sample-code {
  display: grid;
  place-items: center;
  min-height: clamp(38px, 10vw, 64px);
  background: url("./assets/generated/key-wide.png") center / 100% 100% no-repeat;
  color: #130904;
  font-family: var(--font-code-pixel);
  font-synthesis: none;
  font-weight: 400;
  font-size: clamp(19px, 5.5vw, 34px);
  letter-spacing: 0;
}

.sample-input {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2%;
  margin: 2% 0 3%;
  padding: 2%;
  background: url("./assets/generated/panel-input.png") center / 100% 100% no-repeat;
}

.sample-input span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: url("./assets/generated/key.png") center / 100% 100% no-repeat;
  font-family: var(--font-code-pixel);
  font-synthesis: none;
  font-weight: 400;
  font-size: clamp(18px, 5.4vw, 34px);
}

.rule-lines {
  display: grid;
  gap: 0.7%;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-weight: 900;
}

.rule-lines p {
  display: grid;
  grid-template-columns: 10% 1fr;
  align-items: center;
  gap: 4%;
  margin: 0;
  min-height: clamp(34px, 8.4vw, 53px);
  border-top: 0.18vw dashed rgba(76, 44, 16, 0.35);
  font-size: clamp(11px, 3.25vw, 20px);
  line-height: 1.15;
}

.rule-lines img {
  width: 100%;
}

.hud {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 4%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2%;
}

.hud-card {
  display: grid;
  grid-template-rows: 36% 64%;
  min-height: clamp(67px, 13vw, 105px);
  padding: 5% 7%;
  background: url("./assets/generated/panel-hud.png") center / 100% 100% no-repeat;
}

.hud-label {
  align-self: center;
  color: #ffc83d;
  font-size: clamp(12px, 3.5vw, 22px);
  line-height: 1;
  text-align: center;
}

.hud-value {
  align-self: center;
  color: #fff8e6;
  font-size: clamp(25px, 8vw, 50px);
  line-height: 1;
  text-align: center;
  text-shadow: 0 0.42vw 0 #000;
}

.fever-row {
  position: absolute;
  left: 8.5%;
  right: 8.5%;
  top: 14.7%;
  display: grid;
  grid-template-columns: 18% minmax(0, 1fr) 16%;
  align-items: center;
  min-height: 5.4%;
  padding: 1.5% 5.6% 1.5% 4.5%;
  background: url("./assets/generated/panel-fever.png") center / 100% 100% no-repeat;
  color: #ff6576;
  font-size: clamp(13px, 3.7vw, 22px);
  overflow: hidden;
}

.fever-row > span {
  white-space: nowrap;
}

.fever-row strong {
  justify-self: end;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
  font-size: 0.9em;
  line-height: 1;
}

.fever-row.is-hot {
  color: #ffe162;
  filter: drop-shadow(0 0 10px rgba(255, 204, 45, 0.55));
}

.fever-track {
  height: 35%;
  min-height: 12px;
  margin-inline: 3%;
  overflow: hidden;
}

.fever-track i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22e5ff, #a24cff, #ffdc3c);
  transition: width 120ms linear;
}

.play-lane {
  position: absolute;
  left: 0;
  right: 0;
  top: 21%;
  height: 38%;
}

.parcel-wrap {
  position: absolute;
  left: -4%;
  right: -4%;
  top: 0;
  height: 92%;
  transform: translateX(0);
  transform-origin: center bottom;
}

.parcel-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2.2vw 1vw rgba(0, 0, 0, 0.55));
}

.parcel-code {
  position: absolute;
  left: 47.1%;
  top: 46%;
  width: 28.8%;
  height: 10.4%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  justify-items: center;
  gap: 0;
  color: #211109;
  font-family: var(--font-code-pixel);
  font-synthesis: none;
  font-weight: 400;
  font-size: clamp(20px, 5.85vw, 37px);
  line-height: 1;
  text-align: center;
  text-shadow: 0.1vw 0 #211109;
  transform: perspective(520px) rotateY(-13deg) rotateZ(-5.5deg) skewX(-3deg);
  transform-origin: left center;
}

.parcel-code span {
  display: block;
  transform: scaleX(0.92);
}

.parcel-code span:nth-child(1),
.parcel-code span:nth-child(6) {
  transform: translateY(1%) scaleX(0.92);
}

.parcel-code span:nth-child(3) {
  transform: translateY(-1%) scaleX(0.92);
}

.parcel-code span:nth-child(5) {
  transform: translateY(1%) scaleX(0.92);
}

.input-board {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 23.4%;
  min-height: 17.3%;
  padding: 4.2% 6% 4.2%;
  background: url("./assets/generated/panel-input.png") center / 100% 100% no-repeat;
  overflow: visible;
}

.input-board::before {
  content: "";
  position: absolute;
  inset: -2%;
  pointer-events: none;
  opacity: 0;
  border: 0.8vw solid transparent;
  border-image: linear-gradient(90deg, #ff4f7b, #ffcf33, #54ff73, #35dcff, #a65cff, #ff4f7b) 1;
}

.input-board::after {
  content: "";
  position: absolute;
  inset: -3%;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    0 0 1vw #ff4f7b,
    0 0 1.6vw #35dcff,
    0 0 2.2vw #ffcf33;
}

.input-board.is-fever::before,
.input-board.is-fever::after {
  opacity: 1;
  animation: fever-rainbow 880ms linear infinite;
}

.prompt {
  margin: 0 0 3%;
  color: #fff8e5;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(13px, 3.5vw, 22px);
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 0.32vw 0 #000;
  white-space: nowrap;
  word-break: keep-all;
}

.prompt b {
  color: var(--gold);
}

.slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2.5%;
}

.slot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: url("./assets/generated/slot.png") center / 100% 100% no-repeat;
  color: #fffdf2;
  font-family: var(--font-code-pixel);
  font-synthesis: none;
  font-weight: 400;
  font-size: clamp(25px, 7.2vw, 42px);
  line-height: 1;
}

.slot.is-active {
  filter: drop-shadow(0 0 0.8vw rgba(255, 209, 50, 0.9));
}

.quick-status {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: center;
  gap: 4%;
  margin-top: 3.1%;
  color: #d7e9ff;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(13px, 3.8vw, 22px);
}

.quick-status strong {
  color: #27deed;
  font-size: clamp(24px, 7vw, 42px);
  line-height: 1;
  text-align: right;
  text-shadow: 0 0.35vw 0 #00304f;
}

.keyboard {
  position: absolute;
  left: 1.4%;
  right: 1.4%;
  bottom: 1.8%;
  display: grid;
  gap: 0.65vw;
  padding: 2.2%;
  background: url("./assets/generated/panel-keyboard.png") center / 100% 100% no-repeat;
}

.key-row {
  display: grid;
  gap: 0.6vw;
}

.key-row:nth-child(1) {
  grid-template-columns: repeat(10, 1fr);
}

.key-row:nth-child(2) {
  grid-template-columns: 0.5fr repeat(9, 1fr) 0.5fr;
}

.key-row:nth-child(3) {
  grid-template-columns: 1.35fr repeat(7, 1fr) 1.35fr;
}

.key {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 0;
  background: url("./assets/generated/key.png") center / 100% 100% no-repeat;
  color: #160c06;
  cursor: pointer;
  font-family: var(--font-code-pixel);
  font-synthesis: none;
  font-weight: 400;
  font-size: clamp(17px, 4.8vw, 29px);
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 0.12vw 0 #fff7db;
}

.key:active {
  transform: translateY(0.45vw);
}

.key-wide {
  aspect-ratio: auto;
  background-image: url("./assets/generated/key-wide.png");
  font-family: var(--font-code-pixel);
  font-size: clamp(13px, 3.8vw, 22px);
}

.key-spacer {
  pointer-events: none;
}

.result-panel {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 7%;
  bottom: 14.5%;
  min-height: 0;
  padding: 5.8% 7% 3.6%;
  background: url("./assets/generated/panel-result-paper.png") center / 100% 100% no-repeat;
  color: var(--ink);
}

.result-panel h1 {
  margin: 0 0 2.8%;
  color: #ffc83d;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(30px, 8.4vw, 54px);
  line-height: 1;
  text-align: center;
  text-shadow:
    0.22vw 0 #1b0c04,
    -0.22vw 0 #1b0c04,
    0 0.22vw #1b0c04,
    0 0.68vw 0 #4b1c04;
}

.result-stats {
  margin: 0;
}

.result-stats div {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-items: center;
  min-height: clamp(24px, 6vw, 39px);
  border-bottom: 0.2vw solid rgba(72, 42, 18, 0.22);
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(12px, 3.4vw, 22px);
}

.result-stats dt {
  display: flex;
  align-items: center;
  gap: 4%;
}

.result-stats img {
  width: 11.5%;
  min-width: 24px;
}

.result-stats dd {
  margin: 0;
  text-align: right;
}

.pay-box {
  display: grid;
  place-items: center;
  margin-top: 3%;
  padding: 1.8% 3% 3.5%;
  background: url("./assets/generated/button-gold.png") center / 100% 100% no-repeat;
}

.pay-box span {
  color: #5c2b09;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(12px, 3.4vw, 22px);
}

.pay-box strong {
  color: #1d0b03;
  font-size: clamp(31px, 8.8vw, 56px);
  line-height: 1;
}

.rank-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4%;
  margin-top: 2.3%;
  padding: 2.2% 5%;
  background: url("./assets/generated/panel-hud.png") center / 100% 100% no-repeat;
  color: #fff9ef;
  font-family: var(--font-ko-pixel), var(--font-ui);
  font-size: clamp(11px, 3.15vw, 20px);
}

.rank-box strong {
  display: grid;
  place-items: center;
  width: clamp(34px, 8.8vw, 56px);
  aspect-ratio: 1;
  background: url("./assets/generated/icon-bolt.png") center / contain no-repeat;
  color: #fff5ff;
  font-size: clamp(21px, 6vw, 38px);
  text-shadow: 0 0.25vw 0 #2f155f;
}

.result-actions {
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 3.2%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3%;
  height: 7%;
}

.result-actions .pixel-btn {
  position: relative;
  min-height: 100%;
  font-size: clamp(18px, 5.1vw, 32px);
}

.parcel-wrap.fly-out {
  animation: parcel-out 260ms cubic-bezier(0.6, -0.02, 0.78, 0.42) forwards;
}

.parcel-wrap.fly-in {
  animation: parcel-in 260ms cubic-bezier(0.2, 0.72, 0.28, 1.04) forwards;
}

.parcel-wrap.shake {
  animation: parcel-shake 210ms linear;
}

@keyframes parcel-out {
  to {
    transform: translateX(120%) rotate(5deg);
    opacity: 0.2;
  }
}

@keyframes parcel-in {
  from {
    transform: translateX(-120%) rotate(-5deg);
    opacity: 0.2;
  }
  to {
    transform: translateX(0) rotate(0);
    opacity: 1;
  }
}

@keyframes parcel-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2.2%);
  }
  50% {
    transform: translateX(2.2%);
  }
  75% {
    transform: translateX(-1.4%);
  }
}

@keyframes fever-rainbow {
  0% {
    filter: hue-rotate(0deg);
  }
  50% {
    filter: hue-rotate(180deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}
