:root {
  --bg: #fdf6ec;
  --surface: #fffaf3;
  --surface-alt: #fdf2e6;
  --ink: #4e3d42;
  --muted: #8a7579;
  --border: #eadbc8;
  --accent: #e58f7c;
  --accent-deep: #d67662;
  --accent-soft: #fde8e2;
  --gold: #e9a94b;
  --gold-soft: #fff2d6;
  --warn-bg: #fde9ec;
  --warn-ink: #b14d5c;
  font-family: "Hiragino Sans", "Pretendard", "Noto Sans JP", "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #fffdf8 0%, #f6ead8 100%);
  color: var(--ink);
  min-height: 100vh;
}

button,
input {
  font: inherit;
  color: inherit;
}

.nkm-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px 22px;
}

/* Header */
.nkm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  image-rendering: pixelated;
}

.nkm-brand h1 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.2;
}

.nkm-brand h1 span {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--muted);
  margin-left: 6px;
}

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

.lang-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.is-active {
  background: var(--accent);
  color: #fffaf6;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.hud-pill strong {
  color: #b55e4c;
}

.plus-pill {
  border: 1.5px solid #ecc071;
  background: var(--gold-soft);
  color: #8f5c16;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.plus-pill.is-active {
  background: linear-gradient(135deg, #f5c96b 0%, #ea9f47 100%);
  color: #42290a;
  border-color: #df963e;
}

/* Main Grid */
.nkm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(320px, 0.86fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 980px) {
  .nkm-grid {
    grid-template-columns: 1fr;
  }
}

/* Stage Card */
.stage-card {
  background: #fffdf9;
  border: 2px solid #e7d4be;
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 14px 34px rgba(120, 84, 66, 0.10);
  margin-bottom: 12px;
}

.stage-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 13px;
  overflow: hidden;
  background: #f3e4d3;
}

#room-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.stage-status-chip {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid #e4cbb3;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  pointer-events: none;
}

.stage-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mood-mini-group {
  display: inline-flex;
  gap: 3px;
  background: rgba(255, 250, 243, 0.90);
  border: 1px solid #e4cbb3;
  padding: 2px;
  border-radius: 999px;
}

.mini-mood-btn {
  border: none;
  background: transparent;
  width: 26px;
  height: 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
}

.mini-mood-btn.is-active {
  background: var(--accent-soft);
}

.guide-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 250, 243, 0.90);
  border: 1px solid #e4cbb3;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 480px) {
  .stage-status-chip {
    top: 6px;
    left: 6px;
    font-size: 0.66rem;
    padding: 3px 8px;
    max-width: 46%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stage-top-right {
    top: 6px;
    right: 6px;
    gap: 4px;
  }

  .mini-mood-btn {
    width: 22px;
    height: 20px;
    font-size: 0.72rem;
  }

  .guide-chip {
    font-size: 0.66rem;
    padding: 3px 7px;
  }
}

.dust-alert {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(255, 245, 224, 0.94);
  border: 1px solid #e9b974;
  color: #7b4e18;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  pointer-events: none;
}

/* Whisper Bar */
.whisper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.cat-whisper {
  font-size: 0.81rem;
  color: var(--ink);
  font-weight: 600;
}

.pet-btn {
  border: 1px solid #f0bdae;
  background: var(--accent-soft);
  color: #a95342;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Gift Banner */
.gift-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff5e3;
  border: 1.5px solid #ecc071;
  font-size: 0.82rem;
  font-weight: 600;
}

.gift-banner.is-fail {
  background: var(--warn-bg);
  border-color: #eab3bc;
}

.gift-banner-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gift-banner-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.gift-banner-actions {
  display: flex;
  gap: 6px;
}

/* Focus Dock */
.focus-dock {
  margin-top: 10px;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--border);
}

.focus-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mode-pills {
  display: inline-flex;
  gap: 6px;
}

.mode-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.mode-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #a95342;
}

.mode-pill-demo {
  background: var(--gold-soft);
  border-color: #ecc888;
  color: #8f5c16;
}

.mode-pill-demo.is-active {
  background: #fde2ac;
  border-color: var(--gold);
  color: #6b4108;
}

.focus-main-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clock-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.clock-digits {
  font-size: 2.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
}

