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

:root {
  --blue: #729bd8;
  --blue-dark: #466b9f;
  --blue-light: #e5efff;
  --background: #f3f6fc;
  --white: #ffffff;
  --text: #28364d;
  --muted: #8996aa;
  --border: #e8edf5;
  --shadow: 0 8px 28px rgba(68, 94, 137, 0.08);
  --danger: #d66c75;
  --danger-light: #fff0f1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  padding: 20px 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

button:active {
  transform: scale(0.97);
}

button:focus-visible {
  outline: 3px solid rgba(114, 155, 216, 0.35);
  outline-offset: 3px;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  animation: pageEnter 0.35s ease both;
}

.page-hidden {
  display: none !important;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* TOPBAR */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-icon {
  color: var(--blue);
  font-size: 25px;
}

.menu-button {
  background: var(--white);
  color: var(--text);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 20px;
  box-shadow: var(--shadow);
}

.menu-button:hover {
  background: var(--blue-light);
}

/* CHARACTER COMPANION */

.companion-card {
  background: linear-gradient(135deg, #dceaff, #eff5ff);
  border: 1px solid #e2ebfa;
  border-radius: 24px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 185px;
  overflow: hidden;
  margin-bottom: 18px;
  animation: cardEnter 0.5s ease both;
}

.character-placeholder {
  position: relative;
  flex: 0 0 42%;
  width: 42%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 18px;
  background: linear-gradient(160deg, #a9c9f2, #d7e7ff);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.character-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  animation: characterEnter 0.45s ease both;
}

@keyframes characterEnter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialogue {
  flex: 1;
  min-width: 0;
}

.dialogue-name {
  color: var(--blue-dark);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
}

.dialogue h2 {
  font-size: 18px;
  line-height: 1.3;
  margin: 7px 0;
}

.dialogue p {
  color: #687c99;
  font-size: 12px;
  line-height: 1.5;
}

.talk-button {
  background: transparent;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 12px;
  margin-top: 12px;
}

.talk-button:hover {
  transform: translateX(3px);
}

/* SAVINGS / GOAL CARD */

.savings-card {
  background: var(--white);
  padding: 22px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
  animation: cardEnter 0.45s 0.05s ease both;
}

.goal-card {
  overflow: hidden;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 17px;
}

.goal-eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.edit-goal-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.edit-goal-button:hover {
  background: #d8e7fc;
  transform: translateY(-1px);
}

/* GOAL LAYOUT */

.goal-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  animation: goalLayoutEnter 0.35s ease both;
}

@keyframes goalLayoutEnter {
  from {
    opacity: 0.85;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* IMAGE IS HIDDEN WHEN NO IMAGE EXISTS */

.goal-image-wrap[hidden],
.goal-image[hidden] {
  display: none !important;
}

.goal-image-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: #edf3fc;
  margin-bottom: 18px;
  animation: goalImageEnter 0.35s ease both;
}

.goal-image {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

@keyframes goalImageEnter {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.goal-content {
  min-width: 0;
  flex: 1;
}

.goal-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.level-badge {
  color: var(--blue-dark);
  background: var(--blue-light);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 10px;
}

#balance {
  font-size: 34px;
  letter-spacing: -1px;
  margin: 12px 0 20px;
  transition: color 0.25s ease;
}

.goal-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 9px;
}

#progressText {
  color: var(--blue-dark);
}

.progress-track {
  width: 100%;
  height: 9px;
  border-radius: 20px;
  background: #edf1f7;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #83a9e2, #a5c9fa);
  border-radius: inherit;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.goal-caption {
  color: var(--muted);
  font-size: 11px;
  margin-top: 9px;
}

.goal-note {
  color: #687c99;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 15px;
  padding: 11px 13px;
  background: #f3f7fd;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

/* WIDE IMAGE: LAYOUT C */

.goal-layout.layout-stacked .goal-image-wrap {
  width: 100%;
  margin-bottom: 18px;
}

.goal-layout.layout-stacked .goal-image {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
}

/* PORTRAIT / SMALL IMAGE: LAYOUT B */

.goal-layout.layout-side {
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.goal-layout.layout-side .goal-image-wrap {
  flex: 0 0 37%;
  width: 37%;
  margin-bottom: 0;
  aspect-ratio: 3 / 4;
}

.goal-layout.layout-side .goal-image {
  width: 100%;
  height: 100%;
  min-height: 130px;
  max-height: 220px;
  object-fit: cover;
}

.goal-layout.layout-side .goal-title {
  font-size: 17px;
}

.goal-layout.layout-side #balance {
  font-size: 27px;
  margin: 10px 0 15px;
}

.goal-layout.layout-side .goal-info {
  font-size: 11px;
}

.goal-layout.layout-side .goal-note {
  padding: 9px 10px;
  font-size: 11px;
}

/* ACTION BUTTONS */

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.primary-button,
.secondary-button {
  flex: 1;
  padding: 13px 8px;
  border-radius: 13px;
  font-weight: 800;
  font-size: 13px;
}

.primary-button {
  color: white;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
  box-shadow: 0 5px 14px rgba(70, 107, 159, 0.17);
}

.secondary-button {
  background: #eef3fa;
  color: var(--blue-dark);
}

.secondary-button:hover {
  background: #e1ebfa;
}

/* QUICK INFORMATION */

.quick-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 23px;
}

.info-card {
  background: var(--white);
  padding: 16px;
  border-radius: 17px;
  box-shadow: var(--shadow);
  animation: cardEnter 0.45s 0.1s ease both;
}

.info-card span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.info-card strong {
  font-size: 16px;
}

/* RECENT ACTIVITY */

.history-section {
  background: var(--white);
  padding: 19px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: cardEnter 0.45s 0.15s ease both;
}

.history-section .section-heading {
  margin-bottom: 15px;
}

.history-section .section-heading button {
  background: transparent;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
}

.empty-message {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px 0;
}

footer {
  text-align: center;
  color: #a5afbf;
  font-size: 10px;
  padding: 24px 0 12px;
}

/* SETTINGS HEADER */

.subpage-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 25px;
}

.back-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--white);
  color: var(--blue-dark);
  font-size: 23px;
  box-shadow: var(--shadow);
}

.back-button:hover {
  background: var(--blue-light);
}

.page-eyebrow {
  display: block;
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.4px;
  margin-bottom: 3px;
}

.subpage-header h1 {
  font-size: 25px;
  line-height: 1.2;
}

/* SETTINGS BANNER */

.settings-banner {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  margin-bottom: 27px;
  border-radius: 21px;
  background: linear-gradient(135deg, #dceaff, #eff5ff);
  border: 1px solid #e2ebfa;
  animation: cardEnter 0.4s ease both;
}

.settings-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 53px;
  height: 53px;
  border-radius: 17px;
  background: white;
  color: var(--blue);
  font-size: 29px;
}

.settings-banner h2 {
  font-size: 15px;
  margin-bottom: 4px;
}

.settings-banner p {
  color: #687c99;
  font-size: 11px;
  line-height: 1.5;
}

/* SETTINGS GROUPS */

.settings-group {
  margin-bottom: 26px;
  animation: cardEnter 0.4s ease both;
}

.settings-group h3 {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  margin: 0 0 11px 5px;
}

.settings-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  margin-bottom: 9px;
  background: var(--white);
  border-radius: 16px;
  text-align: left;
  box-shadow: var(--shadow);
}

