:root {
  --bg: #eef3f0;
  --panel: #ffffff;
  --ink: #16211f;
  --muted: #60716c;
  --line: #d7e1dd;
  --brand: #117a72;
  --brand-dark: #0b5f59;
  --gold: #d99a2b;
  --red: #b9413b;
  --green: #23865f;
  --shadow: 0 16px 42px rgba(20, 48, 43, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.38)),
    radial-gradient(circle at 18% 8%, rgba(17, 122, 114, .14), transparent 32%),
    radial-gradient(circle at 82% 20%, rgba(217, 154, 43, .16), transparent 30%),
    var(--bg);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}

button:hover,
.file-button:hover {
  background: var(--brand-dark);
}

button.secondary,
.secondary {
  color: var(--brand);
  background: #e7f2f0;
  border: 1px solid #bcd8d4;
}

button.secondary:hover,
.secondary:hover {
  color: #fff;
  background: var(--brand);
}

button:disabled,
button:disabled:hover {
  color: #91a19c;
  border-color: #d7e1dd;
  background: #edf2f0;
  cursor: not-allowed;
}

button.danger {
  background: var(--red);
}

button.danger:hover {
  filter: brightness(.95);
}

button.icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 122, 114, .12);
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 390px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(215, 225, 221, .9);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 34% 30%, #fff 0 8%, transparent 9%),
    #151515;
  font-weight: 800;
}

.brand p {
  margin-top: 3px;
  font-size: 13px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  overflow-x: auto;
}

.nav-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

#cloudAccountBadge {
  flex: 0 0 auto;
  white-space: nowrap;
}

.nav-tab:hover,
.nav-tab.active {
  color: #fff;
  background: var(--brand);
}

.cloud-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f6faf8;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.cloud-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.cloud-status.connected,
.cloud-status.saved {
  color: var(--green);
  border-color: rgba(35, 134, 95, .28);
  background: #eefaf4;
}

.cloud-status.saving {
  color: #a66e12;
  border-color: rgba(217, 154, 43, .34);
  background: #fff8e7;
}

.cloud-status.saving .dot {
  animation: status-pulse 1s ease-in-out infinite;
}

.cloud-status.error,
.cloud-status.expired {
  color: var(--red);
  border-color: rgba(185, 65, 59, .3);
  background: #fff2f1;
}

.cloud-status.offline {
  color: #7a8682;
  background: #f2f5f4;
}

