/* ── Developer Tools ── */

.dev-footer {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 900;
  pointer-events: none;
  text-align: right;
  font-size: 0.62rem;
  line-height: 1.35;
  color: rgba(245, 230, 200, 0.42);
  user-select: none;
}

.dev-footer__name {
  font-weight: 600;
}

.dev-footer__version {
  opacity: 0.85;
}

.dev-footer__build {
  opacity: 0.72;
  font-size: 0.58rem;
}

.dev-bug-report {
  position: fixed;
  bottom: 56px;
  right: 12px;
  z-index: 901;
  padding: 0.35rem 0.65rem;
  border: 1px solid rgba(245, 230, 200, 0.22);
  border-radius: 8px;
  background: rgba(24, 16, 10, 0.72);
  color: rgba(245, 230, 200, 0.88);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}

.dev-bug-report:hover {
  background: rgba(24, 16, 10, 0.92);
  color: #f5e6c8;
}

.dev-overlay {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 950;
  width: min(92vw, 20rem);
  max-height: min(88vh, 36rem);
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: rgba(12, 10, 8, 0.88);
  border: 1px solid rgba(245, 230, 200, 0.18);
  color: #e8dcc8;
  font-size: 0.72rem;
  line-height: 1.4;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  user-select: text;
}

.dev-overlay__title {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f5d76e;
  letter-spacing: 0.04em;
}

.dev-overlay__list {
  margin: 0;
}

.dev-overlay__row {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.dev-overlay__row dt {
  margin: 0;
  color: rgba(232, 220, 200, 0.62);
}

.dev-overlay__row dd {
  margin: 0;
  font-weight: 600;
  word-break: break-all;
}

.dev-overlay__row--url dd {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.9;
}

.dev-overlay__hint {
  margin: 0.55rem 0 0;
  font-size: 0.62rem;
  color: rgba(232, 220, 200, 0.45);
}

.dev-overlay__subtitle {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(245, 215, 110, 0.88);
  letter-spacing: 0.04em;
}

.dev-overlay__fail {
  color: #ff8a80;
}

.dev-overlay__rank-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}

.dev-overlay__rank-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  padding: 0.2rem 0.15rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.62rem;
}

.dev-overlay__rank-cell strong {
  font-size: 0.72rem;
  color: #f5e6c8;
}

.dev-overlay__rank-cell--bad {
  background: rgba(180, 48, 48, 0.28);
  outline: 1px solid rgba(255, 120, 120, 0.35);
}

.dev-overlay__errors {
  margin: 0.55rem 0 0;
  padding-left: 1rem;
  color: #ffb4a9;
  font-size: 0.62rem;
}

.dev-overlay__errors li {
  margin-bottom: 0.15rem;
}

.dev-overlay__weights {
  margin: 0 0 0.45rem;
  padding-left: 1rem;
  font-size: 0.62rem;
  color: rgba(232, 220, 200, 0.82);
}

.dev-overlay__weights li {
  margin-bottom: 0.12rem;
}

.dev-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 960;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  background: rgba(61, 43, 31, 0.92);
  color: #f5e6c8;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.game-settings__export {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px dashed rgba(61, 43, 31, 0.35);
  background: rgba(91, 45, 130, 0.08);
  color: #5b2d82;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.game-settings__export:hover {
  background: rgba(91, 45, 130, 0.14);
}
/* ── Dynamic pyramid camera (document flow — no fixed play area) ── */

.pyramid-area.pyramid-area--camera {
  min-height: 0;
  transition: height 300ms ease;
}

.pyramid-area--camera .pyramid-card-position {
  transition:
    top 300ms ease,
    left 300ms ease;
}

.game-pyramid-area {
  align-items: flex-start;
  min-height: 0;
  flex-shrink: 0;
}

.game-table-bottom {
  flex-shrink: 0;
  width: 100%;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Waste — overlap layout within piles row (no horizontal scroll) */
.game-piles-area .waste-pile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
}

.game-piles-area .waste-row {
  overflow: visible;
}

@media (max-width: 640px) {
  .game-piles-area {
    gap: 1.25rem;
  }

  .game-piles-area .waste-pile {
    flex: 1 1 100%;
    max-width: 100%;
  }
}
/* ── Item Box — leather tool belt / inventory bar ── */

.item-box {
  position: relative;
  z-index: 30;
  width: 100%;
  max-width: min(540px, 100%);
  padding: 0.7rem 0.85rem 0.75rem;
  border-radius: 14px;
  background:
    linear-gradient(
      180deg,
      rgba(48, 30, 18, 0.88) 0%,
      rgba(28, 16, 8, 0.92) 100%
    );
  border: 1.5px solid rgba(232, 197, 71, 0.48);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 -1px 0 rgba(255, 220, 160, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.item-box--full {
  border-color: rgba(196, 96, 64, 0.55);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(160, 56, 40, 0.28),
    0 8px 22px rgba(0, 0, 0, 0.32);
}

.item-box--full .item-box__title {
  color: #f0b8a0;
}

.item-box__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  padding: 0 0.15rem;
}

.item-box__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.55rem;
  padding: 0 0.15rem;
}

.item-box__title {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #f8e8c8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.item-box__status {
  font-size: 0.74rem;
  color: rgba(232, 212, 168, 0.9);
  white-space: nowrap;
}

.item-box__status--used {
  color: #f0c868;
  font-weight: 700;
}

.item-box__gp {
  position: relative;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffd978;
  white-space: nowrap;
}

.item-box__gp-flash {
  margin-left: 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #a8f0c0;
  animation: item-box-gp-flash 1.1s ease-out forwards;
}

@keyframes item-box-gp-flash {
  0% {
    opacity: 0;
    transform: translateY(4px);
  }
  15% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.item-box__buy-btn {
  margin-left: auto;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 120, 0.45);
  background: rgba(255, 215, 120, 0.12);
  color: #ffe8a8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background 0.12s ease,
    transform 0.12s ease;
}

.item-box__buy-btn:hover:not(:disabled) {
  background: rgba(255, 215, 120, 0.22);
  transform: translateY(-1px);
}

.item-box__buy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.item-box__belt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.item-box__belt-edge {
  flex-shrink: 0;
  width: 6px;
  height: 58px;
  border-radius: 3px;
  background: linear-gradient(180deg, #c9a050, #7a5528);
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.35);
  opacity: 0.85;
}

.item-box__slots {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.2rem 0.1rem 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 168, 88, 0.35) transparent;
}

.item-box__slots::-webkit-scrollbar {
  height: 5px;
}

.item-box__slots::-webkit-scrollbar-thumb {
  background: rgba(212, 168, 88, 0.35);
  border-radius: 999px;
}

/* ── Slot ── */

.item-slot-wrap {
  position: relative;
  flex-shrink: 0;
}

.item-slot {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(145deg, rgba(48, 28, 16, 0.98), rgba(24, 12, 6, 0.99));
  border: 2px solid rgba(232, 197, 71, 0.5);
  box-shadow:
    inset 0 4px 10px rgba(0, 0, 0, 0.62),
    inset 0 -1px 0 rgba(255, 220, 160, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.32);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease,
    filter 0.18s ease;
}

button.item-slot {
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.item-slot--empty {
  border-style: dashed;
  border-color: rgba(196, 168, 128, 0.28);
  background: rgba(24, 14, 8, 0.55);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.item-slot__empty-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px dashed rgba(196, 168, 128, 0.22);
  opacity: 0.55;
}

.item-slot__icon {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  user-select: none;
}

.item-slot--common,
.item-slot--filled {
  border-color: rgba(196, 186, 168, 0.45);
}

.item-slot--rare {
  border-color: rgba(110, 168, 228, 0.55);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.55),
    0 0 10px rgba(90, 150, 220, 0.18);
}

.item-slot--epic {
  border-color: rgba(210, 150, 255, 0.58);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.55),
    0 0 12px rgba(180, 120, 240, 0.22);
}

.item-slot--interactive:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: rgba(232, 197, 71, 0.72);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    0 0 16px rgba(232, 197, 71, 0.28),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.item-slot--active {
  animation: item-slot-pulse 1.2s ease-in-out infinite;
}

.item-slot--selected {
  border-color: rgba(232, 197, 71, 0.72);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    0 0 14px rgba(232, 197, 71, 0.28);
}

.item-slot--disabled,
.item-slot:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.82);
}

.item-slot--flash {
  animation: item-slot-acquire 1.5s ease;
}

@keyframes item-slot-acquire {
  0%,
  100% {
    box-shadow:
      inset 0 4px 10px rgba(0, 0, 0, 0.62),
      0 0 0 rgba(232, 197, 71, 0);
  }

  20%,
  55% {
    box-shadow:
      inset 0 4px 10px rgba(0, 0, 0, 0.45),
      0 0 24px rgba(232, 197, 71, 0.55);
    border-color: rgba(255, 220, 120, 0.85);
  }
}

.item-slot--card {
  width: 72px;
  height: 72px;
}

.item-slot--card .item-slot__icon {
  font-size: 34px;
}

@keyframes item-slot-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 3px 8px rgba(0, 0, 0, 0.55),
      0 0 8px rgba(232, 197, 71, 0.2);
  }

  50% {
    box-shadow:
      inset 0 3px 8px rgba(0, 0, 0, 0.55),
      0 0 20px rgba(232, 197, 71, 0.45);
  }
}

/* ── Custom Tooltip ── */

.item-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  z-index: 220;
  width: max-content;
  max-width: 240px;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background:
    linear-gradient(160deg, rgba(42, 26, 14, 0.98), rgba(22, 12, 6, 0.99));
  border: 1.5px solid rgba(232, 197, 71, 0.55);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 18px rgba(232, 197, 71, 0.16);
  pointer-events: none;
  animation: item-tooltip-in 0.16s ease;
}

.item-tooltip--below {
  bottom: auto;
  top: calc(100% + 12px);
}

.item-tooltip--below::after {
  top: -6px;
  bottom: auto;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid rgba(232, 197, 71, 0.4);
  border-top: 1px solid rgba(232, 197, 71, 0.4);
}

.item-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: rgba(40, 26, 16, 0.98);
  border-right: 1px solid rgba(212, 168, 88, 0.35);
  border-bottom: 1px solid rgba(212, 168, 88, 0.35);
}

.item-tooltip__header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.item-tooltip__icon {
  font-size: 1.35rem;
  line-height: 1;
}

.item-tooltip__titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.item-tooltip__name {
  font-size: 0.92rem;
  font-weight: 800;
  color: #f8edd4;
}

.item-tooltip__flavor {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  line-height: 1.45;
  font-style: italic;
  color: rgba(232, 214, 186, 0.82);
}

.item-tooltip__rarity {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.item-tooltip__rarity--common {
  color: #c8c0b0;
}

.item-tooltip__rarity--rare {
  color: #8ec0ff;
}

.item-tooltip__rarity--epic {
  color: #d8a8ff;
}

.item-tooltip__desc {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  line-height: 1.5;
  color: rgba(240, 220, 180, 0.95);
}

.item-tooltip__limit {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.68rem;
  color: rgba(212, 188, 148, 0.88);
}

.item-tooltip__status {
  font-size: 0.7rem;
  font-weight: 700;
  color: #8ee0a0;
}

.item-tooltip__status--used {
  color: #f0c868;
}

.item-tooltip__status--blocked {
  color: #e0a090;
}

.item-tooltip--inline {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  max-width: none;
  pointer-events: auto;
  animation: none;
}

.item-tooltip--inline::after {
  display: none;
}

.item-tooltip--interactive {
  pointer-events: auto;
}

.item-tooltip__action {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  min-height: 44px;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 210, 100, 0.58);
  background: linear-gradient(180deg, #a67c2a 0%, #7a5520 52%, #5c3d18 100%);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.item-tooltip__action:active {
  background: linear-gradient(180deg, #8f6a22 0%, #6a4818 100%);
}

.item-box__detail-panel {
  margin-top: 0.65rem;
}

@keyframes item-tooltip-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Table integration ── */

.game-piles-area__item-box {
  position: relative;
  z-index: 28;
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
  min-width: min(100%, 540px);
}

.game-piles-area__item-box--pulse .item-box {
  animation: item-box-pulse 0.45s ease;
}

.game-table-bottom__item-row {
  position: relative;
  z-index: 28;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  padding: 0 0.5rem 0.65rem;
}

.game-table-bottom__item-row--pulse .item-box {
  animation: item-box-pulse 0.45s ease;
}

@keyframes item-box-pulse {
  0% {
    box-shadow:
      inset 0 2px 6px rgba(0, 0, 0, 0.45),
      0 0 0 rgba(232, 197, 71, 0);
  }

  50% {
    box-shadow:
      inset 0 2px 6px rgba(0, 0, 0, 0.45),
      0 0 28px rgba(232, 197, 71, 0.42);
  }

  100% {
    box-shadow:
      inset 0 2px 6px rgba(0, 0, 0, 0.45),
      0 8px 22px rgba(0, 0, 0, 0.32);
  }
}

.card--item-reveal {
  box-shadow:
    0 0 0 2px rgba(232, 197, 71, 0.55),
    0 0 18px rgba(232, 197, 71, 0.35);
}

.card--item-target {
  box-shadow:
    0 0 0 2px rgba(232, 197, 71, 0.72),
    0 0 22px rgba(232, 197, 71, 0.42);
}

.card--item-target:hover {
  box-shadow:
    0 0 0 3px rgba(255, 220, 120, 0.85),
    0 0 28px rgba(232, 197, 71, 0.55);
}

.card--item-dimmed {
  opacity: 0.38;
  filter: grayscale(0.25) brightness(0.72);
  pointer-events: none;
}

.pyramid-card-position.item-dimmed {
  opacity: 0.38;
}

.pyramid-card-position.item-target .card {
  transform: translateY(-2px);
}

/* ── Acquire Toast ── */

.item-reward-toast {
  position: fixed;
  top: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 480;
  width: min(92vw, 420px);
  pointer-events: none;
}

.item-reward-toast__glow {
  position: absolute;
  inset: -14px -18px;
  border-radius: 20px;
  background: radial-gradient(
    ellipse at center,
    rgba(232, 197, 71, 0.22) 0%,
    transparent 72%
  );
}

.item-reward-toast__panel {
  position: relative;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(42, 26, 14, 0.96), rgba(22, 12, 6, 0.98));
  border: 1.5px solid rgba(232, 197, 71, 0.55);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
}

.item-reward-toast__label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f0c868;
}

.item-reward-toast__body {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.item-reward-toast__icon {
  font-size: 2.2rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(232, 197, 71, 0.45));
}

.item-reward-toast__text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.item-reward-toast__name {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8edd4;
}

.item-reward-toast__desc {
  font-size: 0.8rem;
  line-height: 1.45;
  color: rgba(232, 212, 168, 0.92);
}

.item-reward-toast--in {
  animation: item-reward-toast-in 0.28s ease forwards;
}

.item-reward-toast--out {
  animation: item-reward-toast-out 0.3s ease forwards;
}

@keyframes item-reward-toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@keyframes item-reward-toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }

  to {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
  }
}

/* ── Reward Modal ── */

.item-reward-overlay {
  position: fixed;
  inset: 0;
  z-index: 520;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 4, 2, 0.72);
  backdrop-filter: blur(4px);
}

.item-reward-modal {
  position: relative;
  width: min(100%, 460px);
  max-height: 86vh;
  overflow: auto;
  padding: 1.35rem 1.25rem 1.15rem;
  border-radius: 16px;
  background:
    linear-gradient(165deg, #f8ecd4 0%, #e8d4b0 48%, #d4bc94 100%);
  color: #3d2b1f;
  box-shadow:
    0 0 0 3px rgba(92, 58, 28, 0.35),
    0 18px 48px rgba(0, 0, 0, 0.45);
}

.item-reward-modal__frame {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(120, 78, 38, 0.22);
  border-radius: 12px;
  pointer-events: none;
}

.item-reward-modal__title {
  position: relative;
  margin: 0 0 0.35rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.35rem;
  color: #4a3020;
}

.item-reward-modal__hint {
  position: relative;
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: #6a4d36;
  line-height: 1.55;
}

.item-reward-modal__hint-item {
  display: inline-block;
  margin: 0 0.15rem;
  font-weight: 800;
  color: #5a3820;
}

.item-reward-modal__section {
  position: relative;
  margin-bottom: 1rem;
}

.item-reward-modal__subtitle {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #7a5838;
}

.item-reward-modal__new-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(255, 248, 230, 0.95), rgba(240, 220, 180, 0.88));
  border: 2px solid rgba(201, 158, 82, 0.55);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    0 6px 18px rgba(80, 48, 20, 0.18);
}

.item-reward-modal__new-icon {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.item-reward-modal__new-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.item-reward-modal__new-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #3d2b1f;
}

.item-reward-modal__new-rarity {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.item-reward-modal__new-rarity--common {
  color: #7a7060;
}

.item-reward-modal__new-rarity--rare {
  color: #3a68a8;
}

.item-reward-modal__new-rarity--epic {
  color: #7a38a8;
}

.item-reward-modal__new-flavor {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  font-style: italic;
  color: rgba(232, 214, 186, 0.82);
}

.item-reward-modal__new-desc {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #5a4030;
}

.item-reward-modal__slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(58, 36, 22, 0.12);
  border: 1px solid rgba(92, 58, 28, 0.18);
}

.item-reward-modal__slots .item-slot-wrap:hover .item-slot {
  transform: translateY(-3px);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(196, 80, 48, 0.35);
  border-color: rgba(196, 80, 48, 0.65);
}

.item-reward-modal__discard-new {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(140, 88, 48, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.35);
  color: #5a4030;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
}

.item-reward-modal__discard-new:hover {
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 14px rgba(160, 96, 56, 0.22);
}

.item-reward-modal__discard-new-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.item-reward-modal__discard-new-name {
  font-size: 0.92rem;
  font-weight: 800;
}

/* ── Use Banner ── */

.item-use-banner {
  position: fixed;
  top: 4.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 430;
  width: min(92vw, 620px);
}

.item-use-banner__glow {
  position: absolute;
  inset: -8px -12px;
  border-radius: 18px;
  background: radial-gradient(
    ellipse at center,
    rgba(232, 197, 71, 0.18) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.item-use-banner__panel {
  position: relative;
  padding: 0.9rem 1.05rem 0.95rem;
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(42, 26, 14, 0.94), rgba(22, 12, 6, 0.96));
  border: 2px solid rgba(232, 197, 71, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 160, 0.12),
    0 14px 36px rgba(0, 0, 0, 0.48);
  color: #f8edd4;
  backdrop-filter: blur(8px);
}

.item-use-banner__content {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.item-use-banner__icon {
  flex-shrink: 0;
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(232, 197, 71, 0.35));
}

.item-use-banner__copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.item-use-banner__name {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.02rem;
  font-weight: 800;
  color: #f8e8c8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.item-use-banner__text {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.4;
  color: rgba(240, 220, 180, 0.95);
}

.item-use-banner__cancel {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(212, 168, 88, 0.38);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(88, 56, 32, 0.9), rgba(52, 32, 18, 0.95));
  color: #f5e6c8;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.12);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
}

.item-use-banner__cancel:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 160, 0.12),
    0 0 12px rgba(232, 197, 71, 0.22);
}

.item-use-banner__picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(212, 168, 88, 0.18);
}

.item-use-banner__pick-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 52px;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(212, 168, 88, 0.32);
  border-radius: 9px;
  background: rgba(68, 44, 26, 0.75);
  color: #f5e6c8;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
  -webkit-appearance: none;
}

.item-use-banner__pick-btn:hover {
  background: rgba(88, 56, 32, 0.92);
  box-shadow: 0 0 12px rgba(232, 197, 71, 0.2);
}

.item-use-banner__pick-btn--row {
  min-width: 64px;
  font-weight: 700;
}

.item-use-banner__pick-rank {
  font-weight: 800;
  font-size: 0.9rem;
}

