:root {
  color-scheme: dark;
  --bg: #18110e;
  --counter: #2a1a14;
  --counter-edge: #593829;
  --paper: #fff4dc;
  --ink: #2d1912;
  --accent: #d9a441;
  --accent-dark: #8f4d1f;
  --matcha: #7a9350;
  --ogura: #6b2b35;
  --kuri: #9a6730;
  --white: #fffaf0;
  --muted: #cdb99b;
  --font-display: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "Sawarabi Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(255, 244, 220, 0.035) 1px, transparent 1px) 0 0 / 88px 100%,
    radial-gradient(circle at 18% 12%, rgba(217, 164, 65, 0.2), transparent 26rem),
    radial-gradient(circle at 82% 28%, rgba(154, 103, 48, 0.18), transparent 24rem),
    linear-gradient(180deg, #141017 0%, #261512 58%, #120e0c 100%);
  color: var(--white);
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 24px;
  font-family: var(--font-display);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}

input {
  min-height: 48px;
  border: 1px solid rgba(255, 244, 220, 0.18);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--white);
  background: rgba(17, 12, 10, 0.72);
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 800;
}

button:hover {
  filter: brightness(1.07);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow-x: hidden;
}

.screen {
  display: none;
  width: min(1080px, 100%);
  max-width: 100%;
}

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

#title-screen,
#result-screen {
  position: relative;
  min-height: min(720px, calc(100vh - 44px));
  place-items: center;
  align-content: center;
  gap: 28px;
  text-align: center;
  overflow: visible;
}

#title-screen::before {
  content: "";
  position: absolute;
  inset: 10% 5% auto;
  height: min(44vh, 340px);
  border: 1px solid rgba(255, 244, 220, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(110, 42, 32, 0.56), rgba(165, 72, 36, 0.5), rgba(110, 42, 32, 0.56)),
    repeating-linear-gradient(90deg, rgba(255, 244, 220, 0.08) 0 2px, transparent 2px 96px);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  transform: perspective(900px) rotateX(6deg);
}

#title-screen::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 11%;
  width: min(760px, 80vw);
  height: 34px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(10px);
}

.lantern-row {
  position: absolute;
  top: clamp(24px, 8vh, 72px);
  left: 50%;
  z-index: 1;
  display: flex;
  gap: clamp(24px, 8vw, 92px);
  transform: translateX(-50%);
}

.lantern-row span {
  position: relative;
  width: clamp(42px, 7vw, 74px);
  height: clamp(64px, 10vw, 108px);
  border-radius: 46% 46% 42% 42%;
  background:
    linear-gradient(
      90deg, transparent 14%,
      rgba(100, 29, 18, 0.28) 18% 20%,
      transparent 18% 38%,
      rgba(100, 29, 18, 0.25) 39% 42%,
      transparent 43% 61%,
      rgba(100, 29, 18, 0.25) 61% 64%,
      transparent 66% 82%,
      rgba(100, 29, 18, 0.28) 82% 84%,
      transparent 89%
      ),
    radial-gradient(circle at 50% 34%, #ffe0a3, #d6472f 58%, #7a1f19 100%);
  box-shadow:
    0 0 36px rgba(255, 130, 70, 0.65),
    0 0 72px rgba(255, 95, 45, 0.45),
    0 0 120px rgba(255, 80, 35, 0.25),
    0 0 150px rgba(255, 80, 35, 0.15),
    inset 0 0 22px rgba(255, 243, 186, 0.32);
}

.lantern-row span::before,
.lantern-row span::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 42%;
  height: 7px;
  border-radius: 2px;
  background: #2d1912;
  transform: translateX(-50%);
}

.lantern-row span::before {
  top: -5px;
}

.lantern-row span::after {
  bottom: -5px;
}

.title-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 11vw, 8rem);
  line-height: 0.95;
  letter-spacing: 0;
  color: #fff4dc;
  text-shadow:
    0 3px 0 #7d2f21,
    0 10px 24px rgba(0, 0, 0, 0.6),
    0 0 28px rgba(217, 164, 65, 0.3);
}