.cloud-diagnostics {
  position: fixed;
  top: 82px;
  right: 18px;
  z-index: 60;
  width: min(360px, calc(100vw - 28px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 16px 42px rgba(30, 45, 42, .16);
}

.cloud-diagnostics.hidden {
  display: none;
}

.security-note {
  display: block;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(217, 154, 43, .32);
  border-radius: 8px;
  color: #8a5a10;
  background: #fff8e7;
  font-size: 13px;
  font-weight: 700;
}

.cloud-diagnostics-head,
.diagnostic-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.diagnostic-state {
  margin: 10px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f7f6;
  font-weight: 800;
}

.diagnostic-state.connected,
.diagnostic-state.saved {
  color: var(--green);
  background: #eefaf4;
}

.diagnostic-state.saving {
  color: #a66e12;
  background: #fff8e7;
}

.diagnostic-state.error,
.diagnostic-state.expired {
  color: var(--red);
  background: #fff2f1;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 10px;
  margin: 0 0 12px;
  font-size: 13px;
}

.diagnostic-grid dt {
  color: var(--muted);
}

.diagnostic-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

main {
  padding: 18px;
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(380px, .95fr) minmax(420px, 1.05fr);
  gap: 28px;
  min-height: calc(100vh - 126px);
  overflow: hidden;
  padding: clamp(28px, 5vw, 72px);
  border: 1px solid rgba(255, 141, 121, .18);
  border-radius: 16px;
  background:
    linear-gradient(110deg, #fffdf6 0%, #fffaf0 48%, #fff2d9 100%),
    #fffaf0;
  box-shadow: 0 22px 60px rgba(119, 77, 42, .11);
}

.home-copy {
  display: grid;
  align-content: center;
  gap: 22px;
  max-width: 680px;
}

.home-badge {
  width: max-content;
  padding: 9px 16px;
  border: 1px solid rgba(255, 183, 77, .75);
  border-radius: 999px;
  color: #9b6500;
  background: rgba(255, 255, 255, .72);
  font-weight: 900;
}

.home-copy h2 {
  max-width: 650px;
  color: #312020;
  font-size: clamp(44px, 6.4vw, 82px);
  line-height: 1.08;
  font-weight: 950;
}

.home-copy p {
  max-width: 620px;
  color: #826665;
  font-size: 20px;
  line-height: 1.8;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.home-actions button {
  min-height: 54px;
  padding: 13px 24px;
  border-radius: 999px;
  background: #ff6d67;
  box-shadow: 0 18px 32px rgba(255, 109, 103, .25);
  font-weight: 900;
}

.home-actions button.secondary {
  color: #ff6d67;
  border-color: rgba(255, 109, 103, .46);
  background: #fff;
  box-shadow: none;
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 10px;
  max-width: 640px;
}

.home-stats div {
  display: grid;
  gap: 3px;
  padding: 13px;
  border: 1px solid rgba(255, 141, 121, .22);
  border-radius: 10px;
  background: rgba(255, 255, 255, .72);
}

.home-stats strong {
  color: #ff6d67;
  font-size: 28px;
}

.home-stats span {
  color: #826665;
  font-weight: 800;
}

.home-stage {
  position: relative;
  min-height: 560px;
}

.home-hero-cards {
  position: absolute;
  inset: 0;
}

.home-pet-card {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 210px;
  padding: 20px 18px 18px;
  border: 2px solid rgba(255, 189, 70, .55);
  border-radius: 18px;
  background: rgba(251, 247, 241, .92);
  box-shadow: 0 24px 54px rgba(102, 67, 45, .13);
  animation: home-card-float 5.6s ease-in-out infinite;
}

.home-pet-card img {
  width: 138px;
  height: 138px;
  object-fit: contain;
  filter: drop-shadow(0 16px 16px rgba(102, 67, 45, .16));
}

.home-pet-card span {
  padding: 4px 10px;
  border-radius: 999px;
  color: #1f8d61;
  background: #dff5e7;
  font-weight: 900;
  font-size: 13px;
}

.home-pet-card strong {
  font-size: 22px;
}

.home-pet-card b {
  color: #ff6d67;
  font-size: 28px;
}

.home-pet-card i {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff6d67, #ffd36d);
}

.home-pet-card.card-1 {
  top: 18%;
  left: 38%;
  z-index: 3;
}

.home-pet-card.card-2 {
  top: 6%;
  left: 4%;
  --r: -5deg;
  transform: rotate(var(--r));
  opacity: .9;
  animation-delay: -.8s;
}

.home-pet-card.card-3 {
  right: 2%;
  top: 18%;
  --r: 5deg;
  transform: rotate(var(--r));
  opacity: .92;
  animation-delay: -1.5s;
}

.home-float-note {
  position: absolute;
  z-index: 4;
  padding: 10px 17px;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 18px 34px rgba(102, 67, 45, .1);
  font-weight: 950;
  animation: home-note-float 4.8s ease-in-out infinite;
}

.home-float-note.reward {
  right: 3%;
  bottom: 16%;
  color: #23a56d;
}

.home-float-note.minus {
  left: 6%;
  top: 14%;
  color: #ff6d67;
  animation-delay: -1.2s;
}

.launch-intro {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: #fffaf0;
  animation: intro-bg 2.6s ease forwards;
}

.launch-intro.closing {
  pointer-events: none;
  animation: intro-out .75s ease forwards;
}

.launch-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 30px;
  text-align: center;
  animation: intro-pop .7s cubic-bezier(.2, 1.15, .22, 1);
}

.launch-card img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  filter: drop-shadow(0 22px 20px rgba(255, 109, 103, .18));
  animation: launch-pet 1.8s ease-in-out infinite;
}

.launch-card strong {
  color: #312020;
  font-size: clamp(28px, 5vw, 48px);
}

.launch-card span {
  color: #826665;
  font-size: 18px;
}

.launch-card button {
  margin-top: 6px;
  border-radius: 999px;
  background: #ff6d67;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#teacherView,
.two-column {
  display: none;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

#teacherView.active,
.view.active .two-column {
  display: grid;
}

.side-panel,
.work-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.side-panel {
  padding: 16px;
}

.work-panel {
  padding: 18px;
}

.work-panel.full {
  min-height: calc(100vh - 118px);
}

#storeView .two-column {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.panel-head,
.screen-toolbar,
.dialog-actions,
.select-actions,
.screen-actions,
.backup-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.screen-actions .pill {
  min-width: 64px;
  text-align: center;
}

.panel-head {
  margin-bottom: 14px;
}

.pill {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--brand);
  background: #e7f2f0;
  font-size: 13px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 16px;
}

.stats-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.stats-grid span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.stats-grid small {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.select-actions {
  justify-content: flex-start;
  margin: 8px 0 12px;
}

.select-actions button {
  min-height: 34px;
  padding: 6px 11px;
}

.pick-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 420px);
  overflow: auto;
  padding-right: 2px;
}

.pick-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.pick-row input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.pick-row strong {
  display: block;
}

.pick-row small {
  color: var(--muted);
}

.pick-row .level {
  color: var(--gold);
  font-weight: 800;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.rule-card,
.product-card,
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.rule-card {
  display: grid;
  align-content: space-between;
  min-height: 116px;
  padding: 13px;
  border-top: 4px solid var(--rule-color, var(--gold));
  text-align: left;
}

.rule-card small {
  color: var(--rule-color, var(--muted));
  font-weight: 800;
}

.rule-card strong {
  font-size: 16px;
}

.rule-card strong i {
  margin-right: 4px;
  font-style: normal;
}

.rule-card span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.rule-card.add {
  border-color: rgba(35, 134, 95, .35);
  background: #f0faf5;
  color: var(--ink);
}

.rule-card.minus {
  border-color: rgba(185, 65, 59, .28);
  background: #fff4f3;
  color: var(--ink);
}

.teacher-batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 14px;
}

.teacher-class-bar {
  display: flex;
  gap: 7px;
  margin-top: 8px;
  padding-bottom: 4px;
  overflow-x: auto;
}

.teacher-class-bar button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 10px;
}

.teacher-class-bar button.active {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.class-manage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.class-manage-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.teacher-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.teacher-search-row button {
  min-height: 42px;
  padding: 8px 10px;
}

.teacher-batch-bar button {
  min-height: 34px;
  padding: 6px 10px;
}

.teacher-wall-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.teacher-wall-head h3,
.teacher-wall-head p {
  margin: 0;
}

.teacher-wall-head h3 {
  font-size: 18px;
}

.teacher-pet-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 12px;
}

.teacher-pet-card {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 9px 10px;
  min-height: 214px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf7f1;
  box-shadow: 0 8px 18px rgba(20, 48, 43, .06);
  cursor: pointer;
}

.teacher-pet-card.selected {
  border-color: rgba(17, 122, 114, .55);
  background: #f0faf7;
  box-shadow: 0 10px 22px rgba(17, 122, 114, .13);
}

.teacher-pet-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  padding: 0;
}