.active-task-chip {
  font-size: 0.78rem;
  color: #8f5c16;
  background: var(--gold-soft);
  border: 1px solid #ecc888;
  padding: 4px 9px;
  border-radius: 8px;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 11px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(135deg, #ed9a85 0%, #dd7d68 100%);
  border: none;
  color: #fffaf5;
}

.btn-soft {
  background: var(--accent-soft);
  border-color: #f0bdae;
  color: #a95342;
}

.btn-warn {
  background: var(--warn-bg);
  border-color: #eab3bc;
  color: var(--warn-ink);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.76rem;
  border-radius: 8px;
}

.interaction-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

/* 8-Cat Roster */
.roster-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 12px;
}

.roster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.roster-head strong {
  font-size: 0.85rem;
}

.roster-head span {
  font-size: 0.74rem;
  color: var(--muted);
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 680px) {
  .roster-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.cat-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 20px 3px 6px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fdf7ef;
  cursor: pointer;
}

.cat-slot.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cat-slot.is-locked {
  opacity: 0.82;
}

.cat-badge-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  line-height: 1.1;
  z-index: 2;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
  background: var(--gold-soft);
  color: #8f5c16;
  border: 1px solid #ecc888;
}

.cat-thumb {
  width: 38px;
  height: 30px;
  image-rendering: pixelated;
}

.cat-name {
  font-size: 0.73rem;
  font-weight: 700;
}

/* Side Drawer */
.drawer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(120, 84, 66, 0.08);
}

.drawer-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.drawer-tab {
  border: none;
  background: transparent;
  padding: 11px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
}

.drawer-tab.is-active {
  color: #b55e4c;
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.drawer-body {
  padding: 12px 14px 16px;
  max-height: 680px;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.is-active {
  display: block;
}

.daily-box {
  background: #fff6e8;
  border: 1px solid #ecc888;
  border-radius: 13px;
  padding: 9px 10px;
  margin-bottom: 12px;
}

.daily-title {
  margin: 0 0 7px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #8f5c16;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.daily-item {
  background: #fffdf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
}

.slot-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.slot-pill {
  border: 1px solid var(--border);
  background: #fdf7ef;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.slot-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffaf5;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: #fdf7ef;
  border: 1px solid var(--border);
}

.item-card.is-equipped {
  border-color: var(--accent);
  background: #fff3ee;
}

.item-swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(78, 61, 66, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-swatch img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
}

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

.item-info h4 {
  margin: 0 0 2px;
  font-size: 0.84rem;
}

.item-info p {
  margin: 0;
  font-size: 0.73rem;
  color: var(--muted);
  line-height: 1.3;
}

/* Gifts */
.gifts-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.gift-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: #fdf7ef;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.gift-card.is-fail {
  background: #fff4f5;
  border-color: #eab8c1;
}

.gift-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

/* Sound Mixer */
.slider-card {
  background: #fdf7ef;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 9px;
}

.slider-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.slider-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.sound-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Todos & Stats */
.todo-form {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.todo-form input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fffdf9;
  font-size: 0.82rem;
}

.todo-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.todo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: #fdf7ef;
  border: 1px solid var(--border);
  font-size: 0.81rem;
}

.todo-row.is-active {
  border-color: var(--accent);
  background: #fff3ee;
}

.todo-title {
  flex: 1;
  cursor: pointer;
}

.todo-title.is-done {
  text-decoration: line-through;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.stat-box {
  background: #fdf7ef;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}

.stat-box span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-box strong {
  font-size: 0.96rem;
  color: #b55e4c;
}

.history-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.76rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 9px;
  border-radius: 8px;
  background: #fffdf9;
  border: 1px solid var(--border);
}

.backup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Modal */
.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(58, 43, 47, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: #fffaf3;
  border: 2px solid #ecc071;
  border-radius: 22px;
  padding: 18px 20px;
  box-shadow: 0 20px 44px rgba(78, 52, 42, 0.24);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.stage-pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  color: #8f5c16;
  background: var(--gold-soft);
  border: 1px solid #ecc888;
  padding: 3px 10px;
  border-radius: 999px;
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.modal-sub {
  margin: 0 0 12px;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.45;
}

.plus-perks {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.perk-item {
  background: #fdf4e4;
  border: 1px solid #edd4a6;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.plus-price-box {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #8f5c16;
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 50;
  background: #4e3d42;
  color: #fffaf3;
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 0.83rem;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(58, 42, 36, 0.25);
}

.account-pill {
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.account-pill:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
}

.nkm-footer {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.nkm-footer a {
  color: var(--muted);
  text-decoration: none;
}

.nkm-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}