.title-actions {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ad-panel {
  position: relative;
  z-index: 2;
  width: min(728px, 100%);
  min-height: 90px;
  display: grid;
  align-items: center;
  border: 1px solid rgba(255, 244, 220, 0.1);
  border-radius: 8px;
  background: rgba(17, 12, 10, 0.24);
  overflow: visible;
}

.title-ad {
  margin-top: 4px;
}

.result-ad {
  width: 100%;
  margin-top: 12px;
}

.title-copy p {
  margin: 14px 0 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
}

.title-copy {
  position: relative;
  z-index: 2;
}

.title-settings {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  display: grid;
  justify-items: end;
  gap: 8px;
}

.language-switch,
.sound-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 244, 220, 0.18);
  border-radius: 8px;
  background: rgba(20, 14, 12, 0.6);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.26);
}

.sound-switch span {
  padding: 0 4px 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.language-button,
.sound-button {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--paper);
  background: transparent;
  font-size: 0.86rem;
}

.language-button.is-active,
.sound-button.is-active {
  color: #24120b;
  background: var(--accent);
}

.game-toolbar {
  display: flex;
  justify-content: flex-end;
}

.game-sound-switch {
  position: relative;
  z-index: 2;
}

.title-logo {
  display: grid;
  justify-items: center;
  gap: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
}

html[lang="en"] h1,
html[lang="en"] h2,
html[lang="en"] h3,
html[lang="en"] .eyebrow,
html[lang="en"] .title-copy p,
html[lang="en"] #order-text,
html[lang="en"] .meter strong,
html[lang="en"] .cut-status,
html[lang="en"] .ranking-rank,
html[lang="en"] .result-popup-rank {
  transform: scaleX(0.96);
  transform-origin: center;
}

.eyebrow {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
}

#game-screen {
  gap: 16px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.meter,
.order-card,
.result-panel {
  border: 1px solid rgba(255, 244, 220, 0.16);
  background: rgba(42, 26, 20, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

.meter {
  min-height: 76px;
  display: grid;
  align-content: center;
  justify-items: center;
  border-radius: 8px;
}

.meter span,
.order-label,
.result-stats dt {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
}

.order-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter strong {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}

.order-card {
  min-height: 112px;
  border-radius: 8px;
  padding: 18px 22px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

#order-text {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 0.14em;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 4.5vw, 2.5rem);
  font-weight: 400;
}

html[lang="en"] #order-text {
  display: grid;
  justify-items: center;
  gap: 0.08em;
  width: 100%;
  max-width: 100%;
  font-size: clamp(1.1rem, 3.8vw, 2.25rem);
  line-height: 1.08;
}

.order-line {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-number {
  display: inline-flex;
  align-items: baseline;
  color: #ffe6a8;
  text-shadow: 0 0 18px rgba(217, 164, 65, 0.42);
}

.order-number-value {
  font-size: 1.18em;
  color: #ffd05f;
  font-weight: 500;
}

.order-quote {
  color: var(--paper);
  font-size: 0.92em;
}

#order-hint {
  color: var(--muted);
}

.rush-hint {
  display: block;
  max-width: 100%;
  min-height: 1.35em;
  color: #d8c28e;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rush-hint.is-active {
  color: #ffd05f;
  text-shadow: 0 0 14px rgba(217, 164, 65, 0.58);
}

.canvas-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 244, 220, 0.12);
  background: linear-gradient(180deg, #342018, var(--counter));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 430;
  touch-action: none;
}

.feedback {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.74);
  min-width: min(520px, 82%);
  min-height: 74px;
  padding: 14px 26px;
  border-radius: 8px;
  border: 2px solid rgba(255, 244, 220, 0.46);
  background:
    linear-gradient(180deg, rgba(255, 244, 220, 0.16), rgba(17, 12, 10, 0.74)),
    rgba(17, 12, 10, 0.84);
  color: var(--white);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1;
  text-align: center;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.28), 0 0 22px currentColor;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 220ms cubic-bezier(0.16, 1.22, 0.32, 1);
}

.feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

html[lang="en"] .feedback {
  transform: translate(-50%, -50%) scale(0.74) scaleX(0.96);
}

html[lang="en"] .feedback.is-visible {
  transform: translate(-50%, -50%) scale(1) scaleX(0.96);
}

html[lang="en"] .feedback.is-perfect-burst {
  animation-name: perfectBurstEn;
}