.teacher-pet-card > img {
  grid-row: span 2;
  align-self: center;
  width: 74px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 8px 9px rgba(20, 48, 43, .12));
}

.teacher-pet-main {
  min-width: 0;
  padding-right: 24px;
}

.teacher-pet-main strong {
  display: block;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-pet-main span,
.teacher-pet-state span {
  color: var(--muted);
  font-size: 12px;
}

.teacher-pet-state {
  display: grid;
  align-content: start;
  gap: 2px;
}

.teacher-pet-state b {
  color: var(--gold);
}

.teacher-mini-meters {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
}

.teacher-mini-meters div {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.teacher-mini-meters i {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece9;
}

.teacher-mini-meters em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #58c891, #f0bd4f);
}

.teacher-mini-meters .exp-bar {
  background: linear-gradient(90deg, #54a6d9, #7bcf87);
}

.teacher-mini-meters b {
  color: var(--ink);
  text-align: right;
}

.teacher-card-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.teacher-card-actions button {
  min-height: 34px;
  padding: 6px;
  border-radius: 8px;
  font-size: 13px;
}

.teacher-card-actions button.minus {
  border-color: rgba(185, 65, 59, .28);
  color: #9f332f;
  background: #fff4f3;
}

.split {
  display: grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 14px;
  margin-top: 16px;
}

.teacher-actions-card {
  grid-column: 1 / -1;
}

.teacher-action-grid,
.rules-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.compact-card,
.card {
  padding: 14px;
}

.three-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.wide {
  width: 100%;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.screen-toolbar {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.screen-toolbar h2 {
  font-size: 28px;
}

.screen-password {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  align-items: end;
  gap: 10px;
  max-width: 420px;
  margin: -4px 0 14px;
  padding: 12px;
  border: 1px solid rgba(17, 122, 114, .22);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(20, 48, 43, .08);
}

.screen-password button {
  height: 42px;
}

.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.pet-card {
  position: relative;
  min-height: 414px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(251,247,241,.92), rgba(251,247,241,.98)),
    repeating-linear-gradient(0deg, transparent 0 29px, rgba(22,33,31,.05) 30px),
    repeating-linear-gradient(90deg, transparent 0 29px, rgba(22,33,31,.05) 30px);
  box-shadow: 0 10px 24px rgba(20, 48, 43, .08);
}

.pet-grid.teacher-mode .pet-card {
  border-color: rgba(17, 122, 114, .38);
  box-shadow: 0 12px 28px rgba(17, 122, 114, .14);
}

.level-burst {
  position: absolute;
  inset: -28px;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 230, 118, .85), transparent 22%),
    conic-gradient(from 0deg, transparent, rgba(255, 194, 66, .78), transparent, rgba(90, 209, 155, .72), transparent);
  filter: blur(2px);
  transform: scale(.65) rotate(0deg);
}

.pet-stage {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.pet-visual {
  position: relative;
  display: grid;
  place-items: center;
  height: 226px;
  margin-top: 22px;
  margin-bottom: 12px;
}

.pet-svg {
  width: 142px;
  height: 142px;
  animation: pet-idle 2.8s ease-in-out infinite;
  transform-origin: 50% 88%;
}

.character-thumb {
  width: min(224px, 94%);
  height: 224px;
  object-fit: contain;
  object-position: center;
  animation: pet-idle 2.8s ease-in-out infinite;
  transform-origin: 50% 88%;
  filter: drop-shadow(0 12px 12px rgba(20, 48, 43, .14));
}

.character-fallback {
  display: grid;
  place-items: center;
  width: 142px;
  height: 142px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-size: 34px;
  font-weight: 900;
}

.level-effect {
  position: absolute;
  width: 220px;
  height: 220px;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}

.pet-card.level-up .level-effect {
  animation: level-flash 1.1s ease-out;
}

.pet-card.level-up .level-burst {
  animation: level-burst 1.25s ease-out;
}

.pet-card.level-up .pet-svg {
  animation: pet-level 1s ease-out, pet-idle 2.8s ease-in-out 1s infinite;
}

.pet-card.rewarded .pet-svg {
  animation: pet-pop .55s ease-out, pet-idle 2.8s ease-in-out .55s infinite;
}

.pet-card.level-up .character-thumb {
  animation: pet-level 1s ease-out, pet-idle 2.8s ease-in-out 1s infinite;
}

.pet-card.rewarded .character-thumb {
  animation: pet-pop .55s ease-out, pet-idle 2.8s ease-in-out .55s infinite;
}

.level-up-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 238, 193, .62);
  backdrop-filter: blur(7px);
  animation: overlay-fade-in .18s ease-out;
}

