body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f7fb;
  color: #222;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.container.small {
  max-width: 420px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

label {
  display: block;
  font-weight: 600;
  margin-top: 8px;
}

input, button, select {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #cfd6e0;
}

button {
  background: #2f6fed;
  color: white;
  border: none;
  cursor: pointer;
}

button:hover {
  background: #265fd1;
}

.button-inline {
  width: auto;
  min-width: 120px;
}

.message {
  min-height: 1.2em;
}

.hint {
  color: #58657a;
  font-size: 0.95rem;
}

.score-badge {
  display: inline-block;
  background: #eef4ff;
  color: #1846a3;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  margin: 6px 0 0;
  position: relative;
  overflow: visible;
}

.score-badge.score-pop {
  animation: score-pop 520ms ease;
}

.score-badge.score-pop::after {
  content: attr(data-delta);
  position: absolute;
  top: -18px;
  right: 6px;
  font-size: 0.85rem;
  color: #0f7b39;
  animation: delta-float 780ms ease forwards;
}

.companion-settings-card {
  margin-bottom: 8px;
}

.companion-spoiler summary,
#pointsLogSpoiler summary,
#vocabSpoiler summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.companion-spoiler summary::-webkit-details-marker,
#pointsLogSpoiler summary::-webkit-details-marker,
#vocabSpoiler summary::-webkit-details-marker {
  display: none;
}

