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

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

:root {
  --ink: #20415f;
  --deep: #18314a;
  --blue: #2a83df;
  --mint: #56d9c8;
  --yellow: #ffdd69;
  --purple: #b8a4ff;
  --white: #fffdf2;
  --shadow: rgba(26, 54, 79, 0.22);
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(42, 131, 223, 0.09) 1px, transparent 1px),
    linear-gradient(0deg, rgba(86, 217, 200, 0.11) 1px, transparent 1px),
    #eaf9ff;
  background-size: 18px 18px;
  color: var(--ink);
  font-family: "Galmuri11", "Malgun Gothic", sans-serif;
  letter-spacing: 0;
}

button {
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.phone-shell {
  position: relative;
  width: min(100%, 430px);
  height: min(860px, calc(100dvh - 24px));
  min-height: 640px;
  overflow: hidden;
  border: 4px solid #234766;
  border-radius: 18px;
  background: #b8eeff;
  box-shadow:
    0 0 0 2px #ffffff,
    0 18px 46px rgba(37, 80, 115, 0.32);
  image-rendering: pixelated;
  touch-action: manipulation;
}

.bgm-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 8;
  min-width: 76px;
  min-height: 34px;
  padding: 0 10px;
  border: 3px solid #2b607f;
  border-radius: 8px;
  background: #fff7bd;
  color: #235270;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.55),
    0 4px 0 rgba(35, 77, 107, 0.18);
}

.bgm-toggle[aria-pressed="false"] {
  background: #e8f5ff;
  color: #5f7180;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 22px;
  background-position: center;
  background-size: cover;
}

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

.title-screen {
  justify-content: space-between;
  align-items: center;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.22)),
    url("./assets/backgrounds/title_bg.png");
}

.howto-screen {
  justify-content: center;
  gap: 14px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(237, 251, 255, 0.26)),
    url("./assets/backgrounds/howto_bg.png");
}

.game-screen {
  gap: 12px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(228, 249, 255, 0.21)),
    url("./assets/backgrounds/game_bg.png");
}

.result-screen {
  justify-content: center;
  gap: 12px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(238, 251, 255, 0.28)),
    url("./assets/backgrounds/result_bg.png");
}

img {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
}

.decor {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 6px 0 rgba(36, 71, 102, 0.12));
}

.title-pipe {
  top: -34px;
  left: -28px;
  width: 170px;
  opacity: 0.92;
}

.title-monitor-a {
  top: 116px;
  right: -24px;
  width: 112px;
  transform: rotate(6deg);
}

.title-monitor-b {
  bottom: 126px;
  left: -22px;
  width: 104px;
  transform: rotate(-8deg);
}

.game-monitor {
  top: 94px;
  right: -18px;
  width: 76px;
  opacity: 0.9;
}

.game-lights {
  top: 56px;
  left: 18px;
  width: 112px;
  opacity: 0.9;
}

.title-stack,
.best-wrap,
.image-button,
.howto-card,
.status-panel,
.round-board,
.machine-panel,
.log-panel,
.result-heading,
.result-panel,
.result-actions {
  position: relative;
  z-index: 1;
}

.title-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  padding-top: 14px;
  text-align: center;
}

.logo-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
}

.logo-wrap img {
  width: 100%;
  filter: drop-shadow(0 7px 0 rgba(29, 71, 103, 0.18));
}

.title-logo-wrap {
  max-width: 362px;
}

.subtitle-logo-wrap {
  max-width: 306px;
  margin-top: -8px;
}

.hero-copy {
  margin: -2px 0 0;
  padding: 7px 14px;
  border: 3px solid #2c6289;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.84);
  color: #2e6f9f;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(33, 77, 111, 0.16);
}

.ghost-button span {
  position: absolute;
  color: #fffdf6;
  font-size: clamp(1.35rem, 7vw, 1.9rem);
  font-weight: 700;
  text-shadow:
    2px 2px 0 rgba(20, 52, 76, 0.66),
    0 3px 0 rgba(20, 52, 76, 0.28);
  pointer-events: none;
}

.best-wrap {
  display: grid;
  place-items: center;
  width: min(82%, 288px);
}

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

.best-wrap div {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 78%;
  color: #1f5278;
  font-weight: 700;
}

.best-wrap span {
  color: #2a83df;
  font-size: 1.05rem;
}

.best-wrap strong {
  font-size: 1.08rem;
}

.image-button {
  display: grid;
  place-items: center;
  width: min(88%, 330px);
  margin: 0 auto;
}

.image-button img {
  width: 100%;
  filter: drop-shadow(0 6px 0 rgba(25, 73, 105, 0.16));
}

.image-button span {
  position: absolute;
  color: #fffef6;
  font-size: 1.58rem;
  font-weight: 700;
  text-shadow:
    2px 2px 0 #1f5278,
    -2px 2px 0 #1f5278,
    2px -2px 0 #1f5278,
    -2px -2px 0 #1f5278;
}

.image-button:focus-visible,
.ghost-button:focus-visible {
  outline: 4px solid #fff279;
  outline-offset: 2px;
}