.level-up-modal {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(420px, 92vw);
  overflow: hidden;
  padding: 24px 22px 22px;
  border: 1px solid rgba(217, 154, 43, .38);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 246, 174, .95), transparent 38%),
    linear-gradient(180deg, #fff8cc, #fff4a9);
  box-shadow: 0 24px 70px rgba(112, 74, 15, .22);
  animation: level-modal-pop .45s cubic-bezier(.2, 1.1, .22, 1);
}

.level-up-modal strong {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: clamp(42px, 8vw, 68px);
  line-height: 1;
  text-shadow: 0 4px 0 rgba(168, 121, 25, .72), 0 10px 24px rgba(140, 90, 12, .34);
}

.level-up-modal img {
  position: relative;
  z-index: 1;
  width: min(260px, 74vw);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(122, 83, 20, .2));
  animation: level-modal-pet 2.2s ease-in-out infinite;
}

.level-up-modal h3,
.level-up-modal p {
  position: relative;
  z-index: 1;
  margin: 0;
  text-align: center;
}

.level-up-modal h3 {
  font-size: 22px;
}

.level-up-modal p {
  color: #6e5a2e;
  font-weight: 800;
}

.level-up-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 19%, #fff 0 5px, transparent 6px),
    radial-gradient(circle at 82% 16%, #fff 0 6px, transparent 7px),
    radial-gradient(circle at 26% 38%, #ff75b7 0 4px, transparent 5px),
    radial-gradient(circle at 72% 42%, #ff75b7 0 4px, transparent 5px),
    radial-gradient(circle at 51% 18%, #ffd65a 0 5px, transparent 6px);
  animation: level-sparkle-drift 1.8s ease-in-out infinite alternate;
}

.screen-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.screen-card-actions button {
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  font-size: 15px;
}

.screen-card-actions button[data-screen-action="minus"] {
  color: #7b2e2e;
  border-color: rgba(180, 67, 67, .32);
  background: #fff7f4;
}

.student-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.student-line strong {
  font-size: 18px;
}

.pet-name {
  min-height: 22px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.meters {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.meter {
  display: grid;
  grid-template-columns: 44px 1fr 38px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.meter-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ece8;
}

.meter-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.meter-track .exp-bar {
  background: var(--gold);
}

.meter-track .coin-bar {
  background: var(--brand);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.store-controls {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(180px, 1fr) minmax(150px, 190px);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.store-student-field {
  margin: 0;
}

.store-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.store-tabs button {
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 6px;
  color: var(--brand);
  background: #fff;
}

.store-tabs button.active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.product-grid.catalog-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.petbook-grid {
  display: grid;
  gap: 18px;
}

.pet-atlas-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.pet-atlas-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.pet-atlas-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fbf7f1;
}

.pet-atlas-card p {
  font-size: 13px;
}

.beast-category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.beast-category-bar button {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--brand);
  background: #fff;
  font-size: 14px;
}

.beast-category-bar button.active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.store-beast-category-bar {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.pet-stage-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pet-stage-row span {
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  font-weight: 700;
}

.pet-stage-row span.active {
  border-color: rgba(17, 122, 114, .35);
  background: #e7f2f0;
  color: var(--brand);
}

.atlas-badge {
  display: inline-grid;
  place-items: center;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: #3498db;
  font-size: 12px;
  vertical-align: middle;
}

.beast-atlas-card {
  border-color: rgba(52, 152, 219, .34);
  box-shadow: 0 10px 24px rgba(52, 152, 219, .1);
}

.pet-stage-preview-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pet-stage-preview-row span {
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7f1;
  color: var(--muted);
  font-size: 11px;
}

.pet-stage-preview-row img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fbf7f1;
}

.animated-pet-demo {
  display: grid;
  grid-template-columns: minmax(220px, .42fr) minmax(320px, .58fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(20, 48, 43, .08);
}

.animated-pet-copy {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 260px;
}

.animated-pet-copy strong {
  font-size: 20px;
}

.animated-pet-copy span {
  color: var(--muted);
  line-height: 1.7;
}

.animated-pet-stage {
  position: relative;
  min-height: 320px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 76%, rgba(17, 122, 114, .16), transparent 32%),
    linear-gradient(180deg, #fbfefd, #edf5f2);
}

.animated-pet-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6%;
  z-index: 1;
  width: 54%;
  height: 12%;
  border-radius: 999px;
  background: radial-gradient(ellipse, rgba(20, 54, 48, .20), rgba(20, 54, 48, 0) 68%);
  transform: translateX(-50%) scale(1);
  animation: plushShadowIdle 4.8s ease-in-out infinite;
  pointer-events: none;
}

.animated-pet-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  filter: blur(.3px) saturate(.9);
}

.plush-pet-layer {
  position: absolute;
  left: 50%;
  bottom: -2%;
  z-index: 2;
  width: min(84%, 520px);
  max-height: 104%;
  object-fit: contain;
  transform: translateX(-50%) perspective(900px) rotateY(-5deg) rotateZ(-.5deg) translateY(0) scale(1);
  transform-origin: 50% 82%;
  filter: drop-shadow(0 18px 22px rgba(21, 50, 45, .18));
  animation: plushPetIdle 4.8s ease-in-out infinite;
  pointer-events: none;
}

.petbook-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf7f1;
  box-shadow: 0 10px 24px rgba(20, 48, 43, .08);
}

.petbook-grid h3 {
  margin-bottom: 12px;
}

.petbook-grid img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #fbf7f1;
}

.character-layout {
  grid-template-columns: 360px 1fr;
}

.character-preview {
  display: grid;
  place-items: center;
  height: 300px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 76%, rgba(17, 122, 114, .12), transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(232,242,240,.72));
}

.character-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.pet-choice-preview-img {
  width: min(86%, 270px);
  max-height: 270px;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  background: transparent;
  filter: drop-shadow(0 18px 20px rgba(20, 48, 43, .14));
  animation: petPreviewIdle 4.8s ease-in-out infinite;
}

.assign-target-panel {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfa;
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pick-list.compact {
  max-height: 190px;
}

.pick-row.compact {
  grid-template-columns: auto 1fr;
  padding: 8px;
}

.compact-empty {
  padding: 14px;
  font-size: 13px;
}

.rules-config-grid {
  margin-bottom: 16px;
}

.classroom-rules-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.classroom-rule-editor {
  display: grid;
  gap: 12px;
}

.classroom-rule-editor-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--rule-color, var(--gold));
  border-radius: 10px;
  background: #fbfcfb;
}