.item-use-banner__pick-suit {
  font-size: 0.72rem;
  opacity: 0.85;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .item-slot {
    width: 48px;
    height: 48px;
  }

  .item-slot__icon {
    font-size: 26px;
  }

  .item-box__belt-edge {
    height: 50px;
  }

  .item-use-banner {
    top: 3.5rem;
  }

  .game-table-bottom__item-row {
    padding-bottom: 0.5rem;
  }
}

@media (max-width: 420px) {
  .item-slot {
    width: 44px;
    height: 44px;
  }

  .item-slot__icon {
    font-size: 24px;
  }

  .item-box__status {
    display: none;
  }
}

/* ── GP purchase panel ── */

.item-purchase-overlay {
  position: fixed;
  inset: 0;
  z-index: 560;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 5, 3, 0.55);
  backdrop-filter: blur(4px);
}

.item-purchase-panel {
  position: relative;
  width: min(100%, 380px);
  max-height: min(88vh, 520px);
  overflow-y: auto;
  padding: 1.25rem 1.2rem 1rem;
  border-radius: 14px;
  background:
    linear-gradient(155deg, rgba(72, 50, 34, 0.95), rgba(28, 18, 12, 0.98)),
    #24180f;
  border: 1px solid rgba(210, 170, 110, 0.28);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
  color: #eadcc4;
}

.item-purchase-panel__close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #d8c8aa;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.item-purchase-panel__header {
  margin-bottom: 0.85rem;
  padding-right: 2rem;
}

.item-purchase-panel__title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.25rem;
  color: #f4e4c4;
}

.item-purchase-panel__balance {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.item-purchase-panel__balance strong {
  color: #ffd978;
  font-size: 1.1rem;
}

.item-purchase-panel__hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(234, 220, 196, 0.72);
}

.item-purchase-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.item-purchase-panel__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(12, 8, 5, 0.35);
  border: 1px solid rgba(210, 170, 110, 0.14);
}

.item-purchase-panel__row--expanded {
  border-color: rgba(232, 197, 71, 0.48);
  background: rgba(18, 12, 8, 0.5);
  box-shadow: inset 0 0 0 1px rgba(232, 197, 71, 0.12);
}

.item-purchase-panel__info {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.item-purchase-panel__info--tap {
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.item-purchase-panel__text {
  min-width: 0;
}

.item-purchase-panel__icon {
  font-size: 1.35rem;
  line-height: 1;
}

.item-purchase-panel__name {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  color: #f5e6c8;
}

.item-purchase-panel__price {
  display: block;
  font-size: 0.76rem;
  color: rgba(255, 215, 120, 0.88);
}

.item-purchase-panel__buy {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 100, 0.58);
  background: linear-gradient(180deg, #a67c2a 0%, #7a5520 52%, #5c3d18 100%);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.item-purchase-panel__buy:hover:not(:disabled) {
  background: linear-gradient(180deg, #b88a32 0%, #8a6024 100%);
}

.item-purchase-panel__buy:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: rgba(38, 26, 18, 0.78);
  border-color: rgba(255, 220, 160, 0.22);
  color: rgba(255, 255, 255, 0.68);
}

.item-purchase-panel__detail {
  flex: 1 1 100%;
  padding: 0.35rem 0.15rem 0.15rem;
  border-top: 1px solid rgba(210, 170, 110, 0.16);
}

.item-purchase-panel__detail-desc {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(245, 230, 200, 0.92);
}

.item-purchase-panel__detail-limit {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: rgba(224, 206, 178, 0.88);
}

.item-purchase-panel__detail-blocked {
  margin: 0.35rem 0 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #f0b878;
  font-weight: 600;
}

/* ── Portal anchor tooltip (purchase panel) ── */

.anchor-tooltip__trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
  padding: 0.15rem 0.2rem;
  margin: -0.15rem -0.2rem;
  border-radius: 8px;
  cursor: help;
  outline: none;
}

.anchor-tooltip__trigger:hover,
.anchor-tooltip__trigger:focus-visible {
  background: rgba(255, 215, 120, 0.08);
  box-shadow: 0 0 0 2px rgba(255, 215, 120, 0.22);
}

@media (hover: none), (pointer: coarse) {
  .anchor-tooltip {
    display: none !important;
  }
}

body.modal-open .anchor-tooltip {
  display: none !important;
}

.anchor-tooltip {
  position: fixed;
  z-index: 700;
  width: max-content;
  max-width: min(228px, calc(100vw - 24px));
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background:
    linear-gradient(160deg, rgba(42, 26, 14, 0.98), rgba(22, 12, 6, 0.99));
  border: 1.5px solid rgba(232, 197, 71, 0.55);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 18px rgba(232, 197, 71, 0.16);
  pointer-events: none;
  animation: item-tooltip-in 0.16s ease;
}

.anchor-tooltip__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.anchor-tooltip__icon {
  font-size: 1.2rem;
  line-height: 1;
}

.anchor-tooltip__name {
  font-size: 0.88rem;
  font-weight: 800;
  color: #f8edd4;
}

.anchor-tooltip__desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: rgba(240, 226, 200, 0.92);
}

.anchor-tooltip__note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f0b888;
}

.anchor-tooltip > .anchor-tooltip__desc:only-child {
  margin: 0;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
  color: #2c2416;
  background: #3d2b1f;
}

.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), transparent 28%),
    repeating-linear-gradient(
      90deg,
      #5c3d2e 0,
      #5c3d2e 4px,
      #6b4a38 4px,
      #6b4a38 28px
    );
}

.game-header {
  /* Legacy — replaced by .floating-hud in hud.css */
  display: none;
}

.game-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  background: rgba(42, 26, 14, 0.94);
  border: 1px solid rgba(232, 197, 71, 0.38);
  color: #f8edd4;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.game-toast--multiline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
  line-height: 1.35;
}

.game-toast__line {
  display: block;
}

.game-page--swap-mode .game-main {
  outline: 2px solid rgba(232, 197, 71, 0.25);
  outline-offset: -2px;
}

.game-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem 1rem 2rem;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(20, 12, 8, 0.55);
  z-index: 400;
}

.game-overlay__panel {
  max-width: 360px;
  width: 100%;
  padding: 1.5rem 1.75rem;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.game-overlay--lost .game-overlay__panel {
  background: #f5e6c8;
  color: #3d2b1f;
}

.game-overlay--won .game-overlay__panel {
  background: #e8f5e0;
  color: #1f3d1f;
}

.game-overlay__panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
}

.game-overlay__panel p {
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.game-overlay__restart {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: #3d2b1f;
  color: #f5e6c8;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.game-overlay--won .game-overlay__restart {
  background: #2d5a2d;
  color: #e8f5e0;
}

.game-overlay__menu {
  margin-top: 0.65rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(61, 43, 31, 0.25);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.game-overlay--won .game-overlay__menu {
  border-color: rgba(45, 90, 45, 0.35);
}

.start-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Legacy start-screen panel styles removed — see splash.css */

.game-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 5, 3, 0.52);
  backdrop-filter: blur(4px);
  animation: settings-overlay-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes settings-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.game-settings {
  width: min(100%, 440px);
  max-height: min(92vh, 820px);
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  border-radius: 14px;
  background: #f5e6c8;
  color: #3d2b1f;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  animation: settings-panel-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes settings-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.game-settings__title {
  margin: 0 0 1rem;
  text-align: center;
  font-size: 1.35rem;
}

.game-settings__section {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.game-settings__label {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.game-settings__radio,
.game-settings__checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.92rem;
  cursor: pointer;
}

.game-settings__radio small {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.78rem;
  color: #6b4a38;
}

.game-settings__radio--preset {
  align-items: flex-start;
  margin-bottom: 0.55rem;
}

.game-settings__radio-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.game-settings__radio-title {
  font-weight: 700;
  color: #3d2b1f;
}

.game-settings__preset-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.45rem;
}

.game-settings__preset-hint {
  font-size: 0.74rem;
  line-height: 1.35;
  color: #6b4a38;
}

.game-settings__checkbox--custom {
  margin-top: 0.35rem;
  margin-bottom: 0.65rem;
}

.game-settings__advanced {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(61, 43, 31, 0.14);
  background: rgba(255, 255, 255, 0.35);
}

.game-settings__divider {
  margin: 0.75rem 0 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: #8a7560;
}

.game-settings__field {
  margin-bottom: 0.85rem;
}

.game-settings__field input[type='range'] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  accent-color: #8b6914;
}

.game-settings__select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(61, 43, 31, 0.2);
  border-radius: 8px;
  background: #fff;
  color: #3d2b1f;
  font-size: 0.95rem;
}

.game-settings__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.game-settings__apply,
.game-settings__reset,
.game-settings__cancel {
  flex: 1;
  min-width: 6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.game-settings__apply {
  border: none;
  background: #3d2b1f;
  color: #f5e6c8;
}

.game-settings__reset,
.game-settings__cancel {
  border: 1px solid rgba(61, 43, 31, 0.25);
  background: transparent;
  color: #3d2b1f;
}

.game-settings__section--joker {
  margin-top: 0.5rem;
}

.game-settings__hint {
  margin: 0.35rem 0 0;
  padding-left: 1.45rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(61, 43, 31, 0.72);
}

.game-settings__section--journal {
  margin-top: 0.5rem;
}

.game-settings__danger {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(139, 58, 58, 0.45);
  background: rgba(139, 58, 58, 0.08);
  color: #6b2f2f;
  font-size: 0.88rem;
  cursor: pointer;
}

.game-settings__danger:hover {
  background: rgba(139, 58, 58, 0.14);
}

.game-settings__danger--confirm {
  background: rgba(139, 58, 58, 0.22);
  border-color: rgba(139, 58, 58, 0.65);
  font-weight: 600;
}

.memory-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: rgba(20, 12, 8, 0.45);
  z-index: 350;
  pointer-events: none;
}

.memory-countdown__number {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  color: #f5e6c8;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.memory-countdown__label {
  font-size: 1rem;
  color: #d4c4a8;
}

.game-pyramid-area {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: auto;
  padding: 0.75rem 0 1rem;
}

.pyramid-area {
  position: relative;
  width: min(100%, 820px);
  min-height: 480px;
  margin: 0 auto;
  flex-shrink: 0;
}

@media (max-height: 820px) {
  .pyramid-area[data-pyramid-rows='8'] {
    transform: scale(0.94);
    transform-origin: top center;
  }
}

@media (max-width: 1366px) and (max-height: 768px) {
  .pyramid-area[data-pyramid-rows='8'] {
    transform: scale(0.88);
    transform-origin: top center;
  }

  .pyramid-area[data-pyramid-rows='7'] {
    transform: scale(0.96);
    transform-origin: top center;
  }
}

.pyramid-card-position {
  position: absolute;
  width: 98px;
  height: 140px;
}

.pyramid-card-position .card {
  width: 100%;
  height: 100%;
}

.pyramid-card-position.selected {
  z-index: 360;
}

.pyramid-card-position.swap-target .card {
  box-shadow:
    0 0 0 3px rgba(232, 197, 71, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.24);
}

.pyramid-card-position.swap-target .card--face-down {
  border-color: #e8c547;
}

.pyramid-card-position.flying-to-graveyard {
  pointer-events: none;
  z-index: 400;
}

.game-piles-area {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 2rem;
  padding: 0.5rem;
  flex: 1;
  min-width: 0;
}

.game-table-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.graveyard-panel__title {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #f5e6c8;
}

.graveyard-panel__total {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  transition: color 0.2s ease;
}

.graveyard-panel__total--highlight {
  animation: graveyard-pop 0.3s ease-out;
  color: #ffd700;
  font-weight: 700;
}

.graveyard-panel__section {
  margin-bottom: 0.75rem;
}

.graveyard-panel__section:last-child {
  margin-bottom: 0;
}

.graveyard-panel__subtitle {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a89880;
}

.graveyard-panel__rank-list,
.graveyard-panel__suit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.15rem;
}

.graveyard-panel__rank-row {
  display: grid;
  grid-template-columns: 1.1rem 2rem 1fr;
  gap: 0.25rem;
  align-items: center;
  font-size: 0.72rem;
  line-height: 1.2;
}

.graveyard-panel__rank-label {
  font-weight: 700;
  color: #f5e6c8;
}

.graveyard-panel__rank-count {
  font-variant-numeric: tabular-nums;
  color: #c9b89a;
  display: inline-block;
}

.graveyard-panel__rank-count--highlight {
  animation: graveyard-pop 0.3s ease-out;
  color: #ffd700;
  font-weight: 700;
}

.graveyard-panel__rank-row--highlight {
  animation: graveyard-row-flash 0.3s ease-out;
  border-radius: 4px;
}

@keyframes graveyard-pop {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes graveyard-row-flash {
  0% {
    background: transparent;
  }

  35% {
    background: rgba(255, 215, 0, 0.18);
  }

  100% {
    background: transparent;
  }
}

.graveyard-panel__rank-bar {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: #8a7560;
  overflow: hidden;
  white-space: nowrap;
}

.graveyard-panel__suit-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.graveyard-panel__suit-label {
  font-weight: 700;
  color: #f5e6c8;
}

.graveyard-panel__suit-count {
  font-variant-numeric: tabular-nums;
}

.card {
  position: relative;
  width: 98px;
  height: 140px;
  padding: 0;
  border: 2px solid #c9b89a;
  border-radius: 12px;
  background: #faf7f0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
  flex-shrink: 0;
  overflow: hidden;
  transform: rotate(var(--card-tilt, 0deg));
  transition:
    transform 0.15s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.15s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.15s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.15s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

button.card {
  cursor: default;
}

.card--face-down {
  padding: 0;
  background: #4a3528;
  border-color: #3d2b1f;
}

.card--face-up {
  padding: 0;
  background: #fff;
}

.card--removed {
  visibility: hidden;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.card--playable {
  cursor: pointer;
}

.card--playable:not(:disabled):not(.card--selected):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):hover {
  transform: translateY(-8px) scale(1.04) rotate(var(--card-tilt, 0deg));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.card--playable.card--selected:not(:disabled):hover {
  box-shadow:
    0 0 28px rgba(255, 220, 80, 0.92),
    0 16px 34px rgba(0, 0, 0, 0.42);
}

.card--playable:not(:disabled):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):active {
  transition-duration: 80ms;
  animation: none;
  transform: translateY(-10px) scale(0.97) rotate(var(--card-tilt, 0deg));
}

.card--playable.card--selected:not(:disabled):active {
  transform: translateY(-16px) scale(1.07) rotate(var(--card-tilt, 0deg));
}

.card--blocked {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.card--blocked:not(:disabled):hover {
  transform: rotate(var(--card-tilt, 0deg));
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
}

/* Hand：僅中間牌壓暗，左右兩端保持正常亮度 */
.card--hand-blocked {
  opacity: 0.58;
  filter: brightness(0.82);
  cursor: not-allowed;
  pointer-events: none;
}

/* Waste 中間牌：視覺壓暗但仍可點擊，由 GameEngine 判斷 Waste↔Waste 合法性 */
.card--waste-middle:not(.card--selected) {
  opacity: 0.58;
  filter: brightness(0.82);
}

.card--hand-available {
  opacity: 1;
}

.card--selected {
  z-index: 350;
  border-color: #ffd700;
  animation: selectedPulse 1s ease-in-out infinite;
  box-shadow:
    0 0 24px rgba(255, 220, 80, 0.8),
    0 12px 30px rgba(0, 0, 0, 0.35);
}

@keyframes selectedPulse {
  0%,
  100% {
    transform: translateY(-18px) scale(1.1)
      rotate(calc(var(--card-tilt, 0deg) - 1deg));
  }

  50% {
    transform: translateY(-18px) scale(1.13)
      rotate(calc(var(--card-tilt, 0deg) + 1deg));
  }
}

.card--flying-to-graveyard {
  pointer-events: none;
  z-index: 400;
  animation: match-to-graveyard 0.52s ease-in forwards;
  will-change: transform, opacity, filter, box-shadow;
}

.card--flying-to-graveyard-left,
.card--flying-to-graveyard-right {
  /* fly delta supplied via inline --fly-x / --fly-y */
}

@keyframes match-to-graveyard {
  0% {
    opacity: 1;
    filter: blur(0);
    transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  }

  8% {
    opacity: 1;
    filter: blur(0) brightness(1.15);
    transform: translate(0, -6px) scale(1.15) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.38);
  }

  16% {
    opacity: 1;
    filter: blur(0) brightness(1.35);
    transform: translate(var(--pull-x, 0px), var(--pull-y, -10px)) scale(1.12)
      rotate(var(--card-tilt, 0deg));
    box-shadow:
      0 0 36px rgba(255, 255, 255, 0.95),
      0 16px 32px rgba(0, 0, 0, 0.4);
  }

  24% {
    opacity: 1;
    filter: blur(0) brightness(1.5);
    transform: translate(var(--pull-x, 0px), var(--pull-y, -10px)) scale(1.3)
      rotate(var(--card-tilt, 0deg));
    box-shadow: 0 0 48px rgba(255, 255, 255, 1);
  }

  32% {
    opacity: 0.95;
    filter: blur(0);
    transform: translate(calc(var(--pull-x, 0px) * 0.5), calc(var(--pull-y, -10px) * 0.5))
      scale(1.05) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  }

  100% {
    opacity: 0;
    filter: blur(3px);
    transform: translate(var(--fly-x, 160px), var(--fly-y, -120px)) scale(0.3)
      rotate(calc(var(--card-tilt, 0deg) + var(--fly-rotate, 20deg)));
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }
}

.card--flying-to-hand {
  pointer-events: none;
  z-index: 480;
  animation: fly-to-hand 0.32s ease-in forwards;
  will-change: transform, opacity, box-shadow;
}

@keyframes fly-to-hand {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1.06) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  }

  55% {
    opacity: 0.92;
    transform: translate(-130px, 28px) scale(0.96)
      rotate(calc(var(--card-tilt, 0deg) + 6deg));
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.38);
  }

  100% {
    opacity: 0.55;
    transform: translate(-200px, 72px) scale(0.88) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  }
}

.card--swap-flying-waste,
.card--swap-flying-pyramid {
  pointer-events: none;
  z-index: 460;
  animation: swap-fly 0.42s cubic-bezier(0.45, 0.05, 0.25, 1) forwards;
  will-change: transform, box-shadow;
}

@keyframes swap-fly {
  0% {
    transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  }

  45% {
    transform: translate(
        calc(var(--fly-x, 0px) * 0.52),
        calc(var(--fly-y, 0px) * 0.28 + var(--arc-y, -48px))
      )
      scale(1.06) rotate(calc(var(--card-tilt, 0deg) + 8deg));
    box-shadow: 0 18px 36px rgba(120, 80, 200, 0.35);
  }

  100% {
    transform: translate(var(--fly-x, 0px), var(--fly-y, 0px)) scale(1)
      rotate(var(--card-tilt, 0deg));
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  }
}

.card--flipping {
  pointer-events: none;
  z-index: 420;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  overflow: visible;
}

.card__flip {
  display: block;
  width: 100%;
  height: 100%;
  perspective: 900px;
}

.card__flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.card__flip-inner--revealing {
  animation: card-flip-reveal 0.28s ease-in-out forwards;
}

.card__flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #c9b89a;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.card__flip-face--back {
  background: #4a3528;
}

.card__flip-face--front {
  transform: rotateY(180deg);
  background: #fff;
}

@keyframes card-flip-reveal {
  0% {
    transform: rotateY(0deg);
  }

  100% {
    transform: rotateY(180deg);
  }
}

.card--removing {
  pointer-events: none;
  z-index: 300;
  animation: card-fly-away 0.35s ease-in forwards;
}

.card--removing-left {
  --fly-x: -40px;
  --fly-rotate: -12deg;
}

.card--removing-right {
  --fly-x: 40px;
  --fly-rotate: 12deg;
}

.card--no-match {
  animation: card-shake 0.25s ease-in-out;
}

