@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap');

:root {
  --ink: #26233f;
  --muted: #77738e;
  --panel: #ffffff;
  --surface: #f6f5ff;
  --surface-2: #ece9ff;
  --line: #e4e0f6;
  --primary: #675fe9;
  --primary-dark: #4d46c7;
  --accent: #ffba55;
  --pink: #ff7fa8;
  --success: #52c79a;
  --shadow: 0 22px 70px rgba(47, 42, 96, 0.18);
  --radius-xl: 34px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--surface);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 12%, rgba(255, 186, 85, 0.17), transparent 22rem),
    radial-gradient(circle at 72% 85%, rgba(103, 95, 233, 0.14), transparent 28rem),
    var(--surface);
  font-family: "Nunito", Inter, ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(103, 95, 233, 0.25);
  outline-offset: 3px;
}


.screen {
  display: none;
  min-height: 100vh;
}

.screen.is-active {
  display: block;
}

.start-screen,
.selection-screen {
  min-height: 100svh;
  padding: clamp(18px, 3vw, 38px);
}

.start-inner,
.setup-container {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.start-inner {
  min-height: calc(100svh - clamp(36px, 6vw, 76px));
  display: grid;
  place-items: center;
}

.start-card {
  position: relative;
  isolation: isolate;
  width: min(820px, 100%);
  overflow: hidden;
  padding: clamp(42px, 7vw, 78px) clamp(24px, 6vw, 70px);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 42px;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 90px rgba(47, 42, 96, 0.18);
}

.start-card::before,
.start-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
}

.start-card::before {
  width: 280px;
  height: 280px;
  top: -165px;
  right: -65px;
  background: rgba(255, 186, 85, 0.22);
}

.start-card::after {
  width: 230px;
  height: 230px;
  left: -125px;
  bottom: -125px;
  background: rgba(103, 95, 233, 0.13);
}