.feedback.is-perfect {
  color: #fff0a8;
  border-color: rgba(255, 223, 109, 0.9);
  background:
    radial-gradient(circle at 50% -12%, rgba(255, 255, 210, 0.62), transparent 48%),
    radial-gradient(circle at 12% 18%, rgba(255, 223, 109, 0.34), transparent 34%),
    radial-gradient(circle at 88% 28%, rgba(255, 223, 109, 0.32), transparent 34%),
    linear-gradient(180deg, rgba(149, 64, 25, 0.92), rgba(54, 25, 13, 0.92));
  box-shadow:
    0 0 0 3px rgba(255, 223, 109, 0.18),
    0 0 34px rgba(255, 223, 109, 0.56),
    0 20px 76px rgba(0, 0, 0, 0.52);
}

.feedback.is-perfect-burst {
  animation: perfectBurst 980ms ease-out both;
}

.feedback.is-perfect-burst::before,
.feedback.is-perfect-burst::after {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 8px;
  pointer-events: none;
}

.feedback.is-perfect-burst::before {
  border: 2px solid rgba(255, 223, 109, 0.78);
  animation: perfectRing 760ms ease-out both;
}

.feedback.is-perfect-burst::after {
  background:
    radial-gradient(circle, rgba(255, 245, 180, 0.95) 0 3px, transparent 4px) 8% 22% / 46px 46px,
    radial-gradient(circle, rgba(255, 208, 95, 0.95) 0 2px, transparent 3px) 92% 28% / 42px 42px,
    radial-gradient(circle, rgba(255, 244, 220, 0.9) 0 2px, transparent 3px) 20% 86% / 48px 48px,
    radial-gradient(circle, rgba(255, 223, 109, 0.9) 0 3px, transparent 4px) 82% 86% / 52px 52px;
  animation: perfectSparkle 980ms ease-out both;
}

@keyframes perfectBurst {
  0% {
    filter: brightness(1.7);
    transform: translate(-50%, -50%) scale(0.72);
  }
  38% {
    filter: brightness(1.25);
    transform: translate(-50%, -50%) scale(1.18);
  }
  100% {
    filter: brightness(1);
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes perfectBurstEn {
  0% {
    filter: brightness(1.7);
    transform: translate(-50%, -50%) scale(0.72) scaleX(0.96);
  }
  38% {
    filter: brightness(1.25);
    transform: translate(-50%, -50%) scale(1.18) scaleX(0.96);
  }
  100% {
    filter: brightness(1);
    transform: translate(-50%, -50%) scale(1) scaleX(0.96);
  }
}

@keyframes perfectRing {
  0% {
    opacity: 0.95;
    transform: scale(0.82);
  }
  100% {
    opacity: 0;
    transform: scale(1.24);
  }
}

@keyframes perfectSparkle {
  0% {
    opacity: 0;
    transform: scale(0.76) rotate(0deg);
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.18) rotate(8deg);
  }
}

.feedback.is-excellent {
  color: #ffe6a8;
  border-color: rgba(244, 207, 120, 0.82);
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 207, 120, 0.26), transparent 58%),
    linear-gradient(180deg, rgba(105, 62, 27, 0.9), rgba(38, 22, 15, 0.92));
}

.feedback.is-good {
  color: #fff4dc;
  border-color: rgba(255, 244, 220, 0.74);
}

.feedback.is-ok {
  color: #d8f0ba;
  border-color: rgba(164, 195, 114, 0.7);
}

.feedback.is-miss {
  color: #ffb199;
  border-color: rgba(255, 142, 102, 0.8);
}

