/* 행성·과일 톡톡 합체 */
:root {
  --pm-bg: #eef2ff;
  --pm-surface: #ffffff;
  --pm-ink: #1e293b;
  --pm-muted: #526071;
  --pm-border: #dbe2f3;
  --pm-accent: #4f46e5;
  --pm-shadow: 0 14px 32px rgba(30, 27, 75, 0.1);
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--pm-bg); color: var(--pm-ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, sans-serif;
}
.pm-app {
  max-width: 1060px; margin: 0 auto; min-height: 100dvh;
  padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 14px;
}
.pm-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.pm-topbar-left, .pm-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-brand-title { margin: 0; font-size: 1.15rem; font-weight: 800; }

.pm-btn-ghost, .pm-btn-pill, .pm-btn-primary, .pm-btn-secondary {
  font-family: inherit; cursor: pointer; border: none; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700;
}
.pm-btn-ghost { background: #fff; color: var(--pm-ink); border: 1.5px solid var(--pm-border); border-radius: 12px; padding: 8px 13px; font-size: 0.92rem; min-height: 40px; }
.pm-btn-sm { padding: 7px 12px; font-size: 0.88rem; }
.pm-btn-pill { background: #fff; color: var(--pm-ink); border: 1.5px solid var(--pm-border); border-radius: 999px; padding: 7px 13px; font-size: 0.88rem; min-height: 38px; }
.pm-btn-share { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.pm-btn-primary {
  background: linear-gradient(135deg, #38bdf8, #4f46e5); color: #fff;
  border-radius: 16px; padding: 13px 26px; font-size: 1.05rem; font-weight: 800;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}
.pm-btn-secondary { background: #f1f5f9; color: var(--pm-ink); border: 1.5px solid #cbd5e1; border-radius: 14px; padding: 12px 20px; font-size: 0.96rem; }
.pm-screen[hidden], .pm-modal-backdrop[hidden], .pm-gameover-overlay[hidden] { display: none !important; }

/* Lobby */
.pm-lobby-card {
  background: #fff; border: 2px solid var(--pm-border); border-radius: 26px;
  padding: 22px; box-shadow: var(--pm-shadow); display: flex; flex-direction: column; gap: 20px;
}
.pm-hero { display: grid; grid-template-columns: minmax(260px, 1.05fr) 1fr; gap: 22px; align-items: center; }
.pm-hero-media { border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; background: #1e1b4b; }
.pm-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pm-hero-copy { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pm-world-tag { background: #e0e7ff; color: #3730a3; font-size: 0.84rem; font-weight: 800; padding: 5px 12px; border-radius: 999px; }
.pm-hero-heading { margin: 0; font-size: 1.6rem; line-height: 1.25; }
.pm-hero-desc { margin: 0; color: var(--pm-muted); line-height: 1.55; font-size: 0.96rem; }
.pm-theme-section h3 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 800; }
.pm-theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pm-theme-card {
  font-family: inherit; cursor: pointer; text-align: left; background: #f8fafc;
  border: 2px solid var(--pm-border); border-radius: 18px; padding: 15px;
  display: flex; flex-direction: column; gap: 6px;
}
.pm-theme-card.is-selected { background: #eef2ff; border-color: var(--pm-accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }
.pm-theme-top { display: flex; justify-content: space-between; gap: 8px; }
.pm-theme-badge { font-size: 0.76rem; font-weight: 800; background: #e0e7ff; color: #3730a3; padding: 3px 8px; border-radius: 999px; }
.pm-theme-best { font-size: 0.78rem; font-weight: 700; color: var(--pm-muted); }
.pm-theme-title { font-size: 1.1rem; font-weight: 800; color: var(--pm-ink); }
.pm-theme-sub { margin: 0; font-size: 0.86rem; color: var(--pm-muted); line-height: 1.4; }

/* Play */
.pm-play { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pm-hud {
  width: 100%; background: #fff; border: 2px solid var(--pm-border); border-radius: 18px;
  padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.pm-hud-left, .pm-hud-stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-stat-pill, .pm-next-pill {
  background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 5px 12px; display: flex; flex-direction: column; align-items: center; min-width: 68px;
}
.pm-stat-pill span, .pm-next-pill span { font-size: 0.72rem; font-weight: 700; color: var(--pm-muted); }
.pm-stat-pill strong, .pm-next-pill strong { font-size: 1rem; font-weight: 900; }

html[data-classroom-playing] .pm-body {
  background: #211e53 url("../img/play-world.7a23ddcdb87a.webp") center bottom / cover no-repeat fixed;
}
html[data-classroom-playing] .pm-app { max-width: 1440px; min-height: calc(100dvh - var(--classroom-play-height)); }
.pm-play-layout {
  display: grid; grid-template-columns: minmax(150px, 200px) auto minmax(150px, 220px);
  gap: clamp(14px, 4vw, 72px); align-items: start; justify-content: center; width: 100%;
}
.pm-play-tip { background: #f0effe; border-radius: 14px; padding: 10px 16px; }
.pm-play-layout summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 800; }
.pm-play-layout :focus-visible { outline: 4px solid #a99cff; outline-offset: -4px; }
.pm-play-layout .pm-hud { gap: 10px; padding: 12px; }
.pm-play-layout .pm-hud-stats { flex-wrap: wrap; }
.pm-play-layout .pm-hud-stats > div { flex: 1; }

.pm-jar-wrap {
  position: relative; width: min(50vw, 510px, calc((100dvh - 170px) * .75)); aspect-ratio: 3 / 4;
  border-radius: 22px; overflow: hidden; box-shadow: var(--pm-shadow);
  border: 3px solid #a49fff; touch-action: none; user-select: none;
}
.pm-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }

.pm-evo-panel {
  background: #fff; border: 2px solid var(--pm-border); border-radius: 20px; padding: 14px;
}
.pm-evo-panel h3 { margin: 0 0 10px; font-size: 0.95rem; font-weight: 800; }
.pm-evo-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pm-evo-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; }
.pm-evo-dot {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.pm-play-tip { margin: 0; font-size: 0.86rem; font-weight: 700; color: var(--pm-muted); text-align: center; }

.pm-gameover-overlay {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pm-gameover-card {
  background: #fff; border-radius: 22px; padding: 24px; text-align: center; width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.pm-clear-badge { background: #e0e7ff; color: #3730a3; font-weight: 900; padding: 5px 12px; border-radius: 999px; font-size: 0.88rem; }
.pm-gameover-card h2 { margin: 4px 0 0; font-size: 2rem; }
.pm-gameover-card p { margin: 0; color: var(--pm-muted); font-weight: 700; }
.pm-go-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }

/* Modals */
.pm-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.pm-modal-card { width: 100%; max-width: 460px; background: #fff; border-radius: 24px; padding: 24px; box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25); }
.pm-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pm-modal-head h2 { margin: 0; font-size: 1.2rem; }
.pm-modal-close { width: 34px; height: 34px; border-radius: 50%; border: none; background: #f1f5f9; font-weight: 800; cursor: pointer; }
.pm-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; line-height: 1.55; color: #334155; }
.pm-modal-foot { display: flex; justify-content: flex-end; }
.pm-qr-desc { margin: 0 0 12px; color: var(--pm-muted); font-size: 0.92rem; }
.pm-qr-box { display: flex; justify-content: center; padding: 12px; background: #f8fafc; border-radius: 16px; margin-bottom: 12px; }
.pm-qr-url-row { display: flex; gap: 8px; }
.pm-qr-url { flex: 1; min-width: 0; border: 1.5px solid #cbd5e1; border-radius: 12px; padding: 8px 10px; font-size: 0.85rem; background: #f8fafc; }
.pm-copy-feedback { margin: 8px 0 0; min-height: 1.2em; font-size: 0.86rem; font-weight: 700; color: #059669; text-align: center; }

@media (max-width: 820px) {
  .pm-hero, .pm-theme-grid, .pm-play-layout { grid-template-columns: 1fr; }
  .pm-jar-wrap { width: min(calc(100vw - 34px), calc((100dvh - 235px) * .75), 440px); min-width: min(244px, calc(100vw - 34px)); margin: 0 auto; }
  .pm-play-layout { gap: 10px; }
  .pm-play-layout .pm-hud { gap: 6px; padding: 8px; }
  .pm-evo-panel { padding: 0 10px 4px; }
  .pm-evo-list { flex-direction: row; flex-wrap: wrap; gap: 8px; }
}

[data-classroom-game-stage] .cg-guide-entry { display: none; }
[data-game-native-reset][data-play-native-control] { display: none; }

#gameover-overlay { inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; padding: 0; background: transparent; }
#gameover-overlay:not([open]) { display: none; }
#gameover-overlay[open] { position: fixed; display: grid; place-items: center; }
#gameover-overlay::backdrop { background: #10182791; }

body.pm-body #classroom-play-toolbar h1 { overflow-wrap: normal; word-break: keep-all; }

@media (min-width: 950px) {
  .pm-play-layout .pm-hud, .pm-play-layout .pm-hud-stats { display: grid; width: 100%; gap: 10px; }
  .pm-play-layout .pm-stat-pill, .pm-play-layout .pm-next-pill { align-items: start; padding: 10px 13px; }
  .pm-play-layout .pm-stat-pill span, .pm-play-layout .pm-next-pill span { font-size: .85rem; }
  .pm-play-layout .pm-stat-pill strong, .pm-play-layout .pm-next-pill strong { font-size: 1.35rem; }
}

@media (min-width: 1200px) and (min-height: 800px) {
  .pm-play-layout { grid-template-columns: minmax(170px, 220px) auto minmax(170px, 232px); }
  .pm-play-layout .pm-hud { padding: 16px; }
  .pm-play-layout .pm-stat-pill { min-height: 68px; }
  .pm-play-layout .pm-next-pill strong { font-size: 2rem; }
  .pm-evo-list { gap: 8px; }
  .pm-evo-item { font-size: 1rem; }
  .pm-evo-dot { width: 30px; height: 30px; font-size: 1rem; }
  .pm-play-tip { font-size: .98rem; }
}