.start-logo {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  border-radius: 29px;
  color: white;
  background: linear-gradient(145deg, var(--primary), #8d78ff);
  box-shadow: 0 18px 38px rgba(103, 95, 233, 0.32);
  font-size: 2.7rem;
}

.start-kicker,
.level-label {
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.start-card h1 {
  margin: 10px 0 0;
  font-size: clamp(3.25rem, 8vw, 6rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.start-card h1 span {
  color: var(--primary);
}

.start-card > p {
  max-width: 620px;
  margin: 24px auto 30px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.55;
}

.primary-setup-btn,
.setup-back-btn,
.text-action-btn,
.unit-select-card,
.change-units-btn {
  border: 0;
  cursor: pointer;
}

.primary-setup-btn {
  min-height: 54px;
  padding: 14px 24px;
  border-radius: 17px;
  color: white;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  box-shadow: 0 13px 30px rgba(103, 95, 233, 0.28);
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-setup-btn.large {
  min-height: 60px;
  padding-inline: 30px;
  font-size: 1.02rem;
}

.primary-setup-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 17px 36px rgba(103, 95, 233, 0.34);
}

.primary-setup-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

.start-features {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.start-features span {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #5e5978;
  background: #f2f0fa;
  font-size: 0.78rem;
  font-weight: 800;
}

.setup-container {
  padding-bottom: 30px;
}

.setup-topbar {
  min-height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.setup-back-btn,
.text-action-btn {
  color: var(--primary-dark);
  background: transparent;
  font-weight: 900;
}

.setup-back-btn {
  justify-self: start;
  padding: 10px 0;
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
}

.mini-brand span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--primary);
}

.setup-heading {
  max-width: 790px;
  margin: clamp(42px, 7vh, 78px) 0 34px;
}

.setup-heading h1 {
  margin: 8px 0 0;
  font-size: clamp(2.45rem, 6vw, 4.7rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.setup-heading p {
  max-width: 650px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
}

.level-block {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 20px 65px rgba(47, 42, 96, 0.1);
}

.level-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.level-heading-row h2 {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  font-weight: 900;
}

.selection-tools {
  display: flex;
  gap: 18px;
}

.text-action-btn {
  padding: 7px 0;
  font-size: 0.8rem;
}

.unit-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.unit-select-card {
  position: relative;
  min-width: 0;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 22px;
  color: var(--ink);
  text-align: left;
  background: #f2f0fa;
  box-shadow: 0 8px 24px rgba(47, 42, 96, 0.06);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.unit-select-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(47, 42, 96, 0.11);
}

.unit-select-card.is-selected {
  border-color: var(--primary);
  background: #efedff;
  box-shadow: 0 13px 32px rgba(103, 95, 233, 0.17);
}

.unit-select-topline {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unit-select-number,
.unit-select-check {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 900;
}

.unit-select-number {
  color: var(--primary-dark);
  background: white;
}

.unit-select-check {
  color: white;
  background: var(--primary);
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 150ms ease, transform 150ms ease;
}

.unit-select-card.is-selected .unit-select-check {
  opacity: 1;
  transform: scale(1);
}

.unit-select-icon {
  min-height: 54px;
  display: flex;
  align-items: center;
  margin-top: 13px;
  color: var(--primary);
  font-size: 2.45rem;
  font-weight: 900;
  line-height: 1;
}

.unit-select-card strong,
.unit-select-card small,
.unit-word-preview {
  display: block;
}

.unit-select-card strong {
  margin-top: 9px;
  font-size: 0.94rem;
  line-height: 1.15;
}

.unit-select-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.unit-word-preview {
  width: 100%;
  margin-top: auto;
  padding-top: 12px;
  overflow: hidden;
  color: #8a86a0;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
}

.selection-count {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.selected-set-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border-radius: 16px;
  background: #f5f3fc;
}

.selected-set-count {
  color: #5b5672;
  font-size: 0.76rem;
  font-weight: 900;
}

.selected-unit-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.selected-unit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 9px;
  color: #5d5875;
  background: white;
  font-size: 0.68rem;
  font-weight: 900;
}

.selected-unit-chip b {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: white;
  background: var(--primary);
  font-size: 0.61rem;
}

.change-units-btn {
  min-height: 39px;
  padding: 8px 12px;
  border-radius: 11px;
  color: var(--primary-dark);
  background: #e6e2ff;
  font-size: 0.71rem;
  font-weight: 900;
}

@media (max-width: 980px) {
  .unit-selection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .start-screen,
  .selection-screen {
    padding: 14px;
  }

  .start-card {
    border-radius: 30px;
  }

  .setup-topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-spacer {
    display: none;
  }

  .setup-heading {
    margin-top: 34px;
  }

  .level-heading-row,
  .setup-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .unit-selection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .unit-select-card {
    min-height: 190px;
  }

  .setup-actions .primary-setup-btn {
    width: 100%;
  }
}

@media (max-width: 390px) {
  .unit-selection-grid {
    grid-template-columns: 1fr;
  }

  .unit-select-card {
    min-height: 170px;
  }
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  transition: grid-template-columns 220ms ease;
}

.app-shell.panel-hidden {
  grid-template-columns: 0 minmax(0, 1fr);
}

.teacher-panel {
  position: relative;
  z-index: 10;
  min-width: 0;
  padding: 24px 22px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 44px rgba(54, 47, 105, 0.06);
  transition: opacity 180ms ease, transform 220ms ease;
}

.panel-hidden .teacher-panel {
  width: 0;
  height: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: white;
  font-size: 1.55rem;
  background: linear-gradient(145deg, var(--primary), #8d78ff);
  box-shadow: 0 10px 24px rgba(103, 95, 233, 0.3);
}

.brand h1 {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.control-section {
  margin-top: 25px;
}

.compact-section {
  display: grid;
  gap: 8px;
}

.section-heading-row {
  min-height: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.control-section h2 {
  margin: 0;
  color: #77738e;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border-radius: 16px;
  background: var(--surface-2);
}

.choice-btn,
.unit-btn,
.secondary-btn,
.text-btn,
.icon-btn,
.action-btn,
.card {
  border: 0;
  cursor: pointer;
}

.choice-btn {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #514d69;
  background: transparent;
  font-size: 0.86rem;
  font-weight: 900;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.choice-btn:hover,
.unit-btn:hover,
.secondary-btn:hover,
.action-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.choice-btn.is-active {
  color: white;
  background: var(--primary);
  box-shadow: 0 7px 16px rgba(103, 95, 233, 0.25);
}

.stacked-options {
  display: grid;
  gap: 8px;
}

.choice-btn.wide {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 39px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  text-align: left;
  color: var(--ink);
  background: #f4f2fc;
  border: 2px solid transparent;
  box-shadow: none;
}

.choice-btn.wide.is-active {
  color: var(--ink);
  background: #efedff;
  border-color: var(--primary);
}

.option-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--primary-dark);
  background: white;
  font-size: 0.95rem;
  font-weight: 900;
}

.choice-btn.wide strong,
.choice-btn.wide small {
  display: block;
}

.choice-btn.wide strong {
  font-size: 0.86rem;
}

.choice-btn.wide small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
}

.text-btn {
  padding: 3px 0;
  color: var(--primary-dark);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 900;
}

.unit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.unit-btn {
  min-height: 54px;
  display: grid;
  grid-template-columns: 29px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
  border-radius: 13px;
  color: #514d69;
  background: #f4f2fc;
  border: 2px solid transparent;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.unit-btn.is-active {
  color: var(--primary-dark);
  background: #efedff;
  border-color: var(--primary);
}

.unit-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #5b5673;
  background: white;
  font-size: 0.76rem;
  font-weight: 900;
}

.unit-btn.is-active .unit-number {
  color: white;
  background: var(--primary);
}

.unit-label {
  overflow: hidden;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.1;
}

.switch-row {
  position: relative;
  min-height: 57px;
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f2f0fa;
  cursor: pointer;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 0.8rem;
}

.switch-row small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 700;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: #cbc7dc;
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 7px rgba(34, 30, 65, 0.25);
  transition: transform 160ms ease;
}

.switch-row input:checked + .switch {
  background: var(--primary);
}

.switch-row input:checked + .switch::after {
  transform: translateX(18px);
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 22px;
}

.secondary-btn {
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 12px;
  color: #56516e;
  background: #eeecf7;
  font-size: 0.74rem;
  font-weight: 900;
  transition: transform 150ms ease, background 150ms ease;
}

.secondary-btn:hover {
  background: #e5e2f3;
}

.play-area {
  --card-max-width: 920px;
  --card-height: clamp(470px, calc(100svh - 300px), 680px);
  --emoji-size: clamp(10rem, 19vw, 17rem);
  --swatch-width: clamp(300px, 39vw, 500px);
  --shape-size: clamp(270px, 31vw, 390px);
  --number-width: clamp(340px, 42vw, 520px);
  --number-height: clamp(290px, 35vh, 390px);

  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px clamp(18px, 4vw, 56px) 24px;
  overflow: hidden;
}

/* Presentation mode: once the teacher panel is hidden, the card becomes the
   main classroom display and uses almost all available screen space. */
.panel-hidden .play-area {
  --card-max-width: 1220px;
  --card-height: clamp(500px, calc(100svh - 320px), 680px);
  --emoji-size: clamp(14rem, 27vw, 23rem);
  --swatch-width: clamp(420px, 48vw, 680px);
  --shape-size: clamp(360px, 39vw, 540px);
  --number-width: clamp(470px, 52vw, 720px);
  --number-height: clamp(380px, 45vh, 520px);

  padding-inline: clamp(24px, 4vw, 70px);
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.play-header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  font-weight: 900;
  letter-spacing: -0.035em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 24px rgba(47, 42, 96, 0.1);
  font-size: 1.15rem;
  transition: transform 150ms ease, background 150ms ease;
}

.show-panel-btn {
  display: none;
}

.panel-hidden .show-panel-btn {
  display: grid;
}

.progress-wrap {
  margin-top: 20px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(103, 95, 233, 0.12);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #9d7df4);
  transition: width 250ms ease;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 22px 0 16px;
  perspective: 1200px;
}

.card {
  width: min(var(--card-max-width), 96%);
  height: var(--card-height);
  min-height: 0;
  padding: 0;
  border-radius: var(--radius-xl);
  color: var(--ink);
  background: transparent;
  perspective: 1200px;
  transition: width 220ms ease, height 220ms ease;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(26px, 5vw, 54px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(249, 248, 255, 0.98));
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-face::before,
.card-face::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
}

.card-face::before {
  width: 180px;
  height: 180px;
  top: -100px;
  right: -55px;
  background: rgba(255, 186, 85, 0.17);
}

.card-face::after {
  width: 130px;
  height: 130px;
  left: -60px;
  bottom: -55px;
  background: rgba(103, 95, 233, 0.1);
}

.card-back {
  transform: rotateY(180deg);
}

.card-content {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(12px, 2vh, 22px);
}

.visual-wrap {
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.card-content.visual-content {
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
}

.visual-content .visual-wrap {
  height: 100%;
}

.image-visual-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.vocab-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 96%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 18px 18px rgba(38, 35, 63, 0.13));
}

.image-fallback {
  font-size: var(--emoji-size);
}

.panel-hidden .visual-content .card-label {
  display: none;
}

.panel-hidden .card-content.visual-content {
  grid-template-rows: minmax(0, 1fr);
}

.panel-hidden .vocab-image {
  max-width: 98%;
  max-height: 100%;
}

.visual {
  display: grid;
  place-items: center;
  font-size: var(--emoji-size);
  line-height: 0.92;
  filter: drop-shadow(0 16px 14px rgba(38, 35, 63, 0.12));
}

.word {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2.8rem, 8vw, 6.3rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.card-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.swatch {
  width: var(--swatch-width);
  max-height: 76%;
  aspect-ratio: 1.3;
  border: clamp(12px, 1.2vw, 18px) solid white;
  border-radius: clamp(42px, 4vw, 68px);
  box-shadow: 0 22px 52px rgba(38, 35, 63, 0.2), inset 0 0 0 2px rgba(38, 35, 63, 0.08);
}

.number-visual {
  width: var(--number-width);
  height: var(--number-height);
  display: grid;
  place-items: center;
  border-radius: clamp(50px, 5vw, 78px);
  color: white;
  background: linear-gradient(150deg, var(--primary), #9b7df4);
  box-shadow: 0 24px 56px rgba(103, 95, 233, 0.32);
  font-size: clamp(10rem, 20vw, 17rem);
  font-weight: 900;
  line-height: 1;
}

.shape-visual {
  width: var(--shape-size);
  height: var(--shape-size);
  filter: drop-shadow(0 22px 18px rgba(38, 35, 63, 0.17));
}

.shape-circle {
  border-radius: 50%;
  background: #ff7fa8;
}

.shape-square {
  border-radius: 32px;
  background: #675fe9;
}

.shape-triangle {
  width: 0;
  height: 0;
  border-left: calc(var(--shape-size) * 0.52) solid transparent;
  border-right: calc(var(--shape-size) * 0.52) solid transparent;
  border-bottom: calc(var(--shape-size) * 0.9) solid #ffba55;
}

.shape-rectangle {
  height: calc(var(--shape-size) * 0.64);
  border-radius: 30px;
  background: #52c79a;
}

.shape-star,
.shape-heart {
  display: grid;
  place-items: center;
  font-size: calc(var(--shape-size) * 0.92);
  line-height: 1;
}

.size-visual {
  width: min(82%, 760px);
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: clamp(28px, 5vw, 70px);
}

.size-object {
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  box-shadow: 0 12px 28px rgba(103, 95, 233, 0.25);
}

.size-object.big {
  width: clamp(210px, 24vw, 330px);
  height: clamp(210px, 24vw, 330px);
  border-radius: clamp(42px, 4vw, 68px);
}

.size-object.small {
  width: clamp(90px, 10vw, 145px);
  height: clamp(90px, 10vw, 145px);
  border-radius: clamp(24px, 2.5vw, 38px);
}

.size-object.long {
  width: min(72vw, 620px);
  height: clamp(76px, 8vw, 112px);
  border-radius: 99px;
}

.size-object.short {
  width: min(30vw, 250px);
  height: clamp(76px, 8vw, 112px);
  border-radius: 99px;
}


.panel-hidden .word {
  font-size: clamp(5rem, 10vw, 9rem);
}

.panel-hidden .card-label {
  font-size: clamp(0.82rem, 1vw, 1rem);
}

.panel-hidden .progress-wrap {
  margin-top: 14px;
}

.panel-hidden .stage {
  padding-block: 14px 12px;
}

.panel-hidden .keyboard-help {
  display: none;
}

.generator-mode .card-inner,
.generator-mode .card.is-flipped .card-inner {
  transform: none;
}

.generator-mode .card-back {
  display: none;
}

.generator-mode .card {
  cursor: default;
}

.action-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  min-width: 128px;
  min-height: 50px;
  padding: 13px 21px;
  border-radius: 17px;
  color: white;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 24px rgba(103, 95, 233, 0.24);
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.action-btn:hover {
  box-shadow: 0 13px 29px rgba(103, 95, 233, 0.3);
}

.secondary-action {
  color: var(--primary-dark);
  background: #e9e6fb;
  box-shadow: none;
}

.action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.keyboard-help {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid #d8d4e9;
  border-bottom-width: 3px;
  border-radius: 7px;
  color: #57526e;
  background: white;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 900;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 18px);
  padding: 11px 17px;
  border-radius: 13px;
  color: white;
  background: rgba(38, 35, 63, 0.94);
  box-shadow: 0 10px 35px rgba(38, 35, 63, 0.26);
  font-size: 0.82rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  }

  .play-area {
    padding-inline: 20px;
  }
}

@media (max-width: 760px) {
  .app-shell,
  .app-shell.panel-hidden {
    grid-template-columns: 1fr;
  }

  .teacher-panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(340px, 90vw);
    border-right: 1px solid var(--line);
    box-shadow: 18px 0 60px rgba(38, 35, 63, 0.22);
  }

  .panel-hidden .teacher-panel {
    transform: translateX(-105%);
  }

  .show-panel-btn {
    display: grid;
  }

  .play-area {
    min-height: 100svh;
    padding: 18px 14px 18px;
  }

  .play-area,
  .panel-hidden .play-area {
    --card-max-width: 720px;
    --card-height: clamp(360px, calc(100svh - 270px), 560px);
    --emoji-size: clamp(8rem, 30vw, 14rem);
    --swatch-width: clamp(240px, 58vw, 420px);
    --shape-size: clamp(220px, 52vw, 360px);
    --number-width: clamp(270px, 64vw, 470px);
    --number-height: clamp(230px, 34vh, 350px);
  }

  .stage {
    min-height: 0;
    padding: 18px 0 14px;
  }

  .card {
    width: min(var(--card-max-width), 98%);
    height: var(--card-height);
    min-height: 0;
  }

  .card-face {
    padding: 24px 18px;
  }

  .visual-wrap {
    min-height: 0;
  }

  .action-btn {
    min-width: 104px;
    padding-inline: 16px;
  }

  .keyboard-help {
    display: none;
  }
}

@media (max-width: 470px) {
  .play-header h2 {
    font-size: 1.35rem;
  }

  .progress-wrap {
    margin-top: 14px;
  }

  .play-area,
  .panel-hidden .play-area {
    --card-height: clamp(315px, calc(100svh - 255px), 470px);
    --emoji-size: clamp(7rem, 34vw, 11rem);
    --swatch-width: clamp(210px, 66vw, 330px);
    --shape-size: clamp(190px, 58vw, 290px);
    --number-width: clamp(235px, 70vw, 350px);
    --number-height: clamp(205px, 31vh, 290px);
  }

  .stage {
    min-height: 0;
    padding-top: 12px;
  }

  .card {
    height: var(--card-height);
    min-height: 0;
    border-radius: 26px;
  }

  .card-face {
    border-radius: 26px;
  }

  .visual-wrap {
    min-height: 0;
  }

  .word {
    font-size: clamp(2.45rem, 14vw, 4.5rem);
  }

  .action-bar {
    gap: 8px;
  }

  .action-btn {
    flex: 1;
    min-width: 0;
    min-height: 47px;
    padding: 11px 9px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ---------- Multi-level selector (Levels 1–3) ---------- */
.selection-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -8px 0 22px;
}

.level-quick-nav {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.level-jump-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #625d7b;
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-weight: 900;
}

.level-jump-btn small {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 8px;
  color: #827d99;
  background: #f0eef8;
  font-size: 0.68rem;
}

.level-jump-btn.has-selection {
  color: var(--primary-dark);
  border-color: rgba(103, 95, 233, 0.3);
  background: #f1efff;
}

.clear-all-btn {
  flex: 0 0 auto;
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
}

.clear-all-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.levels-container {
  display: grid;
  gap: 24px;
}

.level-block {
  scroll-margin-top: 18px;
  --level-accent: var(--primary);
  --level-soft: #efedff;
}

.level-block[data-level-theme="mint"] {
  --level-accent: #2a9f7f;
  --level-soft: #e8f8f2;
}

.level-block[data-level-theme="sun"] {
  --level-accent: #e58b2c;
  --level-soft: #fff3df;
}

.level-block[data-level-theme="ocean"] {
  --level-accent: #2f7ebd;
  --level-soft: #e9f4ff;
}

.level-block[data-level-theme="rose"] {
  --level-accent: #c85d85;
  --level-soft: #fff0f5;
}

.level-block .level-label {
  color: var(--level-accent);
}

.level-heading-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.level-block .text-action-btn {
  color: var(--level-accent);
}

.level-block .unit-select-card.is-selected {
  border-color: var(--level-accent);
  background: var(--level-soft);
  box-shadow: 0 13px 32px color-mix(in srgb, var(--level-accent) 18%, transparent);
}

.level-block .unit-select-check {
  background: var(--level-accent);
}

.level-block .unit-select-icon {
  color: var(--level-accent);
}

.level-block .unit-select-number {
  color: var(--level-accent);
}

.more-chip {
  color: var(--primary-dark);
  background: #ebe8ff;
}

@media (max-width: 680px) {
  .selection-overview {
    align-items: stretch;
    flex-direction: column;
  }

  .clear-all-btn {
    align-self: flex-start;
  }
}

/* =========================================================
   TUTORIAL LAYER
   Added on top of the v1.4 stylesheet. It does not alter
   the existing app layout or component selectors.
   ========================================================= */
.es-help-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9500;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  box-shadow: 0 14px 34px rgba(47, 42, 96, 0.30);
  cursor: pointer;
  font-weight: 900;
  font-size: 1.25rem;
}

.es-help-button:hover { transform: translateY(-2px); }
body.es-tutorial-running .es-help-button { visibility: hidden; }

.es-tutorial-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 32, 70, 0.58);
}

.es-tutorial-modal {
  width: min(520px, 100%);
  padding: 30px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(30, 26, 70, 0.30);
}

.es-tutorial-modal-kicker,
.es-tutorial-step-label {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.es-tutorial-modal h2 {
  margin: 7px 0 10px;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1.05;
}

.es-tutorial-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.es-tutorial-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.es-tutorial-primary,
.es-tutorial-secondary {
  min-height: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.es-tutorial-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
}

.es-tutorial-secondary {
  color: #5f5a77;
  background: #f0eef8;
}

/* A fixed transparent hole + giant shadow creates the dimmed screen
   without changing z-index/position of the real app control. */
.es-tutorial-spotlight {
  position: fixed;
  z-index: 9600;
  border: 4px solid #fff;
  border-radius: 18px;
  box-shadow:
    0 0 0 6px rgba(120, 109, 255, 0.96),
    0 0 0 9999px rgba(31, 28, 66, 0.72),
    0 18px 50px rgba(30, 26, 70, 0.35);
  pointer-events: none;
  transition: top 180ms ease, left 180ms ease, width 180ms ease, height 180ms ease;
}

.es-tutorial-bubble {
  position: fixed;
  z-index: 9700;
  width: min(390px, calc(100vw - 28px));
  padding: 20px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(25, 22, 60, 0.34);
}

.es-tutorial-bubble h3 {
  margin: 6px 0 7px;
  color: var(--ink);
  font-size: 1.35rem;
}

.es-tutorial-bubble p {
  margin: 0;
  color: #68637d;
  line-height: 1.55;
}

.es-tutorial-bubble-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.es-tutorial-hint {
  color: #8a859d;
  font-size: 0.73rem;
  font-weight: 800;
}

.es-tutorial-exit {
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  color: #6f6984;
  background: #f1eff8;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 900;
}

.es-help-sheet {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 32, 70, 0.58);
}

.es-help-card {
  width: min(570px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 28px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(30, 26, 70, 0.30);
}

.es-help-card h2 { margin: 5px 0 8px; }
.es-help-card > p { color: var(--muted); }
.es-help-menu { display: grid; gap: 10px; margin-top: 20px; }
.es-help-menu button,
.es-help-menu details {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #faf9ff;
  color: var(--ink);
  font: inherit;
}
.es-help-menu button {
  padding: 15px 16px;
  cursor: pointer;
  text-align: left;
  font-weight: 900;
}
.es-help-menu details summary {
  padding: 15px 16px;
  cursor: pointer;
  font-weight: 900;
}
.es-help-menu details ol {
  margin: 0 22px 18px 38px;
  padding: 0;
  color: var(--muted);
  line-height: 1.6;
}
.es-help-close-row { display: flex; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 700px) {
  .es-help-button { right: 14px; bottom: 14px; }
  .es-tutorial-bubble { padding: 17px; }
  .es-tutorial-modal, .es-help-card { padding: 22px; }
}

/* =========================================================
   v1.7 — RESPONSIVE VOCAB IMAGE FIT + FALLBACK PATCH
   Keep the entire vocabulary illustration visible at any
   preview/window ratio. The emoji fallback occupies the same
   grid cell and appears only when the image fails to load.
   ========================================================= */
.card-content.visual-content {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
}

.visual-content .visual-wrap {
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-visual-shell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px 18px 16px;
  overflow: hidden;
}

.vocab-image,
.image-fallback {
  grid-area: 1 / 1;
}

.image-fallback[hidden] {
  display: none !important;
}

.vocab-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.panel-hidden .card-content.visual-content {
  grid-template-rows: minmax(0, 1fr);
}

.panel-hidden .image-visual-shell {
  padding-top: 8px;
  padding-bottom: 12px;
}

/* =========================================================
   v1.9 — RESPONSIVE IMAGE FIT + SAFE FALLBACK
   Restore the v1.6 flex sizing behavior that keeps tall
   illustrations fully visible, while keeping the emoji
   fallback out of layout unless the Cloudinary image fails.
   ========================================================= */
.image-visual-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vocab-image {
  flex: 0 1 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-fallback[hidden] {
  display: none !important;
}


/* Last Bell Studio website integration */
.es-site-return {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 80;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.96);
  box-shadow: 4px 4px 0 rgba(47,42,96,.20);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}
.es-site-return:hover { transform: translate(-1px,-1px); }
.es-site-return:focus-visible { outline: 4px solid rgba(103,95,233,.28); outline-offset: 3px; }
.es-video-tutorial-link {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}
@media (max-width: 620px) {
  .es-site-return { top: 8px; left: 8px; min-height: 38px; padding: 7px 9px; font-size: .65rem; }
}


/* V13 QA: stronger unit-card separation while keeping the clean palette */
.unit-select-card { background:#ebe9f4; }
.unit-select-card:hover { background:#e7e4f2; }
.unit-btn { background:#ebe9f4; }

/* =========================================================
   V16 — persistent start action after unit selection
   ========================================================= */
.floating-start-btn{
  position:fixed;
  right:22px;
  bottom:88px;
  z-index:9400;
  min-height:54px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:0 20px;
  border:3px solid #302b63;
  border-radius:17px;
  background:#ffbf18;
  color:#302b63;
  box-shadow:5px 5px 0 #302b63,0 14px 34px rgba(47,42,96,.2);
  cursor:pointer;
  font-weight:900;
  letter-spacing:.04em;
  animation:floatingStartIn .28s cubic-bezier(.2,.8,.2,1);
}
.floating-start-btn[hidden]{display:none!important}
.floating-start-btn:hover{transform:translateY(-2px);background:#ffd04b}
.floating-start-btn:active{transform:translate(2px,2px);box-shadow:2px 2px 0 #302b63}
@keyframes floatingStartIn{from{opacity:0;transform:translateY(12px) scale(.94)}to{opacity:1;transform:none}}
body.es-tutorial-running .floating-start-btn{visibility:hidden}
@media(max-width:680px){
  .floating-start-btn{right:14px;bottom:78px;min-height:50px;padding:0 15px;font-size:.84rem}
}
@media(prefers-reduced-motion:reduce){.floating-start-btn{animation:none}}


/* V17.6 — keep Last Bell with Home / Fullscreen, outside flashcard content. */
.es-site-return{display:none!important}
.header-actions .es-last-bell-header{
  width:auto;
  min-width:44px;
  padding:0 12px;
  gap:6px;
  text-decoration:none;
  white-space:nowrap;
  font-size:.78rem;
  font-weight:900;
}
@media(max-width:720px){.header-actions .es-last-bell-header span{display:none}.header-actions .es-last-bell-header{padding:0;width:44px}}

/* Tutorial UI is a viewport overlay; opening it must not alter header/content geometry. */
.tutorial-layer,.tutorial-overlay,.tutorial-dimmer,.tutorial-highlight,.tutorial-card,
#tutorialHighlight,#tutorialCard{position:fixed!important;margin:0!important}
