.psmj-game,
.psmj-game * {
  box-sizing: border-box;
}

.psmj-game {
  --psmj-orange: #ed8b2a;
  --psmj-brown: #4b2f1c;
  --psmj-dark: #15110d;
  --psmj-cream: #fff5df;
  --psmj-paper: #f8ead0;
  --psmj-green: #22543d;
  --psmj-scale: 1;
  width: 100%;
  margin: 2rem auto;
  padding: clamp(10px, 2vw, 24px);
  color: var(--psmj-dark);
  background:
    radial-gradient(circle at 20% 10%, rgba(237,139,42,.20), transparent 28%),
    linear-gradient(135deg, #f7e8c8 0%, #e5c994 100%);
  border: 3px solid rgba(75,47,28,.32);
  border-radius: 24px;
  box-shadow: 0 22px 55px rgba(0,0,0,.18);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

.psmj-shell {
  max-width: 1220px;
  margin: 0 auto;
}

.psmj-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.psmj-kicker {
  margin: 0 0 3px;
  color: var(--psmj-brown);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.psmj-title {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.1rem);
  line-height: 1;
  color: #1b130b;
  text-transform: uppercase;
  letter-spacing: -.04em;
  text-shadow: 1px 1px 0 rgba(255,255,255,.5);
}

.psmj-intro {
  margin: 8px 0 0;
  max-width: 780px;
  color: rgba(21,17,13,.78);
  font-size: 1rem;
}

.psmj-modebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.psmj-mode-btn,
.psmj-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--psmj-brown);
  color: #fff;
  font-size: .9rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.psmj-mode-btn:hover,
.psmj-btn:hover,
.psmj-mode-btn:focus-visible,
.psmj-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
  outline: 3px solid rgba(237,139,42,.35);
  outline-offset: 2px;
}

.psmj-mode-btn.is-active {
  background: var(--psmj-orange);
  color: #1d1208;
}

.psmj-scoreboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.psmj-stat {
  min-height: 66px;
  padding: 10px 12px;
  background: rgba(255,255,255,.48);
  border: 2px solid rgba(75,47,28,.18);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}

.psmj-stat-label {
  display: block;
  color: rgba(75,47,28,.76);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.psmj-stat-value {
  display: block;
  margin-top: 4px;
  color: #130c06;
  font-size: clamp(1.1rem, 2.4vw, 1.55rem);
  font-weight: 1000;
  line-height: 1;
}

.psmj-drive-wrap {
  display: none;
  margin: 12px 0 16px;
  padding: 12px;
  background: #24623a;
  border: 3px solid #173d27;
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08);
}

.psmj-game[data-mode="drive"] .psmj-drive-wrap {
  display: block;
}

.psmj-field {
  position: relative;
  height: 58px;
  border-radius: 14px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.17) 0 2px, transparent 2px 10%),
    linear-gradient(90deg, #1f6b3a 0%, #2d7f45 50%, #1f6b3a 100%);
}

.psmj-field::before,
.psmj-field::after {
  content: "END ZONE";
  position: absolute;
  top: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 12%;
  color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.18);
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.psmj-field::before { left: 0; }
.psmj-field::after { right: 0; }

.psmj-ball {
  position: absolute;
  top: 50%;
  left: 12%;
  width: 34px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #7a3b18;
  border: 2px solid #fff0cf;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
  transition: left .35s ease;
}

.psmj-ball::after {
  content: "";
  position: absolute;
  inset: 8px 7px auto;
  height: 2px;
  background: rgba(255,255,255,.85);
}

.psmj-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
}

.psmj-message {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #24160b;
  background: rgba(255,255,255,.48);
  border: 1px solid rgba(75,47,28,.15);
  font-weight: 800;
}

.psmj-key {
  margin: 0 0 16px;
  border: 1px solid rgba(75,47,28,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.45);
  overflow: hidden;
}

.psmj-key summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 900;
  color: var(--psmj-brown);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.psmj-key summary::-webkit-details-marker {
  display: none;
}

.psmj-key[open] summary {
  border-bottom: 1px solid rgba(75,47,28,.12);
}

.psmj-key-note {
  margin: 0;
  padding: 12px 14px 4px;
  color: rgba(21,17,13,.82);
  font-size: .92rem;
  font-weight: 700;
}

.psmj-key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px 10px;
  padding: 10px 14px 14px;
  max-height: 260px;
  overflow: auto;
}

.psmj-key-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.psmj-key-swatch {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--psmj-tile-shine, #fff), var(--psmj-tile-surface, #f9efd8));
  box-shadow: inset 0 0 0 2px var(--psmj-tile-accent, #6b3d20), 0 2px 6px rgba(0,0,0,.12);
}

.psmj-key-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--psmj-tile-iconbg, #fff0cf);
  font-size: 1rem;
  font-weight: 900;
}

.psmj-key-icon img {
  max-width: 18px;
  max-height: 18px;
  object-fit: contain;
}

.psmj-key-name {
  min-width: 0;
  font-size: .82rem;
  line-height: 1.15;
  font-weight: 800;
  color: #2e1a0d;
}

