.psp-app {
  --psp-radius: 18px;
  width: 100%;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

.psp-app *,
.psp-app *::before,
.psp-app *::after {
  box-sizing: border-box;
}

.psp-app [hidden] {
  display: none !important;
}

.psp-card {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid rgba(0,0,0,.09);
  border-radius: var(--psp-radius);
  background: #fff;
  box-shadow: 0 10px 35px rgba(0,0,0,.07);
}

.psp-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.psp-title {
  margin: 0 0 4px;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.2;
}

.psp-subtitle {
  margin: 0;
  opacity: .72;
}

.psp-version {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f2f3f5;
  font-size: 12px;
}

.psp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.psp-file-button,
.psp-btn,
.psp-preview-toggle {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}

.psp-file-button,
.psp-btn {
  background: #222;
  color: #fff;
}

.psp-btn-secondary,
.psp-preview-toggle {
  background: #f0f1f3;
  color: #222;
}

.psp-file-button:hover,
.psp-btn:hover,
.psp-preview-toggle:hover {
  transform: translateY(-1px);
}

.psp-file-button input {
  display: none;
}

.psp-btn:disabled,
.psp-preview-toggle:disabled {
  cursor: default;
  opacity: .4;
  transform: none;
}

.psp-control-group {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 12px;
  background: #f6f7f8;
  font-weight: 700;
}

.psp-control-group select {
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  font: inherit;
}

.psp-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.psp-status > div {
  min-width: 95px;
  padding: 9px 12px;
  border-radius: 12px;
  background: #f7f7f8;
}

.psp-label {
  display: inline-block;
  margin-right: 8px;
  font-size: 12px;
  opacity: .65;
}

.psp-stage-wrap {
  position: relative;
}

.psp-empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 2px dashed rgba(0,0,0,.15);
  border-radius: 16px;
  text-align: center;
  background: #fafafa;
}

.psp-empty-state p {
  margin: 8px 0 0;
  font-weight: 700;
  opacity: .65;
}

.psp-empty-icon {
  font-size: 58px;
  line-height: 1;
}

.psp-stage {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

.psp-board {
  --psp-grid: 3;
  display: grid;
  grid-template-columns: repeat(var(--psp-grid), 1fr);
  grid-template-rows: repeat(var(--psp-grid), 1fr);
  max-width: 100%;
  max-height: min(76vh, 860px);
  margin: 0 auto;
  overflow: hidden;
  border: 10px solid #1d1d1f;
  border-radius: 16px;
  background: #202124;
  gap: 2px;
  padding: 2px;
  touch-action: manipulation;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.psp-tile {
  appearance: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  border-radius: 2px;
  background-repeat: no-repeat;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

.psp-tile:hover {
  filter: brightness(1.04);
}

.psp-tile:focus-visible {
  outline: 3px solid #111;
  outline-offset: -3px;
}

.psp-blank {
  position: relative;
  background:
    linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,0)),
    #111214;
  cursor: default;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.08);
}

.psp-blank::after {
  content: "";
  position: absolute;
  inset: 26%;
  border-radius: 10px;
  border: 2px dashed rgba(255,255,255,.18);
}

.psp-preview-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(0,0,0,.76);
  backdrop-filter: blur(3px);
}

.psp-preview-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.psp-help {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f7f7f8;
  font-size: 14px;
  line-height: 1.65;
}

.psp-help p {
  margin: 0;
}

.psp-help p + p {
  margin-top: 4px;
}

.psp-complete {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.6);
}

.psp-complete-box {
  width: min(92vw, 420px);
  padding: 28px;
  border-radius: 20px;
  background: #fff;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.24);
}

.psp-complete-icon {
  font-size: 58px;
}

.psp-complete-box h3 {
  margin: 6px 0;
  font-size: 30px;
}

.psp-complete-box p {
  margin: 0 0 18px;
  font-size: 18px;
}

@media (max-width: 640px) {
  .psp-card {
    padding: 14px;
    border-radius: 14px;
  }

  .psp-controls {
    align-items: stretch;
  }

  .psp-file-button,
  .psp-btn,
  .psp-control-group {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
    text-align: center;
  }

  .psp-status {
    gap: 8px;
  }

  .psp-status > div {
    flex: 1 1 90px;
  }

  .psp-preview-toggle {
    width: 100%;
  }

  .psp-board {
    border-width: 6px;
    gap: 1px;
    padding: 1px;
    max-height: 72vh;
  }
}