:root {
  /* High-Res Cozy Strawberry-Milk Sanctuary Palette */
  --bg-page: #FCE7F0;
  --bg-pattern: #F6D0E1;
  --surface: #FFF7FA;
  --surface-soft: #FFEAF2;
  --surface-tint: #FFD6E6;
  --ink: #3E1C31;
  --ink-muted: #663854;
  --rose: #BA2F67;
  --rose-deep: #982151;
  --rose-soft: #F9A8C7;
  --butter: #FFE08A;
  --mint: #97E0BC;
  --mint-deep: #226648;
  --plum-night: #3A2042;
  --border: #4A233A;
  --shadow-soft: 0 8px 24px rgba(74, 35, 58, 0.12);

  --font-display: "Fredoka", system-ui, -apple-system, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--rose-soft);
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--surface-soft);
}
::-webkit-scrollbar-thumb {
  background: var(--rose-soft);
  border-radius: 6px;
  border: 2px solid var(--surface-soft);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-page);
  background-image:
    radial-gradient(var(--bg-pattern) 1.5px, transparent 1.5px),
    radial-gradient(var(--bg-pattern) 1.5px, var(--bg-page) 1.5px);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--rose);
  outline-offset: 2px;
}

canvas {
  display: block;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 42px;
}

/* Header */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 16px;
  padding: 10px 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
}

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

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-tint);
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.2vw, 1.42rem);
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.heart-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 99px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
  color: var(--rose-deep);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
  transition: transform 0.14s ease, background-color 0.15s ease;
}

.icon-btn.icon-only {
  padding: 6px 10px;
}

.icon-btn:hover {
  background: var(--surface-tint);
  transform: translateY(-1px);
}

.icon-btn.active-toggle {
  background: var(--surface-tint);
  border-color: var(--rose);
  color: var(--rose-deep);
}

.icon-btn:active {
  transform: translateY(1px);
}

.pill-count {
  background: var(--rose);
  color: #FFF8FA;
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

/* Main Grid */
.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.92fr);
  gap: 18px;
  align-items: start;
}

/* Interactive Shelter Stage */
.shelter-stage {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.stage-frame {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

#shelter-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 528;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--plum-night);
  cursor: pointer;
}

.speech-bubble {
  margin-top: 11px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
}

.speech-name {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--rose-deep);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 2px 10px;
  margin-bottom: 5px;
}

.speech-bubble p {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
  max-width: 68ch;
}

.stage-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 9px 14px;
}

.status-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.cloud-pill {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.74rem;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-muted);
}

.cloud-pill.synced {
  background: #E2F7EC;
  color: var(--mint-deep);
}

.status-pill strong {
  color: var(--mint-deep);
}

.dot-live {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint-deep);
  border: 1.5px solid var(--border);
}

.cat-roster-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.roster-chip {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--surface-tint);
  color: var(--ink);
}

.roster-chip.locked {
  background: var(--surface-soft);
  color: var(--ink-muted);
  border-style: dashed;
}

/* Mood Check-In Console */
.mood-console {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.console-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.22rem;
  color: var(--ink);
  line-height: 1.25;
}

.console-hint {
  margin: 5px 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.mood-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mood-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 14px;
  transition: transform 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.mood-item:hover {
  background: var(--surface-tint);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(186, 47, 103, 0.16);
}

.mood-item:active {
  transform: translateY(0);
}

.mood-sprite {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.mood-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.mood-feeling {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--rose-deep);
}

.mood-game-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.2;
}

.mood-desc {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-muted);
  line-height: 1.35;
}

.mood-tag {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--rose);
  color: #FFF8FA;
  border: 2px solid var(--border);
  white-space: nowrap;
}

.mood-tag.cleared {
  background: var(--mint);
  color: var(--ink);
}

/* Overlays & Modals */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(58, 28, 46, 0.62);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 14px;
  overflow-y: auto;
}

.game-modal,
.panel-modal {
  width: min(820px, 100%);
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 20px 44px rgba(42, 16, 33, 0.34);
  max-height: 94vh;
  overflow-y: auto;
}

.game-topbar,
.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.game-title-wrap h2,
.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.22rem;
  color: var(--ink);
}

.game-title-wrap p,
.panel-sub {
  margin: 2px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.game-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-pill {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  padding: 5px 11px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
}

.close-btn,
.secondary-btn {
  padding: 7px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
  transition: background-color 0.14s ease, transform 0.12s ease;
}

.close-btn:hover,
.secondary-btn:hover {
  background: var(--surface-tint);
  transform: translateY(-1px);
}

.primary-btn {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--rose);
  color: #FFF8FA;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  transition: background-color 0.14s ease, transform 0.12s ease;
}