.howto-card,
.log-panel,
.result-panel,
.machine-panel,
.status-panel {
  display: grid;
  place-items: center;
}

.howto-card {
  min-height: 530px;
}

.panel-img,
.status-panel > img,
.result-panel > img,
.log-panel > img,
.machine-panel > img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.panel-content {
  position: absolute;
  inset: 9% 9%;
  display: flex;
  flex-direction: column;
}

.howto-card .panel-content {
  inset: 10% 11%;
  justify-content: center;
}

.howto-card h2,
.log-panel h2,
.result-heading h2 {
  margin: 0;
  color: #226797;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.howto-card h2 {
  margin-bottom: 10px;
  font-size: 2.25rem;
}

.count-sample {
  align-self: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 3px solid #3a87b9;
  border-radius: 6px;
  background: #effcff;
  color: #1c5d8c;
  font-size: clamp(0.95rem, 4.5vw, 1.15rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  word-break: keep-all;
}

.howto-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #244a66;
  font-size: 0.98rem;
  line-height: 1.35;
}

.howto-list li {
  padding: 8px 10px;
  border: 2px solid rgba(59, 135, 185, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.sample-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.sample-buttons div {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
}

.sample-buttons img {
  width: 100%;
}

.sample-buttons span {
  position: absolute;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-shadow: 1px 1px 0 #20415f;
}

.result-kinds {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.result-kinds span {
  padding: 5px 7px;
  border: 2px solid rgba(44, 125, 180, 0.34);
  border-radius: 5px;
  background: #fff9d9;
  color: #275f88;
  font-size: 0.84rem;
  font-weight: 700;
}

.start-button {
  width: min(82%, 316px);
}

.status-panel {
  height: 92px;
}

.status-grid {
  position: absolute;
  inset: 16px 22px 20px;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 8px;
}

.status-grid div {
  display: grid;
  place-items: center;
  min-width: 0;
  color: #1e638f;
}

.status-grid span {
  font-size: 0.72rem;
  font-weight: 700;
}

.status-grid strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #174565;
  font-size: clamp(1.14rem, 5vw, 1.55rem);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.round-board {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 104px;
  padding: 12px;
  border: 3px solid #4a92c2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 5px 0 rgba(35, 77, 107, 0.12);
  text-align: center;
}

.round-board p {
  margin: 0;
  color: #23638e;
  font-size: 1.1rem;
  font-weight: 700;
}

.round-board strong {
  color: #174565;
  font-size: clamp(1.08rem, 5.2vw, 1.45rem);
  line-height: 1.15;
}

.round-board span {
  color: #47718d;
  font-size: 0.94rem;
  font-weight: 700;
}

.machine-panel {
  flex: 1 1 auto;
  min-height: 294px;
}

.machine-content {
  position: absolute;
  inset: 18% 10% 18%;
  display: grid;
  place-items: center;
}

.ghost-button {
  position: relative;
  display: grid;
  place-items: center;
  width: min(92%, 310px);
  cursor: pointer;
}

.ghost-button[disabled] {
  cursor: default;
}

.ghost-button img {
  width: 100%;
  pointer-events: none;
  user-select: none;
}

.ghost-button,
.ghost-button * {
  transition: none;
  animation: none;
}

.ghost-button span {
  display: grid;
  place-items: center;
  min-width: 5.2em;
  line-height: 1;
  font-size: clamp(1.48rem, 7.6vw, 2.12rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bubble-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.anxiety-bubble {
  --bubble-border: #66bfe0;
  position: absolute;
  display: grid;
  place-items: center;
  width: min(34%, 132px);
  min-height: 46px;
  padding: 8px 10px 11px;
  border: 2px solid var(--bubble-border);
  border-radius: 10px;
  background: #fffef7;
  box-shadow:
    inset 0 0 0 2px rgba(135, 225, 213, 0.36),
    0 4px 0 rgba(39, 96, 132, 0.16);
  color: #235270;
  animation: bubble-float var(--life, 2.5s) ease-out forwards;
}

.anxiety-bubble::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--bubble-border);
  border-bottom: 2px solid var(--bubble-border);
  background: #fffef7;
  transform: rotate(45deg);
}

.anxiety-bubble span {
  font-size: clamp(0.62rem, 2.8vw, 0.72rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  word-break: keep-all;
}

.bubble-tone-2 {
  --bubble-border: #8fd8a8;
}

.bubble-tone-2::after {
  left: auto;
  right: 22px;
}

.bubble-tone-3 {
  --bubble-border: #a99cf4;
  min-height: 50px;
}

.bubble-tone-3::after {
  top: 15px;
  bottom: auto;
  left: -9px;
  transform: rotate(135deg);
}

.bubble-tone-4 {
  width: min(31%, 120px);
  min-height: 42px;
  --bubble-border: #7fd7d0;
}

.bubble-tone-4::after {
  top: -9px;
  bottom: auto;
  left: 24px;
  transform: rotate(225deg);
}

.bubble-tone-5 {
  width: min(38%, 148px);
  --bubble-border: #73afe8;
}

.bubble-tone-5::after {
  top: 17px;
  right: -9px;
  bottom: auto;
  left: auto;
  transform: rotate(315deg);
}

.score-popup {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 5;
  display: grid;
  place-items: center;
  min-width: 136px;
  min-height: 64px;
  padding: 9px 18px 11px;
  border: 4px solid #1f5278;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: #195880;
  font-size: clamp(1.9rem, 9vw, 2.7rem);
  font-weight: 700;
  line-height: 1;
  text-shadow:
    2px 2px 0 #ffffff,
    0 4px 0 rgba(40, 102, 142, 0.16);
  box-shadow:
    inset 0 0 0 2px rgba(134, 220, 236, 0.48),
    0 8px 0 rgba(38, 83, 117, 0.18);
  transform: translate(-50%, -50%);
  animation: score-popup 920ms ease-out forwards;
}

.score-plus {
  border-color: #3fb478;
  background: #f0fff5;
  color: #168454;
}

.score-minus {
  border-color: #6a91bd;
  background: #f0f8ff;
  color: #2d648f;
}

.log-panel {
  min-height: 132px;
}

.log-panel::before,
.result-panel::before {
  content: "";
  position: absolute;
  inset: 5%;
  z-index: 0;
  border: 4px solid #4a92c2;
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(235, 253, 255, 0.9)),
    #f7feff;
  box-shadow:
    inset 0 0 0 2px rgba(137, 226, 216, 0.34),
    0 6px 0 rgba(35, 77, 107, 0.13);
  pointer-events: none;
}

.log-panel::before {
  display: none;
}

.result-panel::before {
  inset: 3.5% 4%;
}

.log-panel > img,
.result-panel > img {
  opacity: 0;
}

.log-panel > img {
  opacity: 1;
}

.log-panel .panel-content {
  inset: 25% 10% 16%;
  z-index: 1;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.log-panel h2 {
  font-size: 1.15rem;
}

.log-panel p {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 286px;
  min-height: 48px;
  margin: 0;
  color: #244b66;
  font-size: clamp(0.92rem, 4.2vw, 1rem);
  font-weight: 700;
  line-height: 1.28;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.result-heading {
  display: grid;
  grid-template-columns: 52px 1fr 84px;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 7px 10px;
  border: 3px solid #4a92c2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.result-heading img {
  width: 48px;
}

.result-heading h2 {
  font-size: 1.65rem;
}

.result-heading span {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border: 2px solid #ddaf2c;
  border-radius: 5px;
  background: #fff0a5;
  color: #975f0b;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.result-heading span[hidden] {
  display: none;
}

.result-panel {
  min-height: 530px;
}

.result-list {
  inset: 7% 9% 7%;
  z-index: 1;
  justify-content: center;
  gap: 4px;
  margin: 0;
}

.result-list div {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 4px 8px;
  border: 2px solid rgba(62, 139, 190, 0.22);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.7);
}

.result-list dt,
.result-list dd {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.15;
}

.result-list dt {
  color: #2b607f;
  font-weight: 700;
}

.result-list dd {
  color: #173e5a;
  font-weight: 700;
  text-align: right;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.leaderboard-slot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 340px);
  min-height: 76px;
  margin: 0 auto;
}

.leaderboard-slot .tycoon-leaderboard-widget {
  width: 100%;
  margin: 0;
}

.leaderboard-fallback {
  margin: 0;
  padding: 10px 14px;
  border: 3px solid #3a87b9;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: #226797;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 0 rgba(35, 77, 107, 0.12);
}

.result-actions .image-button {
  width: 100%;
}

.result-actions .image-button span {
  font-size: clamp(1rem, 5vw, 1.32rem);
}

@keyframes bubble-float {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }

  16% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  72% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-18px) scale(0.98);
  }
}

@keyframes score-popup {
  0% {
    opacity: 0;
    transform: translate(-50%, -32%) scale(0.82);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }

  70% {
    opacity: 1;
    transform: translate(-50%, -68%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -92%) scale(0.94);
  }
}

@media (max-width: 380px), (max-height: 730px) {
  body {
    padding: 0;
  }

  .phone-shell {
    width: 100%;
    height: 100dvh;
    min-height: 620px;
    border-width: 0;
    border-radius: 0;
  }

  .screen {
    padding: 16px;
  }

  .howto-card {
    min-height: 500px;
  }

  .howto-list {
    gap: 6px;
    font-size: 0.9rem;
  }

  .status-panel {
    height: 82px;
  }

  .round-board {
    min-height: 94px;
  }

  .machine-panel {
    min-height: 258px;
  }

  .log-panel {
    min-height: 118px;
  }

  .result-panel {
    min-height: 492px;
  }

  .result-list {
    gap: 4px;
  }

  .result-list div {
    min-height: 26px;
    padding-block: 4px;
  }

  .result-list dt,
  .result-list dd {
    font-size: 0.78rem;
  }
}