.classroom-rule-editor-head,
.classroom-rule-scope {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.classroom-rule-editor-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.classroom-rule-editor-head > div {
  display: flex;
  gap: 6px;
}

.classroom-rule-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 9px;
}

.classroom-rule-scope {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.classroom-rule-scope strong {
  margin-right: 4px;
}

.rule-mini-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.rule-mini-list span {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--ink);
  font-size: 13px;
}

.character-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.character-meta strong {
  font-size: 18px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.character-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf7f1;
  text-align: left;
  color: var(--ink);
}

.character-card.active {
  outline: 3px solid rgba(17, 122, 114, .24);
  border-color: var(--brand);
}

.character-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 0;
  background: #fbf7f1;
  filter: drop-shadow(0 10px 12px rgba(20, 48, 43, .12));
}

.character-card strong {
  font-size: 14px;
}

.character-card span {
  color: var(--muted);
  font-size: 12px;
}

.character-filter.active {
  color: #fff;
  background: var(--brand);
}

.product-card {
  padding: 14px;
}

.catalog-card {
  display: grid;
  gap: 8px;
  align-content: start;
  background: #fbf7f1;
}

.store-item-image,
.store-item-token {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background: #fbf7f1;
}

.store-item-image {
  object-fit: contain;
  object-position: center;
  padding: 8px;
  filter: drop-shadow(0 10px 14px rgba(20, 48, 43, .14));
}