.cut-status {
  justify-self: center;
  min-width: 180px;
  margin-top: -4px;
  padding: 8px 18px;
  border: 1px solid rgba(255, 244, 220, 0.18);
  border-radius: 8px;
  background: rgba(42, 26, 20, 0.78);
  color: var(--paper);
  font-family: var(--font-display);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  text-align: center;
  font-size: 1.08rem;
  font-weight: 500;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button {
  color: #24120b;
  background: linear-gradient(180deg, #f4cf78, var(--accent));
}

.secondary-button {
  color: var(--paper);
  background: #5a3728;
  border: 1px solid rgba(255, 244, 220, 0.18);
}

.result-panel {
  width: min(640px, 100%);
  max-width: 100%;
  border-radius: 8px;
  padding: clamp(22px, 5vw, 42px);
}

.ranking-panel {
  width: min(1080px, 100%);
  max-width: 100%;
  border: 1px solid rgba(255, 244, 220, 0.16);
  border-radius: 8px;
  padding: clamp(18px, 4vw, 34px);
  background: rgba(42, 26, 20, 0.86);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  text-align: center;
}

.ranking-panel .ranking-grid,
.ranking-panel .action-row {
  text-align: left;
}

.result-panel > .eyebrow,
.ranking-panel > .eyebrow {
  margin: 0 0 10px;
  text-align: center;
  font-size: clamp(1.25rem, 3.2vw, 2rem);
  text-shadow: 0 0 18px rgba(217, 164, 65, 0.28);
}

.result-popup-panel > .eyebrow {
  margin: 4px 0 0;
  text-align: center;
  font-size: clamp(1.25rem, 3.2vw, 2rem);
  text-shadow: 0 0 18px rgba(217, 164, 65, 0.28);
}

.result-panel h2 {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 7vw, 4.2rem);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.result-stats div {
  min-height: 82px;
  display: grid;
  align-content: center;
  justify-items: center;
  border-radius: 8px;
  background: rgba(255, 244, 220, 0.08);
}

.result-stats dd {
  margin: 4px 0 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
}

#final-rank,
.result-popup-rank {
  display: grid;
  justify-items: center;
  max-width: 100%;
}

html[lang="en"] #final-rank {
  font-size: clamp(1.08rem, 3.8vw, 1.65rem);
  line-height: 1.08;
}

.rank-line {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-local-ranking,
.result-submit {
  margin: 0 0 16px;
}

.result-local-ranking h3,
.ranking-section h3 {
  margin: 0 0 10px;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1rem;
}

.result-submit {
  display: grid;
  gap: 8px;
  text-align: left;
}

.result-submit label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-actions {
  align-items: stretch;
}

.ranking-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
  margin: 18px 0 22px;
}

.ranking-section {
  min-width: 0;
  max-width: 100%;
  min-height: 280px;
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 244, 220, 0.07);
}

.ranking-section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.ranking-section-header h3 {
  white-space: nowrap;
}

.icon-text-button {
  min-height: 34px;
  padding: 0 14px;
  color: var(--paper);
  background: #5a3728;
  font-size: 0.9rem;
}

.ranking-list {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 7px;
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  list-style: none;
}

.world-ranking {
  max-height: min(52vh, 470px);
  overflow: auto;
  padding-right: 4px;
}

.ranking-item,
.ranking-empty {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 74px 104px;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(17, 12, 10, 0.42);
}

.local-ranking-section .ranking-item {
  grid-template-columns: 64px minmax(120px, 1fr) 72px 94px;
}

.world-ranking-section .ranking-item {
  grid-template-columns: 64px minmax(0, 1fr) 70px 104px;
}

.ranking-empty {
  grid-template-columns: 1fr;
  color: var(--muted);
  text-align: center;
}

.ranking-rank {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 500;
}

.ranking-name,
.ranking-date {
  min-width: 0;
  overflow: hidden;
  color: var(--paper);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-ranking-section .ranking-name {
  overflow: visible;
  text-overflow: clip;
}

.ranking-date {
  width: 104px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.ranking-score {
  width: 70px;
  color: #ffd05f;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.compact-ranking .ranking-item {
  min-height: 38px;
}

.status-message {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.startup-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(12, 8, 7, 0.78);
  backdrop-filter: blur(6px);
}

.startup-modal.is-visible {
  display: grid;
}

.startup-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 244, 220, 0.22);
  border-radius: 8px;
  padding: clamp(20px, 6vw, 34px);
  background:
    linear-gradient(180deg, rgba(88, 47, 31, 0.92), rgba(31, 18, 14, 0.96)),
    var(--counter);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.startup-panel h2 {
  margin: 0;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1;
}

.startup-lead {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.startup-control {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.startup-control > span {
  color: var(--paper);
  font-weight: 500;
}

.startup-language-switch {
  position: static;
  box-shadow: none;
}

.startup-sound-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.result-popup {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(12, 8, 7, 0.72);
  backdrop-filter: blur(5px);
}

.result-popup.is-visible {
  display: grid;
}

.result-popup-panel {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 244, 220, 0.24);
  border-radius: 8px;
  padding: clamp(18px, 6vw, 34px);
  background:
    radial-gradient(circle at 50% 0%, rgba(217, 164, 65, 0.24), transparent 54%),
    linear-gradient(180deg, rgba(91, 48, 29, 0.96), rgba(27, 15, 12, 0.98));
  box-shadow: 0 26px 86px rgba(0, 0, 0, 0.52);
  text-align: center;
}

.result-popup-next {
  justify-self: stretch;
}

.result-popup-rank {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 9vw, 4rem);
  font-weight: 400;
  line-height: 1;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.28), 0 0 24px rgba(217, 164, 65, 0.34);
}

