:root {
  --bg-top: #fff8ef;
  --bg-bottom: #ffe7dc;
  --panel: rgba(255, 255, 255, 0.82);
  --ink: #513647;
  --muted: #7d6271;
  --accent: #e46e9b;
  --accent-strong: #c8527c;
  --peach: #ffcfb2;
  --mint: #d8f2ea;
  --shadow: 0 24px 54px rgba(197, 111, 147, 0.18);
  --border: rgba(195, 104, 142, 0.14);
  --jp-accent: #ff9a5c;
  --romaji-accent: #4da7d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 18%, rgba(255, 220, 232, 0.9), transparent 20%),
    radial-gradient(circle at 85% 14%, rgba(255, 236, 210, 0.88), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.menu-button {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 140;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 20px rgba(114, 72, 95, 0.18);
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
  cursor: pointer;
}

.support-button {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 140;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 20px rgba(114, 72, 95, 0.18);
}

.support-button:hover {
  transform: translateY(-1px);
}

.support-modal.hidden {
  display: none;
}

.support-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 14px;
}

.support-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 18, 31, 0.45);
}

.support-modal-card {
  position: relative;
  z-index: 1;
  width: min(600px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  border: 1px solid rgba(195, 104, 142, 0.2);
  box-shadow: 0 24px 54px rgba(80, 40, 58, 0.24);
  padding: 18px;
}

.support-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--accent-strong);
  background: rgba(255, 244, 250, 0.96);
}

.support-copy-button {
  margin-top: 12px;
  padding: 12px 16px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #ef7ba1, #ffb280);
  color: #fff;
  font-family: "Noto Sans", sans-serif;
  font-weight: 800;
  cursor: pointer;
}

.support-kofi-link {
  color: #8d516a;
  font-weight: 700;
  word-break: break-all;
}

.support-feedback {
  min-height: 1.5em;
  color: #8d516a;
  font-weight: 700;
}

.menu-button span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-strong);
}

.menu-drawer {
  position: fixed;
  inset: 0;
  z-index: 150;
}

.menu-drawer.hidden {
  display: none;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 18, 29, 0.4);
}

.menu-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: min(360px, 90vw);
  height: 100%;
  background: rgba(255, 250, 254, 0.98);
  border-right: 1px solid rgba(195, 104, 142, 0.2);
  padding: 18px;
  overflow: auto;
}

.menu-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.4rem;
  background: rgba(255, 244, 250, 0.96);
  color: var(--accent-strong);
}

.menu-nav,
.menu-subsection {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.menu-link,
.language-option {
  border: 1px solid rgba(195, 104, 142, 0.24);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.language-list {
  display: grid;
  gap: 8px;
}

.language-option.active {
  border-color: rgba(228, 110, 155, 0.56);
  background: rgba(255, 239, 247, 0.8);
}

.stage-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
}

.stage-intro-overlay p {
  margin: 0;
  text-align: center;
  color: #ffffff;
  text-shadow: 0 10px 24px rgba(60, 26, 43, 0.38);
  opacity: 0;
}

.stage-intro-stage {
  font-family: "Kiwi Maru", serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
}

.stage-intro-start {
  font-family: "Noto Sans", sans-serif;
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
}

.stage-intro-overlay.active {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(220, 119, 162, 0.24), rgba(41, 17, 31, 0.3));
}

.stage-intro-overlay.active .stage-intro-stage {
  animation: stage-pop 0.8s ease forwards;
}

.stage-intro-overlay.active .stage-intro-start {
  animation: start-pop 0.8s ease 0.72s forwards;
}

.score-fx {
  position: fixed;
  left: 50%;
  top: 34%;
  z-index: 125;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  font-family: "Noto Sans", sans-serif;
  font-weight: 900;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  color: #fff;
  text-shadow: 0 10px 22px rgba(55, 28, 42, 0.36);
}

.score-fx.active {
  animation: score-fx-pop 700ms cubic-bezier(0.2, 0.84, 0.3, 1) forwards;
}

.score-fx.good {
  color: #fff7d7;
}

.score-fx.bad {
  color: #ffd5d5;
}

.score-fx.combo {
  font-size: clamp(2rem, 5vw, 3.3rem);
  animation: score-fx-combo 920ms cubic-bezier(0.2, 0.84, 0.3, 1) forwards;
}

