.ph-hub,
.ph-player {
  --ph-ink: #24314f;
  --ph-muted: #66708f;
  --ph-card: rgba(255, 255, 255, 0.92);
  --ph-primary: #7c4dff;
  --ph-primary-2: #00bcd4;
  --ph-good: #17b978;
  --ph-warn: #ffb020;
  --ph-shadow: 0 22px 60px rgba(66, 60, 120, 0.18);
  color: var(--ph-ink);
}

.ph-player [hidden] {
  display: none !important;
}

.ph-hub {
  display: grid;
  gap: 18px;
  padding: 4px 0 28px;
}

.ph-hub--category {
  --ph-card-size: minmax(168px, 1fr);
}

.ph-category-description {
  max-width: 760px;
  margin: 0 auto 8px;
  text-align: center;
  color: var(--ph-muted);
  font-weight: 700;
}

.ph-category-description p {
  margin: 0;
}

body.dk-kids #grid_container.ph-category-grid,
body.dk-kids .ph-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--ph-card-size));
  gap: 12px;
  align-items: stretch;
}

body.dk-kids #grid_container.ph-category-grid .item,
body.dk-kids .ph-game-grid .item {
  width: auto !important;
  flex: none !important;
  max-width: none;
  display: flex;
  flex-direction: column;
  margin: 0;
}

body.dk-kids #grid_container.ph-category-grid .item a,
body.dk-kids .ph-game-grid .item a {
  flex: 1;
  width: 100%;
  color: var(--dk-ink);
}

body.dk-kids .ph-cat-icon-wrap {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  border-radius: 18px;
  background: var(--dk-section-bg);
  border: 1px solid rgba(20, 33, 61, 0.08);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.1);
  overflow: hidden;
}

body.dk-kids .ph-cat-icon {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: contain;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

body.dk-kids #grid_container.ph-category-grid .item .title,
body.dk-kids .ph-game-grid .item .title {
  font-size: clamp(14px, 2.1vw, 17px);
  font-weight: 800;
  line-height: 1.3;
  margin-top: 8px;
}

body.dk-kids .ph-cat-progress {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--dk-blue);
  margin: 4px 0 0;
  text-align: center;
}

@media (max-width: 30em) {
  body.dk-kids #grid_container.ph-category-grid,
  body.dk-kids .ph-game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 22em) {
  body.dk-kids #grid_container.ph-category-grid,
  body.dk-kids .ph-game-grid {
    grid-template-columns: 1fr;
  }
}

.ph-hero {
  align-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 214, 102, 0.5), transparent 26%),
    radial-gradient(circle at 86% 10%, rgba(124, 77, 255, 0.28), transparent 24%),
    linear-gradient(135deg, #fff7df 0%, #eaf7ff 45%, #f2ebff 100%);
  border: 1px solid rgba(124, 77, 255, 0.15);
  border-radius: 34px;
  box-shadow: var(--ph-shadow);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 230px;
  overflow: hidden;
  padding: clamp(22px, 4vw, 42px);
  position: relative;
}