.store-item-token {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
}

.store-item-title {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
}

.store-item-title h3 {
  min-width: 0;
  font-size: 17px;
}

.store-item-title span {
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
  background: #3498db;
  font-size: 12px;
  font-weight: 800;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0;
  color: var(--muted);
}

.manage-list,
.stack-form {
  display: grid;
  gap: 10px;
}

.manage-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.manage-hint {
  padding: 10px;
  border: 1px dashed rgba(17, 122, 114, .3);
  border-radius: 8px;
  color: var(--muted);
  background: #f7fbfa;
  font-size: 13px;
}

.beast-manage-item {
  grid-template-columns: 48px 1fr minmax(78px, 96px) auto;
}

.beast-manage-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 6px;
  background: #f5f7f7;
}

.mini-field {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mini-field input {
  min-height: 34px;
  padding: 5px 8px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.account-panel {
  margin-top: 18px;
}

.account-password-form {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  align-items: end;
}

.account-user-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.account-user-row {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 240px) auto;
}

.spaced {
  margin-top: 16px;
}

.data-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f6f9f8;
  font-size: 13px;
}

td.actions {
  white-space: nowrap;
}

td.actions button {
  min-height: 32px;
  padding: 5px 10px;
}

.rank-board {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 20px rgba(20, 48, 43, .08);
}