.companion-spoiler summary::after {
  content: '▾';
  color: #58657a;
  font-size: 1rem;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.companion-spoiler[open] summary::after {
  transform: rotate(180deg);
}

.setting-intro {
  margin: 0 0 6px;
}

.pet-sticky-shell {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 0 16px;
}

.companion-card {
  overflow: visible;
  background: linear-gradient(135deg, #ffffff 0%, #f6f9ff 100%);
}

.pet-sticky-card {
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 30px rgba(30, 56, 119, 0.12);
  border: 1px solid rgba(219, 229, 244, 0.92);
}

.pet-panel {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.pet-avatar {
  --pet-surface-top: rgba(255,255,255,0.95);
  --pet-surface-bottom: rgba(224,235,255,0.8);
  --pet-shadow-color: rgba(47,111,237,0.16);
  --pet-body-color: #ffb44d;
  --pet-ear-color: #f58b54;
  --pet-accessory-color: rgba(255,255,255,0.9);
  --pet-cheek-color: rgba(255, 124, 124, 0.42);
  width: 150px;
  min-width: 150px;
  border-radius: 28px;
  background: radial-gradient(circle at top, var(--pet-surface-top), var(--pet-surface-bottom));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 14px 34px var(--pet-shadow-color);
  padding: 12px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.pet-avatar[data-color="sunset"] {
  --pet-surface-bottom: rgba(255, 237, 219, 0.9);
  --pet-shadow-color: rgba(255, 160, 68, 0.22);
  --pet-body-color: #ffb44d;
  --pet-ear-color: #f58b54;
  --pet-accessory-color: rgba(255,255,255,0.9);
}

.pet-avatar[data-color="mint"] {
  --pet-surface-bottom: rgba(222, 255, 244, 0.92);
  --pet-shadow-color: rgba(37, 169, 123, 0.2);
  --pet-body-color: #6ed8b2;
  --pet-ear-color: #33b28b;
  --pet-accessory-color: rgba(19, 110, 85, 0.5);
}

.pet-avatar[data-color="berry"] {
  --pet-surface-bottom: rgba(255, 227, 238, 0.92);
  --pet-shadow-color: rgba(195, 73, 122, 0.22);
  --pet-body-color: #f07ca8;
  --pet-ear-color: #d75485;
  --pet-accessory-color: rgba(122, 28, 68, 0.42);
}

.pet-avatar[data-color="violet"] {
  --pet-surface-bottom: rgba(236, 232, 255, 0.94);
  --pet-shadow-color: rgba(105, 87, 204, 0.24);
  --pet-body-color: #9c8df2;
  --pet-ear-color: #7867dc;
  --pet-accessory-color: rgba(76, 56, 177, 0.44);
}

.pet-avatar[data-color="ocean"] {
  --pet-surface-bottom: rgba(225, 244, 255, 0.95);
  --pet-shadow-color: rgba(29, 120, 189, 0.22);
  --pet-body-color: #68c0f6;
  --pet-ear-color: #3197d6;
  --pet-accessory-color: rgba(26, 92, 147, 0.44);
}

.pet-avatar svg {
  display: block;
  width: 100%;
  height: auto;
}

.pet-shadow {
  fill: rgba(55, 76, 119, 0.18);
}

.pet-body,
.pet-ear,
.pet-accessory,
.pet-cheek,
.pet-eye,
.pet-mouth {
  transition: transform 0.25s ease, fill 0.25s ease, stroke 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}

.pet-body {
  fill: var(--pet-body-color);
}

.pet-ear {
  fill: var(--pet-ear-color);
}

.pet-eye {
  fill: #2a2e3a;
}

.pet-mouth {
  fill: none;
  stroke: #2a2e3a;
  stroke-width: 5;
  stroke-linecap: round;
}

.pet-cheek {
  fill: var(--pet-cheek-color);
}

.pet-accessory {
  fill: none;
  stroke: var(--pet-accessory-color);
  stroke-width: 5;
  stroke-linecap: round;
}

.pet-avatar[data-skin="cat"] .pet-accessory {
  stroke-width: 4;
  stroke-dasharray: 6 6;
}

.pet-avatar[data-skin="star"] .pet-accessory {
  stroke-width: 6;
}

.pet-avatar[data-mood="happy"],
.pet-avatar[data-mood="celebrate"] {
  transform: translateY(-3px) scale(1.02);
}

.pet-avatar[data-mood="sad"] {
  filter: saturate(0.85);
}

.pet-avatar[data-mood="thinking"] .pet-eye {
  transform: scaleY(0.55);
}

.pet-avatar[data-mood="celebrate"] {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 16px 38px rgba(255,185,54,0.28);
  animation: pet-bounce 760ms ease;
}

.pet-copy {
  flex: 1;
  min-width: 0;
}

.pet-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pet-title-row h2 {
  margin: 0;
}

.pet-mood-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: #eef4ff;
  color: #1846a3;
}

.pet-bubble {
  position: relative;
  margin: 12px 0 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #dbe5f4;
  box-shadow: 0 10px 24px rgba(30, 56, 119, 0.08);
}

.pet-bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 18px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-left: 1px solid #dbe5f4;
  border-bottom: 1px solid #dbe5f4;
  transform: rotate(45deg);
}

.companion-settings {
  display: grid;
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.sound-toggle {
  width: 100%;
}

.setting-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-weight: 600;
}

.setting-check input {
  width: auto;
  margin: 0;
}

.setting-hint {
  margin: 4px 0 0;
}

.card.effect-glow {
  animation: card-glow 760ms ease;
}

.effect-shake {
  animation: card-shake 440ms ease;
}

.message.is-success {
  color: #0f7b39;
  font-weight: 700;
}

.message.is-error {
  color: #ad2d2d;
  font-weight: 700;
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.fx-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  left: 0;
  top: 0;
  border-radius: 999px;
  background: var(--particle-color, #2f6fed);
  box-shadow: 0 0 10px color-mix(in srgb, var(--particle-color, #2f6fed) 75%, white);
  opacity: 0;
  animation: particle-flight 720ms ease-out forwards;
}

.log-list {
  display: grid;
  gap: 12px;
}

.points-log-card {
  margin-top: 24px;
}

.vocab-card {
  margin-top: 24px;
}

.spoiler-content {
  margin-top: 16px;
}

.vocab-list {
  display: grid;
  gap: 14px;
}

.vocab-entry {
  border: 1px solid #d9e0eb;
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfe;
}

.vocab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.vocab-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.vocab-actions .button-inline {
  margin: 0;
}

.danger-btn {
  background: #cf3c3c;
}

.danger-btn:hover {
  background: #b22e2e;
}

.log-entry {
  border: 1px solid #d9e0eb;
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfe;
}

.log-entry.ok {
  border-left: 6px solid #1f9d55;
}

.log-entry.wrong {
  border-left: 6px solid #f0a020;
}

.log-entry p {
  margin: 6px 0;
}

.log-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination .button-inline {
  margin: 0;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: default;
}

.success {
  color: #0f7b39;
  font-weight: 700;
}

code {
  background: #eef2f8;
  padding: 2px 6px;
  border-radius: 6px;
}

@keyframes score-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes delta-float {
  0% { opacity: 0; transform: translateY(6px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

@keyframes pet-bounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-6px) scale(1.04); }
  100% { transform: translateY(-3px) scale(1.02); }
}

@keyframes card-glow {
  0% { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
  35% { box-shadow: 0 0 0 4px rgba(47,111,237,0.16), 0 14px 30px rgba(47,111,237,0.18); }
  100% { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
}

@keyframes card-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes particle-flight {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.6);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx, 0px), var(--dy, -36px), 0) scale(0.2) rotate(var(--rot, 180deg));
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .pet-sticky-shell {
    top: 0;
  }

  .pet-avatar {
    width: 112px;
    min-width: 112px;
    margin: 0;
  }

  .pet-panel {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .score-badge.score-pop,
  .card.effect-glow,
  .effect-shake,
  .pet-avatar[data-mood="celebrate"],
  .fx-particle {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

body.reduced-effects .score-badge.score-pop,
body.reduced-effects .card.effect-glow,
body.reduced-effects .effect-shake,
body.reduced-effects .pet-avatar[data-mood="celebrate"],
body.reduced-effects .fx-particle {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

body.reduced-effects .fx-layer {
  display: none;
}

