:root {
  --frame-width: 844;
  --frame-height: 1766;
  --frame-ratio: 0.4779161948;
}

@font-face {
  font-family: "Jua";
  src: url("assets/font/Jua-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  background: #4b3838;
  color: #fff;
  font-family: "Jua", sans-serif;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

img {
  display: block;
}

#app {
  min-height: 100dvh;
}

.compare-panel {
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
}

.compare-panel input[type="range"] {
  width: 140px;
}

.compare-reference-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 2000;
}

#toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.28);
  animation: toast-in 0.18s ease, toast-out 0.3s ease 1.8s forwards;
}

.toast-success {
  background: #74d58d;
  color: #11401d;
}

.toast-info {
  background: #fff1c2;
  color: #6c421f;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.app-viewport {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

body.capture-mode {
  background: transparent;
}

body.capture-mode .app-viewport {
  min-height: 0;
  padding: 0;
}

body.capture-mode .mobile-stage-shell {
  width: 844px;
  height: 1766px;
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

.mobile-stage-shell {
  position: relative;
  width: min(calc(100dvh * var(--frame-ratio)), calc(100dvw - 24px));
  height: min(calc((100dvw - 24px) / var(--frame-ratio)), calc(100dvh - 24px));
  max-width: calc(var(--frame-width) * 1px);
  max-height: calc(var(--frame-height) * 1px);
  overflow: hidden;
  border-radius: 36px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.46);
  background: #eed9a8;
}

.mobile-stage-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--frame-width) * 1px);
  height: calc(var(--frame-height) * 1px);
  transform-origin: top left;
  overflow: hidden;
}

.screen-root {
  position: relative;
  width: 844px;
  height: 1766px;
  overflow: hidden;
}

.menu-screen {
  font-family: "Jua", sans-serif;
}