.settings-item:hover,
.settings-action:hover {
  background: #f9fbff;
  transform: translateY(-1px);
}

.settings-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 39px;
  height: 39px;
  border-radius: 12px;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 19px;
}

.settings-item-text {
  flex: 1;
  min-width: 0;
}

.settings-item-text strong,
.settings-action strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.settings-item-text small,
.settings-action small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  line-height: 1.4;
}

.settings-arrow {
  color: #a3b3c9;
  font-size: 23px;
}

/* SETTINGS SUBPAGES */

.subpage {
  min-height: 70vh;
}

.settings-content-card {
  background: var(--white);
  border-radius: 21px;
  padding: 22px;
  margin-bottom: 23px;
  box-shadow: var(--shadow);
  animation: cardEnter 0.4s ease both;
}

.content-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 49px;
  height: 49px;
  border-radius: 15px;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 24px;
  margin-bottom: 16px;
}

.settings-content-card h2 {
  font-size: 19px;
  margin-bottom: 8px;
}

.settings-content-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.info-note {
  margin-top: 18px;
  padding: 13px;
  border-radius: 12px;
  background: #f3f7fd;
  color: var(--blue-dark);
  font-size: 11px;
  line-height: 1.6;
}

.about-detail {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0 0;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.about-detail span {
  color: var(--muted);
}

.about-detail strong {
  color: var(--text);
}

/* SETTINGS ACTIONS */

.settings-action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: var(--white);
  padding: 16px;
  margin-bottom: 9px;
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.settings-action > span:last-child {
  color: var(--blue-dark);
  font-size: 20px;
  font-weight: 800;
}

.danger-group {
  margin-top: 30px;
}

.danger-action {
  background: var(--danger-light);
  box-shadow: none;
}

.danger-action strong,
.danger-action > span:last-child {
  color: var(--danger);
}

.danger-action small {
  color: #b98589;
}

/* MODALS */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(25, 40, 65, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.active {
  display: flex;
  animation: overlayIn 0.2s ease both;
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  background: white;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 23px;
  padding: 25px;
  box-shadow: 0 15px 50px rgba(25, 40, 65, 0.2);
  animation: popIn 0.25s ease;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.close-button {
  position: absolute;
  right: 17px;
  top: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
}

.modal h2 {
  font-size: 21px;
  margin-bottom: 6px;
  padding-right: 20px;
}

.modal p {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 19px;
  line-height: 1.6;
}

.modal label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
}

.modal input {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-size: 16px;
  color: var(--text);
}

.modal input:focus {
  border-color: var(--blue);
}

/* GOAL EDITOR */

.goal-edit-modal {
  max-width: 390px;
}

.goal-edit-modal .form-group {
  margin-bottom: 16px;
}

.goal-edit-modal input[type="text"],
.goal-edit-modal input[type="number"],
.goal-edit-modal textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fbfcff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.goal-edit-modal input:focus,
.goal-edit-modal textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(114, 155, 216, 0.12);
}

.goal-edit-modal textarea {
  resize: vertical;
  min-height: 85px;
}

.goal-image-picker {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  background: #f3f7fd;
  border: 1px dashed #c7d8ef;
  border-radius: 14px;
}

.goal-image-picker input[type="file"] {
  padding: 0;
  border: none;
  background: transparent;
  font-size: 11px;
}

.goal-image-help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.goal-image-preview {
  display: block;
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  border-radius: 10px;
  background: white;
}

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

.goal-image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.remove-image-button {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 11px;
  font-weight: 800;
}

.remove-image-button:hover {
  background: #ffe3e5;
}

.modal-submit {
  width: 100%;
  margin-top: 15px;
}

/* ERROR MESSAGE */

.modal .error-message {
  color: var(--danger);
  margin: 10px 0 0;
  min-height: 14px;
}

/* CARD ANIMATION */

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* SMALLER SCREENS */

@media (max-width: 360px) {
  body {
    padding: 16px 11px;
  }

  .companion-card {
    gap: 9px;
    padding: 11px;
  }

  .character-placeholder {
    flex-basis: 39%;
    width: 39%;
  }

  .dialogue h2 {
    font-size: 15px;
  }

  #balance {
    font-size: 29px;
  }

  .settings-item {
    padding: 12px;
  }

  .settings-banner {
    padding: 15px;
  }

  .savings-card {
    padding: 18px;
  }

  .goal-layout.layout-side {
    gap: 11px;
  }

  .goal-layout.layout-side .goal-image-wrap {
    flex-basis: 34%;
    width: 34%;
  }

  .goal-layout.layout-side #balance {
    font-size: 23px;
  }

  .goal-layout.layout-side .goal-title {
    font-size: 15px;
  }
}

/* REDUCED MOTION */

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