@keyframes card-fly-away {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--fly-x, 0), -80px) scale(0.7)
      rotate(var(--fly-rotate, 12deg));
  }
}

@keyframes card-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

.game-page--busy {
  cursor: wait;
}

.game-page--busy .card--playable:not(:disabled):hover,
.game-page--busy .card--selected,
.game-page--busy .pyramid-card-position.playable:hover {
  transform: rotate(var(--card-tilt, 0deg));
  animation: none;
  box-shadow: inherit;
}

.game-page--busy .waste-pile__reshuffle-btn,
.game-page--busy .stock-pile__draw,
.game-page--busy .floating-hud__btn {
  pointer-events: none;
  opacity: 0.55;
}

.card--stock {
  display: block;
  pointer-events: none;
}

.card__face-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  pointer-events: none;
  user-select: none;
}

.card-back {
  width: 100%;
  height: 100%;
}

.card-back__pattern {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
}

.card-back__emblem {
  fill: #d4b896;
  font-size: 22px;
  font-family: 'Segoe UI', serif;
}

/* CSS fallback face (CssCardFace) */
.card__css-face {
  position: relative;
  width: 100%;
  height: 100%;
}

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1;
  font-weight: 800;
  padding: 6px 8px;
  z-index: 2;
}

.card-corner--top {
  top: 0;
  left: 0;
}

.card-corner--bottom {
  bottom: 0;
  right: 0;
  transform: rotate(180deg);
}

.card-corner__rank {
  font-size: 22px;
}

.card-corner__rank--wide {
  font-size: 18px;
}

.card-corner__suit {
  font-size: 18px;
}

.card-pips {
  position: absolute;
  inset: 18% 8% 18% 8%;
}

.card-pip {
  position: absolute;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.card-suit--red {
  color: #c62828;
}

.card-suit--black {
  color: #1a1a1a;
}

.card-face-art {
  position: absolute;
  inset: 22% 10% 18% 10%;
  width: 80%;
  height: auto;
}

.card-face-art__frame {
  fill: #faf7f0;
  stroke: currentColor;
  stroke-width: 1.5;
}

.card-face-art__head {
  fill: #f2d6b3;
  stroke: currentColor;
  stroke-width: 1.2;
}

.card-face-art__robe {
  fill: currentColor;
  opacity: 0.85;
}

.card-face-art__crown {
  fill: #e8c547;
  stroke: #8a6d1d;
  stroke-width: 0.8;
}

.card-face-art__label {
  font-size: 8px;
  fill: currentColor;
  font-weight: 700;
}

.stock-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.stock-pile__draw {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.stock-pile__draw:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.stock-pile__draw--empty {
  width: 98px;
  height: 140px;
  border: 2px dashed rgba(245, 230, 200, 0.35);
  border-radius: 12px;
  cursor: not-allowed;
}

.stock-pile__count {
  font-size: 0.85rem;
  color: #d4c4a8;
}

.waste-pile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
  max-width: 100%;
}

.waste-pile__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.waste-pile__label {
  font-size: 0.85rem;
  color: #d4c4a8;
}

.waste-pile__reshuffle-btn {
  flex-shrink: 0;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 196, 168, 0.45);
  background: rgba(212, 196, 168, 0.1);
  color: #e8dcc0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.waste-pile__reshuffle-btn:hover:not(:disabled) {
  background: rgba(212, 196, 168, 0.2);
  border-color: rgba(232, 220, 192, 0.65);
  color: #f5ecd8;
}

.waste-pile__reshuffle-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.waste-pile__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  height: 140px;
  border: 2px dashed rgba(245, 230, 200, 0.25);
  border-radius: 12px;
  color: #a89880;
  font-size: 0.85rem;
}

.waste-pile .card--blocked {
  opacity: 0.4;
}

/* ── Joker ── */

.card--joker {
  border-color: #9b59b6;
}

.card--joker-glow {
  pointer-events: none;
  z-index: 430;
  animation: joker-glow 0.65s ease-in-out infinite alternate;
  box-shadow:
    0 0 18px rgba(155, 89, 182, 0.75),
    0 0 36px rgba(232, 197, 71, 0.45);
}

.card--resonating {
  animation: joker-resonate 0.45s ease-in-out infinite alternate;
}

.card--resonance-fly {
  pointer-events: none;
  z-index: 440;
  animation: joker-resonance-fly 0.62s cubic-bezier(0.22, 0.85, 0.3, 1) forwards;
  filter: drop-shadow(0 0 10px rgba(232, 197, 71, 0.85));
}

.card--joker-transform {
  pointer-events: none;
  z-index: 435;
}

.card__joker-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #fff8ef 0%, #f3e2ff 55%, #fff8ef 100%);
  color: #5b2d82;
  gap: 0.35rem;
}

.card__joker-icon {
  font-size: 2rem;
  line-height: 1;
}

.card__joker-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.card__joker-rank {
  font-size: 1.6rem;
  font-weight: 800;
}

.card__joker-suit {
  font-size: 1.4rem;
}

.card__tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 12rem;
  max-width: 16rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: rgba(24, 16, 10, 0.94);
  color: #f5e6c8;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-line;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.card:hover .card__tooltip,
.card:focus-visible .card__tooltip {
  opacity: 1;
}

.joker-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.62);
  backdrop-filter: blur(3px);
}

.joker-dialog {
  width: min(92vw, 26rem);
  padding: 1.25rem 1.35rem 1.1rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #fff9f0, #f7ecff);
  border: 1px solid rgba(91, 45, 130, 0.25);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.joker-dialog__title {
  margin: 0;
  font-size: 1.2rem;
  color: #3d2b1f;
}

.joker-dialog__subtitle {
  margin: 0.55rem 0 0.85rem;
  color: rgba(61, 43, 31, 0.78);
  font-size: 0.92rem;
}

.joker-dialog__ranks {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.joker-dialog__rank-btn {
  padding: 0.45rem 0;
  border-radius: 8px;
  border: 1px solid rgba(61, 43, 31, 0.22);
  background: rgba(255, 255, 255, 0.75);
  color: #3d2b1f;
  font-weight: 700;
  cursor: pointer;
}

.joker-dialog__rank-btn:hover:not(:disabled) {
  background: #5b2d82;
  border-color: #5b2d82;
  color: #fff8ef;
}

.joker-dialog__rank-btn--disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.joker-dialog__cancel {
  margin-top: 0.9rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(61, 43, 31, 0.25);
  background: transparent;
  color: #3d2b1f;
  cursor: pointer;
}

.table-reshuffle-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.62);
  backdrop-filter: blur(3px);
}

.table-reshuffle-dialog {
  width: min(92vw, 24rem);
  padding: 1.25rem 1.35rem 1.1rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #fff9f0, #f3ebe0);
  border: 1px solid rgba(91, 60, 30, 0.22);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.table-reshuffle-dialog__title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.45;
  color: #3d2b1f;
}

.table-reshuffle-dialog__body {
  margin: 0.75rem 0 1rem;
  color: rgba(61, 43, 31, 0.82);
  font-size: 0.9rem;
  line-height: 1.55;
}

.table-reshuffle-dialog__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.table-reshuffle-dialog__confirm {
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(91, 60, 30, 0.28);
  background: rgba(139, 90, 43, 0.15);
  color: #3d2b1f;
  font-weight: 700;
  cursor: pointer;
}

.table-reshuffle-dialog__confirm:hover {
  background: rgba(139, 90, 43, 0.25);
}

.table-reshuffle-dialog__cancel {
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(61, 43, 31, 0.25);
  background: transparent;
  color: #3d2b1f;
  cursor: pointer;
}

.new-game-confirm-dialog-overlay {
  z-index: 1250;
}

.new-game-confirm-dialog__continue,
.new-game-confirm-dialog__abandon {
  min-height: 44px;
}

.joker-resonance-banner {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(24, 16, 10, 0.82);
  color: #f5d76e;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  animation: joker-banner-pop 0.65s ease-out;
  pointer-events: none;
}

@keyframes joker-glow {
  0% {
    filter: brightness(1);
  }

  100% {
    filter: brightness(1.18);
  }
}

@keyframes joker-resonate {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  100% {
    transform: scale(1.06);
    filter: brightness(1.25) drop-shadow(0 0 12px rgba(232, 197, 71, 0.9));
  }
}

@keyframes joker-resonance-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  70% {
    transform: translate(var(--fly-x, 0px), var(--fly-y, 0px)) scale(0.35);
    opacity: 0.85;
  }

  100% {
    transform: translate(var(--fly-x, 0px), var(--fly-y, 0px))
      scale(var(--resonance-scale, 0.15));
    opacity: 0;
  }
}

@keyframes joker-banner-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.85);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@media (max-width: 820px) {
  .game-pyramid-area {
    justify-content: flex-start;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* itch.io iframe: prevent min-height: 100vh from stretching the document */
.is-itch-embed body {
  min-height: 0;
}

.is-itch-embed .game-page {
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.is-itch-embed .game-page--desktop-scale {
  height: 100%;
  max-height: 100%;
}

.is-itch-embed .start-screen {
  min-height: 0;
  height: 100svh;
  max-height: 100svh;
  padding: 0;
}
/* ── Premium Polish v0.6 ── */

:root {
  --font-display: 'Libre Baskerville', 'Georgia', 'Times New Roman', serif;
  --font-body: 'Crimson Pro', 'Georgia', 'Microsoft JhengHei', serif;
  --ease-out-premium: cubic-bezier(0.22, 1, 0.36, 1);
  --card-edge-light: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  --card-edge-dark: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

body {
  font-family: var(--font-body);
}

.game-page {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(
      ellipse 85% 70% at 50% 42%,
      rgba(255, 220, 160, 0.14) 0%,
      transparent 62%
    ),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 32%),
    repeating-linear-gradient(
      92deg,
      #4a3124 0,
      #4a3124 3px,
      #563a2b 3px,
      #563a2b 26px,
      #614232 26px,
      #614232 52px
    );
}

.game-page__table-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    circle at 50% 38%,
    rgba(255, 235, 190, 0.1) 0%,
    transparent 55%
  );
  mix-blend-mode: soft-light;
}

.game-page__vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    ellipse at center,
    transparent 42%,
    rgba(10, 6, 4, 0.48) 100%
  );
}

.game-page__noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.floating-hud,
.game-main,
.game-swap-banner,
.game-toast {
  position: relative;
  z-index: 3;
}

.floating-hud__stat-value,
.floating-hud__btn,
.graveyard-panel__title,
.start-screen__title {
  font-family: var(--font-display);
}

/* ── Card thickness & sheen ── */

.card {
  border: 1px solid rgba(255, 248, 230, 0.35);
  box-shadow:
    var(--card-edge-light),
    var(--card-edge-dark),
    0 3px 8px rgba(0, 0, 0, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.15s var(--ease-out-premium),
    box-shadow 0.15s var(--ease-out-premium),
    filter 0.15s var(--ease-out-premium),
    border-color 0.15s var(--ease-out-premium),
    opacity 0.15s var(--ease-out-premium);
}

.card__sheen {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0) 35%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0) 65%
  );
  transition: opacity 0.15s var(--ease-out-premium);
  z-index: 2;
}

.card--playable:not(:disabled):hover .card__sheen {
  opacity: 1;
}

.card--hover-partner {
  box-shadow:
    var(--card-edge-light),
    var(--card-edge-dark),
    0 0 0 1px rgba(255, 220, 80, 0.25),
    0 0 18px rgba(255, 220, 80, 0.2),
    0 6px 16px rgba(0, 0, 0, 0.26);
  filter: brightness(1.06);
}

/* ── Hand fly bezier + bounce ── */

.card--flying-to-hand {
  animation: fly-to-hand-bezier 0.35s var(--ease-out-premium) forwards;
}

@keyframes fly-to-hand-bezier {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1.04) rotate(var(--card-tilt, 0deg));
  }

  50% {
    opacity: 0.95;
    transform: translate(
        calc(var(--fly-x, -160px) * 0.55),
        calc(var(--fly-y, 60px) * 0.45 - 28px)
      )
      scale(0.98) rotate(calc(var(--card-tilt, 0deg) + 5deg));
  }

  78% {
    opacity: 0.88;
    transform: translate(var(--fly-x, -160px), var(--fly-y, 60px))
      scale(1.08) rotate(var(--card-tilt, 0deg));
  }

  100% {
    opacity: 0.7;
    transform: translate(var(--fly-x, -160px), var(--fly-y, 60px))
      scale(1) rotate(var(--card-tilt, 0deg));
  }
}

/* ── Swap magic ── */

.card--swap-flying-waste,
.card--swap-flying-pyramid {
  animation: swap-fly-magic 0.42s cubic-bezier(0.34, 0.02, 0.15, 1) forwards;
}

@keyframes swap-fly-magic {
  0% {
    transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg));
  }

  42% {
    transform: translate(
        calc(var(--fly-x, 0px) * 0.5),
        calc(var(--fly-y, 0px) * 0.22 + var(--arc-y, -58px))
      )
      scale(1.05) rotate(calc(var(--card-tilt, 0deg) + 8deg));
  }

  100% {
    transform: translate(var(--fly-x, 0px), var(--fly-y, 0px)) scale(1)
      rotate(var(--card-tilt, 0deg));
  }
}

/* ── Screen shake ── */

.game-page--shake {
  animation: screen-shake 0.08s ease-out;
}

@keyframes screen-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-2px, 1px);
  }

  75% {
    transform: translate(2px, -1px);
  }
}

/* Graveyard stack — layout in hud.css (fixed panel) */

.graveyard-panel__stack-wrap {
  position: relative;
  height: 72px;
  margin-bottom: 0.65rem;
}

.graveyard-panel__stack {
  position: absolute;
  right: 0.35rem;
  bottom: 0;
  width: 52px;
  height: 72px;
}

.graveyard-panel__stack-card {
  position: absolute;
  inset: 0;
  width: 52px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
}

.graveyard-panel__stack-card .card-back {
  width: 100%;
  height: 100%;
}

.graveyard-panel__stack-count {
  position: absolute;
  right: 0;
  bottom: -0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #ffd700;
  font-family: var(--font-display);
}

.graveyard-panel--shake .graveyard-panel__stack-wrap {
  animation: graveyard-stack-shake 0.3s var(--ease-out-premium);
}

@keyframes graveyard-stack-shake {
  0%,
  100% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.05);
  }
}

.graveyard-panel__spread {
  position: absolute;
  right: -0.5rem;
  top: 0.5rem;
  width: 180px;
  height: 100px;
  z-index: 20;
  pointer-events: none;
}

.graveyard-panel__spread-card {
  position: absolute;
  width: 42px;
  height: 58px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  left: calc(var(--i, 0) * 16px);
}

.graveyard-panel--expanded {
  z-index: 30;
}

/* ── Combo ── */

.combo-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 500;
}

.combo-overlay__text {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: #ffd700;
  text-shadow:
    0 0 24px rgba(255, 215, 0, 0.65),
    0 4px 16px rgba(0, 0, 0, 0.45);
  animation: combo-pop 0.6s var(--ease-out-premium) forwards;
}

@keyframes combo-pop {
  0% {
    opacity: 0;
    transform: scale(1);
  }

  18% {
    opacity: 1;
    transform: scale(1.2);
  }

  100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* ── Perfect Memory ── */

.perfect-memory-badge {
  position: fixed;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: rgba(255, 235, 180, 0.92);
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.22);
  animation: perfect-memory-fade 2.2s var(--ease-out-premium) forwards;
}

@keyframes perfect-memory-fade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }

  15%,
  75% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  100% {
    opacity: 0;
  }
}

/* ── Win celebration ── */

.game-page--win-celebration .card--win-fly {
  animation: win-card-fly 1.2s var(--ease-out-premium) forwards;
  pointer-events: none;
}

@keyframes win-card-fly {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--card-tilt, 0deg));
  }

  100% {
    opacity: 0;
    transform: translateY(-120px) scale(0.85)
      rotate(calc(var(--card-tilt, 0deg) + 12deg));
  }
}

.game-overlay--won {
  background: rgba(8, 6, 4, 0.45);
  animation: win-overlay-in 0.6s var(--ease-out-premium) forwards;
}

.win-overlay__sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 220, 120, 0.12) 50%,
    transparent 60%
  );
  animation: win-light-sweep 2.4s ease-in-out infinite;
}

@keyframes win-light-sweep {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(120%);
  }
}

.win-overlay__glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 0, 0.28) 0%,
    transparent 68%
  );
  filter: blur(8px);
  animation: win-glow-pulse 2s ease-in-out infinite;
}

@keyframes win-glow-pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.win-overlay__panel {
  position: relative;
  z-index: 2;
  background: rgba(28, 20, 12, 0.88) !important;
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: #f5e6c8 !important;
  box-shadow:
    0 0 48px rgba(255, 215, 0, 0.22),
    0 12px 40px rgba(0, 0, 0, 0.45) !important;
}

.win-overlay__title {
  font-family: var(--font-display);
  font-size: 2rem !important;
  letter-spacing: 0.08em;
  color: #ffd700;
  text-shadow: 0 0 24px rgba(255, 215, 0, 0.45);
  animation: win-title-in 0.8s var(--ease-out-premium) forwards;
}

@keyframes win-title-in {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes win-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Lose fade ── */

.game-page--lose-fade {
  filter: brightness(0.92) saturate(0.94);
  transition: filter 0.6s var(--ease-out-premium);
}

.game-overlay--lost {
  background: rgba(4, 2, 1, 0.62);
  animation: lose-overlay-in 0.6s var(--ease-out-premium) forwards;
}

.lose-overlay__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 20%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.lose-overlay__panel {
  position: relative;
  z-index: 2;
  background: rgba(22, 16, 12, 0.92) !important;
  border: 1px solid rgba(245, 230, 200, 0.15);
  color: #d4c4a8 !important;
}

.lose-overlay__title {
  font-family: var(--font-display);
  font-size: 1.75rem !important;
  letter-spacing: 0.06em;
  color: #c9b89a;
}

.lose-overlay__restart {
  margin-top: 0.5rem;
  font-family: var(--font-display);
}

@keyframes lose-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.game-page--enter {
  animation: game-page-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes game-page-enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
/* ── Splash Screen / Main Menu ── */

.splash-page {
  --splash-aspect: 3 / 2;
  --ease-splash: cubic-bezier(0.22, 1, 0.36, 1);
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow: hidden;
  background: #060403;
}

.splash-page__curtain {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #000;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.splash-page--ready .splash-page__curtain {
  opacity: 0;
}

.splash-page__scene {
  position: absolute;
  inset: 0;
}

.splash-page__backdrop,
.splash-frame,
.splash-bg,
.splash-page__bg-blur,
.splash-page__lamp-glow {
  /* Legacy art-in-image layout — replaced by visual-theme overlay */
  display: none;
}

.splash-page__dust {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.splash-page__dust-particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 235, 200, 0.35);
  opacity: 0;
  animation: splash-dust-float linear infinite;
}

.splash-page--ready .splash-page__dust-particle {
  opacity: 0.18;
}

@keyframes splash-dust-float {
  0% {
    transform: translate(0, 0);
    opacity: 0;
  }

  15% {
    opacity: 0.16;
  }

  85% {
    opacity: 0.1;
  }

  100% {
    transform: translate(12px, -36px);
    opacity: 0;
  }
}

/* Menu — wooden plaque buttons (React overlay only) */
.splash-menu {
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
  width: 100%;
  margin: 0;
  padding: 0;
}

.splash-menu__btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0.72rem 1.1rem;
  border: 1.5px solid rgba(212, 168, 88, 0.62);
  border-radius: 10px;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: clamp(0.88rem, 1.35vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #f5e8d0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  touch-action: manipulation;
  background:
    linear-gradient(
      180deg,
      rgba(88, 62, 40, 0.96) 0%,
      rgba(52, 34, 22, 0.98) 48%,
      rgba(38, 24, 14, 1) 100%
    );
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 220, 160, 0.16),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(6px);
  transition:
    transform 0.18s var(--ease-splash),
    box-shadow 0.18s var(--ease-splash),
    border-color 0.18s var(--ease-splash),
    filter 0.18s var(--ease-splash);
}