.rank-no {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}

.backup-actions {
  justify-content: flex-start;
  margin: 14px 0;
}

.file-button input {
  display: none;
}

.hidden {
  display: none !important;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(11, 31, 28, .38);
}

.dialog-card {
  min-width: 320px;
  padding: 18px;
}

.dialog-card h2 {
  margin-bottom: 16px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

body.performance-smooth {
  --shadow: 0 6px 16px rgba(20, 48, 43, .08);
  background: var(--bg);
}

body.performance-smooth *,
body.performance-smooth *::before,
body.performance-smooth *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: .01ms !important;
}

body.performance-smooth .home-float-note,
body.performance-smooth .level-effect,
body.performance-smooth .level-burst,
body.performance-smooth .level-up-overlay,
body.performance-smooth .launch-intro {
  display: none !important;
}

body.performance-smooth .side-panel,
body.performance-smooth .work-panel,
body.performance-smooth .screen-toolbar,
body.performance-smooth .pet-card,
body.performance-smooth .teacher-pet-card,
body.performance-smooth .card,
body.performance-smooth .product-card {
  box-shadow: none !important;
}

body.performance-smooth .character-thumb,
body.performance-smooth .teacher-pet-card > img,
body.performance-smooth .store-item-image,
body.performance-smooth .petbook-grid img {
  filter: none !important;
}

body.performance-smooth .pet-card {
  min-height: 366px;
  background: #fbf7f1;
}

body.performance-smooth .pet-visual {
  height: 184px;
  margin-bottom: 8px;
}

body.performance-smooth .character-thumb {
  width: min(184px, 90%);
  height: 184px;
}

body.performance-smooth .pet-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

body.performance-smooth .teacher-pet-wall {
  grid-template-columns: repeat(auto-fill, minmax(214px, 1fr));
  gap: 9px;
}

body.performance-show .pet-card {
  box-shadow: 0 18px 42px rgba(20, 48, 43, .14);
}

body.performance-show .character-thumb {
  filter: drop-shadow(0 16px 16px rgba(20, 48, 43, .18));
}

@keyframes pet-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.012); }
}