html[lang="en"] .result-popup-rank {
  font-size: clamp(1.65rem, 7vw, 3.25rem);
  line-height: 1.05;
}

.result-popup-label {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 500;
}

.result-popup-score {
  color: #ffd05f;
  font-family: var(--font-body);
  font-size: clamp(2.4rem, 10vw, 4.5rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(217, 164, 65, 0.3);
}

@media (max-width: 1070px) {
  .ranking-grid {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .ranking-list {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .ranking-item,
  .ranking-empty {
    grid-template-columns: 46px 140px 68px 98px;
    width: max-content;
    min-width: 100%;
  }

  .ranking-date {
    width: 98px;
  }

  .ranking-name {
    width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .local-ranking-section .ranking-name {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ranking-score {
    width: 68px;
  }

  .world-ranking {
    max-height: 360px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
    place-items: center;
  }

  #game-screen {
    min-height: calc(100vh - 20px);
    align-content: center;
    padding-bottom: 8vh;
  }

  .screen {
    width: 100%;
    min-width: 0;
  }

  .hud,
  .result-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .meter {
    min-height: 48px;
    padding: 6px 4px;
  }

  .meter span {
    display: block;
    font-size: clamp(0.68rem, 2.7vw, 0.78rem);
    line-height: 1.1;
    white-space: nowrap;
  }

  .meter strong {
    font-size: clamp(1.1rem, 6vw, 1.55rem);
  }

  canvas {
    height: auto;
  }

  .feedback {
    min-height: 58px;
    padding: 12px 18px;
  }

  button {
    width: 100%;
  }

  .title-actions {
    width: 100%;
  }

  .title-settings {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    width: min(100%, 340px);
    margin: 0 auto 28px;
    justify-items: center;
  }

  .language-switch,
  .sound-switch {
    justify-content: center;
  }

  .language-button {
    width: auto;
  }

  .sound-button {
    width: auto;
  }

  .game-toolbar {
    margin-bottom: -6px;
  }

  .game-sound-switch {
    transform: scale(0.92);
    transform-origin: right center;
  }

  .startup-sound-actions button {
    width: 100%;
  }

  #title-screen {
    align-content: start;
    gap: 18px;
    padding-top: 16px;
  }

  #title-screen::before {
    inset: 150px 4% auto;
  }

  .lantern-row {
    top: 156px;
    transform: translateX(-50%) scale(0.88);
    transform-origin: top center;
  }

  .title-copy h1 {
    font-size: clamp(3.1rem, 18vw, 4.7rem);
  }

  #title-screen .title-copy {
    margin-top: 60px;
  }

  .title-copy p {
    font-size: clamp(1rem, 4.6vw, 1.25rem);
  }

  .ad-panel {
    width: calc(100vw - 48px);
    max-width: none;
    min-height: 80px;
  }

  .order-card {
    min-height: 88px;
    padding: 12px 14px;
  }

  .rush-hint {
    font-size: 0.74rem;
  }

  #order-text {
    font-size: clamp(1.2rem, 6.2vw, 1.7rem);
  }

  html[lang="en"] #order-text {
    font-size: clamp(0.95rem, 5.2vw, 1.48rem);
  }

  .cut-status {
    padding: 6px 14px;
    font-size: 0.95rem;
  }

  .result-panel {
    width: 100%;
    padding: 16px;
    overflow: hidden;
  }

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .result-stats div {
    min-height: 64px;
  }

  .result-stats dd {
    font-size: 1.35rem;
  }

  .ranking-section-header {
    gap: 8px;
  }

  .ranking-section-header h3 {
    font-size: 0.96rem;
  }

  .icon-text-button {
    width: auto;
    min-width: 64px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.86rem;
  }

  .ranking-item,
  .ranking-empty {
    font-size: 0.92rem;
  }
}