@keyframes score-fx-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.72);
  }
  20% {
    opacity: 1;
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(0.96);
  }
}

@keyframes score-fx-combo {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.66) rotate(-2deg);
  }
  18% {
    opacity: 1;
  }
  58% {
    opacity: 1;
    transform: translate(-50%, -54%) scale(1.14) rotate(1deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -66%) scale(0.98) rotate(0deg);
  }
}

@keyframes stage-pop {
  0% {
    transform: translateY(8px) scale(0.8);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  60% {
    transform: translateY(0) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translateY(-6px) scale(0.98);
    opacity: 0;
  }
}

@keyframes start-pop {
  0% {
    transform: translateY(10px) scale(0.8);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  68% {
    transform: translateY(0) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(-6px) scale(0.98);
    opacity: 0;
  }
}

.match-shell {
  width: min(1200px, calc(100% - 24px));
  margin: 0 auto;
  padding: 28px 0 42px;
  display: grid;
  gap: 18px;
}

.hero-card,
.board-card,
.guide-card,
.result-card {
  background: var(--panel);
  border-radius: 30px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card,
.board-card,
.guide-card,
.result-card {
  padding: 24px;
}

.eyebrow {
  display: inline-flex;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 14px 0 12px;
  font-family: "Kiwi Maru", serif;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.06;
}

.hero-copy {
  margin: 0;
  max-width: 760px;
  line-height: 1.8;
  color: var(--muted);
}

.difficulty-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(195, 104, 142, 0.2);
  background: rgba(255, 255, 255, 0.74);
}

.difficulty-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.difficulty-options {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.difficulty-option {
  border: 1px solid rgba(195, 104, 142, 0.24);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 10px 8px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.difficulty-option.active {
  border-color: rgba(228, 110, 155, 0.6);
  background: rgba(255, 234, 244, 0.95);
  color: var(--accent-strong);
}

.difficulty-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.hero-link,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 0.96rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.hero-link,
.primary-button {
  background: linear-gradient(135deg, var(--accent), #f4a17b);
  color: #fff;
  box-shadow: 0 14px 24px rgba(228, 110, 155, 0.2);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent-strong);
  box-shadow: 0 12px 22px rgba(197, 111, 147, 0.14);
}

.status-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

.status-box {
  padding: 18px 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
}

.status-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-box strong {
  font-size: clamp(1.3rem, 3vw, 1.9rem);
}

.board-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.side-panel {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
}

.side-panel h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.side-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.match-card {
  position: relative;
  min-height: 92px;
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: transparent;
  color: transparent;
  font-family: "Noto Sans", "Noto Sans JP", sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  perspective: 900px;
  transform-style: preserve-3d;
  transition: transform 160ms ease;
}

.match-card:hover:not(:disabled) {
  transform: translateY(-2px);
}

.match-card:disabled {
  cursor: default;
}

.match-card.locked {
  opacity: 0.72;
}

.match-card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transition: transform 420ms cubic-bezier(0.2, 0.85, 0.3, 1);
  transform-style: preserve-3d;
}

.match-card.revealed .match-card-inner,
.match-card.matched .match-card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    inset 0 -6px 0 rgba(255, 219, 233, 0.36),
    0 10px 18px rgba(197, 111, 147, 0.12);
}

.card-face.back {
  flex-direction: column;
  gap: 0;
  color: #ffffff;
}

.match-card.side-left .card-face.back {
  background:
    radial-gradient(circle at 74% 24%, rgba(255, 255, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #ffb871, var(--jp-accent));
}

.match-card.side-right .card-face.back {
  background:
    radial-gradient(circle at 74% 24%, rgba(255, 255, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #7dc9ef, var(--romaji-accent));
}

.card-back-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow:
    inset 0 2px 6px rgba(255, 255, 255, 0.26),
    0 6px 14px rgba(0, 0, 0, 0.08);
  position: relative;
}

.card-back-icon::before,
.card-back-icon::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.card-back-icon::before {
  width: 18px;
  height: 18px;
  left: 6px;
  top: 6px;
}

.card-back-icon::after {
  width: 10px;
  height: 10px;
  right: 7px;
  bottom: 7px;
}

.card-back-star {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  clip-path: polygon(50% 0%, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0% 50%, 38% 38%);
  transform: rotate(18deg);
}

.card-face.front {
  transform: rotateY(180deg);
  color: #3f2f3d;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.95), transparent 36%),
    linear-gradient(180deg, #fffdfa, #ffe7ce);
}

.card-number {
  font-size: clamp(1.2rem, 1.7vw, 1.6rem);
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.card-number.visual {
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 1;
  transform: translateY(2px);
}

.match-card.revealed {
  color: var(--ink);
}

.match-card.matched {
  color: var(--ink);
}

.match-card.matched .card-face.front {
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.95), transparent 36%),
    linear-gradient(180deg, #f4fff9, #dff7ec);
  box-shadow:
    inset 0 -6px 0 rgba(149, 215, 188, 0.42),
    0 10px 18px rgba(98, 178, 145, 0.12);
}

.match-card.matched {
  animation: pulse-match 380ms ease-out;
}

.card-grid.mixing {
  pointer-events: none;
}

@keyframes pulse-match {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.feedback {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.guide-list {
  margin: 16px 0 0;
  padding-left: 20px;
  line-height: 1.8;
}

.result-card.hidden {
  display: none;
}

.result-card {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(32, 18, 31, 0.45);
}

.result-dialog {
  width: min(680px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  border: 1px solid rgba(195, 104, 142, 0.2);
  box-shadow: 0 24px 54px rgba(80, 40, 58, 0.24);
  padding: 18px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.close-modal-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  color: var(--accent-strong);
  background: rgba(255, 244, 250, 0.96);
}

.rank-register {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.rank-register label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}

.rank-register input {
  border: 1px solid rgba(195, 104, 142, 0.24);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

.rank-register .primary-button {
  width: fit-content;
}

.leaderboard-list {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.8;
  color: var(--ink);
}

@media (max-width: 860px) {
  .status-grid,
  .board-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .match-shell {
    width: min(100% - 14px, 100%);
    padding: 12px 0 20px;
  }

  .hero-card,
  .board-card,
  .guide-card,
  .result-card {
    padding: 14px;
    border-radius: 24px;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .match-card {
    min-height: 68px;
    font-size: 1rem;
  }

  .card-back-icon {
    width: 34px;
    height: 34px;
  }

  .card-back-star {
    right: 11px;
    top: 11px;
    width: 12px;
    height: 12px;
  }

  .side-panel {
    padding: 12px;
  }
}

@media (max-width: 430px) {
  .card-grid {
    gap: 6px;
  }

  .match-card {
    min-height: 60px;
    border-radius: 14px;
    font-size: 0.9rem;
  }

  .card-back-icon {
    width: 26px;
    height: 26px;
  }

  .card-back-star {
    right: 8px;
    top: 8px;
    width: 10px;
    height: 10px;
  }
}

/* Unified hamburger menu style (match Japanese speed match) */
.menu-button {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 140;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 234, 242, 0.95));
  box-shadow:
    inset 0 -4px 0 rgba(255, 219, 233, 0.62),
    0 12px 24px rgba(219, 130, 163, 0.18);
  cursor: pointer;
}

.menu-button span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 4px auto;
  border-radius: 999px;
  background: #b3537d;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(92, 57, 77, 0.24);
  backdrop-filter: blur(4px);
}

.menu-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  height: 100%;
  padding: 24px 20px;
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.98), rgba(255, 244, 248, 0.96));
  box-shadow: 18px 0 44px rgba(92, 57, 77, 0.18);
  overflow-y: auto;
  border-right: 0;
}

.menu-panel h2 {
  margin: 0 0 18px;
  font-family: "Kiwi Maru", serif;
  font-size: 1.8rem;
  color: #9a5274;
}

.menu-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 236, 243, 0.96);
  color: #eb5a82;
  font-size: 1.4rem;
  cursor: pointer;
}

.menu-nav,
.menu-subsection {
  display: grid;
  gap: 10px;
}

.menu-link,
.language-option {
  border: 0;
  border-radius: 18px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.74);
  color: #2f2423;
  font-family: "Noto Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-subsection {
  margin-top: 18px;
}

.menu-subsection h3 {
  margin: 0 0 4px;
  color: #e85e8c;
  font-size: 0.95rem;
}

.language-list {
  display: grid;
  gap: 10px;
}

.language-option.active {
  background: linear-gradient(135deg, #f07ea8, #f7aa8a);
  color: #fff;
}