@keyframes status-pulse {
  0%, 100% { opacity: .42; transform: scale(.82); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes pet-pop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-6px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pet-level {
  0% { transform: translateY(0) scale(1) rotate(0); }
  35% { transform: translateY(-8px) scale(1.12) rotate(-3deg); }
  70% { transform: translateY(-2px) scale(1.05) rotate(3deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}

@keyframes level-flash {
  0% { opacity: 0; transform: scale(.68) rotate(0); }
  25% { opacity: 1; transform: scale(1) rotate(18deg); }
  100% { opacity: 0; transform: scale(1.35) rotate(80deg); }
}

@keyframes level-burst {
  0% { opacity: 0; transform: scale(.45) rotate(0deg); }
  18% { opacity: .95; }
  100% { opacity: 0; transform: scale(1.18) rotate(140deg); }
}

@keyframes overlay-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes level-modal-pop {
  0% { opacity: 0; transform: translateY(16px) scale(.86); }
  70% { opacity: 1; transform: translateY(-4px) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes level-modal-pet {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.035); }
}

@keyframes level-sparkle-drift {
  from { transform: translateY(0) scale(1); opacity: .78; }
  to { transform: translateY(-10px) scale(1.04); opacity: 1; }
}

@keyframes home-card-float {
  0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
  50% { transform: translateY(-14px) rotate(var(--r, 0deg)); }
}

@keyframes home-note-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes intro-pop {
  from { opacity: 0; transform: translateY(18px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes launch-pet {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.03); }
}

@keyframes intro-bg {
  from { background: #fffaf0; }
  to { background: rgba(255, 250, 240, .96); }
}

@keyframes intro-out {
  to { opacity: 0; transform: scale(1.02); }
}

@keyframes plushPetIdle {
  0%, 100% {
    transform: translateX(-50%) perspective(900px) rotateY(-5deg) rotateZ(-.5deg) translateY(0) scale(1);
  }
  45% {
    transform: translateX(-50%) perspective(900px) rotateY(5deg) rotateZ(.6deg) translateY(-8px) scale(1.018);
  }
  70% {
    transform: translateX(-50%) perspective(900px) rotateY(1deg) rotateZ(.2deg) translateY(-3px) scale(1.006);
  }
}

@keyframes petPreviewIdle {
  0%, 100% {
    transform: perspective(900px) rotateY(-4deg) rotateZ(-.4deg) translateY(0) scale(1);
  }
  45% {
    transform: perspective(900px) rotateY(4deg) rotateZ(.5deg) translateY(-7px) scale(1.018);
  }
  70% {
    transform: perspective(900px) rotateY(1deg) rotateZ(.15deg) translateY(-3px) scale(1.006);
  }
}

@keyframes plushShadowIdle {
  0%, 100% {
    opacity: .86;
    transform: translateX(-50%) scale(1);
  }
  45% {
    opacity: .62;
    transform: translateX(-50%) scale(.92);
  }
  70% {
    opacity: .74;
    transform: translateX(-50%) scale(.96);
  }
}

@media (max-width: 1400px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .nav-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 1050px) {

  #teacherView.active,
  .view.active .two-column,
  .home-hero,
  .character-layout,
  .animated-pet-demo,
  .split {
    grid-template-columns: 1fr;
  }

  .home-stage {
    min-height: 420px;
  }

  .home-pet-card.card-1 {
    left: 34%;
  }

  .animated-pet-copy {
    min-height: auto;
  }

  .pick-list {
    max-height: 320px;
  }

  .store-controls {
    grid-template-columns: 1fr;
  }

  .store-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  main {
    padding: 10px;
  }

  .app-header {
    padding: 12px;
  }

  .cloud-diagnostics {
    top: 104px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .diagnostic-grid {
    grid-template-columns: 76px 1fr;
  }

  .three-cols {
    grid-template-columns: 1fr;
  }

  .classroom-rule-fields {
    grid-template-columns: 1fr 1fr;
  }

  .pet-grid,
  .product-grid,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
    padding: 20px;
  }

  .home-copy h2 {
    font-size: 42px;
  }

  .home-copy p {
    font-size: 17px;
  }

  .home-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-stage {
    min-height: 620px;
  }

  .home-pet-card {
    width: min(230px, 82vw);
  }

  .home-pet-card.card-1,
  .home-pet-card.card-2,
  .home-pet-card.card-3 {
    left: 50%;
    right: auto;
    transform: translateX(-50%) rotate(var(--r, 0deg));
  }

  .home-pet-card.card-1 { top: 190px; }
  .home-pet-card.card-2 { top: 0; }
  .home-pet-card.card-3 { top: 385px; }

  .home-float-note.minus {
    left: 0;
    top: 142px;
  }

  .home-float-note.reward {
    right: 0;
    bottom: 8px;
  }

  .animated-pet-demo {
    padding: 12px;
  }

  .animated-pet-stage {
    min-height: 260px;
    aspect-ratio: 1 / 1;
  }
}