.asset-layer {
  position: absolute;
  inset: auto;
  width: auto;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.flip-y {
  transform: scaleY(-1);
  transform-origin: center;
}

.menu-art-image {
  position: absolute;
  left: 38px;
  top: 225px;
  width: 769px;
  height: 567px;
  object-fit: fill;
  pointer-events: none;
  border-radius: 18px;
  border: 4px solid #3c281c;
  box-shadow:
    0 8px 16px rgba(41, 21, 10, 0.18),
    inset 0 0 0 1px rgba(255, 236, 200, 0.24);
  background: #2e1a10;
}

.hit-area {
  position: absolute;
  z-index: 150;
  border-radius: 28px;
  background: transparent;
}

.hit-area:hover {
  background: rgba(255, 255, 255, 0.04);
}

.start-hit {
  border-radius: 40px;
}

.menu-title-curve {
  position: absolute;
  left: 162px;
  top: 128px;
  width: 520px;
  height: 96px;
  z-index: 120;
  pointer-events: none;
}

.menu-title-curve-text {
  fill: #62401f;
  font-size: 33px;
  font-family: "Jua", sans-serif;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-shadow:
    1px 0 #f6e3b9,
    -1px 0 #f6e3b9,
    0 1px #f6e3b9,
    0 -1px #f6e3b9;
}

.menu-artist-curve {
  position: absolute;
  left: 212px;
  top: 168px;
  width: 420px;
  height: 78px;
  z-index: 120;
  pointer-events: none;
}

.menu-artist-curve-text {
  fill: #62401f;
  font-size: 24px;
  font-family: "Jua", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-shadow: 0 1px rgba(246, 227, 185, 0.55);
}

.menu-artist-text {
  position: absolute;
  left: 286px;
  top: 192px;
  width: 280px;
  text-align: center;
  color: #62401f;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 900;
  text-shadow: 0 1px #f6e3b9;
  pointer-events: none;
  z-index: 120;
}

.menu-mode-note-image {
  z-index: 120;
  pointer-events: none;
}

.menu-art-description {
  position: absolute;
  left: 112px;
  top: 648px;
  width: 620px;
  text-align: center;
  color: #fff;
  font-size: 28px;
  line-height: 1.22;
  font-weight: 500;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-shadow:
    0 1px 5px rgba(0, 0, 0, 0.55),
    0 1px 1px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 120;
}

.menu-mode-note {
  position: absolute;
  left: 64px;
  top: 1382px;
  width: 716px;
  min-height: 33px;
  text-align: center;
  color: #8a5628;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
  text-shadow: 0 1px #f6e3b9;
  pointer-events: none;
  z-index: 120;
}

.ranking-button {
  position: absolute;
  z-index: 220;
  border-radius: 999px;
  border: 3px solid rgba(143, 91, 45, 0.66);
  background: linear-gradient(180deg, #fff7db, #ecd8a6);
  color: #6a3f1d;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 14px rgba(92, 53, 24, 0.2);
}

.ranking-button-success {
  font-size: 28px;
}

.game-time-text {
  position: absolute;
  left: 286px;
  top: 144px;
  width: 102px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #754824;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  z-index: 120;
  pointer-events: none;
}

.game-score-text {
  position: absolute;
  left: 501px;
  top: 144px;
  width: 92px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #754824;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  z-index: 120;
  pointer-events: none;
}

.hint-counter {
  position: absolute;
  left: 658px;
  top: 218px;
  width: 120px;
  text-align: center;
  color: #7f4e25;
  font-size: 20px;
  font-weight: 900;
  text-shadow: 0 1px #fce8b2;
  z-index: 130;
  pointer-events: none;
}

.game-top-artist {
  position: absolute;
  left: 286px;
  top: 138px;
  width: 270px;
  text-align: center;
  color: #845028;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 120;
}

.game-top-title {
  position: absolute;
  left: 190px;
  top: 168px;
  width: 462px;
  text-align: center;
  color: #65401f;
  font-size: 40px;
  line-height: 1.08;
  font-weight: 900;
  white-space: nowrap;
  letter-spacing: -0.02em;
  text-shadow:
    1px 0 #f6e3b9,
    -1px 0 #f6e3b9,
    0 1px #f6e3b9,
    0 -1px #f6e3b9;
  pointer-events: none;
  z-index: 120;
}

.game-board-ghost {
  position: absolute;
  z-index: 73;
  object-fit: cover;
  opacity: 0.18;
  filter: saturate(0.92) brightness(1.02);
  border-radius: 8px;
  clip-path: inset(0 round 8px);
  pointer-events: none;
}

.game-board-base-fill {
  position: absolute;
  z-index: 72;
  border-radius: 8px;
  clip-path: inset(0 round 8px);
  background:
    linear-gradient(180deg, rgba(119, 93, 69, 0.3), rgba(94, 71, 48, 0.22)),
    rgba(255, 247, 234, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(78, 52, 28, 0.12);
  pointer-events: none;
}

.game-board-surface {
  position: absolute;
  overflow: hidden;
  border-radius: 8px;
  clip-path: inset(0 round 8px);
  background: transparent;
  z-index: 76;
  pointer-events: none;
}

.board-grid {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  pointer-events: none;
}

.hint-box {
  position: absolute;
  border-radius: 12px;
  border: 5px solid rgba(255, 217, 98, 0.95);
  background: rgba(255, 227, 134, 0.12);
  box-shadow: 0 0 18px rgba(255, 211, 77, 0.55);
  animation: hint-pulse 1s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes hint-pulse {
  from {
    opacity: 0.65;
  }

  to {
    opacity: 1;
  }
}

.piece {
  position: absolute;
  z-index: 90;
  cursor: grab;
  touch-action: none;
}

.piece.placed {
  cursor: default;
}

.piece svg {
  display: block;
  overflow: visible;
}

.hint-stroke {
  animation: hint-stroke-pulse 0.8s ease-in-out infinite;
}

.piece-outline {
  stroke-opacity: 0;
}

.piece-outline.hint-stroke {
  stroke-opacity: 1;
}

@keyframes hint-stroke-pulse {
  0%,
  100% {
    stroke-opacity: 1;
  }

  50% {
    stroke-opacity: 0.3;
  }
}

.success-screen {
  color: #6f421f;
}

.success-bg-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(160, 224, 242, 0.52) 0%,
    rgba(160, 224, 242, 0.35) 55%,
    rgba(160, 224, 242, 0.25) 100%
  );
  pointer-events: none;
  z-index: 40;
}

.success-art-image {
  position: absolute;
  left: 37px;
  top: 327px;
  width: 769px;
  height: 570px;
  object-fit: cover;
  border-radius: 26px;
  pointer-events: none;
  z-index: 110;
}

.success-player-rank {
  position: absolute;
  left: 122px;
  top: 1030px;
  width: 600px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #466a94;
  font-size: 32px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 500;
  text-shadow:
    1px 0 #eaf4ff,
    -1px 0 #eaf4ff,
    0 1px #eaf4ff,
    0 -1px #eaf4ff;
  pointer-events: none;
  z-index: 130;
}

.success-fixed-ment {
  position: absolute;
  left: 172px;
  top: 1085px;
  width: 500px;
  text-align: center;
  color: #5b7ea4;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 500;
  text-shadow: 0 1px #e8f3ff;
  pointer-events: none;
  z-index: 130;
}

.success-time-value {
  position: absolute;
  left: 157px;
  top: 1185px;
  width: 186px;
  height: 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #466a94;
  font-size: 52px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 130;
}

.success-diff-value {
  position: absolute;
  left: 536px;
  top: 1183px;
  width: 120px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #466a94;
  font-size: 44px;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  font-weight: 900;
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 130;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(10px);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  overflow: hidden;
  color: #6f421f;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.34);
}

.ranking-modal {
  width: min(92vw, 757px);
  aspect-ratio: 757 / 713;
}

.name-entry-modal {
  width: min(88vw, 730px);
  aspect-ratio: 757 / 545;
}

.figma-card .modal-bg {
  position: absolute;
  width: 100%;
  object-fit: fill;
  pointer-events: none;
}

.modal-bg-ranking {
  left: 0;
  top: 8.27%;
  height: 91.73%;
}

.modal-bg-record {
  left: 0;
  top: 0;
  height: 100%;
}

.ranking-ribbon {
  position: absolute;
  left: 13.87%;
  top: 0;
  width: 72.26%;
  pointer-events: none;
}

.ranking-title-image {
  position: absolute;
  left: 34.35%;
  top: 17.81%;
  width: 31.31%;
  pointer-events: none;
}

.ranking-list-bg {
  position: absolute;
  left: 6.47%;
  top: 29.45%;
  width: 86.92%;
  height: 45.86%;
  pointer-events: none;
}

.ranking-list-viewport {
  position: absolute;
  left: 8.72%;
  top: 33.1%;
  width: 78.47%;
  height: 38.43%;
  overflow: hidden;
}

.ranking-list {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.ranking-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.ranking-row {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 58px 66px;
  align-items: center;
  min-height: 48px;
  margin-bottom: 1px;
  padding: 0 10px 0 4px;
}

.ranking-row:last-child {
  margin-bottom: 0;
}

.ranking-row-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.ranking-rank {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9c5b2a;
  font-size: 19px;
  font-weight: 500;
}

.ranking-medal {
  width: 27px;
  height: auto;
}

.ranking-info {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.ranking-name {
  position: relative;
  z-index: 1;
  overflow: hidden;
  white-space: nowrap;
  color: #7b4622;
  font-size: 14px;
  font-weight: 500;
}

.ranking-score {
  position: relative;
  z-index: 1;
  text-align: center;
  white-space: nowrap;
  color: #7b4622;
  font-size: 13px;
  font-weight: 500;
}

.ranking-time {
  position: relative;
  z-index: 1;
  text-align: right;
  color: #36628e;
  font-size: 16px;
  line-height: 1;
  font-weight: 500;
}

.ranking-scroll-decor {
  position: absolute;
  left: 88.51%;
  top: 32.68%;
  width: 2.91%;
  height: 38.43%;
  pointer-events: auto;
}

.ranking-scroll-track {
  position: absolute;
  left: 39%;
  top: 0;
  width: 22%;
  height: 100%;
  object-fit: fill;
}

.ranking-scroll-thumb {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  min-height: 44px;
  object-fit: fill;
  cursor: grab;
  touch-action: none;
}

.ranking-scroll-thumb:active {
  cursor: grabbing;
}

.ranking-tabs {
  position: absolute;
  left: 7.66%;
  top: 77.42%;
  width: 85.34%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3.41%;
}

.ranking-tab {
  border: 0;
  background: transparent;
  padding: 0;
  filter: brightness(0.9);
}

.ranking-tab.is-active {
  filter: brightness(1);
}

.ranking-tab-image {
  width: 100%;
  height: auto;
  pointer-events: none;
}

.modal-actions {
  position: absolute;
  pointer-events: none;
}

.modal-btn {
  cursor: pointer;
  pointer-events: auto;
}

.ranking-actions {
  inset: 0;
}

.modal-btn-close {
  position: absolute;
  left: 85.6%;
  top: 3.5%;
  width: 10.2%;
  height: 12.8%;
  border: 0;
  background: transparent;
  padding: 0;
}

.record-title-image {
  position: absolute;
  left: 9.78%;
  top: 10.64%;
  width: 80.32%;
  height: auto;
  pointer-events: none;
  z-index: 2;
}

.record-stats {
  position: absolute;
  left: 24.17%;
  top: 24.59%;
  width: 50.07%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  color: #c09368;
  font-size: clamp(15px, 2vw, 21px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.record-stat-label {
  color: #c09368;
}

.record-stat-value {
  color: #9a6338;
}

.record-input-bg {
  position: absolute;
  left: 6.47%;
  top: 40.1%;
  width: 87.05%;
  height: 21.4%;
  object-fit: fill;
  pointer-events: none;
}

.name-input {
  position: absolute;
  left: 11.1%;
  top: 44%;
  width: 75.96%;
  height: 14%;
  border: 0;
  background: transparent;
  color: #9c6639;
  font-size: clamp(20px, 3.75vw, 38px);
  line-height: 1.18;
  font-weight: 700;
  outline: 0;
  padding: 4px 0 0;
  box-sizing: border-box;
}

.name-input::placeholder {
  color: #cfbea9;
  font-size: 0.8em;
  opacity: 1;
}

.record-actions {
  inset: 0;
}

.record-btn-cancel {
  position: absolute;
  left: 13.87%;
  top: 69.36%;
  width: 32.1%;
}

.record-btn-confirm {
  position: absolute;
  left: 53.76%;
  top: 69.36%;
  width: 32.23%;
}

.modal-btn-image {
  border: 0;
  background: transparent;
  padding: 0;
}

.modal-btn-image img {
  width: 100%;
  height: auto;
  display: block;
}

.ranking-empty,
.ranking-loading {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #8a5a30;
  font-size: 22px;
  font-weight: 500;
}

.overlay-card {
  width: min(92vw, 520px);
  border-radius: 32px;
  padding: 28px 26px;
  background: linear-gradient(180deg, #fff8e6, #f0dcae);
  border: 6px solid #9f612d;
  color: #6e3f1f;
  box-shadow: 0 28px 48px rgba(0, 0, 0, 0.32);
}

.overlay-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 38px;
}

.overlay-title-image {
  display: block;
  width: min(88%, 420px);
  margin: 0 auto 10px;
  height: auto;
}

.overlay-subtitle {
  margin: 0 0 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
}

.overlay-preview {
  width: 100%;
  border-radius: 22px;
  margin-bottom: 14px;
}

.overlay-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  text-align: center;
  font-size: 17px;
  font-weight: 500;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 144px;
  padding: 12px 18px;
  border-radius: 999px;
  background: #fff4d4;
  border: 3px solid rgba(131, 81, 40, 0.54);
  color: #774621;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(91, 49, 19, 0.16);
}

@media (max-width: 480px) {
  .app-viewport {
    padding: 8px;
  }

  .mobile-stage-shell {
    width: min(calc(100dvh * var(--frame-ratio)), calc(100dvw - 16px));
    height: min(calc((100dvw - 16px) / var(--frame-ratio)), calc(100dvh - 16px));
    border-radius: 28px;
  }

  .ranking-list-bg {
    top: 28.8%;
    height: 47.2%;
  }

  .ranking-list-viewport {
    top: 33.0%;
    width: 77.6%;
    height: 38.8%;
  }

  .ranking-list {
    padding-top: 2px;
    padding-bottom: 4px;
  }

  .ranking-row {
    grid-template-columns: 36px minmax(0, 1fr) 54px 62px;
    min-height: 42px;
    margin-bottom: 1px;
    padding: 0 8px 0 3px;
  }

  .ranking-rank {
    font-size: 17px;
  }

  .ranking-name {
    font-size: 13px;
  }

  .ranking-score {
    font-size: 12px;
  }

  .ranking-time {
    font-size: 14px;
  }

  .ranking-scroll-decor {
    display: block;
    pointer-events: auto;
  }
}

.replay-ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #071845;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.replay-ad-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.replay-ad-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.replay-ad-counter {
  position: absolute;
  right: 20px;
  top: 27px;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: center / contain no-repeat;
}

.replay-ad-count {
  display: block;
  color: #2f3340;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.58);
  transform: translateY(4px);
}
