html:has(.mj-page),
.mj-page {
  overflow-x: clip;
  touch-action: manipulation;
}

.mj-page button,
.mj-tile {
  touch-action: manipulation;
}

.mj-page {
  --mj-ink: #f7fff6;
  --mj-muted: #d7efe0;
  --mj-felt: #1b6b45;
  --mj-panel: #155a3a;
  --mj-gold: #ffe08a;
  --mj-red: #d92c2c;
  --mj-mini-h: 2.16rem;
  --mj-river-gap: 0.12rem;
  background: #0e3d28;
  max-width: 100%;
}

.mj-page .site-header,
.mj-page .site-header.is-scrolled,
.mj-page .site-header.is-open {
  border-bottom: 2px solid var(--foreground);
  background: color-mix(in oklch, var(--background) 90%, transparent);
  backdrop-filter: blur(12px);
}

.mj-page .footer-nav a,
.mj-page .site-footer p,
.mj-page .footer-logo {
  color: var(--mj-muted);
}

.mj-skip {
  background: var(--mj-gold);
  color: #1a1408;
}

.mj-shell {
  padding: 5.75rem 0.6rem 3rem;
  max-width: 100%;
}

.mj-layout {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  min-width: 0;
}

.mj-ad {
  display: flex;
  min-height: 5.5rem;
  align-items: center;
  justify-content: center;
  border: 1px dashed color-mix(in srgb, var(--mj-ink) 28%, transparent);
  border-radius: 0.75rem;
  background: color-mix(in srgb, #0a2a1c 70%, transparent);
  color: var(--mj-muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.mj-ad-side {
  display: none;
}

.mj-stage {
  border-radius: 1.25rem;
  background: linear-gradient(180deg, #1f7a4c, #145c3a);
  border: 1px solid color-mix(in srgb, var(--mj-gold) 40%, transparent);
  padding: 1.25rem 0.75rem 1.5rem;
  color: var(--mj-ink);
  min-width: 0;
}

.mj-kicker {
  margin: 0;
  color: var(--mj-gold);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.mj-stage h1 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 900;
}

.mj-lead {
  margin: 0.6rem 0 0;
  color: var(--mj-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.mj-screen[hidden],
#mj-resume[hidden] {
  display: none;
}

.mj-start-form,
.mj-levels {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.mj-levels legend {
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.mj-levels label {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--mj-ink) 16%, transparent);
  background: var(--mj-panel);
  cursor: pointer;
}

.mj-levels span span {
  display: block;
  margin-top: 0.15rem;
  color: var(--mj-muted);
  font-size: 0.8rem;
}

.mj-mode-row,
.mj-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

.mj-btn {
  min-height: 2.75rem;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 0;
  background: var(--mj-gold);
  color: #1a1408;
  font-weight: 800;
  cursor: pointer;
}

.mj-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.mj-btn-ghost {
  background: transparent;
  color: var(--mj-ink);
  border: 1px solid color-mix(in srgb, var(--mj-ink) 35%, transparent);
}

.mj-btn-win {
  background: #ffb020;
}

.mj-btn-gold {
  background: #fff1b8;
}

.mj-home-stats,
.mj-info,
.mj-msg,
.mj-center-note {
  margin: 0.8rem 0 0;
  color: var(--mj-muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.mj-info {
  color: var(--mj-gold);
  font-weight: 800;
  font-size: 1rem;
}

.mj-msg {
  color: var(--mj-gold);
  text-align: center;
  font-weight: 700;
  min-height: 1.4em;
}

.mj-board {
  margin-top: 0.75rem;
}

.mj-felt {
  background:
    radial-gradient(ellipse at 50% 42%, #2f9a5a 0%, #1c6b3d 55%, #145530 100%);
  border: 12px solid #6b3f1f;
  outline: 2px solid #3d2412;
  border-radius: 10px;
  box-shadow:
    inset 0 0 48px rgba(0, 0, 0, 0.28),
    0 10px 28px rgba(0, 0, 0, 0.35);
  padding: 0.45rem 0.4rem 0.55rem;
  min-width: 0;
}

.mj-felt-grid {
  display: grid;
  grid-template-columns: minmax(6.4rem, 1fr) minmax(0, 1.45fr) minmax(6.4rem, 1fr);
  grid-template-areas:
    "top top top"
    "left center right"
    "bottom bottom bottom";
  gap: 0.35rem 0.4rem;
}

.mj-felt-top { grid-area: top; }
.mj-felt-left { grid-area: left; }
.mj-felt-center { grid-area: center; }
.mj-felt-right { grid-area: right; }
.mj-felt-bottom { grid-area: bottom; }

.mj-seat {
  padding: 0.28rem 0.3rem;
  border-radius: 0.4rem;
  background: color-mix(in srgb, #0d3d24 22%, transparent);
  min-width: 0;
}

.mj-seat.is-call-from {
  box-shadow: inset 0 0 0 2px #ffe08a;
  background: color-mix(in srgb, #ffe08a 18%, transparent);
}

.mj-tile.is-call-target {
  outline: 2px solid #ffe08a;
  outline-offset: 2px;
  z-index: 2;
  animation: mj-call-pulse 1s ease-in-out infinite;
}

.mj-tile.is-call-target.is-riichi {
  animation: none;
}

@keyframes mj-call-pulse {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.mj-seat.is-dealer .mj-wind {
  color: var(--mj-gold);
}

.mj-seat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.55rem;
  font-size: 0.72rem;
  color: #e7f6ea;
}

.mj-riichi-flag {
  color: var(--mj-gold);
  font-weight: 800;
}

.mj-plate {
  min-height: 6.5rem;
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.4rem;
  border-radius: 0.55rem;
  background: linear-gradient(180deg, #8b5a2b, #5c3a18);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
}

.mj-plate-round {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4efe4;
  color: #7a1c1c;
  font-weight: 900;
  font-size: 0.78rem;
  box-shadow: inset 0 0 0 3px #c41e3a;
}

.mj-center-note {
  margin: 0;
  color: #f3e2c5;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
}

.mj-dora-row,
.mj-meld,
.mj-win-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.14rem;
}

.mj-hand {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.14rem;
  width: 100%;
  min-width: 0;
  padding-top: 0.7rem;
}

.mj-meld {
  align-items: center;
  padding: 0.12rem 0.18rem;
  border-radius: 0.28rem;
  background: rgba(8, 32, 18, 0.22);
}

.mj-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.15rem;
}

.mj-win-hand {
  justify-content: center;
  min-height: 1.8rem;
}

.mj-river {
  margin-top: 0.2rem;
  display: grid;
  gap: var(--mj-river-gap);
  justify-items: start;
}

.mj-river-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.14rem;
  min-height: var(--mj-mini-h);
  height: var(--mj-mini-h);
}

.mj-seat-top .mj-river,
.mj-seat-bottom .mj-river {
  justify-items: center;
  height: calc(4 * var(--mj-mini-h) + 3 * var(--mj-river-gap));
  overflow: hidden;
}

.mj-seat-left .mj-river,
.mj-seat-right .mj-river {
  height: calc(5 * var(--mj-mini-h) + 4 * var(--mj-river-gap));
  overflow: hidden;
}

.mj-you {
  margin-top: 0.7rem;
  padding: 0.45rem 0.2rem 0.2rem;
  border-radius: 0.7rem;
  background: color-mix(in srgb, #0d4a30 55%, transparent);
}

.mj-hand .mj-tile.is-tenpai-cut {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 2px #ffe08a,
    2px 3px 0 #2f7a4a,
    2px 4px 5px rgba(0, 0, 0, 0.28);
}

.mj-waits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.4rem;
  margin: 0.35rem 0 0;
  color: var(--mj-gold);
  font-size: 0.82rem;
  font-weight: 700;
}

.mj-waits[hidden] {
  display: none;
}

.mj-waits-label {
  margin-right: 0.2rem;
}

.mj-waits-note {
  font-weight: 500;
  color: var(--mj-muted);
}

.mj-tile {
  position: relative;
  width: 1.7rem;
  height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 0.22rem 0.22rem 0.18rem 0.18rem;
  background:
    linear-gradient(180deg, #fffaf0 0%, #f3ead6 42%, #e4d5b6 100%);
  color: #1a1510;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(120, 90, 40, 0.22),
    1px 0 0 #c9b48a,
    2px 3px 0 #2f7a4a,
    2px 4px 5px rgba(0, 0, 0, 0.28);
  flex: 0 0 auto;
}

.mj-tile-face,
.mj-tile-back {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mj-tile-face svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mj-tile.is-mini {
  width: 1.55rem;
  height: 2.16rem;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    1px 2px 0 #2f7a4a,
    1px 3px 3px rgba(0, 0, 0, 0.22);
}

.mj-tile.is-called {
  transform: rotate(90deg);
  z-index: 1;
  margin: 0.28rem 0.2rem 0.08rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 0 0 2px #ffe08a,
    1px 2px 0 #2f7a4a,
    1px 3px 3px rgba(0, 0, 0, 0.22);
}

.mj-tsumo-gap {
  width: 0.55rem;
  height: 1px;
  flex: 0 0 0.55rem;
}

.mj-hand .mj-tile.is-tsumo {
  margin-left: 0.05rem;
}

.mj-tile.is-back {
  background: linear-gradient(180deg, #2a8a4e, #176338);
  box-shadow:
    inset 0 0 0 1px #0d3d24,
    1px 2px 0 #0f4a2c;
}

.mj-tile-back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 5px);
  border-radius: inherit;
}

.mj-tile.is-selected {
  transform: translateY(-8px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 2px var(--mj-gold),
    2px 8px 0 #2f7a4a,
    2px 10px 10px rgba(0, 0, 0, 0.3);
}

.mj-tile.is-riichi {
  transform: rotate(90deg);
  margin: 0.28rem 0.18rem 0.12rem;
}

.mj-hand .mj-tile {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 2.2rem;
  height: auto;
  aspect-ratio: 2.2 / 3.05;
  cursor: pointer;
}

.mj-actions-play {
  justify-content: center;
}

.mj-dl {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  line-height: 1.9;
}

.mj-col-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.35rem;
}

.mj-col-list li {
  padding: 0.4rem 0.55rem;
  border-radius: 0.5rem;
  background: var(--mj-panel);
}

.mj-col-list .is-got {
  background: color-mix(in srgb, var(--mj-gold) 18%, var(--mj-panel));
}

.mj-ranks {
  list-style: none;
  margin: 1rem auto;
  padding: 0;
  max-width: 22rem;
  text-align: left;
}

.mj-ranks li {
  padding: 0.4rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--mj-ink) 12%, transparent);
}

.mj-result {
  text-align: center;
}

.mj-dialog {
  width: min(24rem, calc(100vw - 2rem));
  padding: 1.35rem 1.25rem 1.2rem;
  border: 1px solid color-mix(in srgb, var(--mj-gold) 45%, transparent);
  border-radius: 1rem;
  background: #145c3a;
  color: var(--mj-ink);
}

.mj-dialog::backdrop {
  background: rgba(6, 24, 16, 0.62);
}

.mj-dialog h2 {
  margin: 0;
  font-family: var(--font-display);
}

.mj-dialog p {
  margin: 0.7rem 0 1.1rem;
  color: var(--mj-muted);
  line-height: 1.7;
}

.mj-win-who {
  color: var(--mj-gold) !important;
  font-weight: 800;
}

.mj-win-pts {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--mj-ink) !important;
}

.mj-seo {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  color: #f4fff8;
}

.mj-seo h2 {
  margin: 2rem 0 0.7rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.mj-seo p,
.mj-seo li {
  color: #d5efe2;
  line-height: 1.85;
  font-size: 0.95rem;
}

@media (min-width: 960px) {
  .mj-layout {
    grid-template-columns: 9.5rem minmax(0, 1fr) 9.5rem;
    align-items: start;
  }

  .mj-ad-side {
    display: flex;
    min-height: 28rem;
    position: sticky;
    top: 5.5rem;
  }

  .mj-ad-mobile {
    display: none;
  }

  .mj-hand .mj-tile {
    max-width: 2.5rem;
    aspect-ratio: 2.5 / 3.45;
  }

  .mj-felt {
    padding: 0.7rem;
  }
}

@media (max-width: 639px) {
  .mj-page {
    --mj-mini-h: 1.22rem;
    --mj-river-gap: 0.06rem;
  }
  .mj-felt {
    border-width: 8px;
    padding: 0.3rem;
  }

  .mj-felt-grid {
    grid-template-columns: minmax(4.1rem, 0.9fr) minmax(0, 1.5fr) minmax(4.1rem, 0.9fr);
    gap: 0.22rem;
  }

  .mj-plate {
    min-height: 5.2rem;
    padding: 0.35rem 0.2rem;
  }

  .mj-stage {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .mj-you {
    padding-left: 0.08rem;
    padding-right: 0.08rem;
  }

  .mj-hand {
    gap: 0.05rem;
  }

  .mj-hand .mj-tile {
    max-width: 1.62rem;
    aspect-ratio: 1.62 / 2.28;
  }

  .mj-tsumo-gap {
    flex-basis: 0.22rem;
    width: 0.22rem;
  }

  .mj-tile.is-mini {
    width: 0.88rem;
    height: 1.22rem;
  }

  .mj-tile.is-called {
    margin: 0.16rem 0.1rem 0.04rem;
  }
}

.mj-cutin {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(6, 18, 12, 0.28);
}

.mj-cutin[hidden] {
  display: none;
}

.mj-cutin-inner {
  min-width: min(22rem, calc(100vw - 2rem));
  padding: 1.1rem 1.6rem 1.25rem;
  text-align: center;
  transform: scale(0.82) translateY(12px);
  animation: mj-cutin-in 0.22s ease-out forwards;
}

.mj-cutin.is-naki .mj-cutin-inner {
  background: linear-gradient(90deg, transparent, #1a5c3a 12%, #1a5c3a 88%, transparent);
  box-shadow: 0 0 0 3px #ffe08a inset;
}

.mj-cutin.is-agari .mj-cutin-inner {
  background: linear-gradient(90deg, transparent, #7a1c1c 10%, #a32626 50%, #7a1c1c 90%, transparent);
  box-shadow: 0 0 0 4px #ffe08a, 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 1.4rem 1.8rem 1.55rem;
}

.mj-cutin-name {
  margin: 0;
  color: #f3e2c5;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mj-cutin-word {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  color: #fffef6;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.mj-cutin.is-reach .mj-cutin-inner {
  background: linear-gradient(90deg, transparent, #7a5a12 10%, #c9a227 50%, #7a5a12 90%, transparent);
  box-shadow: 0 0 0 3px #fff4c2 inset;
}

.mj-cutin.is-reach .mj-cutin-word {
  font-size: 3.4rem;
  color: #fff6c8;
  letter-spacing: 0.08em;
}

@keyframes mj-cutin-in {
  to {
    transform: scale(1) translateY(0);
  }
}