.splash-menu__btn:nth-child(1) {
  animation: splash-btn-in 0.95s var(--ease-splash) forwards;
  animation-delay: 1s;
}

.splash-menu__btn:nth-child(2) {
  animation: splash-btn-in 0.95s var(--ease-splash) forwards;
  animation-delay: 1.1s;
}

.splash-menu__btn:nth-child(3) {
  animation: splash-btn-in 0.95s var(--ease-splash) forwards;
  animation-delay: 1.2s;
}

.splash-menu__btn:nth-child(4) {
  animation: splash-btn-in 0.95s var(--ease-splash) forwards;
  animation-delay: 1.3s;
}

.splash-menu__btn:nth-child(5) {
  animation: splash-btn-in 0.95s var(--ease-splash) forwards;
  animation-delay: 1.4s;
}

@keyframes splash-btn-in {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.splash-menu__btn:hover,
.splash-menu__btn:focus-visible {
  transform: scale(1.03);
  border-color: rgba(232, 197, 71, 0.82);
  color: #fff4e0;
  box-shadow:
    0 0 18px rgba(232, 197, 71, 0.42),
    0 0 36px rgba(212, 168, 88, 0.22),
    0 8px 22px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 230, 180, 0.24);
  outline: none;
}

.splash-menu__btn:active {
  transform: scale(1) translateY(2px);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.45),
    inset 0 2px 6px rgba(0, 0, 0, 0.35);
  transition-duration: 0.08s;
}

.splash-best {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(8, 5, 3, 0.42);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 220, 160, 0.12);
  color: rgba(245, 230, 200, 0.82);
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  pointer-events: none;
}

.splash-best__label {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 215, 0, 0.75);
}

.splash-best__value {
  font-variant-numeric: tabular-nums;
}

.splash-page--exit {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.splash-page--exit .splash-page__curtain {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Dev-only hitbox debug */
.splash-page__hitbox-banner {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  z-index: 500;
  transform: translateX(-50%);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  background: rgba(180, 20, 20, 0.92);
  color: #fff;
  font-family: monospace;
  font-size: 0.75rem;
  pointer-events: none;
}

.splash-page--hitbox-debug .splash-menu__btn,
.splash-page--hitbox-debug .splash-journal-button,
.splash-page--hitbox-debug .start-screen__footer-link {
  outline: 3px solid rgba(255, 48, 48, 0.9) !important;
  outline-offset: 2px;
}

.splash-page--hitbox-debug .splash-menu__btn::after,
.splash-page--hitbox-debug .splash-journal-button::after {
  content: attr(data-hitbox-label);
  position: absolute;
  top: -1.35rem;
  left: 0.25rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(255, 48, 48, 0.92);
  color: #fff;
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 20;
}

.splash-page--hitbox-debug .splash-menu__btn {
  background: rgba(255, 48, 48, 0.38) !important;
  color: #fff !important;
}

.splash-page--hitbox-debug .splash-journal-button {
  background: rgba(255, 48, 48, 0.38) !important;
}

/* ── Grandpa Story Dialog ── */

.story-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 5, 3, 0.55);
  backdrop-filter: blur(4px);
  animation: story-overlay-in 0.35s var(--ease-splash) forwards;
}

@keyframes story-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.story-dialog {
  position: relative;
  width: min(100%, 480px);
  max-height: min(88vh, 640px);
  overflow-y: auto;
  padding: 1.75rem 1.85rem 1.5rem;
  border-radius: 18px;
  background:
    linear-gradient(
      145deg,
      rgba(245, 230, 200, 0.18) 0%,
      rgba(92, 64, 48, 0.22) 100%
    ),
    rgba(38, 26, 18, 0.82);
  backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid rgba(255, 220, 160, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 20px 50px rgba(0, 0, 0, 0.45),
    0 0 40px rgba(255, 200, 100, 0.06);
  color: #f0e2c8;
  animation: story-dialog-in 0.45s var(--ease-splash) forwards;
}

@keyframes story-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.story-dialog__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #d4c4a8;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.12s ease,
    transform 0.12s ease;
}

.story-dialog__close:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.05);
}

.story-dialog__title {
  margin: 0 0 1.1rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffd700;
  text-align: center;
}

.story-dialog__body {
  display: grid;
  gap: 0.85rem;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 1.02rem;
  line-height: 1.75;
  color: rgba(240, 226, 200, 0.92);
}

.story-dialog__body p {
  margin: 0;
}

.story-dialog__quote {
  padding-left: 0.75rem;
  border-left: 2px solid rgba(255, 215, 0, 0.35);
  font-style: italic;
  color: #ffe8a8;
}

.story-dialog__closing {
  margin-top: 0.35rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 220, 160, 0.12);
  color: rgba(255, 235, 200, 0.88);
}

.story-dialog--legal {
  max-height: min(85vh, 720px);
  overflow-y: auto;
}

.story-dialog__section {
  display: grid;
  gap: 0.45rem;
}

.story-dialog__section-title {
  margin: 0.65rem 0 0;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffd978;
}

.story-dialog__list {
  margin: 0;
  padding-left: 1.25rem;
}

.story-dialog__list li {
  margin: 0.2rem 0;
}

.story-dialog__section--todo p {
  color: rgba(255, 220, 160, 0.75);
  font-size: 0.92rem;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .splash-best {
    font-size: 0.62rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-page__dust-particle {
    display: none;
  }

  .splash-page__curtain,
  .splash-overlay,
  .splash-menu__btn,
  .splash-best,
  .splash-journal-button {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .splash-page--ready .splash-page__curtain {
    opacity: 0;
  }

  .splash-page--ready .splash-overlay {
    opacity: 1;
    transform: none;
  }

  .splash-menu__btn,
  .splash-journal-button,
  .splash-best {
    opacity: 1;
  }
}

/* ── Language Switcher ── */

.language-switcher {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0;
}

.language-switcher__label {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(245, 230, 200, 0.78);
}

.language-switcher__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.language-switcher__btn {
  min-width: 5.5rem;
  padding: 0.42rem 0.75rem;
  border: 1px solid rgba(212, 168, 88, 0.45);
  border-radius: 8px;
  background: rgba(38, 26, 18, 0.72);
  color: rgba(245, 230, 200, 0.88);
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.88rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.language-switcher__btn:hover,
.language-switcher__btn:focus-visible {
  border-color: rgba(232, 197, 71, 0.72);
  color: #fff4e0;
  outline: none;
}

.language-switcher__btn--active {
  border-color: rgba(255, 215, 0, 0.72);
  background: rgba(92, 64, 48, 0.55);
  color: #ffd700;
  font-weight: 700;
}

/* ── Changelog ── */

.changelog-entry {
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid rgba(255, 220, 160, 0.12);
}

.changelog-entry:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.changelog-entry__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.65rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd700;
}

.changelog-entry__date {
  font-size: 0.82rem;
  font-weight: 400;
  color: rgba(240, 226, 200, 0.62);
}

.changelog-entry__section {
  margin-bottom: 0.75rem;
}

.changelog-entry__section:last-child {
  margin-bottom: 0;
}

.changelog-entry__section-title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: rgba(255, 235, 200, 0.9);
}

.changelog-entry__list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: rgba(240, 226, 200, 0.88);
}

.changelog-entry__list li + li {
  margin-top: 0.25rem;
}

/* ── itch.io iframe embed: lock document + start screen to visible viewport ── */

.is-itch-embed,
.is-itch-embed body,
.is-itch-embed #root,
.is-itch-embed .app {
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

.is-itch-embed .splash-page,
.is-itch-embed .start-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100svh;
  max-height: 100svh;
  overflow: hidden;
}

.is-itch-embed .splash-page__scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.is-itch-embed .splash-page .visual-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.is-itch-embed .splash-page .visual-background__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.is-itch-embed .splash-overlay {
  top: 0;
  bottom: 0;
  height: auto;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.is-itch-embed .splash-page__scene > .splash-best {
  max-height: calc(100% - 1rem);
}
/* ── Floating HUD & Graveyard Rail ── */

:root {
  --hud-right: 20px;
  --hud-top: 20px;
  --hud-width: 168px;
  --hud-rail-gap: 12px;
  --hud-glass-bg: rgba(38, 26, 18, 0.88);
  --hud-glass-border: rgba(255, 220, 160, 0.16);
  --hud-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.game-page--playing,
.game-page--memorizing,
.game-page--won,
.game-page--lost {
  --hud-rail-width: calc(var(--hud-width) + var(--hud-right) + 16px);
}

/* ── Fixed HUD Rail (HUD + Graveyard) ── */

  .game-hud-rail {
  position: fixed;
  top: calc(var(--hud-top) + env(safe-area-inset-top, 0px));
  right: calc(var(--hud-right) + env(safe-area-inset-right, 0px));
  z-index: 380;
  display: flex;
  flex-direction: column;
  gap: var(--hud-rail-gap);
  width: var(--hud-width);
  max-height: calc(100dvh - var(--hud-top) * 2 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.game-hud-rail > * {
  pointer-events: auto;
}

/* ── Floating HUD ── */

.floating-hud {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  padding: 0.75rem 0.8rem;
  border-radius: 14px;
  background:
    linear-gradient(
      155deg,
      rgba(255, 235, 200, 0.1) 0%,
      rgba(255, 235, 200, 0.02) 42%
    ),
    var(--hud-glass-bg);
  backdrop-filter: blur(14px) saturate(1.05);
  border: 1px solid var(--hud-glass-border);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 10px 32px rgba(0, 0, 0, 0.38),
    0 0 24px rgba(255, 200, 100, 0.04);
  color: #f0e2c8;
  animation: floating-hud-in 0.3s var(--hud-ease) forwards;
}

@keyframes floating-hud-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating-hud__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.55rem;
}

.floating-hud__stat {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.floating-hud__stat--wide {
  grid-column: 1 / -1;
}

.floating-hud__stat-label {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(200, 180, 150, 0.82);
}

.floating-hud__stat-value {
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f5e6c8;
  line-height: 1.2;
}

.floating-hud__stat-value--ready {
  color: #b8f0b0;
}

.floating-hud__stat-value--muted {
  color: rgba(168, 152, 128, 0.88);
}

.floating-hud__divider {
  height: 1px;
  margin: 0.6rem 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 220, 160, 0.22),
    transparent
  );
}

.floating-hud__actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.floating-hud__btn {
  width: 100%;
  padding: 0.42rem 0.65rem;
  border: 1px solid rgba(255, 220, 160, 0.18);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: #e8dcc4;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.12s var(--hud-ease),
    background 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.floating-hud__btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 220, 160, 0.28);
  color: #fff8ea;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.floating-hud__btn:active:not(:disabled) {
  transform: scale(0.98);
}

.floating-hud__btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.floating-hud__btn--primary {
  background: linear-gradient(180deg, #f5e6c8 0%, #e8d4a8 100%);
  color: #3d2b1f;
  border-color: rgba(245, 230, 200, 0.55);
  font-weight: 700;
}

.floating-hud__btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff4dc 0%, #f0e0bc 100%);
  color: #3d2b1f;
}

.floating-hud__btn--accent {
  border-color: rgba(232, 197, 71, 0.45);
  color: #ffd700;
}

.floating-hud__btn--icon {
  font-size: 0.78rem;
}

.floating-hud__reserved {
  display: none;
}

/* ── Fixed Graveyard ── */

.graveyard-panel {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.7rem 0.65rem;
  border-radius: 14px;
  background:
    linear-gradient(
      155deg,
      rgba(255, 235, 200, 0.08) 0%,
      rgba(255, 235, 200, 0.02) 40%
    ),
    rgba(32, 22, 14, 0.86);
  backdrop-filter: blur(12px) saturate(1.04);
  border: 1px solid rgba(245, 230, 200, 0.14);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 8px 28px rgba(0, 0, 0, 0.34);
  color: #d4c4a8;
  flex-shrink: 0;
  transition:
    width 0.2s var(--hud-ease),
    box-shadow 0.2s var(--hud-ease);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 220, 160, 0.25) transparent;
  animation: floating-hud-in 0.3s var(--hud-ease) 0.08s both;
}

.graveyard-panel:hover,
.graveyard-panel--expanded {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 12px 36px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(255, 200, 100, 0.05);
}

.game-hud-rail:has(.graveyard-panel:hover),
.game-hud-rail:has(.graveyard-panel--expanded) {
  width: 196px;
  transition: width 0.2s var(--hud-ease);
}

.graveyard-panel__rank-bar {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    opacity 0.2s var(--hud-ease),
    max-width 0.2s var(--hud-ease);
}

.graveyard-panel:hover .graveyard-panel__rank-bar,
.graveyard-panel--expanded .graveyard-panel__rank-bar {
  opacity: 1;
  max-width: 4rem;
}

.graveyard-panel__section:last-child {
  transition: opacity 0.2s var(--hud-ease);
}

.graveyard-panel:not(:hover):not(.graveyard-panel--expanded)
  .graveyard-panel__section:last-child {
  opacity: 0.72;
}

/* ── Game layout offset ── */

.game-main--with-hud {
  padding-right: var(--hud-rail-width, 1rem);
}

.game-table-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
}

.game-piles-area {
  width: 100%;
}

/* Swap banner — stay visible while scrolling */
.game-swap-banner {
  position: fixed;
  top: var(--hud-top);
  left: 50%;
  transform: translateX(-50%);
  z-index: 360;
  max-width: min(92vw, 420px);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 197, 71, 0.35);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  color: #f5e6c8;
  background: rgba(232, 197, 71, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.game-page--busy .floating-hud__btn:not(:disabled),
.game-page--busy .floating-hud__btn--icon {
  pointer-events: none;
  opacity: 0.55;
}

/* ── Responsive ── */

@media (min-width: 1600px) {
  :root {
    --hud-width: 180px;
  }
}

@media (max-width: 900px) {
  :root {
    --hud-width: 152px;
  }

  .floating-hud__stat-value {
    font-size: 0.88rem;
  }

  .floating-hud__btn {
    font-size: 0.76rem;
    padding: 0.38rem 0.55rem;
  }
}

@media (max-width: 640px) {
  :root {
    --hud-right: 10px;
    --hud-top: 10px;
    --hud-width: 128px;
    --hud-rail-width: calc(var(--hud-width) + var(--hud-right) + 8px);
  }

  .floating-hud {
    padding: 0.55rem 0.6rem;
    border-radius: 12px;
  }

  .floating-hud__stat-label {
    font-size: 0.58rem;
  }

  .floating-hud__stat-value {
    font-size: 0.75rem;
  }

  .floating-hud__btn {
    font-size: 0.7rem;
    padding: 0.34rem 0.45rem;
  }

  .graveyard-panel {
    padding: 0.55rem 0.5rem;
  }

  .graveyard-panel:hover,
  .graveyard-panel--expanded {
    /* width handled by .game-hud-rail:has() */
  }

  .game-hud-rail:has(.graveyard-panel:hover),
  .game-hud-rail:has(.graveyard-panel--expanded) {
    width: 168px;
  }

  .graveyard-panel__title {
    font-size: 0.72rem !important;
  }

  .graveyard-panel__total,
  .graveyard-panel__rank-row,
  .graveyard-panel__suit-row {
    font-size: 0.65rem !important;
  }

  .game-main--with-hud {
    padding-right: 0;
    padding-bottom: 0.5rem;
  }

  .game-pyramid-area {
    padding-right: calc(var(--hud-rail-width) - 8px);
  }
}

@media (max-height: 700px) {
  .game-hud-rail {
    max-height: calc(100vh - 16px);
  }

  .floating-hud {
    padding: 0.55rem 0.65rem;
  }

  .floating-hud__stats {
    gap: 0.3rem 0.45rem;
  }

  .floating-hud__divider {
    margin: 0.45rem 0;
  }

  .floating-hud__actions {
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-hud,
  .graveyard-panel {
    animation: none;
  }
}
/* ── Tutorial Viewer ── */

.tutorial-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  background: rgba(6, 4, 3, 0.72);
  backdrop-filter: blur(6px);
  animation: tutorial-overlay-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes tutorial-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.tutorial-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(96vw, 1120px);
  max-height: min(94vh, 900px);
  border-radius: 20px;
  background:
    linear-gradient(
      155deg,
      rgba(245, 230, 200, 0.14) 0%,
      rgba(92, 64, 48, 0.2) 48%,
      rgba(38, 26, 18, 0.28) 100%
    ),
    rgba(42, 28, 20, 0.82);
  backdrop-filter: blur(18px) saturate(1.08);
  border: 1px solid rgba(255, 220, 160, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 64px rgba(0, 0, 0, 0.52),
    0 0 48px rgba(255, 200, 100, 0.06);
  color: #f0e2c8;
  animation: tutorial-panel-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes tutorial-panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tutorial-viewer__close {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #d4c4a8;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    color 0.15s ease;
}

.tutorial-viewer__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff8ef;
  transform: scale(1.05);
}

.tutorial-viewer__header {
  flex-shrink: 0;
  padding: 1.15rem 1.5rem 0.65rem;
  text-align: center;
}

.tutorial-viewer__title {
  margin: 0;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffd700;
}

.tutorial-viewer__page-title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgba(255, 230, 160, 0.92);
}

.tutorial-viewer__body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(0.35rem, 1.2vw, 0.85rem);
  padding: 0 0.65rem;
}

.tutorial-viewer__stage {
  position: relative;
  min-height: 0;
  height: min(62vh, 640px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(8, 5, 3, 0.35);
  border: 1px solid rgba(255, 220, 160, 0.1);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.28);
}

.tutorial-viewer__slide {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: clamp(0.5rem, 1.5vw, 1rem);
}