.primary-btn:hover {
  background: var(--rose-deep);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  background: var(--surface-soft);
  color: var(--ink-muted);
  cursor: not-allowed;
  transform: none;
}

.game-canvas-wrap {
  position: relative;
}

#game-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 600;
  border: 2.5px solid var(--border);
  border-radius: 14px;
  background: var(--plum-night);
  touch-action: none;
  user-select: none;
}

.kdrama-banner {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  background: rgba(58, 28, 46, 0.92);
  color: #FFF6FA;
  border: 2px solid var(--rose-soft);
  border-radius: 12px;
  padding: 9px 14px;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 700;
  pointer-events: none;
  animation: fadeBanner 0.25s ease-out;
}

.kdrama-banner strong {
  color: var(--butter);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  display: block;
  margin-bottom: 2px;
}

@keyframes fadeBanner {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-controls {
  margin-top: 11px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.ctrl-btn {
  padding: 9px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  touch-action: manipulation;
}

.ctrl-btn:hover,
.ctrl-btn:active {
  background: var(--surface-tint);
}

.ctrl-btn.accent {
  background: var(--rose);
  color: #FFF8FA;
}

.ctrl-btn.accent:hover {
  background: var(--rose-deep);
}

/* End-of-round K-Drama Episode Card */
.episode-card {
  position: absolute;
  inset: 0;
  background: rgba(58, 28, 46, 0.84);
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 16px;
}

.episode-card-inner {
  width: min(490px, 100%);
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 16px;
  padding: 20px 20px 18px;
  text-align: center;
  box-shadow: 0 14px 30px rgba(34, 12, 26, 0.35);
}

.episode-stamp {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--rose-deep);
}

.episode-card-inner h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.24rem;
  color: var(--ink);
}

.result-message {
  margin: 0 0 12px;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.55;
}

.result-unlock {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--rose-deep);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mailbox Toolbar & 50 Sealed Envelopes */
.mail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.mail-tabs {
  display: inline-flex;
  gap: 6px;
}

.tab-btn {
  padding: 7px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

.tab-btn.active {
  background: var(--surface-tint);
  color: var(--rose-deep);
  border-color: var(--rose);
}

.mail-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sealed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.mail-card {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.mail-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mail-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--rose-deep);
}

.mail-tag {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.74rem;
  padding: 2px 9px;
  border-radius: 99px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  white-space: nowrap;
}

.mail-body {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.58;
  max-width: 68ch;
}

/* Sealed Envelope Card — hides title & content completely until unlocked! */
.sealed-card {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.sealed-card.opened-tile {
  background: var(--surface-soft);
  border-style: solid;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.14s ease;
}

.sealed-card.opened-tile:hover {
  background: var(--surface-tint);
  transform: translateY(-2px);
}

.sealed-num {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
}

.sealed-hint {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* Decor & Cat Squad */
.decor-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sub-heading {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.upgrade-list,
.cat-collection {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.upgrade-row,
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
}

.cat-row.locked {
  background: var(--surface);
  border-style: dashed;
}

.row-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}

.row-desc {
  margin: 2px 0 0;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #FFF6FA;
  border: 2px solid var(--rose-soft);
  border-radius: 12px;
  padding: 10px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 10px 24px rgba(42, 16, 33, 0.35);
}

/* Volume Settings Modal */
.volume-modal {
  width: min(470px, 100%);
}

.volume-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.volume-row {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.volume-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.volume-label-line label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
}

.vol-pct {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  color: var(--rose-deep);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
}

.pink-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 99px;
  background: var(--surface-tint);
  border: 2px solid var(--border);
  outline: none;
  cursor: pointer;
}

.pink-slider:focus-visible {
  outline: 3px solid var(--rose);
  outline-offset: 3px;
}

.pink-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--rose);
  border: 2.5px solid var(--border);
  box-shadow: 0 2px 6px rgba(74, 35, 58, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.pink-slider::-webkit-slider-thumb:hover {
  transform: scale(1.08);
  background: var(--rose-deep);
}

.pink-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--rose);
  border: 2.5px solid var(--border);
  box-shadow: 0 2px 6px rgba(74, 35, 58, 0.25);
  cursor: pointer;
}

.volume-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.yt-audio-host {
  position: fixed;
  width: 200px;
  height: 200px;
  right: 0;
  bottom: 0;
  opacity: 0.001;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

@media (max-width: 880px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .decor-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 10px 10px 30px;
  }
  .mood-item {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .mood-tag {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
  }
}