.ph-kicker {
  color: #7159c8;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.ph-hero h1,
.ph-section-head h2,
.ph-player h1 {
  color: var(--ph-ink);
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-weight: 900;
  line-height: 1;
  margin: 0;
}

.ph-hero h1 {
  font-size: clamp(2.2rem, 6vw, 4.7rem);
}

.ph-hero p {
  color: var(--ph-muted);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  max-width: 680px;
}

.ph-hero__actions,
.ph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ph-btn {
  align-items: center;
  background: #fff;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(45, 50, 100, 0.14);
  color: var(--ph-ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ph-btn:hover,
.ph-btn:focus-visible {
  box-shadow: 0 14px 30px rgba(45, 50, 100, 0.18);
  transform: translateY(-2px);
}

.ph-btn--primary {
  background: linear-gradient(135deg, var(--ph-primary), var(--ph-primary-2));
  color: #fff;
}

.ph-btn--ghost {
  background: rgba(255, 255, 255, 0.7);
}

.ph-mascot {
  align-items: center;
  display: grid;
  justify-items: center;
  min-height: 220px;
  position: relative;
}

.ph-mascot__face {
  animation: ph-bounce 2.1s ease-in-out infinite;
  background: linear-gradient(135deg, #fff, #ffeec0);
  border: 8px solid rgba(124, 77, 255, 0.18);
  border-radius: 42% 58% 50% 50%;
  box-shadow: var(--ph-shadow);
  color: var(--ph-primary);
  display: grid;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 4.2rem;
  font-weight: 900;
  height: 160px;
  place-items: center;
  width: 160px;
  z-index: 2;
}

.ph-wave {
  animation: ph-wave 1.9s ease-out infinite;
  border: 4px solid rgba(0, 188, 212, 0.22);
  border-radius: 999px;
  height: 160px;
  position: absolute;
  width: 160px;
}

.ph-wave--two {
  animation-delay: 0.55s;
}

.ph-section-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 14px;
}

.ph-section-head span,
.ph-card-meta,
.ph-game-card small {
  color: var(--ph-muted);
  font-weight: 800;
}

.ph-category-grid,
.ph-game-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.ph-category-card,
.ph-game-card {
  min-width: 0;
}

.ph-category-card a,
.ph-game-card {
  background: var(--ph-card);
  border: 1px solid rgba(124, 77, 255, 0.13);
  border-radius: 28px;
  box-shadow: 0 14px 34px rgba(60, 70, 130, 0.12);
  color: var(--ph-ink);
  display: grid;
  gap: 9px;
  height: 100%;
  padding: 18px;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ph-category-card a:hover,
.ph-game-card:hover {
  box-shadow: var(--ph-shadow);
  transform: translateY(-4px);
}

.ph-category-card__icon {
  align-items: center;
  background: linear-gradient(135deg, #ffde7d, #ff8ec7);
  border-radius: 22px;
  color: #fff;
  display: flex;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 900;
  height: 74px;
  justify-content: center;
  width: 74px;
}

.ph-category-card p {
  color: var(--ph-muted);
  margin: 0;
}

.ph-meter,
.ph-progress {
  background: rgba(124, 77, 255, 0.12);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.ph-meter__fill,
.ph-progress__bar {
  background: linear-gradient(90deg, var(--ph-good), var(--ph-primary-2));
  border-radius: inherit;
  height: 100%;
  transition: width 0.28s ease;
}

.ph-game-card__type {
  background: rgba(124, 77, 255, 0.1);
  border-radius: 999px;
  color: #7159c8;
  font-size: 0.8rem;
  font-weight: 900;
  justify-self: start;
  padding: 6px 10px;
  text-transform: uppercase;
}

.ph-empty {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  padding: 20px;
}

.ph-player {
  background:
    radial-gradient(circle at top left, rgba(255, 222, 125, 0.45), transparent 30%),
    linear-gradient(180deg, #f6fbff, #fff8ef);
  border-radius: 32px;
  box-shadow: var(--ph-shadow);
  display: grid;
  gap: 18px;
  margin: 0 auto 24px;
  max-width: 1100px;
  padding: clamp(14px, 3vw, 28px);
}

.ph-player__top {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.ph-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.ph-hud span {
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(40, 50, 100, 0.1);
  font-weight: 900;
  padding: 8px 12px;
}

.ph-stage {
  display: grid;
  gap: 12px;
}

.ph-lesson-card {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(124, 77, 255, 0.1);
  border-radius: 34px;
  box-shadow: 0 16px 40px rgba(60, 70, 130, 0.12);
  display: grid;
  gap: 12px;
  justify-items: center;
  min-height: 480px;
  overflow: hidden;
  padding: clamp(16px, 3vw, 30px);
  position: relative;
}

.ph-sound-wave {
  display: flex;
  gap: 6px;
  height: 44px;
}

.ph-sound-wave span {
  animation: ph-sound 0.85s ease-in-out infinite;
  background: linear-gradient(180deg, var(--ph-primary), var(--ph-primary-2));
  border-radius: 999px;
  display: block;
  height: 22px;
  width: 10px;
}

.ph-sound-wave span:nth-child(2) {
  animation-delay: 0.12s;
}

.ph-sound-wave span:nth-child(3) {
  animation-delay: 0.24s;
}

.ph-big-letter {
  animation: ph-bounce 2.3s ease-in-out infinite;
  background: linear-gradient(135deg, #fff, #fff2bd);
  border: 10px solid rgba(124, 77, 255, 0.16);
  border-radius: 44px;
  box-shadow: 0 24px 54px rgba(124, 77, 255, 0.18);
  color: var(--ph-primary);
  cursor: pointer;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: clamp(5rem, 18vw, 11rem);
  font-weight: 900;
  line-height: 1;
  min-height: 190px;
  min-width: 190px;
  padding: 18px 34px;
}

.ph-phoneme {
  color: #ff7a59;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: clamp(2rem, 7vw, 4.2rem);
  font-weight: 900;
  margin: 0;
}

.ph-object {
  background: linear-gradient(135deg, #e8fff6, #eff3ff);
  border-radius: 24px;
  color: var(--ph-ink);
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 900;
  padding: 12px 24px;
}

.ph-prompt {
  color: var(--ph-muted);
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
  text-align: center;
}

.ph-options {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  max-width: 760px;
  width: 100%;
}

.ph-option {
  background: #fff;
  border: 3px solid transparent;
  border-radius: 24px;
  box-shadow: 0 12px 26px rgba(40, 50, 100, 0.12);
  color: var(--ph-ink);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  min-height: 82px;
  padding: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.ph-option:hover,
.ph-option:focus-visible {
  transform: translateY(-3px) scale(1.02);
}

.ph-option.is-correct {
  border-color: var(--ph-good);
}

.ph-option.is-wrong {
  border-color: #ff5a7a;
}

.ph-blend-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.ph-blend-chip {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 10px 22px rgba(40, 50, 100, 0.12);
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  padding: 10px 18px;
}

.ph-blend-chip.is-active {
  background: #fff1a6;
  transform: translateY(-5px);
}

.ph-trace {
  background: repeating-linear-gradient(0deg, rgba(124, 77, 255, 0.08), rgba(124, 77, 255, 0.08) 1px, transparent 1px, transparent 48px);
  border: 2px dashed rgba(124, 77, 255, 0.2);
  border-radius: 24px;
  max-width: 100%;
  touch-action: none;
}

.ph-reward {
  align-items: center;
  background: rgba(20, 24, 48, 0.48);
  border-radius: 32px;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 1000;
}

.ph-reward[hidden] {
  display: none;
}

.ph-reward__card {
  background: #fff;
  border-radius: 30px;
  box-shadow: var(--ph-shadow);
  max-width: 420px;
  padding: 26px;
  text-align: center;
}

.ph-stars {
  color: var(--ph-warn);
  font-size: 2.8rem;
  letter-spacing: 6px;
}

.ph-confetti {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 999;
}

.ph-confetti i {
  animation: ph-confetti 900ms ease-out forwards;
  background: var(--ph-primary);
  border-radius: 4px;
  display: block;
  height: 12px;
  left: 50%;
  position: absolute;
  top: 50%;
  width: 8px;
}

.ph-player.ph-high-contrast {
  --ph-ink: #000;
  --ph-muted: #111;
  --ph-card: #fff;
  background: #fff;
}

.ph-player.ph-dyslexia {
  font-family: "Comic Sans MS", "Trebuchet MS", "Nunito", system-ui, sans-serif;
  letter-spacing: 0.03em;
}

@keyframes ph-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes ph-wave {
  0% { opacity: 0.55; transform: scale(0.75); }
  100% { opacity: 0; transform: scale(1.55); }
}

@keyframes ph-sound {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1.6); }
}

@keyframes ph-confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(420deg); }
}

@keyframes ph-pop {
  0% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.7; transform: scale(1.18) rotate(4deg); }
  100% { opacity: 0.15; transform: scale(0.2) rotate(-10deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ph-hub *,
  .ph-player * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (max-width: 760px) {
  .ph-hero,
  .ph-player__top {
    grid-template-columns: 1fr;
  }

  .ph-hud {
    justify-content: start;
  }

  .ph-mascot {
    min-height: 140px;
  }

  .ph-mascot__face {
    font-size: 3rem;
    height: 120px;
    width: 120px;
  }

  .ph-lesson-card {
    min-height: 420px;
  }

  .ph-big-letter {
    min-height: 150px;
    min-width: 150px;
  }
}

/* Final category hub overrides: keep Phonics aligned with Writing Lab cards. */
body.dk-kids main.ph-hub--category {
  display: block;
  padding-bottom: 28px;
}

body.dk-kids main.ph-hub--category .ph-section-head {
  align-items: center;
  margin: 18px 0 12px;
}

body.dk-kids main.ph-hub--category .ph-section-head h2 {
  font-size: clamp(1.2rem, 3vw, 1.55rem);
}

body.dk-kids main.ph-hub--category #grid_container.ph-category-grid,
body.dk-kids main.ph-hub--category .ph-game-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)) !important;
  gap: 12px !important;
  align-items: stretch !important;
}

body.dk-kids main.ph-hub--category #grid_container.ph-category-grid .item,
body.dk-kids main.ph-hub--category .ph-game-grid .item {
  display: flex !important;
  flex-direction: column;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  position: relative;
  border-radius: var(--dk-radius-xl);
  border: 1px solid var(--dk-stroke);
  background: var(--dk-grid-item-bg);
  box-shadow: var(--dk-shadow);
  padding: 12px;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  min-width: 0;
}

body.dk-kids main.ph-hub--category .ph-game-grid .item::after {
  content: "";
  position: absolute;
  inset: -25% -45%;
  transform: translateX(-80%) rotate(6deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  opacity: 0;
  pointer-events: none;
}

body.dk-kids main.ph-hub--category #grid_container.ph-category-grid .item:hover,
body.dk-kids main.ph-hub--category .ph-game-grid .item:hover {
  transform: translateY(-3px);
  box-shadow: var(--dk-shadow-2);
  border-color: rgba(47,125,255,.22);
}

body.dk-kids main.ph-hub--category .ph-game-grid .item:hover::after {
  opacity: .9;
  animation: dkShine .9s ease forwards;
}

body.dk-kids main.ph-hub--category #grid_container.ph-category-grid .item:active,
body.dk-kids main.ph-hub--category .ph-game-grid .item:active {
  transform: translateY(-1px) scale(.99);
}

body.dk-kids main.ph-hub--category #grid_container.ph-category-grid .item a,
body.dk-kids main.ph-hub--category .ph-game-grid .item a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  flex: 1;
  width: 100%;
  min-height: 100%;
  color: var(--dk-ink);
  text-decoration: none;
  gap: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit;
}

body.dk-kids main.ph-hub--category .ph-game-grid .item a:focus-visible {
  outline: 3px solid rgba(47,125,255,.45);
  outline-offset: 4px;
  border-radius: 18px;
}

body.dk-kids main.ph-hub--category .ph-cat-icon-wrap {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  margin: 0 auto 8px;
}

body.dk-kids main.ph-hub--category .ph-cat-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body.dk-kids main.ph-hub--category .ph-game-grid .item .title {
  font-family: "Raleway", "HelveticaNeue", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(14px, 2.1vw, 17px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-top: 8px;
  color: var(--dk-ink);
}

@media (max-width: 30em) {
  body.dk-kids main.ph-hub--category #grid_container.ph-category-grid,
  body.dk-kids main.ph-hub--category .ph-game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 22em) {
  body.dk-kids main.ph-hub--category #grid_container.ph-category-grid,
  body.dk-kids main.ph-hub--category .ph-game-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Game-page shell: Phonics should live inside Kridopia's normal game chrome. */
.dk-game-page .ph-game-container {
  display: block;
  width: min(100%, calc(100vw - 48px));
  max-width: min(920px, calc(100vw - 48px));
  margin: 0 auto;
  box-sizing: border-box;
  overflow: visible;
}

.dk-game-page .ph-game-shell {
  width: 100%;
  max-width: 100%;
  min-height: min(82vh, 760px);
  position: relative;
  background: transparent;
}

.dk-game-page .ph-player {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  margin: 0;
  box-sizing: border-box;
  border-radius: var(--dk-radius-xl, 20px);
  overflow: hidden;
}

.dk-game-page .ph-lesson-card {
  min-height: clamp(300px, 42vh, 430px);
  gap: 8px;
  padding: clamp(12px, 2vw, 22px);
}

.dk-game-page .ph-big-letter {
  min-height: 138px;
  min-width: 138px;
  padding: 12px 24px;
  font-size: clamp(4.2rem, 10vw, 7rem);
}

.dk-game-page .ph-sound-wave {
  height: 34px;
}

.dk-game-page .ph-sound-wave span {
  height: 19px;
  width: 8px;
}

.dk-game-page .ph-phoneme {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.dk-game-page .ph-object {
  font-size: clamp(1.3rem, 3.4vw, 2.1rem);
  padding: 8px 20px;
}

.dk-game-page .ph-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 760px;
  overflow: visible;
}

.dk-game-page .ph-option {
  min-width: 0;
  min-height: 64px;
}

.dk-game-page .ph-option--balloon {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.95), transparent 24%),
    linear-gradient(135deg, #fff, #ffe6f2 55%, #e9f7ff);
  border-radius: 999px 999px 82% 82%;
  box-shadow: 0 16px 28px rgba(124, 77, 255, 0.14);
  min-height: 92px;
  position: relative;
  transform-origin: center bottom;
}

.dk-game-page .ph-option--balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 18px;
  height: 18px;
  background: #ffe6f2;
  border: 2px solid rgba(124, 77, 255, 0.08);
  border-radius: 4px;
  transform: translateX(-50%) rotate(45deg);
}

.dk-game-page .ph-option--balloon.is-popped {
  animation: ph-pop 320ms ease forwards;
}

.dk-game-page .ph-option--object {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-align: left;
}

.dk-game-page .ph-option__emoji {
  align-items: center;
  background: linear-gradient(135deg, #fff7d6, #e0f7ff);
  border-radius: 18px;
  display: inline-flex;
  font-size: 2rem;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.dk-game-page .ph-option--number {
  justify-content: center;
  text-align: center;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
}

.dk-game-page .ph-drop-target {
  outline: 4px dashed rgba(23, 185, 120, 0.45);
  outline-offset: 8px;
}

.dk-game-page .ph-game--drag .ph-object {
  background: linear-gradient(135deg, #ecfff6, #fff6d8);
}

.dk-game-page .ph-game--memory .ph-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 820px;
}

.dk-game-page .ph-memory-card {
  min-height: 96px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, #7c4dff, #00bcd4);
  box-shadow: 0 12px 26px rgba(40, 50, 100, 0.14);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  padding: 10px;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.dk-game-page .ph-memory-card:hover {
  transform: translateY(-3px);
}

.dk-game-page .ph-memory-card__front {
  display: none;
}

.dk-game-page .ph-memory-card__back {
  font-size: 2.4rem;
}

.dk-game-page .ph-memory-card.is-open,
.dk-game-page .ph-memory-card.is-matched {
  background: #fff;
  border: 3px solid rgba(124, 77, 255, 0.2);
  color: var(--ph-ink);
}

.dk-game-page .ph-memory-card.is-matched {
  border-color: var(--ph-good);
  opacity: 0.78;
}

.dk-game-page .ph-memory-card.is-open .ph-memory-card__back,
.dk-game-page .ph-memory-card.is-matched .ph-memory-card__back {
  display: none;
}

.dk-game-page .ph-memory-card.is-open .ph-memory-card__front,
.dk-game-page .ph-memory-card.is-matched .ph-memory-card__front {
  display: grid;
  gap: 2px;
}

.dk-game-page .ph-memory-card__front span {
  font-size: 1.8rem;
}

.dk-game-page .ph-memory-card__front small {
  color: var(--ph-muted);
  font-weight: 800;
}

.dk-game-page .ph-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  width: 100%;
  align-items: stretch;
}

.dk-game-page .ph-controls {
  justify-content: center;
}

.dk-game-page .ph-controls .ph-btn {
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  width: 100%;
}

.ph-worksheet-btn {
  margin-top: 10px;
  width: 100%;
}

@media (min-width: 44em) {
  .dk-game-page .ph-lesson-card {
    align-items: center;
    grid-template-columns: minmax(210px, 0.8fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto;
    justify-items: center;
  }

  .dk-game-page .ph-sound-wave {
    grid-column: 1;
    grid-row: 1;
  }

  .dk-game-page .ph-big-letter {
    grid-column: 1;
    grid-row: 2 / span 3;
  }

  .dk-game-page .ph-phoneme {
    grid-column: 1;
    grid-row: 5;
  }

  .dk-game-page .ph-object {
    grid-column: 1;
    grid-row: 6;
  }

  .dk-game-page .ph-blend-row {
    grid-column: 1 / -1;
    grid-row: 7;
  }

  .dk-game-page .ph-prompt {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
  }

  .dk-game-page .ph-options {
    grid-column: 2;
    grid-row: 3 / span 2;
    align-self: start;
  }

  .dk-game-page .ph-trace {
    grid-column: 2;
    grid-row: 5 / span 2;
  }

  .dk-game-page .ph-trace[hidden] {
    display: none;
  }
}

@media (max-width: 55em) {
  html,
  body.dk-game-page,
  body.dk-game-page #wrapper,
  body.dk-game-page #middle_column {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body.dk-game-page #middle_column {
    width: 100% !important;
    max-width: 100vw !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  body.dk-game-page .ph-play-page,
  body.dk-game-page #game_container.ph-game-container,
  body.dk-game-page #game.ph-game-shell {
    width: min(100%, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  body.dk-game-page #game_container.ph-game-container {
    margin: 0 auto !important;
    padding: 0 !important;
  }

  body.dk-game-page .ph-player {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 12px !important;
    border-radius: 18px;
    overflow-x: hidden;
  }

  body.dk-game-page .ph-player__top {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: center;
  }

  body.dk-game-page .ph-player__top > div:first-child {
    min-width: 0;
  }

  body.dk-game-page .ph-player__top h1 {
    font-size: clamp(1.45rem, 8vw, 2.1rem);
    overflow-wrap: anywhere;
  }

  body.dk-game-page .ph-kicker {
    font-size: 0.85rem;
    overflow-wrap: anywhere;
  }

  body.dk-game-page .ph-hud {
    grid-column: 1 / -1;
    justify-content: center;
  }

  body.dk-game-page .ph-hud span {
    flex: 1 1 92px;
    text-align: center;
    padding: 8px 10px;
  }

  body.dk-game-page .ph-lesson-card {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 14px 10px;
    border-radius: 22px;
    overflow-x: hidden;
  }

  body.dk-game-page .ph-big-letter {
    min-width: 0;
    width: min(58vw, 176px);
    min-height: 0;
    height: min(58vw, 176px);
    padding: 10px;
    border-width: 7px;
    border-radius: 30px;
    font-size: clamp(4rem, 28vw, 7rem);
  }

  body.dk-game-page .ph-phoneme {
    font-size: clamp(1.9rem, 12vw, 3rem);
  }

  body.dk-game-page .ph-object {
    max-width: 100%;
    font-size: clamp(1.35rem, 8vw, 2.2rem);
    overflow-wrap: anywhere;
  }

  body.dk-game-page .ph-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  body.dk-game-page .ph-game--memory .ph-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.dk-game-page .ph-option {
    min-width: 0;
    min-height: 64px;
    padding: 10px 8px;
    font-size: 1rem;
    overflow-wrap: anywhere;
  }

  body.dk-game-page .ph-trace {
    width: 100%;
    height: auto;
    max-height: 140px;
  }

  body.dk-game-page .ph-controls {
    justify-content: center;
    gap: 8px;
  }

  body.dk-game-page .ph-controls .ph-btn {
    flex: 1 1 130px;
    min-width: 0;
    padding: 10px 12px;
  }
}

@media (max-width: 25em) {
  body.dk-game-page .ph-player {
    padding: 10px 8px !important;
  }

  body.dk-game-page .ph-options {
    grid-template-columns: 1fr;
  }

  body.dk-game-page .ph-hud span {
    flex-basis: 100%;
  }
}