.tutorial-viewer__slide--from-next {
  animation: tutorial-slide-from-next 250ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.tutorial-viewer__slide--from-prev {
  animation: tutorial-slide-from-prev 250ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes tutorial-slide-from-next {
  from {
    opacity: 0;
    transform: translateX(28px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tutorial-slide-from-prev {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.tutorial-viewer__image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

.tutorial-viewer__nav {
  flex-shrink: 0;
  width: clamp(2.2rem, 4vw, 2.75rem);
  height: clamp(2.2rem, 4vw, 2.75rem);
  border: 1px solid rgba(255, 220, 160, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #f5e6c8;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    opacity 0.15s ease;
}

.tutorial-viewer__nav:hover:not(:disabled) {
  background: rgba(255, 220, 160, 0.16);
  transform: scale(1.06);
}

.tutorial-viewer__nav:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.tutorial-viewer__footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1.25rem 0.55rem;
}

.tutorial-viewer__dots {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tutorial-viewer__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(245, 230, 200, 0.28);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.tutorial-viewer__dot--active {
  background: #ffd700;
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.tutorial-viewer__counter {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: rgba(240, 226, 200, 0.72);
  letter-spacing: 0.04em;
}

.tutorial-viewer__nav-labels {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem 1.1rem;
}

.tutorial-viewer__nav-text {
  border: none;
  background: transparent;
  color: rgba(245, 230, 200, 0.82);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  transition: color 0.15s ease;
}

.tutorial-viewer__nav-text:hover:not(:disabled) {
  color: #ffd700;
}

.tutorial-viewer__nav-text:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.tutorial-viewer__nav-text--complete {
  color: #ffd700;
}

.tutorial-viewer__text-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: clamp(1rem, 3vw, 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.tutorial-viewer__bullets {
  margin: 0;
  padding: 0 0 0 1.35rem;
  max-width: 36rem;
  list-style: disc;
  font-size: clamp(0.95rem, 1.8vw, 1.12rem);
  line-height: 1.75;
  color: rgba(245, 230, 200, 0.94);
}

.tutorial-viewer__bullet-heading {
  list-style: none;
  margin-left: -1.35rem;
  margin-top: 0.85rem;
  font-weight: 700;
  color: #ffd978;
}

.tutorial-viewer__bullet-heading:first-child {
  margin-top: 0;
}

.tutorial-viewer__bullets li + li {
  margin-top: 0.55rem;
}

/* ── Coach Marks ── */

.coach-marks {
  position: fixed;
  inset: 0;
  z-index: 750;
  pointer-events: none;
}

.coach-marks__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 3, 0.55);
  pointer-events: auto;
}

.coach-marks__spotlight {
  position: fixed;
  z-index: 1;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(6, 4, 3, 0.68);
  pointer-events: none;
  transition:
    top 0.25s ease,
    left 0.25s ease,
    width 0.25s ease,
    height 0.25s ease;
}

.coach-marks__tooltip {
  position: fixed;
  z-index: 2;
  width: min(92vw, 320px);
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background:
    linear-gradient(
      155deg,
      rgba(245, 230, 200, 0.14) 0%,
      rgba(92, 64, 48, 0.22) 48%,
      rgba(38, 26, 18, 0.3) 100%
    ),
    rgba(42, 28, 20, 0.92);
  border: 1px solid rgba(255, 220, 160, 0.24);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 16px 40px rgba(0, 0, 0, 0.45);
  color: #f0e2c8;
  pointer-events: auto;
}

.coach-marks__step-label {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 230, 160, 0.75);
}

.coach-marks__title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd700;
}

.coach-marks__body {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: rgba(245, 230, 200, 0.92);
}

.coach-marks__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.coach-marks__btn {
  border: 1px solid rgba(255, 220, 160, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(245, 230, 200, 0.9);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.coach-marks__btn:hover {
  background: rgba(255, 220, 160, 0.14);
  color: #fff8ef;
}

.coach-marks__btn--primary {
  background: rgba(255, 215, 0, 0.18);
  border-color: rgba(255, 215, 0, 0.35);
  color: #ffd700;
}

.coach-marks__btn--primary:hover {
  background: rgba(255, 215, 0, 0.28);
}

.coach-marks__btn--ghost {
  border-color: transparent;
  background: transparent;
  color: rgba(240, 226, 200, 0.62);
}

.coach-marks__btn--ghost:hover {
  color: rgba(240, 226, 200, 0.88);
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 720px) {
  .tutorial-viewer__body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding: 0 0.85rem;
  }

  .tutorial-viewer__nav--prev,
  .tutorial-viewer__nav--next {
    display: none;
  }

  .tutorial-viewer__stage {
    height: min(58vh, 520px);
  }

  .tutorial-viewer__nav-labels {
    padding-bottom: 1.25rem;
  }
}

@media (min-aspect-ratio: 21/9) {
  .tutorial-viewer {
    width: min(88vw, 1280px);
  }

  .tutorial-viewer__stage {
    height: min(68vh, 720px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-viewer-overlay,
  .tutorial-viewer,
  .tutorial-viewer__slide {
    animation: none !important;
  }
}
/* ── Gameplay Polish Pass — interaction juice & table feel ── */

:root {
  --card-hover-lift: -10px;
  --card-hover-scale: 1.05;
  --card-selected-scale: 1.08;
  --ease-game: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Card base depth ── */

.card {
  transition:
    transform 150ms var(--ease-game),
    box-shadow 150ms var(--ease-game),
    filter 150ms ease,
    opacity 150ms ease;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.18),
    0 6px 16px rgba(0, 0, 0, 0.22),
    var(--card-edge-light, inset 0 1px 0 rgba(255, 255, 255, 0.55));
}

.card__sheen {
  opacity: 0.35;
}

/* ── Hover ── */

.card--playable:not(:disabled):not(.card--selected):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):not(.card--no-match):hover {
  transform: translateY(var(--card-hover-lift)) scale(var(--card-hover-scale))
    rotate(var(--card-tilt, 0deg));
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.42),
    0 4px 12px rgba(0, 0, 0, 0.28);
}

/* ── Hover partner glow ── */

.card--hover-partner:not(.card--selected) {
  box-shadow:
    0 0 22px rgba(120, 200, 255, 0.55),
    0 0 40px rgba(80, 160, 255, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.3);
  filter: brightness(1.06);
}

/* ── Hint highlight — golden breathe ── */

.card--hint-highlight:not(.card--selected) {
  z-index: 340;
  border-color: #ffd700 !important;
  animation: card-hint-breathe 1.2s ease-in-out infinite;
  box-shadow:
    0 0 28px rgba(255, 215, 0, 0.7),
    0 0 52px rgba(255, 190, 60, 0.35),
    0 8px 22px rgba(0, 0, 0, 0.28);
}

@keyframes card-hint-breathe {
  0%,
  100% {
    transform: translateY(-4px) scale(1.04);
    box-shadow:
      0 0 22px rgba(255, 215, 0, 0.55),
      0 0 40px rgba(255, 190, 60, 0.25),
      0 8px 20px rgba(0, 0, 0, 0.28);
  }
  50% {
    transform: translateY(-8px) scale(1.07);
    box-shadow:
      0 0 36px rgba(255, 215, 0, 0.85),
      0 0 64px rgba(255, 190, 60, 0.4),
      0 10px 26px rgba(0, 0, 0, 0.32);
  }
}

/* ── Selected — golden breathe ── */

.card--selected {
  z-index: 350;
  border-color: #ffd700 !important;
  animation: card-selected-breathe 1.4s ease-in-out infinite;
  box-shadow:
    0 0 32px rgba(255, 215, 0, 0.75),
    0 0 56px rgba(255, 180, 40, 0.35),
    0 16px 34px rgba(0, 0, 0, 0.42);
  transform: translateY(-14px) scale(var(--card-selected-scale))
    rotate(var(--card-tilt, 0deg));
}

@keyframes card-selected-breathe {
  0%,
  100% {
    transform: translateY(-14px) scale(1.08) rotate(calc(var(--card-tilt, 0deg) - 0.5deg));
    box-shadow:
      0 0 28px rgba(255, 215, 0, 0.7),
      0 0 48px rgba(255, 180, 40, 0.3),
      0 14px 30px rgba(0, 0, 0, 0.38);
  }

  50% {
    transform: translateY(-18px) scale(1.1) rotate(calc(var(--card-tilt, 0deg) + 0.5deg));
    box-shadow:
      0 0 40px rgba(255, 215, 0, 0.95),
      0 0 64px rgba(255, 180, 40, 0.45),
      0 18px 38px rgba(0, 0, 0, 0.45);
  }
}

/* ── Wrong match ── */

.card--no-match {
  animation: card-wrong-match 100ms ease-in-out;
  box-shadow:
    0 0 24px rgba(255, 60, 60, 0.85),
    0 0 40px rgba(255, 30, 30, 0.4) !important;
  border-color: rgba(255, 80, 80, 0.9) !important;
}

@keyframes card-wrong-match {
  0%,
  100% {
    transform: translateX(0) rotate(var(--card-tilt, 0deg));
  }

  20% {
    transform: translateX(-5px) rotate(calc(var(--card-tilt, 0deg) - 2deg));
  }

  40% {
    transform: translateX(5px) rotate(calc(var(--card-tilt, 0deg) + 2deg));
  }

  60% {
    transform: translateX(-4px) rotate(calc(var(--card-tilt, 0deg) - 1deg));
  }

  80% {
    transform: translateX(4px) rotate(calc(var(--card-tilt, 0deg) + 1deg));
  }
}

/* ── Waste middle — fully blocked ── */

.card--waste-middle:not(.card--selected) {
  opacity: 0.5;
  filter: brightness(0.78) saturate(0.85);
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.waste-pile .card--waste-middle:not(.card--selected):hover {
  transform: scale(var(--waste-scale, 1)) rotate(var(--card-tilt, 0deg));
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
}

/* ── Match success — squash → glow → fly ── */

.card--flying-to-graveyard {
  pointer-events: none;
  z-index: 400;
  animation: match-success-fly 450ms var(--ease-game) forwards;
  will-change: transform, opacity, filter, box-shadow;
}

@keyframes match-success-fly {
  0% {
    transform: translateY(-12px) scale(1.12) rotate(var(--card-tilt, 0deg));
    filter: brightness(1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  }

  12% {
    transform: translateY(-8px) scale(0.92) rotate(var(--card-tilt, 0deg));
    filter: brightness(1.35);
    box-shadow:
      0 0 36px rgba(255, 220, 100, 0.9),
      0 12px 28px rgba(0, 0, 0, 0.35);
  }

  28% {
    transform: translateY(-16px) scale(1.06)
      rotate(calc(var(--card-tilt, 0deg) + var(--fly-rotate, 12deg)));
    filter: brightness(1.2);
    opacity: 1;
  }

  100% {
    transform: translate(var(--fly-x, 120px), var(--fly-y, -100px)) scale(0.35)
      rotate(calc(var(--card-tilt, 0deg) + var(--fly-rotate, 24deg)));
    opacity: 0;
    filter: brightness(1.1) blur(1px);
  }
}

/* ── Swap arc flight ── */

.card--swap-flying-waste,
.card--swap-flying-pyramid {
  pointer-events: none;
  z-index: 420;
  animation: swap-arc-fly 480ms cubic-bezier(0.45, 0.05, 0.25, 1) forwards;
  will-change: transform, box-shadow;
}

@keyframes swap-arc-fly {
  0% {
    transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  }

  35% {
    transform: translate(
        calc(var(--fly-x, 0px) * 0.45),
        calc(var(--fly-y, 0px) * 0.2 + var(--arc-y, -64px))
      )
      scale(1.12) rotate(calc(var(--card-tilt, 0deg) + 10deg));
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }

  100% {
    transform: translate(var(--fly-x, 0px), var(--fly-y, 0px)) scale(1)
      rotate(var(--card-tilt, 0deg));
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  }
}

/* ── Screen shake (stronger on combo) ── */

.game-page--shake {
  animation: screen-shake-strong 100ms ease-out;
}

@keyframes screen-shake-strong {
  0%,
  100% {
    transform: translate(0, 0);
  }

  20% {
    transform: translate(-3px, 2px);
  }

  40% {
    transform: translate(3px, -2px);
  }

  60% {
    transform: translate(-2px, -1px);
  }

  80% {
    transform: translate(2px, 1px);
  }
}

/* ── Combo overlay ── */

.combo-overlay__text {
  animation: combo-pop-strong 700ms var(--ease-snap) forwards;
}

@keyframes combo-pop-strong {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(20px);
  }

  15% {
    opacity: 1;
    transform: scale(1.35) translateY(-8px);
  }

  35% {
    transform: scale(1.15) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(1) translateY(-24px);
  }
}

/* ── Graveyard panel polish ── */

.graveyard-panel--shake {
  animation: graveyard-panel-flash 280ms var(--ease-game);
}

@keyframes graveyard-panel-flash {
  0% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.03) inset,
      0 8px 28px rgba(0, 0, 0, 0.34);
  }

  30% {
    box-shadow:
      0 0 0 1px rgba(255, 220, 120, 0.2) inset,
      0 0 32px rgba(255, 200, 80, 0.35),
      0 12px 36px rgba(0, 0, 0, 0.42);
    filter: brightness(1.12);
  }

  100% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.03) inset,
      0 8px 28px rgba(0, 0, 0, 0.34);
    filter: brightness(1);
  }
}

.graveyard-panel__total--highlight {
  animation: graveyard-count-pop 280ms var(--ease-snap);
}

@keyframes graveyard-count-pop {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.18);
    color: #ffd700;
  }

  100% {
    transform: scale(1);
  }
}

.graveyard-panel__rank-row--highlight .graveyard-panel__rank-count {
  animation: graveyard-count-pop 280ms var(--ease-snap);
}

/* ── Buttons — press & hover ── */

.floating-hud__btn,
.game-overlay__restart,
.game-overlay__menu,
.splash-menu__btn,
.stock-pile__draw {
  transition:
    transform 120ms var(--ease-game),
    box-shadow 120ms var(--ease-game),
    filter 120ms ease;
}

.floating-hud__btn:not(:disabled):hover,
.game-overlay__restart:hover,
.game-overlay__menu:hover,
.stock-pile__draw:not(:disabled):hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  filter: brightness(1.06);
}

.floating-hud__btn:not(:disabled):active,
.game-overlay__restart:active,
.game-overlay__menu:active,
.stock-pile__draw:not(:disabled):active {
  transform: translateY(1px) scale(0.97);
  transition-duration: 60ms;
}

.splash-menu__btn:hover,
.splash-menu__btn:focus-visible {
  filter: brightness(1.12) drop-shadow(0 8px 20px rgba(255, 200, 80, 0.35));
}

.splash-menu__btn:active {
  filter: brightness(0.94);
  transform: scale(0.98);
}

/* ── Win celebration ── */

.game-page--win-celebration .card--win-fly {
  animation: win-card-fly-strong 1.2s var(--ease-game) forwards;
}

@keyframes win-card-fly-strong {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(var(--card-tilt, 0deg)) scale(1);
  }

  40% {
    opacity: 1;
    transform: translateY(-40px) rotate(calc(var(--card-tilt, 0deg) + 15deg)) scale(1.05);
  }

  100% {
    opacity: 0.15;
    transform: translateY(-120px) rotate(calc(var(--card-tilt, 0deg) + 40deg)) scale(0.85);
  }
}

.win-overlay__sweep {
  animation: win-gold-sweep 2s ease-in-out infinite;
}

@keyframes win-gold-sweep {
  0%,
  100% {
    opacity: 0.4;
    transform: rotate(0deg) scale(1);
  }

  50% {
    opacity: 0.7;
    transform: rotate(8deg) scale(1.05);
  }
}

.win-overlay__panel::before {
  content: '';
  position: absolute;
  inset: -20%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 0, 0.15) 0%,
    transparent 65%
  );
  pointer-events: none;
  animation: win-particle-pulse 1.8s ease-in-out infinite;
}

@keyframes win-particle-pulse {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.95);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.win-overlay__title {
  animation: win-title-pop 600ms var(--ease-snap) forwards;
}

.win-overlay__particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.win-overlay__particle {
  position: absolute;
  left: calc(10% + (var(--i, 0) * 7%));
  bottom: -10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd700 0%, rgba(255, 200, 60, 0.2) 100%);
  animation: win-particle-rise 2.2s ease-out infinite;
  animation-delay: calc(var(--i, 0) * 0.15s);
  opacity: 0;
}

@keyframes win-particle-rise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }

  15% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translateY(-280px) scale(1.2);
  }
}

@keyframes win-title-pop {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(12px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Lose — warm table, board stays visible ── */

.game-page--lose-fade {
  filter: brightness(0.92) saturate(0.94);
  transition: filter 0.6s var(--ease-game);
}

.game-page--lose-fade .game-page__vignette {
  opacity: 0.55;
  background: radial-gradient(
    ellipse at center,
    transparent 35%,
    rgba(40, 25, 15, 0.28) 100%
  );
}

.game-overlay--lost {
  animation: lose-overlay-in 600ms var(--ease-game) forwards;
}

.lose-overlay__panel {
  animation: lose-panel-fade 500ms var(--ease-game) forwards;
}

@keyframes lose-panel-fade {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(16px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Swap mode banner ── */

.game-swap-banner {
  animation: swap-banner-pulse 1.2s ease-in-out infinite;
}

@keyframes swap-banner-pulse {
  0%,
  100% {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  }

  50% {
    box-shadow:
      0 6px 24px rgba(232, 197, 71, 0.35),
      0 0 20px rgba(232, 197, 71, 0.2);
  }
}

/* ── Pyramid swap target ── */

.pyramid-card-position.swap-target .card {
  animation: swap-target-glow 0.8s ease-in-out infinite alternate;
}

@keyframes swap-target-glow {
  from {
    box-shadow: 0 0 16px rgba(232, 197, 71, 0.4);
  }

  to {
    box-shadow: 0 0 28px rgba(232, 197, 71, 0.75);
  }
}

/* ── Layout: allow scroll on small screens, keep HUD fixed ── */

#root {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border: none;
  text-align: initial;
}

.game-page {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100svh;
}

.is-itch-embed .game-page {
  overflow-y: hidden;
  min-height: 0;
}

/* ── Header / HUD — sticky glass panel ── */

.game-hud-rail {
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.42));
}

.floating-hud {
  background:
    linear-gradient(
      160deg,
      rgba(255, 240, 210, 0.14) 0%,
      rgba(255, 240, 210, 0.03) 48%
    ),
    rgba(32, 22, 14, 0.82) !important;
  backdrop-filter: blur(18px) saturate(1.15) !important;
  border: 1px solid rgba(255, 230, 180, 0.2) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 16px 40px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(255, 200, 100, 0.06) !important;
}

.graveyard-panel {
  backdrop-filter: blur(16px) saturate(1.12) !important;
  border: 1px solid rgba(255, 230, 180, 0.16) !important;
}

/* ── Memory countdown — cinematic ── */

.memory-countdown {
  background: radial-gradient(
    ellipse at center,
    rgba(255, 220, 140, 0.12) 0%,
    rgba(20, 12, 8, 0.72) 70%
  ) !important;
  backdrop-filter: blur(4px);
}

.memory-countdown__glow {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 0, 0.22) 0%,
    transparent 70%
  );
  animation: memory-glow-pulse 1s ease-in-out infinite;
}

.memory-countdown__number {
  position: relative;
  z-index: 1;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  color: #ffe8a8 !important;
  text-shadow:
    0 0 40px rgba(255, 215, 0, 0.65),
    0 4px 20px rgba(0, 0, 0, 0.5) !important;
  animation: memory-number-pop 0.55s var(--ease-snap) both;
}

@keyframes memory-glow-pulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.95);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes memory-number-pop {
  0% {
    opacity: 0;
    transform: scale(1.6);
  }

  60% {
    opacity: 1;
    transform: scale(0.92);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Win card rain ── */

.game-page--win-celebration::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 250;
  background-image:
    radial-gradient(2px 2px at 10% 20%, rgba(255, 215, 0, 0.7), transparent),
    radial-gradient(2px 2px at 30% 60%, rgba(255, 200, 80, 0.5), transparent),
    radial-gradient(3px 3px at 70% 30%, rgba(255, 230, 140, 0.6), transparent),
    radial-gradient(2px 2px at 85% 75%, rgba(255, 180, 60, 0.55), transparent);
  animation: win-sparkle 2.4s ease-in-out infinite;
}

@keyframes win-sparkle {
  0%,
  100% {
    opacity: 0.35;
  }

  50% {
    opacity: 0.75;
  }
}

/* ── Hover partner — warmer matchable glow ── */

.card--hover-partner:not(.card--selected) {
  transform: translateY(-6px) scale(1.03) rotate(var(--card-tilt, 0deg));
  box-shadow:
    0 0 26px rgba(255, 220, 120, 0.55),
    0 0 48px rgba(255, 190, 80, 0.28),
    0 10px 24px rgba(0, 0, 0, 0.32) !important;
  filter: brightness(1.08);
  transition: transform 170ms var(--ease-game), box-shadow 170ms var(--ease-game);
}

.card--playable:not(:disabled):not(.card--selected):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):not(.card--no-match):hover {
  transition-duration: 170ms;
}

@media (prefers-reduced-motion: reduce) {
  .card--selected,
  .card--flying-to-graveyard,
  .card--swap-flying-waste,
  .card--swap-flying-pyramid,
  .card--no-match,
  .combo-overlay__text,
  .game-page--shake,
  .win-overlay__title {
    animation: none !important;
  }
}
/* ── Waste pile — auto scale & overlap (no horizontal scroll) ── */

.game-piles-area .waste-pile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
}

.waste-pile__cards {
  --waste-card-scale: 1;
  --waste-card-gap: 0.5rem;
  --waste-card-overlap: 0px;
  --waste-scale: var(--waste-card-scale);

  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  width: 100%;
  min-height: calc(140px * var(--waste-card-scale));
  overflow: visible;
}

.waste-pile__card-wrap {
  position: relative;
  flex: 0 0 auto;
  width: calc(98px * var(--waste-card-scale));
  z-index: calc(var(--waste-item-index, 0) + 1);
}