.psmj-board-outer {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 14px 8px 16px;
  border-radius: 22px;
  background:
    linear-gradient(rgba(255,255,255,.14), rgba(255,255,255,.03)),
    radial-gradient(circle at center, rgba(255,255,255,.16), transparent 62%),
    #2d5b37;
  border: 4px solid #5a331c;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08), inset 0 18px 45px rgba(0,0,0,.16);
  -webkit-overflow-scrolling: touch;
}

.psmj-board-stage {
  position: relative;
  margin: 0 auto;
}

.psmj-board {
  position: relative;
  margin: 0;
  transform: scale(var(--psmj-scale));
  transform-origin: top left;
}

.psmj-tile {
  position: absolute;
  width: 58px;
  height: 74px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  color: #24160b;
  background:
    linear-gradient(145deg, var(--psmj-tile-shine, rgba(255,255,255,.84)), rgba(255,255,255,0) 42%),
    var(--psmj-tile-surface, var(--psmj-paper));
  box-shadow:
    0 5px 0 #9f6a39,
    0 8px 12px rgba(0,0,0,.28),
    inset 0 0 0 2px #6b3d20,
    inset 0 0 0 5px color-mix(in srgb, var(--psmj-tile-accent, rgba(237,139,42,.55)) 28%, transparent);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: 6px 5px 7px;
  user-select: none;
  touch-action: manipulation;
  transition: transform .12s ease, filter .12s ease, opacity .16s ease, box-shadow .12s ease;
}

.psmj-tile::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed color-mix(in srgb, var(--psmj-tile-accent, #6b3d20) 45%, rgba(75,47,28,.24));
  border-radius: 9px;
  pointer-events: none;
}

.psmj-tile:hover,
.psmj-tile:focus-visible {
  outline: 0;
  filter: brightness(1.05);
}

.psmj-tile.is-locked {
  cursor: not-allowed;
  opacity: .9;
  filter: saturate(.78) brightness(.8);
}

.psmj-tile.is-free:not(.is-selected):hover,
.psmj-tile.is-free:focus-visible {
  transform: translateY(-3px);
}

.psmj-tile.is-selected {
  transform: translateY(-5px) scale(1.03);
  box-shadow:
    0 5px 0 #9f6a39,
    0 0 0 4px rgba(237,139,42,.78),
    0 10px 14px rgba(0,0,0,.34),
    inset 0 0 0 2px #6b3d20;
}

.psmj-tile.is-hint {
  box-shadow:
    0 5px 0 #9f6a39,
    0 0 0 4px rgba(255,255,255,.9),
    0 0 0 7px rgba(237,139,42,.78),
    0 10px 14px rgba(0,0,0,.34),
    inset 0 0 0 2px #6b3d20;
}

.psmj-tile.is-bad {
  animation: psmj-shake .24s linear;
}

.psmj-tile.is-matched {
  opacity: 0;
  transform: scale(.75);
  pointer-events: none;
}

.psmj-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  width: 34px;
  height: 34px;
  padding: 2px;
  border-radius: 10px;
  background: var(--psmj-tile-iconbg, rgba(255,255,255,.72));
  box-shadow: inset 0 0 0 1px rgba(75,47,28,.14);
  font-size: 1.45rem;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
}

.psmj-icon img {
  display: block;
  max-width: 34px;
  max-height: 34px;
  object-fit: contain;
}

.psmj-label {
  position: relative;
  z-index: 1;
  width: 100%;
  color: #2e1a0d;
  font-size: .48rem;
  font-weight: 1000;
  line-height: 1.02;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.psmj-game:not(.psmj-show-labels) .psmj-label {
  display: none;
}

.psmj-tile.is-free {
  opacity: 1;
  filter: none;
}

.psmj-tile.is-locked .psmj-label {
  opacity: .78;
}

.psmj-compact-note {
  display: none;
}

.psmj-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(16,11,7,.68);
}

.psmj-modal.is-open {
  display: grid;
}

.psmj-modal-card {
  width: min(560px, 100%);
  padding: clamp(22px, 4vw, 34px);
  border-radius: 24px;
  background: var(--psmj-cream);
  border: 4px solid var(--psmj-brown);
  box-shadow: 0 22px 60px rgba(0,0,0,.38);
  text-align: center;
}

.psmj-modal-card h3 {
  margin: 0 0 10px;
  color: #1d1208;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1;
  text-transform: uppercase;
}

.psmj-modal-card p {
  margin: 8px 0 16px;
  color: rgba(21,17,13,.82);
  font-size: 1rem;
}

.psmj-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

