/* 麻雀牌パズル固有スタイル — Neon Sky ネオン強調 */

.game-panel {
  margin-top: 20px;
}

.mtp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "main panel";
  gap: 16px;
  align-items: start;
}

.mtp-main {
  grid-area: main;
  min-width: 0;
}

.mtp-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 148px;
}

.mtp-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(96, 154, 214, 0.32);
  border-radius: var(--md-sys-shape-corner-medium);
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(63, 196, 255, 0.07), transparent 55%),
    linear-gradient(165deg, #121e3a 0%, #0c1428 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.mtp-status__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: rgba(63, 196, 255, 0.06);
}

.mtp-status__label {
  color: rgba(180, 210, 255, 0.85);
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mtp-status__value {
  color: #e8f4ff;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.mtp-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mtp-actions .btn {
  width: 100%;
  justify-content: center;
}

.mtp-stage-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--md-sys-shape-corner-large);
}

.mtp-stage {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  padding: clamp(10px, 2.5vw, 18px);
  border: 1px solid rgba(96, 180, 255, 0.42);
  border-radius: inherit;
  background:
    radial-gradient(ellipse 70% 45% at 15% 0%, rgba(63, 196, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 85% 100%, rgba(180, 100, 255, 0.12), transparent 50%),
    linear-gradient(165deg, #101c38 0%, #0a1224 55%, #070e1a 100%);
  box-shadow:
    0 0 0 1px rgba(63, 196, 255, 0.12),
    0 14px 34px rgba(8, 16, 36, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.mtp-stage::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(63, 196, 255, 0.14);
  border-radius: calc(var(--md-sys-shape-corner-large) - 4px);
  pointer-events: none;
}

.mtp-board {
  --mtp-grid-w: 22;
  --mtp-grid-h: 8;
  --mtp-offset-x: 0;
  --mtp-offset-y: 0;
  --mtp-unit-w: 24px;
  --mtp-unit-h: 32px;
  --mtp-tile-w: calc(var(--mtp-unit-w) * 2);
  --mtp-tile-h: calc(var(--mtp-unit-h) * 2);
  --mtp-depth-x: clamp(1px, 0.35vw, 3px);
  --mtp-depth-y: clamp(2px, 0.5vw, 5px);

  position: relative;
  width: 100%;
  max-width: min(100%, 640px);
  min-height: 180px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mtp-tile {
  position: absolute;
  left: calc(var(--mtp-x) * var(--mtp-unit-w));
  top: calc(var(--mtp-y) * var(--mtp-unit-h));
  width: var(--mtp-tile-w);
  height: var(--mtp-tile-h);
  padding: 0;
  border: none;
  border-radius: clamp(4px, 1vw, 8px);
  background: transparent;
  cursor: default;
  appearance: none;
  -webkit-appearance: none;
  z-index: calc(10 + var(--mtp-z) * 10);
  transform: translate(
    calc(var(--mtp-z) * var(--mtp-depth-x)),
    calc(var(--mtp-z) * var(--mtp-depth-y) * -1)
  );
  transition:
    box-shadow 0.18s ease,
    transform 0.18s ease,
    filter 0.18s ease,
    opacity 0.28s ease;
  container-type: size;
}

.mtp-tile.is-free {
  cursor: pointer;
}

.mtp-tile.is-free:not(.is-selected):not(.is-hint) {
  box-shadow: 0 0 0 1px rgba(63, 196, 255, 0.22);
}

.mtp-tile.is-free:hover {
  transform: translate(
      calc(var(--mtp-z) * var(--mtp-depth-x)),
      calc(var(--mtp-z) * var(--mtp-depth-y) * -1 - 2px)
    );
  box-shadow: 0 0 0 1px rgba(120, 210, 255, 0.45);
}

.mtp-tile.is-blocked {
  filter: brightness(0.82) saturate(0.85);
}

.mtp-tile.is-selected {
  transform: translate(
      calc(var(--mtp-z) * var(--mtp-depth-x)),
      calc(var(--mtp-z) * var(--mtp-depth-y) * -1 - 3px)
    )
    scale(1.03);
  box-shadow:
    0 0 0 2px rgba(63, 196, 255, 0.75),
    0 0 10px rgba(63, 196, 255, 0.22);
  z-index: calc(100 + var(--mtp-z));
}

.mtp-tile.is-hint {
  animation: mtp-hint-pulse 0.9s ease-in-out infinite alternate;
}

.mtp-tile.is-denied {
  animation: mtp-deny 0.22s ease;
}

.mtp-tile.is-removing {
  pointer-events: none;
  animation: mtp-remove 380ms ease forwards;
}

.mtp-tile.is-removed {
  pointer-events: none;
}

.mtp-tile:focus-visible {
  outline: 2px solid #3fc4ff;
  outline-offset: 2px;
}

.mtp-tile__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(30, 50, 80, 0.2);
  border-radius: inherit;
  background: linear-gradient(180deg, #fffef8 0%, #f0ebe0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.mtp-tile.is-selected .mtp-tile__inner {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 0 0 1px rgba(63, 196, 255, 0.4);
}

.mtp-tile__num {
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(0.75rem, 38cqh, 1.6rem);
  font-weight: 800;
  line-height: 1;
  color: var(--mtp-accent, #c62828);
}

.mtp-tile__suit-label {
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(0.55rem, 24cqh, 1rem);
  font-weight: 700;
  line-height: 1;
  color: var(--mtp-accent, #c62828);
}

.mtp-tile__face-text {
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(0.85rem, 44cqh, 1.75rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--mtp-accent, #1a2438);
}

.mtp-tile__pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 80%;
  height: 80%;
}

.mtp-tile__pin-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.mtp-dot {
  display: inline-block;
  width: clamp(4px, 12cqw, 10px);
  height: clamp(4px, 12cqw, 10px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5eb3ff, #1565c0 70%);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.mtp-tile__suit--sou .mtp-tile__face-text {
  font-size: clamp(0.7rem, 36cqh, 1.4rem);
}

.mtp-tile__suit--wind .mtp-tile__face-text,
.mtp-tile__suit--dragon .mtp-tile__face-text,
.mtp-tile__suit--flower .mtp-tile__face-text {
  font-size: clamp(0.9rem, 46cqh, 1.8rem);
}

.mtp-guide {
  margin: 12px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
  line-height: 1.55;
  text-align: center;
}

.mtp-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 20px 16px;
  border-radius: inherit;
  background: rgba(6, 10, 20, 0.82);
  backdrop-filter: blur(4px);
  text-align: center;
  z-index: 200;
}

.mtp-overlay__panel {
  box-sizing: border-box;
  width: min(100%, 420px);
  padding: 4px 16px;
}

.mtp-overlay[hidden] {
  display: none !important;
}

.mtp-overlay[data-mode="clear"] {
  background: rgba(6, 10, 20, 0.88);
}

.mtp-overlay__title {
  margin: 0 0 10px;
  font-family: Outfit, "Noto Sans JP", sans-serif;
  font-size: clamp(1.25rem, 4.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #e8f4ff;
  text-wrap: balance;
  text-shadow: 0 0 10px rgba(63, 196, 255, 0.28);
}

.mtp-overlay[data-mode="clear"] .mtp-overlay__title {
  color: #7dffb8;
  text-shadow: 0 0 12px rgba(80, 255, 170, 0.35);
}

.mtp-overlay__detail {
  margin: 0;
  color: rgba(200, 220, 255, 0.9);
  font-size: 0.875rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.mtp-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.mtp-overlay__actions .btn {
  min-width: 9rem;
}

@keyframes mtp-hint-pulse {
  from {
    box-shadow:
      0 0 0 2px rgba(255, 180, 80, 0.5),
      0 0 8px rgba(255, 180, 80, 0.22);
  }
  to {
    box-shadow:
      0 0 0 2px rgba(255, 220, 120, 0.8),
      0 0 14px rgba(255, 180, 80, 0.35);
  }
}

@keyframes mtp-deny {
  0%, 100% { filter: brightness(0.82) saturate(0.85); }
  50% { filter: brightness(0.55) saturate(0.7); }
}

@keyframes mtp-remove {
  0% {
    opacity: 1;
    transform: translate(
        calc(var(--mtp-z) * var(--mtp-depth-x)),
        calc(var(--mtp-z) * var(--mtp-depth-y) * -1)
      )
      scale(1);
    box-shadow: 0 0 12px rgba(120, 255, 200, 0.35);
  }
  40% {
    opacity: 1;
    transform: translate(
        calc(var(--mtp-z) * var(--mtp-depth-x)),
        calc(var(--mtp-z) * var(--mtp-depth-y) * -1 - 4px)
      )
      scale(1.06);
    box-shadow: 0 0 16px rgba(63, 196, 255, 0.4);
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(var(--mtp-z) * var(--mtp-depth-x)),
        calc(var(--mtp-z) * var(--mtp-depth-y) * -1 + 6px)
      )
      scale(0.6);
    box-shadow: none;
  }
}

@media (max-width: 760px) {
  body.game-page main {
    padding-left: 20px;
    padding-right: 20px;
  }

  body.game-page .hero__tagline {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tool-card {
    padding-left: 22px;
    padding-right: 22px;
  }

  .tool-card__desc,
  .mtp-guide {
    padding-left: 6px;
    padding-right: 6px;
    line-height: 1.7;
  }

  .mtp-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "status"
      "main"
      "actions";
    gap: 10px;
  }

  .mtp-panel {
    display: contents;
  }

  .mtp-status {
    grid-area: status;
    flex-direction: row;
  }

  .mtp-status__item {
    flex: 1 1 0;
    min-width: 0;
  }

  .mtp-main {
    grid-area: main;
  }

  .mtp-actions {
    grid-area: actions;
    flex-direction: row;
  }

  .mtp-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 8px;
    font-size: 0.75rem;
  }

  .mtp-board {
    max-width: 100%;
  }

  .mtp-stage-wrap {
    width: 100%;
  }

  .mtp-stage {
    padding: 12px 8px;
  }

  .mtp-overlay {
    padding: 24px 12px;
  }

  .mtp-overlay__panel {
    width: 100%;
    max-width: none;
    padding: 4px 8px;
  }

  .mtp-overlay__detail {
    font-size: 0.875rem;
    line-height: 1.8;
  }
}

@media (max-width: 420px) {
  body.game-page main {
    padding-left: 18px;
    padding-right: 18px;
  }

  .tool-card {
    padding-left: 20px;
    padding-right: 20px;
  }

  .tool-card__desc,
  .mtp-guide {
    padding-left: 4px;
    padding-right: 4px;
  }

  .mtp-overlay__panel {
    padding: 4px 4px;
  }
}

/* 共通プレイ画面。牌の立体表現だけをゲーム固有のまま保つ。 */
html.gs-playing .game-panel {
  align-items: center;
}
html.gs-playing .game-panel > .gs-bar,
html.gs-playing .mtp-layout {
  width: 100%;
  max-width: 640px;
  flex: none;
}
html.gs-playing .mtp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "status" "main" "actions";
  gap: 12px;
}
html.gs-playing .mtp-panel { display: contents; }
html.gs-playing .mtp-status {
  grid-area: status;
  flex-direction: row;
  gap: 0;
  padding: 6px 4px;
  border-color: var(--play-border);
  background: color-mix(in srgb, var(--play-hud-bg) 88%, transparent);
  box-shadow: none;
}
html.gs-playing .mtp-status__item {
  flex: 1 1 0;
  padding: 2px 8px;
  border-radius: 0;
  background: none;
}
html.gs-playing .mtp-status__item + .mtp-status__item { border-left: 1px solid var(--play-border); }
html.gs-playing .mtp-status__label { color: var(--play-text-muted); font-size: .72rem; }
html.gs-playing .mtp-status__value { color: var(--play-text); font-size: 1.15rem; }
html.gs-playing .mtp-main { grid-area: main; }
html.gs-playing .mtp-stage-wrap { width: 100%; }
html.gs-playing .mtp-stage { padding: 16px 8px 8px; border-color: var(--play-border); }
html.gs-playing .mtp-board { min-height: 0; }
html.gs-playing .mtp-actions {
  grid-area: actions;
  flex-direction: row;
  justify-content: center;
  gap: 12px;
}
html.gs-playing .mtp-actions .gs-icon-btn { flex: none; width: 44px; padding: 0; }
html.gs-playing .mtp-guide {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
html.gs-playing .mtp-overlay { padding: 10px 8px; }
html.gs-playing .mtp-overlay__title { font-size: clamp(1rem, 4vw, 2rem); }
@media (min-width: 768px) and (min-height: 700px) {
  html.gs-playing .game-panel { padding-top: 28px; }
  html.gs-playing .game-panel > .gs-bar { margin-bottom: 18px; }
  html.gs-playing .mtp-layout { gap: 20px; }
}
@media (max-height: 450px) {
  html.gs-playing .mtp-layout { gap: 6px; }
  html.gs-playing .mtp-overlay__title { margin-bottom: 4px; }
  html.gs-playing .mtp-overlay__detail { font-size: .75rem; line-height: 1.4; }
  html.gs-playing .mtp-overlay__actions { margin-top: 6px; }
}