.waste-pile__cards:not(.waste-pile__cards--compact) .waste-pile__card-wrap + .waste-pile__card-wrap {
  margin-left: var(--waste-card-gap);
}

.waste-pile__cards--compact .waste-pile__card-wrap + .waste-pile__card-wrap {
  margin-left: calc(-1 * var(--waste-card-overlap));
}

.waste-pile__card-wrap:hover,
.waste-pile__card-wrap:focus-within,
.waste-pile__card-wrap:has(.card--selected),
.waste-pile__card-wrap:has(.card--hover-partner) {
  z-index: 220;
}

.waste-pile__card-wrap .card {
  position: relative;
  width: 98px;
  height: 140px;
  transform: scale(var(--waste-scale)) rotate(var(--card-tilt, 0deg));
  transform-origin: bottom center;
}

/* Hover — lift without shifting siblings */
.waste-pile .card--playable:not(:disabled):not(.card--selected):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):not(.card--no-match):hover {
  transform: translateY(-8px) scale(calc(var(--waste-scale) * 1.04))
    rotate(var(--card-tilt, 0deg));
  z-index: 1;
}

.waste-pile .card--playable:not(:disabled):not(.card--flying-to-graveyard):not(.card--flying-to-hand):not(.card--swap-flying-waste):not(.card--swap-flying-pyramid):not(.card--flipping):active {
  transform: translateY(-10px) scale(calc(var(--waste-scale) * 0.97))
    rotate(var(--card-tilt, 0deg));
}

.waste-pile .card--playable.card--selected:not(:disabled):active {
  transform: translateY(-16px) scale(calc(var(--waste-scale) * 1.07))
    rotate(var(--card-tilt, 0deg));
}

.waste-pile .card--blocked:not(:disabled):hover,
.waste-pile .card--waste-middle:not(.card--selected):hover {
  transform: scale(var(--waste-scale)) rotate(var(--card-tilt, 0deg));
}

.waste-pile .card--hover-partner:not(.card--selected) {
  transform: translateY(-6px) scale(calc(var(--waste-scale) * 1.03))
    rotate(var(--card-tilt, 0deg));
  z-index: 1;
}

.waste-pile .card--selected {
  z-index: 2;
  animation: waste-card-selected-breathe 1.4s ease-in-out infinite;
  transform: translateY(-14px)
    scale(calc(var(--waste-scale) * var(--card-selected-scale, 1.08)))
    rotate(var(--card-tilt, 0deg));
}

@keyframes waste-card-selected-breathe {
  0%,
  100% {
    transform: translateY(-14px) scale(calc(var(--waste-scale) * 1.08))
      rotate(calc(var(--card-tilt, 0deg) - 0.5deg));
  }

  50% {
    transform: translateY(-18px) scale(calc(var(--waste-scale) * 1.1))
      rotate(calc(var(--card-tilt, 0deg) + 0.5deg));
  }
}

.waste-pile .card--no-match {
  animation: waste-card-wrong-match 100ms ease-in-out;
}

@keyframes waste-card-wrong-match {
  0%,
  100% {
    transform: translateX(0) scale(var(--waste-scale)) rotate(var(--card-tilt, 0deg));
  }

  20% {
    transform: translateX(-5px) scale(var(--waste-scale))
      rotate(calc(var(--card-tilt, 0deg) - 2deg));
  }

  40% {
    transform: translateX(5px) scale(var(--waste-scale))
      rotate(calc(var(--card-tilt, 0deg) + 2deg));
  }

  60% {
    transform: translateX(-4px) scale(var(--waste-scale))
      rotate(calc(var(--card-tilt, 0deg) - 1deg));
  }

  80% {
    transform: translateX(4px) scale(var(--waste-scale))
      rotate(calc(var(--card-tilt, 0deg) + 1deg));
  }
}

/* ── Table reshuffle animation (waste + pyramid) ── */

.waste-pile__cards--table-reshuffle-exit .waste-pile__card-wrap,
.game-page--table-reshuffle-exit
  .pyramid-card-position--table-reshuffle-exit:not(.flying-to-graveyard) {
  animation: table-reshuffle-exit 400ms ease-in forwards;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap,
.game-page--table-reshuffle-enter
  .pyramid-card-position--table-reshuffle-enter:not(.flying-to-graveyard) {
  animation: table-reshuffle-enter 550ms ease-out forwards;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap:nth-child(1),
.game-page--table-reshuffle-enter
  .pyramid-card-position--table-reshuffle-enter:nth-child(1) {
  animation-delay: 0ms;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap:nth-child(2) {
  animation-delay: 35ms;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap:nth-child(3) {
  animation-delay: 70ms;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap:nth-child(4) {
  animation-delay: 105ms;
}

.waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap:nth-child(n + 5) {
  animation-delay: 140ms;
}

@keyframes table-reshuffle-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(var(--waste-scale, 1));
  }

  100% {
    opacity: 0.15;
    transform: translateY(-18px) scale(calc(var(--waste-scale, 1) * 0.86));
  }
}

@keyframes table-reshuffle-enter {
  0% {
    opacity: 0.15;
    transform: translateY(-20px) scale(0.86);
  }

  65% {
    opacity: 1;
    transform: translateY(-5px) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .waste-pile .card--selected,
  .waste-pile .card--no-match {
    animation: none !important;
  }

  .waste-pile__cards--table-reshuffle-exit .waste-pile__card-wrap,
  .waste-pile__cards--table-reshuffle-enter .waste-pile__card-wrap,
  .game-page--table-reshuffle-exit .pyramid-card-position--table-reshuffle-exit,
  .game-page--table-reshuffle-enter .pyramid-card-position--table-reshuffle-enter {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
/* ── Pyramid deal-in animation (new game) ── */

.game-main--dealing {
  cursor: pointer;
}

.pyramid-area--dealing {
  --deal-from-x: 130px;
  --deal-from-y: 220px;
}

.pyramid-area--dealing.pyramid-deal--skip .pyramid-card-position--dealing {
  animation: none !important;
  opacity: 1 !important;
  pointer-events: auto;
}

.pyramid-area--dealing.pyramid-deal--skip .pyramid-card-position--dealing .card {
  animation: none !important;
  opacity: 1 !important;
  transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg)) !important;
}

.pyramid-card-position--dealing {
  pointer-events: none;
  animation: pyramid-deal-slot-in var(--deal-duration, 260ms)
    cubic-bezier(0.22, 1, 0.36, 1) var(--deal-delay, 0ms) both;
}

.pyramid-card-position--dealing .card {
  animation: pyramid-deal-card-in var(--deal-duration, 260ms)
    cubic-bezier(0.22, 1, 0.36, 1) var(--deal-delay, 0ms) both;
}

@keyframes pyramid-deal-card-in {
  0% {
    opacity: 0;
    transform: translate(var(--deal-from-x), var(--deal-from-y)) scale(0.85)
      rotate(var(--card-tilt, 0deg));
  }

  78% {
    opacity: 1;
    transform: translate(0, -5px) scale(1.02) rotate(var(--card-tilt, 0deg));
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(var(--card-tilt, 0deg));
  }
}

@keyframes pyramid-deal-slot-in {
  0%,
  99% {
    pointer-events: none;
  }

  100% {
    pointer-events: auto;
  }
}

.deal-skip-hint {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 350;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(38, 26, 18, 0.72);
  border: 1px solid rgba(255, 220, 160, 0.18);
  color: rgba(232, 220, 192, 0.88);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  pointer-events: none;
  animation: deal-skip-hint-in 0.25s ease forwards;
}

@keyframes deal-skip-hint-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pyramid-card-position--dealing,
  .pyramid-card-position--dealing .card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .deal-skip-hint {
    display: none;
  }
}
/* ── Game Journal / Statistics Dialog ── */

.journal-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 610;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 5, 3, 0.58);
  backdrop-filter: blur(5px);
  animation: journal-overlay-in 0.35s var(--ease-splash, ease) forwards;
}

@keyframes journal-overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.journal-dialog {
  position: relative;
  width: min(100%, 520px);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: 1.65rem 1.75rem 1.4rem;
  border-radius: 14px 18px 16px 12px;
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 230, 0.08) 0%,
      transparent 18%
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(120, 88, 52, 0.08) 27px,
      rgba(120, 88, 52, 0.08) 28px
    ),
    linear-gradient(155deg, #4a3424 0%, #2e1f14 48%, #24180f 100%);
  border: 1px solid rgba(210, 170, 110, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 18px 42px rgba(0, 0, 0, 0.48),
    0 0 0 6px rgba(62, 42, 28, 0.35);
  color: #eadcc4;
  animation: journal-dialog-in 0.42s var(--ease-splash, ease) forwards;
}

@keyframes journal-dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) rotate(-0.4deg);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

.journal-dialog__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: #d8c8aa;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.12s ease,
    transform 0.12s ease;
}

.journal-dialog__close:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: scale(1.05);
}

.journal-dialog__header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed rgba(210, 170, 110, 0.22);
}

.journal-dialog__eyebrow {
  margin: 0 0 0.25rem;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(230, 200, 150, 0.72);
}

.journal-dialog__title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f4e4c4;
}

.journal-dialog__subtitle {
  margin: 0;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(234, 220, 196, 0.78);
  font-style: italic;
}

.journal-dialog__body {
  display: grid;
  gap: 1rem;
}

.journal-dialog__section {
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 10px;
  background: rgba(18, 12, 8, 0.22);
  border: 1px solid rgba(210, 170, 110, 0.12);
}

.journal-dialog__section-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 228, 180, 0.88);
}

.journal-dialog__section-body {
  display: grid;
  gap: 0.42rem;
}

.journal-dialog__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 0.96rem;
  line-height: 1.45;
}

.journal-dialog__label {
  color: rgba(230, 214, 188, 0.78);
}

.journal-dialog__value {
  color: #f7edd8;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* ── Splash journal entry ── */

.splash-journal-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  width: 100%;
  padding: 0.42rem 0.58rem;
  border: 1px solid rgba(212, 168, 88, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(48, 32, 22, 0.72), rgba(22, 14, 10, 0.82)),
    rgba(12, 8, 5, 0.5);
  backdrop-filter: blur(4px);
  color: rgba(240, 226, 200, 0.88);
  font-family: var(--font-body, 'Crimson Pro', serif);
  text-align: left;
  cursor: pointer;
  opacity: 0;
  animation: splash-btn-in 0.8s var(--ease-splash, ease) forwards;
  animation-delay: 1.45s;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.splash-journal-button:hover,
.splash-journal-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(212, 168, 88, 0.42);
  box-shadow: 0 0 12px rgba(212, 168, 88, 0.18);
  outline: none;
}

.splash-journal-button__title {
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: clamp(0.62rem, 1.1vw, 0.74rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(232, 210, 170, 0.9);
}

.splash-journal-button__line {
  font-size: clamp(0.54rem, 0.95vw, 0.66rem);
  line-height: 1.35;
  color: rgba(224, 206, 178, 0.78);
}

@media (max-width: 640px) {
  .splash-journal-button {
    padding: 0.38rem 0.52rem;
  }

  .journal-dialog {
    padding: 1.35rem 1.2rem 1.1rem;
  }

  .journal-dialog__row {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .journal-dialog-overlay,
  .journal-dialog,
  .splash-journal-button {
    animation: none;
    opacity: 1;
  }
}
/* ── Victory art screen — locale background + left info card ── */

.game-result-overlay--win-art {
  background: #060403;
  animation: game-result-backdrop-in 0.45s var(--ease-out-premium, ease-out) forwards;
}

.game-result-overlay--win-art .visual-background__image {
  object-fit: cover;
  object-position: center center;
}

.game-result-overlay__win-layout {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.game-result-overlay__win-card {
  position: absolute;
  left: 33%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: min(420px, 34vw);
  max-width: calc(100% - 1.5rem);
  pointer-events: auto;
  padding: 0.95rem 1rem 0.85rem;
  border-radius: 12px;
  background: rgba(38, 24, 14, 0.78);
  border: 1px solid rgba(210, 170, 100, 0.42);
  box-shadow:
    0 0 0 1px rgba(255, 220, 160, 0.06) inset,
    0 10px 28px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  animation: game-result-win-card-in 0.55s var(--ease-out-premium, ease-out) 0.15s both;
}

@keyframes game-result-win-card-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.game-result__stats--win {
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(210, 170, 100, 0.14);
  gap: 0.38rem 0.65rem;
}

.game-result__stats--win .game-result__stat-label {
  color: rgba(245, 230, 200, 0.78);
  font-size: 0.68rem;
}

.game-result__stats--win .game-result__stat-value {
  color: #f8edd4;
  font-size: 0.88rem;
}

.game-result-overlay__win-actions {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.game-result-overlay__wood-btn {
  width: 100%;
  padding: 0.44rem 0.75rem;
  border-radius: 7px;
  border: 1px solid rgba(190, 145, 85, 0.4);
  background: rgba(62, 40, 22, 0.68);
  color: #f3e4c6;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow:
    0 1px 0 rgba(255, 230, 190, 0.08) inset,
    0 3px 10px rgba(0, 0, 0, 0.22);
  transition:
    transform 120ms var(--ease-game, ease),
    filter 120ms ease,
    background 120ms ease;
}

.game-result-overlay__wood-btn--primary {
  border-color: rgba(210, 175, 95, 0.55);
  background: rgba(78, 52, 28, 0.82);
  color: #fff8eb;
}

.game-result-overlay__wood-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.game-result-overlay__wood-btn:active {
  transform: translateY(1px);
}

.game-result-overlay__feedback {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
  color: rgba(245, 230, 200, 0.82);
}

.game-result-overlay--lose .game-result-overlay__feedback {
  margin: 0.75rem 0 0;
  color: rgba(240, 226, 200, 0.82);
}

.game-result-overlay__feedback-link {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: #f0d898;
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  cursor: pointer;
}

.game-result-overlay__feedback-link:hover,
.game-result-overlay__feedback-link:focus-visible {
  color: #ffe8b0;
}

.game-result-overlay__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .game-result-overlay__win-card {
    left: 30%;
    top: 59%;
    width: min(380px, 42vw);
  }
}

@media (max-width: 768px), (max-aspect-ratio: 1/1) {
  .game-result-overlay--win-art .visual-background__image {
    object-position: 62% center;
  }

  .game-result-overlay__win-card {
    left: 28%;
    top: 60%;
    transform: translate(-50%, -50%);
    width: min(300px, 46vw);
    max-height: min(58dvh, 380px);
    overflow-y: auto;
    overscroll-behavior: contain;
    animation-name: game-result-win-card-in;
  }

  .game-result__stats--win {
    grid-template-columns: 1fr 1fr;
  }

  .game-result-overlay__wood-btn {
    min-height: 44px;
    font-size: 0.84rem;
  }
}

@media (max-width: 480px) {
  .game-result-overlay__win-card {
    left: 26%;
    top: 61%;
    width: min(280px, 52vw);
    padding: 0.75rem 0.8rem 0.7rem;
  }

  .game-result__stats--win {
    grid-template-columns: 1fr;
    gap: 0.32rem;
    padding: 0.55rem 0.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-result-overlay--win-art,
  .game-result-overlay__win-card {
    animation: none !important;
  }
}

/* ── Game result overlay — warm wooden finish ── */

.game-result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 420;
  pointer-events: auto;
}

.game-result-overlay--win {
  background: rgba(8, 6, 4, 0.38);
  animation: game-result-backdrop-in 0.5s var(--ease-out-premium, ease-out) forwards;
}

.game-result-overlay--lose {
  background: rgba(40, 25, 15, 0);
  animation: game-result-lose-backdrop 300ms var(--ease-out-premium, ease-out) forwards;
}

@keyframes game-result-lose-backdrop {
  from {
    background: rgba(40, 25, 15, 0);
  }

  to {
    background: rgba(40, 25, 15, 0.42);
  }
}

.game-result-overlay__lose-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 44%,
    rgba(255, 200, 120, 0.12) 0%,
    transparent 58%
  );
  animation: game-result-lose-backdrop 300ms var(--ease-out-premium, ease-out) forwards;
}

@keyframes game-result-backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.game-result-overlay__warmth {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 42%,
    rgba(255, 210, 120, 0.22) 0%,
    transparent 62%
  );
  pointer-events: none;
  animation: game-result-warmth 2.8s ease-in-out forwards;
}

@keyframes game-result-warmth {
  0% {
    opacity: 0;
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0.75;
  }
}

.game-result-overlay__sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 220, 120, 0.1) 50%,
    transparent 62%
  );
  pointer-events: none;
  animation: game-result-sweep 2.4s ease-in-out 0.2s forwards;
}

@keyframes game-result-sweep {
  0% {
    transform: translateX(-120%);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  100% {
    transform: translateX(120%);
    opacity: 0.4;
  }
}

.game-result-overlay__particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.game-result-overlay__particle {
  position: absolute;
  left: calc(12% + (var(--i, 0) * 14%));
  bottom: 8%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd700 0%, rgba(255, 200, 60, 0.15) 100%);
  animation: game-result-particle-rise 2.2s ease-out calc(0.3s + var(--i, 0) * 0.12s)
    forwards;
  opacity: 0;
}

@keyframes game-result-particle-rise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }

  18% {
    opacity: 0.75;
  }

  100% {
    opacity: 0;
    transform: translateY(-220px) scale(1.1);
  }
}

.game-result-overlay__veil {
  display: none;
}

.game-result-overlay__panel {
  position: relative;
  z-index: 2;
  width: min(100%, 380px);
  padding: 0;
  border-radius: 14px;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.game-result-overlay--win .game-result-overlay__panel {
  padding: 1.5rem 1.65rem 1.35rem;
  animation: game-result-panel-in 0.65s var(--ease-out-premium, ease-out) 0.55s both;
}

.game-result-overlay__panel-body--lose {
  padding: 1.35rem 1.5rem 1.1rem;
  border-radius: 14px;
  background: rgba(48, 32, 20, 0.82);
  border: 1px solid rgba(210, 170, 120, 0.28);
  color: #e8d4b0;
  box-shadow:
    0 0 0 1px rgba(255, 220, 160, 0.06) inset,
    0 10px 32px rgba(20, 12, 6, 0.28);
  backdrop-filter: blur(8px);
  animation: game-result-lose-stats-in 300ms var(--ease-out-premium, ease-out) 150ms both;
}

.game-result-overlay__actions--lose {
  padding: 0.85rem 0.35rem 0.15rem;
  animation: game-result-lose-actions-in 250ms var(--ease-out-premium, ease-out) 350ms both;
}

@keyframes game-result-lose-stats-in {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes game-result-lose-actions-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-result-overlay--win .game-result-overlay__panel {
  background: rgba(28, 20, 12, 0.9);
  border: 1px solid rgba(255, 215, 0, 0.32);
  color: #f5e6c8;
  box-shadow:
    0 0 40px rgba(255, 215, 0, 0.18),
    0 12px 36px rgba(0, 0, 0, 0.42);
}

.game-result-overlay--lose .game-result-overlay__panel {
  background: transparent;
  border: none;
  color: #e8d4b0;
  box-shadow: none;
}

@keyframes game-result-panel-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(14px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game-result-overlay__title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display, 'Libre Baskerville', serif);
  font-size: 1.65rem;
  letter-spacing: 0.06em;
  line-height: 1.25;
}

.game-result-overlay--win .game-result-overlay__title {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.35);
}

.game-result-overlay--lose .game-result-overlay__title {
  color: #f0e0c4;
  text-shadow: 0 1px 0 rgba(255, 240, 210, 0.12);
}

.game-result-overlay--lose .game-result-overlay__subtitle {
  color: rgba(240, 226, 200, 0.88);
}

.game-result-overlay--lose .game-result__stats {
  background: rgba(30, 20, 12, 0.35);
  border: 1px solid rgba(210, 170, 120, 0.12);
  margin-bottom: 0;
}