@keyframes psmj-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (max-width: 900px) {
  .psmj-header {
    grid-template-columns: 1fr;
  }
  .psmj-modebar {
    justify-content: flex-start;
  }
  .psmj-scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .psmj-game {
    margin: 1rem auto;
    border-radius: 18px;
  }
  .psmj-scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .psmj-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .psmj-message {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .psmj-btn,
  .psmj-mode-btn {
    width: 100%;
    padding: 11px 10px;
  }
  .psmj-key {
  margin: 0 0 16px;
  border: 1px solid rgba(75,47,28,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.45);
  overflow: hidden;
}

.psmj-key summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 900;
  color: var(--psmj-brown);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.psmj-key summary::-webkit-details-marker {
  display: none;
}

.psmj-key[open] summary {
  border-bottom: 1px solid rgba(75,47,28,.12);
}

.psmj-key-note {
  margin: 0;
  padding: 12px 14px 4px;
  color: rgba(21,17,13,.82);
  font-size: .92rem;
  font-weight: 700;
}

.psmj-key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px 10px;
  padding: 10px 14px 14px;
  max-height: 260px;
  overflow: auto;
}

.psmj-key-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.psmj-key-swatch {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--psmj-tile-shine, #fff), var(--psmj-tile-surface, #f9efd8));
  box-shadow: inset 0 0 0 2px var(--psmj-tile-accent, #6b3d20), 0 2px 6px rgba(0,0,0,.12);
}

.psmj-key-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--psmj-tile-iconbg, #fff0cf);
  font-size: 1rem;
  font-weight: 900;
}

.psmj-key-icon img {
  max-width: 18px;
  max-height: 18px;
  object-fit: contain;
}

.psmj-key-name {
  min-width: 0;
  font-size: .82rem;
  line-height: 1.15;
  font-weight: 800;
  color: #2e1a0d;
}

.psmj-board-outer {
    padding: 10px 4px 12px;
    border-width: 3px;
    border-radius: 16px;
  }
  .psmj-title {
    font-size: clamp(1.55rem, 9vw, 2.15rem);
  }
  .psmj-intro {
    font-size: .92rem;
  }
  .psmj-stat {
    min-height: 54px;
    padding: 8px;
    border-radius: 13px;
  }
  .psmj-game.psmj-show-labels .psmj-label {
    display: none;
  }
  .psmj-tile {
    box-shadow:
      0 4px 0 #9f6a39,
      0 6px 10px rgba(0,0,0,.26),
      inset 0 0 0 2px #6b3d20,
      inset 0 0 0 4px rgba(237,139,42,.2);
  }
}

@media (max-width: 380px) {
  .psmj-game {
    padding-left: 6px;
    padding-right: 6px;
  }
  .psmj-scoreboard {
    gap: 7px;
  }
}


@media (max-width: 782px) {
  .psmj-key-grid {
    grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
    max-height: 220px;
  }

  .psmj-key-name {
    font-size: .76rem;
  }
}


.psmj-face-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 46px;
}

.psmj-sprite {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-repeat: no-repeat;
  background-color: transparent;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

.psmj-key-swatch {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.55);
  box-shadow: inset 0 0 0 1px rgba(75,47,28,.12), 0 2px 6px rgba(0,0,0,.08);
}

.psmj-key-sprite {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background-repeat: no-repeat;
}

.psmj-key-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--psmj-tile-iconbg, #fff0cf);
  font-size: 1rem;
  font-weight: 900;
}

.psmj-key-icon img {
  max-width: 18px;
  max-height: 18px;
  object-fit: contain;
}

.psmj-tile {
  background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(255,255,255,.72));
}

.psmj-tile::before {
  border: 1px dashed rgba(75,47,28,.18);
}

.psmj-tile.is-locked {
  opacity: .86;
  filter: saturate(.82) brightness(.84);
}

.psmj-tile .psmj-label {
  margin-top: 2px;
}

.psmj-game:not(.psmj-show-labels) .psmj-tile {
  padding-bottom: 6px;
}

.psmj-game:not(.psmj-show-labels) .psmj-face-wrap {
  min-height: 56px;
}

.psmj-game:not(.psmj-show-labels) .psmj-sprite {
  width: 48px;
  height: 48px;
}

@media (max-width: 782px) {
  .psmj-sprite {
    width: 40px;
    height: 40px;
  }

  .psmj-game:not(.psmj-show-labels) .psmj-sprite {
    width: 44px;
    height: 44px;
  }

  .psmj-key-swatch {
    width: 36px;
    height: 36px;
  }

  .psmj-key-sprite {
    width: 28px;
    height: 28px;
  }
}


/* Force sprite-only card faces on the board */
.psmj-board .psmj-label {
  display: none !important;
}

.psmj-board .psmj-tile {
  grid-template-rows: 1fr;
  padding: 6px;
}

.psmj-board .psmj-face-wrap {
  min-height: 58px;
}

.psmj-board .psmj-sprite {
  width: 48px;
  height: 48px;
}

@media (max-width: 782px) {
  .psmj-board .psmj-sprite {
    width: 44px;
    height: 44px;
  }
}


/* Extra depth for disabled / covered tiles */
.psmj-board .psmj-tile.is-locked {
  opacity: .92;
  filter: saturate(.72) brightness(.76);
  box-shadow:
    0 5px 0 #7f522d,
    0 14px 22px rgba(0,0,0,.46),
    0 3px 0 rgba(0,0,0,.10),
    inset 0 0 0 2px #6b3d20,
    inset 0 0 0 5px rgba(0,0,0,.08);
}