.game-result-overlay__actions--lose .game-result-overlay__menu {
  margin-top: 0;
}

.game-result-overlay__subtitle {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.55;
  opacity: 0.88;
}

.game-result__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.75rem;
  margin-bottom: 1.1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  text-align: left;
}

.game-result__stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.game-result__stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  opacity: 0.72;
}

.game-result__stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.game-result-overlay__actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.game-result-overlay__restart--lose-primary {
  padding: 0.72rem 1.2rem;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #c9a066 0%, #8b6238 100%);
  color: #fff8ef;
  border: 1px solid rgba(255, 230, 180, 0.35);
  box-shadow:
    0 4px 16px rgba(80, 50, 20, 0.35),
    0 0 20px rgba(255, 200, 100, 0.15);
}

.game-result-overlay__restart--lose-primary:hover {
  filter: brightness(1.08);
  box-shadow:
    0 6px 20px rgba(80, 50, 20, 0.4),
    0 0 24px rgba(255, 200, 100, 0.22);
}

.game-result-overlay--lose .game-result-overlay__menu {
  opacity: 0.82;
  font-size: 0.88rem;
  border-color: rgba(210, 170, 120, 0.2);
}

.game-result-overlay__restart,
.game-result-overlay__menu {
  width: 100%;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition:
    transform 120ms var(--ease-game, ease),
    box-shadow 120ms var(--ease-game, ease),
    filter 120ms ease;
}

.game-result-overlay__restart {
  padding: 0.58rem 1.1rem;
  border: none;
  font-weight: 600;
}

.game-result-overlay--win .game-result-overlay__restart {
  background: linear-gradient(180deg, #4a7a3a 0%, #2d5a2d 100%);
  color: #f0f5e8;
}

.game-result-overlay--lose .game-result-overlay__restart:not(.game-result-overlay__restart--lose-primary) {
  background: linear-gradient(180deg, #5a4a38 0%, #3d2b1f 100%);
  color: #f5e6c8;
}

.game-result-overlay__menu {
  margin-top: 0.55rem;
  padding: 0.48rem 0.9rem;
  background: transparent;
  color: inherit;
}

.game-result-overlay--win .game-result-overlay__menu {
  border: 1px solid rgba(255, 215, 0, 0.22);
}

.game-result-overlay--lose .game-result-overlay__menu {
  border: 1px solid rgba(245, 230, 200, 0.18);
}

.game-result-overlay__restart:hover,
.game-result-overlay__menu:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.06);
}

.game-result-overlay__restart:active,
.game-result-overlay__menu:active {
  transform: translateY(1px) scale(0.98);
}

/* ── Board ambience during result ── */

.game-page--win-celebration .game-page__table-glow {
  opacity: 1;
  background: radial-gradient(
    ellipse at 50% 38%,
    rgba(255, 200, 100, 0.28) 0%,
    transparent 68%
  );
  transition: opacity 0.8s ease;
}

.graveyard-panel--result-glow {
  box-shadow:
    0 0 24px rgba(255, 210, 120, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 215, 0, 0.28);
  transition: box-shadow 0.8s ease, border-color 0.8s ease;
}

.game-piles-area--win-settle {
  opacity: 0.55;
  transform: scale(0.98);
  filter: saturate(0.85);
  transition:
    opacity 1.2s ease,
    transform 1.2s ease,
    filter 1.2s ease;
  pointer-events: none;
}

.stock-pile--lose-shake .stock-pile__draw {
  animation: stock-pile-shake 0.55s var(--ease-game, ease) forwards;
}

@keyframes stock-pile-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  20% {
    transform: translateX(-4px) rotate(-2deg);
  }

  40% {
    transform: translateX(4px) rotate(2deg);
  }

  60% {
    transform: translateX(-3px) rotate(-1deg);
  }

  80% {
    transform: translateX(2px) rotate(1deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-result-overlay--lose,
  .game-result-overlay__lose-glow,
  .game-result-overlay__panel-body--lose,
  .game-result-overlay__actions--lose {
    animation: none !important;
  }

  .game-result-overlay--lose {
    background: rgba(40, 25, 15, 0.42);
  }
}

@media (max-width: 480px) {
  .game-result-overlay--win .game-result-overlay__panel,
  .game-result-overlay__panel-body--lose {
    padding: 1.25rem 1.15rem 1.1rem;
  }

  .game-result-overlay__title {
    font-size: 1.45rem;
  }

  .game-result__stats {
    grid-template-columns: 1fr;
  }
}
/* ── Mobile Web Layout (max-width: 768px) ── */

@media (max-width: 768px) {
  html,
  body,
  #root {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  html,
  body {
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    overflow-x: hidden;
  }

  #root {
    min-height: 100dvh;
    min-height: 100svh;
  }

  .game-page--mobile {
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    height: 100svh;
    min-height: 100dvh;
    min-height: 100svh;
    overflow: hidden;
    overflow-x: hidden;
    -webkit-touch-callout: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
  }

  .game-page--mobile.game-page {
    overflow: hidden;
    overflow-y: hidden;
  }

  .game-page--mobile .game-hud-rail {
    display: none;
  }

  .game-page--mobile .game-main {
    flex: 1;
    min-height: 0;
    padding:
      0.35rem 0.5rem
      calc(var(--mobile-action-bar-height, 64px) + env(safe-area-inset-bottom, 0px) + 0.35rem);
    padding-right: 0.5rem;
    gap: 0.35rem;
    overflow: hidden;
  }

  .game-page--mobile .game-main--with-hud {
    padding-right: 0.5rem;
  }

  .game-page--mobile .game-pyramid-area {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    overflow-x: hidden;
    padding: 0.25rem 0;
    padding-right: 0 !important;
    padding-left: 0 !important;
    justify-content: center;
    align-items: flex-start;
  }

  .game-page--mobile .pyramid-view-root {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 0;
    overflow: hidden;
  }

  .game-page--mobile .pyramid-scale-frame {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    margin: 0 auto;
  }

  .game-page--mobile .pyramid-area {
    min-height: 0 !important;
    width: auto;
    margin: 0;
    /* Disable desktop height-based transforms; scaling handled by JS */
    transform: none;
  }

  .game-page--mobile .pyramid-area[data-pyramid-rows='8'],
  .game-page--mobile .pyramid-area[data-pyramid-rows='7'],
  .game-page--mobile .pyramid-area[data-pyramid-rows='6'] {
    transform: none;
  }

  .game-page--mobile .game-table-bottom {
    flex-shrink: 0;
    padding-top: 0;
    width: 100%;
    max-width: 100%;
  }

  .game-page--mobile .game-piles-area {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .game-page--mobile .game-piles-area__item-box,
  .game-page--mobile .stock-pile {
    display: none;
  }

  .game-page--mobile .waste-pile {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }

  /* ── Mobile Status Bar ── */

  .mobile-status-bar {
    position: sticky;
    top: 0;
    z-index: 350;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    margin: 0;
    background:
      linear-gradient(
        155deg,
        rgba(255, 235, 200, 0.1) 0%,
        rgba(255, 235, 200, 0.02) 42%
      ),
      rgba(38, 26, 18, 0.92);
    backdrop-filter: blur(14px) saturate(1.05);
    border-bottom: 1px solid rgba(255, 220, 160, 0.14);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    color: #f0e2c8;
  }

  .mobile-status-bar__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    min-width: 0;
  }

  .mobile-status-bar__label {
    font-family: var(--font-display, 'Libre Baskerville', serif);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(200, 180, 150, 0.82);
    white-space: nowrap;
  }

  .mobile-status-bar__value {
    font-family: var(--font-body, 'Crimson Pro', serif);
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #f5e6c8;
    line-height: 1.15;
    position: relative;
  }

  .mobile-status-bar__stat--gp .mobile-status-bar__value {
    color: #ffd978;
  }

  .mobile-status-bar__gp-flash {
    position: absolute;
    left: 100%;
    margin-left: 0.15rem;
    font-size: 0.65rem;
    color: #a8f0c0;
    white-space: nowrap;
    animation: item-box-gp-flash 1.1s ease-out forwards;
  }

  .mobile-status-bar__graveyard-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    min-width: 0;
    min-height: 44px;
    padding: 0.15rem 0.2rem;
    border: 1px solid rgba(255, 220, 160, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-status-bar__graveyard-btn:active {
    background: rgba(255, 255, 255, 0.12);
  }

  /* ── Mobile Action Bar ── */

  .mobile-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 360;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0.25rem;
    padding:
      0.35rem 0.4rem
      calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background:
      linear-gradient(
        0deg,
        rgba(28, 18, 10, 0.96) 0%,
        rgba(38, 26, 18, 0.92) 100%
      );
    backdrop-filter: blur(14px) saturate(1.05);
    border-top: 1px solid rgba(255, 220, 160, 0.16);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.32);
  }

  .mobile-action-bar__btn {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    min-width: 0;
    min-height: 56px;
    padding: 0.35rem 0.15rem;
    border: 1px solid rgba(255, 220, 160, 0.16);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #e8dcc4;
    font-family: var(--font-body, 'Crimson Pro', serif);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-action-bar__btn:active:not(:disabled) {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-action-bar__btn:disabled {
    opacity: 1;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(255, 220, 160, 0.24);
    color: rgba(232, 220, 200, 0.88);
  }

  .mobile-action-bar__btn:disabled .mobile-action-bar__text {
    color: rgba(232, 220, 200, 0.88);
  }

  .mobile-action-bar__btn:disabled .mobile-action-bar__icon {
    color: rgba(216, 200, 175, 0.8);
    filter: saturate(0.82) brightness(0.95);
  }

  .mobile-action-bar__btn--primary:disabled {
    background: rgba(38, 26, 18, 0.78);
    border-color: rgba(255, 220, 160, 0.22);
    color: rgba(255, 255, 255, 0.65);
  }

  .mobile-action-bar__btn--primary:disabled .mobile-action-bar__text {
    color: rgba(255, 255, 255, 0.65);
  }

  .mobile-action-bar__btn--primary:disabled .mobile-action-bar__icon {
    opacity: 0.65;
    filter: saturate(0.7) brightness(0.95);
  }

  .mobile-action-bar__btn--primary {
    background: linear-gradient(180deg, #a67c2a 0%, #7a5520 52%, #5c3d18 100%);
    color: #ffffff;
    border-color: rgba(255, 210, 100, 0.58);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
    font-weight: 700;
  }

  .mobile-action-bar__btn--primary:active:not(:disabled) {
    background: linear-gradient(180deg, #8f6a22 0%, #6a4818 100%);
    color: #ffffff;
  }

  .mobile-action-bar__btn--accent {
    border-color: rgba(232, 197, 71, 0.45);
    color: #ffd700;
  }

  .mobile-action-bar__btn--wide {
    flex: 1 1 100%;
    font-size: 0.85rem;
  }

  .mobile-action-bar__icon {
    font-size: 1.05rem;
    line-height: 1;
  }

  .mobile-action-bar__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .game-page--mobile.game-page--busy .mobile-action-bar__btn:not(:disabled) {
    pointer-events: none;
    opacity: 0.55;
  }

  /* ── Bottom Sheet ── */

  .bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 480;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(8, 5, 3, 0.52);
    backdrop-filter: blur(4px);
    animation: bottom-sheet-overlay-in 0.25s ease forwards;
  }

  @keyframes bottom-sheet-overlay-in {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  .bottom-sheet {
    width: min(100%, 480px);
    max-height: min(85vh, 640px);
    display: flex;
    flex-direction: column;
    border-radius: 16px 16px 0 0;
    background: #f5e6c8;
    color: #3d2b1f;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    animation: bottom-sheet-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  @keyframes bottom-sheet-in {
    from {
      transform: translateY(100%);
    }

    to {
      transform: translateY(0);
    }
  }

  .bottom-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px solid rgba(61, 43, 31, 0.12);
    flex-shrink: 0;
  }

  .bottom-sheet__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
  }

  .bottom-sheet__close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: rgba(61, 43, 31, 0.08);
    color: #3d2b1f;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  .bottom-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 1rem 1rem;
  }

  /* Graveyard in sheet */
  .bottom-sheet .graveyard-panel {
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    color: #3d2b1f;
    animation: none;
  }

  .bottom-sheet .graveyard-panel__title {
    color: #3d2b1f !important;
    font-size: 0.95rem !important;
  }

  .bottom-sheet .graveyard-panel__total,
  .bottom-sheet .graveyard-panel__rank-row,
  .bottom-sheet .graveyard-panel__suit-row {
    font-size: 0.82rem !important;
    color: #3d2b1f;
  }

  .bottom-sheet .graveyard-panel__subtitle {
    color: #6b5344;
  }

  .bottom-sheet .graveyard-panel__rank-bar {
    opacity: 1;
    max-width: 4rem;
  }

  /* Item box in sheet */
  .bottom-sheet .item-box {
    max-width: 100%;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  .bottom-sheet .item-box__title {
    color: #3d2b1f;
    text-shadow: none;
  }

  .bottom-sheet .item-box__status {
    color: #6b5344;
  }

  .bottom-sheet .item-box__gp {
    color: #8a6020;
  }

  .bottom-sheet .item-box__buy-btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 210, 100, 0.58);
    background: linear-gradient(180deg, #a67c2a 0%, #7a5520 52%, #5c3d18 100%);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  }

  .bottom-sheet .item-box__buy-btn:active:not(:disabled) {
    background: linear-gradient(180deg, #8f6a22 0%, #6a4818 100%);
  }

  .bottom-sheet .item-box__buy-btn:disabled {
    opacity: 1;
    color: rgba(255, 255, 255, 0.68);
    background: rgba(38, 26, 18, 0.78);
    border-color: rgba(255, 220, 160, 0.22);
    cursor: not-allowed;
  }

  .bottom-sheet .item-box__detail-panel .item-tooltip {
    border-color: rgba(138, 96, 32, 0.35);
    background: rgba(255, 250, 240, 0.96);
    color: #3d2b1f;
    box-shadow: 0 4px 16px rgba(61, 43, 31, 0.12);
  }

  .bottom-sheet .item-box__detail-panel .item-tooltip__name,
  .bottom-sheet .item-box__detail-panel .item-tooltip__desc,
  .bottom-sheet .item-box__detail-panel .item-tooltip__limit {
    color: #3d2b1f;
  }

  .bottom-sheet .item-box__detail-panel .item-tooltip__flavor {
    color: #6b5344;
  }

  .bottom-sheet .item-box__detail-panel .item-tooltip__status--used {
    color: #8a6020;
  }

  .bottom-sheet .item-box__detail-panel .item-tooltip__status--blocked {
    color: #a04830;
  }

  .bottom-sheet .item-slot {
    width: 52px;
    height: 52px;
  }

  /* ── Modals on mobile ── */

  .game-settings-overlay,
  .item-purchase-overlay,
  .joker-dialog-overlay,
  .deep-table-reshuffle-overlay,
  .new-game-confirm-dialog-overlay,
  .item-reward-overlay {
    padding:
      calc(0.75rem + env(safe-area-inset-top, 0px))
      0.75rem
      calc(0.75rem + env(safe-area-inset-bottom, 0px));
    align-items: center;
  }

  .game-settings,
  .item-purchase-panel,
  .joker-dialog,
  .deep-table-reshuffle-dialog,
  .item-reward-panel,
  .game-result-overlay__panel {
    width: min(92vw, 440px) !important;
    max-height: 85vh !important;
  }

  .game-settings__apply,
  .game-settings__reset,
  .game-settings__cancel,
  .item-purchase-panel__buy,
  .joker-dialog__btn,
  .table-reshuffle-dialog__confirm,
  .table-reshuffle-dialog__cancel,
  .new-game-confirm-dialog__continue,
  .new-game-confirm-dialog__abandon,
  .game-result-overlay__btn {
    min-height: 44px;
  }

  .game-settings__apply:disabled,
  .game-settings__reset:disabled,
  .game-settings__cancel:disabled {
    opacity: 1;
    cursor: not-allowed;
  }

  .game-settings__apply:disabled {
    background: rgba(61, 43, 31, 0.48);
    color: rgba(245, 230, 200, 0.9);
  }

  .game-settings__reset:disabled,
  .game-settings__cancel:disabled {
    color: rgba(80, 60, 40, 0.85);
    border-color: rgba(90, 64, 48, 0.3);
    background: rgba(255, 255, 255, 0.35);
  }

  .item-purchase-panel__buy:disabled {
    opacity: 1;
    color: rgba(255, 255, 255, 0.68);
    background: rgba(38, 26, 18, 0.78);
    border-color: rgba(255, 220, 160, 0.22);
  }

  .item-purchase-panel__buy {
    min-width: 4.5rem;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .waste-pile__reshuffle-btn:disabled {
    opacity: 1;
    color: rgba(232, 218, 192, 0.88);
    border-color: rgba(212, 196, 168, 0.42);
    background: rgba(212, 196, 168, 0.1);
  }

  .tutorial-viewer__nav:disabled,
  .tutorial-viewer__nav-text:disabled {
    opacity: 1;
    cursor: not-allowed;
  }

  .tutorial-viewer__nav:disabled {
    color: rgba(232, 220, 200, 0.62);
    border-color: rgba(255, 220, 160, 0.18);
    background: rgba(255, 255, 255, 0.04);
  }

  .tutorial-viewer__nav-text:disabled {
    color: rgba(232, 220, 200, 0.62);
  }

  /* Item purchase as bottom sheet style on mobile */
  .item-purchase-overlay {
    align-items: flex-end;
  }

  .item-purchase-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(85vh, 560px) !important;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  /* Toasts & banners */
  .game-page--mobile .game-toast {
    top: calc(env(safe-area-inset-top, 0px) + 3.5rem);
    max-width: 92vw;
  }

  .game-page--mobile .game-swap-banner {
    top: calc(env(safe-area-inset-top, 0px) + 3.25rem);
    max-width: 92vw;
  }

  .game-page--mobile .deal-skip-hint {
    bottom: calc(var(--mobile-action-bar-height, 64px) + env(safe-area-inset-bottom, 0px) + 0.5rem);
  }

  /* Card touch targets */
  .game-page--mobile .card--playable,
  .game-page--mobile .pyramid-card-position.playable .card {
    min-width: 44px;
    min-height: 44px;
  }

  /* Tooltip tap mode */
  .item-slot-wrap--tooltip-open .item-tooltip,
  .anchor-tooltip--tap-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Start screen */
  .splash-page {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .splash-overlay__logo {
    width: min(100%, clamp(240px, 68vw, 360px));
  }

  .splash-menu__btn {
    min-height: 44px;
  }

  .start-screen__footer-meta {
    gap: 0.5rem;
  }

  .start-screen__footer-link {
    min-height: 44px;
  }

  /* Fallback: apply even before JS adds game-page--mobile */
  .game-main--with-hud {
    padding-right: 0 !important;
  }

  .game-pyramid-area {
    padding-right: 0 !important;
    padding-left: 0 !important;
    overflow-x: hidden !important;
    justify-content: center !important;
    max-width: 100%;
  }

  .game-hud-rail {
    display: none;
  }
}

@media (max-width: 380px) {
  .mobile-action-bar__text {
    font-size: 0.6rem;
  }

  .mobile-status-bar__value {
    font-size: 0.75rem;
  }
}
/* ── Desktop / tablet viewport fit scaling (itch.io iframe + fullscreen) ── */

@media (min-width: 769px) {
  html,
  body,
  #root,
  .app {
    height: 100%;
    overflow: hidden;
  }

  body {
    min-height: 0;
  }

  #root,
  .app {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .game-page--desktop-scale {
    --game-bottom-inset: calc(env(safe-area-inset-bottom, 0px) + 4px);
    --game-top-inset: calc(env(safe-area-inset-top, 0px) + 2px);
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    padding-top: var(--game-top-inset);
    padding-bottom: var(--game-bottom-inset);
    box-sizing: border-box;
    overflow: hidden;
  }

  .game-page--desktop-scale.game-page {
    min-height: 0;
  }

  .is-itch-embed .game-page--desktop-scale {
    height: 100%;
    max-height: 100%;
  }

  /* iPad / tablet landscape: 100dvh can exceed painted area when Safari UI is visible */
  @media (min-width: 769px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) and (orientation: landscape) {
    .game-page--desktop-scale {
      --game-bottom-inset: calc(env(safe-area-inset-bottom, 0px) + 8px);
      height: 100svh;
      max-height: 100svh;
    }

    .is-itch-embed .game-page--desktop-scale {
      height: 100%;
      max-height: 100%;
    }
  }

  .game-page--desktop-scale .game-viewport-scale {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    width: 100%;
  }

  .game-page--desktop-scale .game-main {
    flex: 0 0 auto;
    min-height: 0;
    gap: 1rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }

  .game-page--desktop-scale .game-pyramid-area {
    flex: 0 0 auto;
    padding-bottom: 0.5rem;
  }

  .game-page--desktop-scale .game-table-bottom {
    flex-shrink: 0;
    padding-bottom: 0.125rem;
  }

  /* Viewport scale handles fit; avoid nested pyramid transforms on desktop. */
  .game-page--desktop-scale .pyramid-area {
    transform: none !important;
  }
}

.game-viewport-scale {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.game-viewport-scale--active {
  overflow: hidden;
  align-items: center;
}

.game-viewport-scale__inner {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.game-viewport-scale--active .game-viewport-scale__inner {
  flex: 0 0 auto;
  min-height: min-content;
  transform: scale(var(--game-scale, 1));
  transform-origin: top center;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .game-viewport-scale--active .game-viewport-scale__inner {
    will-change: auto;
  }
}
/* ── Mobile / tablet battery-friendly rendering reductions ── */

@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .game-page__noise {
    display: none;
  }

  .game-page__table-glow {
    opacity: 0.45;
  }

  .mobile-status-bar,
  .mobile-action-bar {
    backdrop-filter: blur(6px) saturate(1.02);
    -webkit-backdrop-filter: blur(6px) saturate(1.02);
  }

  .floating-hud,
  .graveyard-panel {
    backdrop-filter: blur(8px) saturate(1.05);
    -webkit-backdrop-filter: blur(8px) saturate(1.05);
  }

  .game-viewport-scale--active .game-viewport-scale__inner {
    will-change: auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  .card--selected-breathe,
  .card-hint-breathe,
  .card-selected-breathe,
  .waste-card-selected-breathe {
    animation: none;
  }

  .game-swap-banner {
    animation: none;
  }

  .card {
    box-shadow:
      0 2px 6px rgba(0, 0, 0, 0.24),
      0 4px 10px rgba(0, 0, 0, 0.14);
  }

  .game-hud-rail {
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.28));
  }
}
/* ── Readability & Contrast pass (WCAG AA oriented) ──
   Loaded last — overrides low-contrast opacity/color only. */

:root {
  --ui-disabled-opacity: 0.62;
  --ui-text-secondary-dark: rgba(245, 232, 210, 0.92);
  --ui-text-muted-dark: rgba(224, 206, 178, 0.88);
  --ui-text-secondary-light: #5a4030;
  --ui-text-muted-light: #6b4a38;
}

/* ── 1. Disabled controls — keep labels readable ── */

.floating-hud__btn:disabled,
.item-box__buy-btn:disabled,
.item-purchase-panel__buy:disabled,
.tutorial-viewer__nav:disabled,
.tutorial-viewer__nav-text:disabled,
.joker-dialog__rank-btn--disabled,
.stock-pile__draw:disabled,
.waste-pile__reshuffle-btn:disabled,
.game-settings__apply:disabled,
.game-settings__reset:disabled,
.game-settings__cancel:disabled {
  opacity: var(--ui-disabled-opacity);
  cursor: not-allowed;
}

.floating-hud__btn:disabled {
  color: rgba(232, 214, 182, 0.82);
  border-color: rgba(255, 220, 160, 0.24);
}

.mobile-action-bar__btn:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.item-slot--disabled,
.item-slot:disabled {
  opacity: 0.68;
  filter: grayscale(0.2) brightness(0.9);
  cursor: not-allowed;
}

.item-purchase-panel__buy:disabled {
  opacity: 1;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.68);
  border-color: rgba(255, 220, 160, 0.22);
  background: rgba(38, 26, 18, 0.78);
}

.joker-dialog__rank-btn--disabled {
  opacity: 0.58;
  color: rgba(61, 43, 31, 0.72);
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(61, 43, 31, 0.18);
}

.tutorial-viewer__nav:disabled,
.tutorial-viewer__nav-text:disabled {
  opacity: 0.58;
  color: rgba(245, 230, 200, 0.58);
}

/* Busy — still legible */
.game-page--busy .floating-hud__btn:not(:disabled),
.game-page--busy .floating-hud__btn--icon,
.game-page--busy .mobile-action-bar__btn:not(:disabled),
.game-page--busy .stock-pile__draw,
.game-page--busy .waste-pile__reshuffle-btn {
  opacity: 0.72;
}

/* ── 2. HUD / status numbers (GP, steps, time, stock) ── */

.floating-hud__stat-label,
.mobile-status-bar__label {
  color: rgba(216, 198, 168, 0.96);
}

.floating-hud__stat-value,
.mobile-status-bar__value {
  color: #f8eed8;
}

.floating-hud__stat-value--muted {
  color: rgba(200, 184, 158, 0.95);
}

.mobile-status-bar__stat--gp .mobile-status-bar__value,
.item-box__gp,
.item-purchase-panel__balance strong {
  color: #ffdf80;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.stock-pile__count,
.waste-pile__label {
  color: #e8dcc8;
}

.waste-pile__empty {
  color: #c8b898;
  border-color: rgba(245, 230, 200, 0.38);
}

.waste-pile__reshuffle-btn {
  color: #f2e8d0;
  border-color: rgba(212, 196, 168, 0.58);
  background: rgba(212, 196, 168, 0.14);
}

.waste-pile__reshuffle-btn:disabled {
  color: rgba(232, 218, 192, 0.85);
}

/* ── 3. Graveyard / secondary panels ── */

.graveyard-panel__subtitle,
.graveyard-panel__rank-label,
.graveyard-panel__suit-label {
  color: #b8a890;
}

.graveyard-panel:not(:hover):not(.graveyard-panel--expanded)
  .graveyard-panel__section:last-child {
  opacity: 0.9;
}

.bottom-sheet .graveyard-panel__subtitle,
.bottom-sheet .item-box__status {
  color: var(--ui-text-secondary-light);
}

.bottom-sheet .graveyard-panel__total,
.bottom-sheet .graveyard-panel__rank-row,
.bottom-sheet .graveyard-panel__suit-row {
  color: #3d2b1f;
}

.bottom-sheet .item-box__gp {
  color: #7a5518;
  font-weight: 800;
}

.bottom-sheet__close {
  background: rgba(61, 43, 31, 0.12);
  color: #2e1f14;
}

/* ── 4. Item box & purchase ── */

.item-box__status {
  color: rgba(240, 228, 200, 0.94);
}

.item-box__title {
  color: #faf0d8;
}

.item-purchase-panel__hint {
  color: rgba(240, 228, 205, 0.88);
}

.item-purchase-panel__price {
  color: #ffd880;
}

.item-purchase-panel__close {
  color: #ece0cc;
  background: rgba(255, 255, 255, 0.12);
}

/* ── 5. Tooltips ── */

.item-tooltip__flavor {
  color: rgba(240, 228, 205, 0.94);
}

.item-tooltip__rarity--common {
  color: #e0d8c8;
}

.item-tooltip__limit {
  color: rgba(224, 204, 168, 0.94);
}

.anchor-tooltip__desc {
  color: rgba(245, 236, 220, 0.96);
}

.anchor-tooltip__note {
  color: #f5c878;
}

/* ── 6. Cards — dimmed / blocked still recognizable ── */

.card--item-dimmed,
.pyramid-card-position.item-dimmed {
  opacity: 0.58;
  filter: brightness(0.86) saturate(0.8);
}

.waste-pile .card--blocked,
.card--blocked {
  opacity: 0.65;
}

.card--hint-highlight {
  filter: brightness(1.08);
}

/* ── 7. Modals / dialogs ── */

.game-settings__hint,
.game-settings__preset-hint {
  color: rgba(61, 43, 31, 0.86);
}

.game-settings__radio small {
  color: rgba(61, 43, 31, 0.8);
}

.joker-dialog__subtitle {
  color: rgba(61, 43, 31, 0.88);
}

.game-result-overlay__subtitle {
  opacity: 1;
  color: rgba(248, 236, 218, 0.96);
}

.game-result__stat-label {
  opacity: 1;
  color: rgba(245, 232, 210, 0.88);
}

.game-result__stat-value {
  color: #fff4e0;
}

.game-result-overlay--lose .game-result-overlay__menu {
  opacity: 1;
  color: rgba(248, 236, 218, 0.92);
  border-color: rgba(210, 170, 120, 0.32);
}

.item-reward-modal__hint,
.item-reward-modal__subtitle {
  color: var(--ui-text-secondary-light);
}

/* ── 8. Tutorial / coach marks ── */

.tutorial-viewer__counter {
  color: rgba(248, 236, 218, 0.92);
}

.tutorial-viewer__dot {
  background: rgba(245, 230, 200, 0.42);
}

.coach-marks__step-label {
  color: rgba(255, 230, 160, 0.92);
}

.coach-marks__body {
  color: rgba(248, 238, 224, 0.96);
}

.coach-marks__btn {
  color: rgba(248, 238, 224, 0.95);
}

/* ── 9. Toast / banners ── */

.game-toast {
  color: #fff8ea;
  border-color: rgba(232, 197, 71, 0.52);
  background: rgba(32, 20, 12, 0.96);
}

.game-swap-banner {
  color: #fff4dc;
}

.item-use-banner__text {
  color: rgba(248, 236, 218, 0.96);
}

.joker-resonance-banner {
  color: #fff8dc;
}

/* ── 10. Splash / menu ── */

.splash-best {
  color: rgba(248, 236, 218, 0.94);
}

.splash-best__label {
  color: rgba(255, 220, 100, 0.92);
}

/* ── 11. Journal / statistics ── */

.journal-dialog__close {
  color: #ece0cc;
  background: rgba(255, 255, 255, 0.1);
}

.journal-dialog__label {
  color: rgba(234, 220, 196, 0.9);
}

.journal-dialog__value {
  color: #fff4e0;
}

.journal-dialog__subtitle {
  color: rgba(234, 220, 196, 0.88);
}

/* ── 12. Mobile action bar labels ── */

.mobile-action-bar__btn {
  color: #f0e4d0;
}

.mobile-action-bar__btn--accent {
  color: #ffe566;
}

@media (max-width: 768px) {
  .bottom-sheet__title {
    color: #2e1f14;
  }

  .game-settings,
  .item-purchase-panel,
  .joker-dialog {
    color: #3d2b1f;
  }
}
/* ── Visual theme: background layer + React overlay ── */

.visual-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #060403;
}

.visual-background__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.visual-background__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(8, 5, 3, 0.18) 0%,
    rgba(8, 5, 3, 0.08) 40%,
    rgba(8, 5, 3, 0.22) 100%
  );
}

.visual-background__scrim--medium {
  background: linear-gradient(
    180deg,
    rgba(8, 5, 3, 0.32) 0%,
    rgba(8, 5, 3, 0.2) 45%,
    rgba(8, 5, 3, 0.42) 100%
  );
}

/* ── Main menu overlay — left column, right side shows pyramid art ── */

.splash-page__scene {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.splash-page .visual-background__image {
  object-fit: cover;
  object-position: center center;
}

.splash-overlay {
  --splash-stack-gap: clamp(0.5rem, 1.2vh, 0.875rem);
  --splash-menu-footer-gap: clamp(0.75rem, 1.5vh, 1.5rem);
  position: absolute;
  left: clamp(1rem, 7vw, 8%);
  top: 0;
  bottom: 0;
  z-index: 2;
  width: clamp(360px, 24vw, 420px);
  max-width: calc(100vw - 2rem);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--splash-stack-gap);
  padding:
    calc(1.25rem + env(safe-area-inset-top, 0px))
    0
    calc(1rem + env(safe-area-inset-bottom, 0px))
    0;
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.9s var(--ease-splash, cubic-bezier(0.22, 1, 0.36, 1)) 0.35s,
    transform 1s var(--ease-splash, cubic-bezier(0.22, 1, 0.36, 1)) 0.35s;
}

.splash-page--ready .splash-overlay {
  opacity: 1;
  transform: translateY(0);
}

.splash-overlay > * {
  pointer-events: auto;
}

.splash-overlay__logo-wrap {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.splash-overlay__logo {
  width: min(100%, clamp(320px, 24vw, 520px));
  height: auto;
  object-fit: contain;
  object-position: left top;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.38));
  user-select: none;
  -webkit-user-drag: none;
}

.splash-overlay .splash-menu {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0.35rem 0;
  gap: 0.48rem;
}

.splash-overlay__footer {
  flex-shrink: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.65rem, 1.2vh, 0.85rem);
  padding-top: var(--splash-menu-footer-gap);
  border-top: 1px solid rgba(255, 220, 160, 0.14);
}

.start-screen__footer-meta {
  display: flex;
  flex-direction: column;
  gap: clamp(0.45rem, 0.9vh, 0.6rem);
  flex-shrink: 0;
}

.start-screen__footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.35rem;
  margin: 0;
  padding: 0;
}

.start-screen__footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.15rem 0.2rem;
  border: none;
  background: transparent;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 14px;
  font-weight: 600;
  color: rgba(245, 230, 200, 0.88);
  opacity: 0.8;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
}

.start-screen__footer-link:hover,
.start-screen__footer-link:focus-visible {
  opacity: 1;
  color: #ffe8a8;
  outline: none;
}

.start-screen__footer-link-sep {
  font-size: 14px;
  color: rgba(245, 230, 200, 0.45);
  opacity: 0.8;
  user-select: none;
  pointer-events: none;
  padding: 0 0.1rem;
}

.splash-overlay__language.language-switcher {
  padding: 0;
}

.splash-overlay__language.language-switcher--compact {
  flex-direction: row;
  align-items: center;
}

.splash-overlay__language .language-switcher--compact .language-switcher__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.splash-overlay__language .language-switcher__inline-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.splash-overlay__language .language-switcher__sep {
  font-size: 14px;
  color: rgba(245, 230, 200, 0.45);
  user-select: none;
}

.splash-overlay__language .language-switcher__btn--inline {
  min-height: 36px;
  min-width: 0;
  padding: 0.2rem 0.35rem;
  border: none;
  background: transparent;
  font-family: var(--font-body, 'Crimson Pro', serif);
  font-size: 14px;
  font-weight: 600;
  color: rgba(245, 230, 200, 0.85);
  opacity: 0.85;
  box-shadow: none;
}

.splash-overlay__language .language-switcher__btn--inline:hover,
.splash-overlay__language .language-switcher__btn--inline:focus-visible {
  opacity: 1;
  color: #ffe8a8;
  outline: none;
  transform: none;
  box-shadow: none;
}

.splash-overlay__language .language-switcher__btn--inline.language-switcher__btn--active {
  opacity: 1;
  color: #ffd978;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.splash-overlay__language .language-switcher__label {
  font-size: 0.76rem;
  color: rgba(245, 230, 200, 0.82);
}

.splash-overlay__language .language-switcher__btn:not(.language-switcher__btn--inline) {
  min-height: 40px;
  min-width: 6.5rem;
  padding: 0.45rem 0.85rem;
}

.splash-overlay .splash-journal-button {
  flex-shrink: 0;
  align-self: stretch;
  position: static;
  opacity: 1;
  width: 100%;
  max-width: 100%;
  margin-top: 0;
}

.splash-overlay .splash-menu__btn {
  opacity: 1;
  height: auto;
  min-height: 44px;
  max-height: none;
  padding: 0.58rem 1rem;
  font-size: clamp(0.82rem, 1.2vw, 0.94rem);
}

.splash-page__scene > .splash-best {
  position: absolute;
  right: clamp(1rem, 4vw, 5%);
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  opacity: 0;
  pointer-events: auto;
  animation: splash-btn-in 0.8s var(--ease-splash, cubic-bezier(0.22, 1, 0.36, 1)) forwards;
  animation-delay: 1.55s;
}

.splash-page--ready .splash-page__scene > .splash-best {
  opacity: 1;
}

/* ── Result screen: full-viewport visual + overlay ── */

.game-result-overlay--visual {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(0.75rem + env(safe-area-inset-top, 0px))
    0.75rem
    calc(0.75rem + env(safe-area-inset-bottom, 0px));
  pointer-events: auto;
}

.game-result-overlay--visual .game-result-overlay__content {
  position: relative;
  z-index: 2;
  width: min(100%, 420px);
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-result-overlay--visual.game-result-overlay--win-art {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.game-result-overlay--visual.game-result-overlay--win-art .game-result-overlay__content {
  display: none;
}

.game-result-overlay--visual.game-result-overlay--win-art .visual-background__scrim {
  display: none;
}

.game-result-overlay--visual.game-result-overlay--lose {
  background: transparent;
  animation: game-result-lose-backdrop 300ms var(--ease-out-premium, ease-out) forwards;
}

.game-result-overlay--visual .game-result-overlay__panel {
  width: 100%;
}

.game-result-overlay--visual .game-result-overlay__panel-body,
.game-result-overlay--visual .game-result-overlay__panel-body--lose {
  padding: 1.35rem 1.5rem 1.1rem;
  background: rgba(28, 20, 12, 0.88);
  border: 1px solid rgba(210, 170, 120, 0.28);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 1px rgba(255, 220, 160, 0.06) inset,
    0 12px 36px rgba(0, 0, 0, 0.42);
}

.game-result-overlay--visual.game-result-overlay--win .game-result-overlay__panel-body {
  border-color: rgba(255, 215, 0, 0.32);
}

.game-result-overlay__actions--row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.game-result-overlay__actions--row .game-result-overlay__restart {
  grid-column: 1 / -1;
}

.game-result-overlay__stats-btn {
  padding: 0.48rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.28);
  background: rgba(255, 215, 0, 0.1);
  color: #ffe8a8;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.game-result-overlay__stats-btn:hover {
  filter: brightness(1.08);
}

@media (max-width: 768px), (max-aspect-ratio: 1/1) {
  .splash-page .visual-background__image {
    object-position: 62% center;
  }

  .splash-overlay {
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: min(92vw, 360px);
    max-width: min(92vw, 360px);
    align-items: stretch;
    text-align: center;
  }

  .splash-page--ready .splash-overlay {
    transform: translateX(-50%) translateY(0);
  }

  .splash-overlay__logo-wrap {
    justify-content: center;
  }

  .splash-overlay__logo {
    width: min(100%, clamp(260px, 72vw, 400px));
    object-position: center top;
  }

  .splash-overlay .splash-menu {
    width: 100%;
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .splash-overlay .splash-journal-button {
    width: 100%;
    margin-top: 0;
  }

  .splash-overlay__footer {
    width: 100%;
    align-items: stretch;
    margin-top: 0;
    padding-top: clamp(0.85rem, 2vh, 1.5rem);
  }

  .start-screen__footer-meta {
    align-items: center;
  }

  .start-screen__footer-links {
    justify-content: center;
  }

  .start-screen__footer-link {
    min-height: 44px;
  }

  .splash-overlay__language .language-switcher__btn--inline {
    min-height: 44px;
  }

  .splash-page__scene > .splash-best {
    right: 50%;
    transform: translateX(50%);
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.62rem;
  }

  .game-result-overlay--visual .game-result-overlay__content {
    width: min(92vw, 400px);
    max-height: 85dvh;
  }

  .game-result-overlay__actions--row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-overlay .splash-menu__btn,
  .splash-overlay .splash-journal-button,
  .splash-overlay .splash-best {
    animation: none !important;
    opacity: 1 !important;
  }
}
