:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #26241f;
  --muted: #716d64;
  --line: #e8e4dc;
  --line-strong: #dcd6ca;
  --primary: #d9563f;
  --primary-deep: #b8432f;
  --primary-soft: #fbe8e3;
  --accent: #1f7a72;
  --accent-soft: #dff0ed;
  --gold: #c8922f;
  --gold-soft: #f7edd7;
  --danger: #c43b34;
  --shadow-sm: 0 1px 2px rgba(38, 36, 31, 0.06), 0 1px 4px rgba(38, 36, 31, 0.05);
  --shadow-md: 0 8px 24px rgba(38, 36, 31, 0.1);
  --shadow-lg: 0 20px 60px rgba(38, 36, 31, 0.22);
  --radius: 8px;
  --radius-lg: 14px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #e5664f, #c23f2c);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-text span {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 14.5px;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item svg {
  font-size: 19px;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Main */
.main {
  min-width: 0;
}

.view {
  display: none;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px clamp(18px, 4vw, 44px) 64px;
  animation: fade-in 0.28s ease;
}

.view.is-active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.page-head .sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn svg {
  font-size: 17px;
}

.btn:hover {
  border-color: #cfc8bb;
  background: var(--surface-2);
}

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

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #17655d;
  border-color: #17655d;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  border-color: #e4b7b3;
  background: #fdf1ef;
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  transition: background 0.16s ease, color 0.16s ease;
}

.icon-btn svg {
  font-size: 18px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn.danger:hover {
  background: #fdf1ef;
  color: var(--danger);
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13.5px;
  transition: all 0.16s ease;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.section-title .muted {
  color: var(--muted);
  font-size: 13px;
}

/* Home hero */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 24px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, #2f2a24 0%, #3c352c 55%, #544435 100%);
  color: #fff;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 82% 16%, rgba(232, 155, 74, 0.28), transparent 38%),
    radial-gradient(circle at 60% 110%, rgba(47, 156, 142, 0.24), transparent 46%);
}

.hero-main {
  position: relative;
  z-index: 1;
  padding: 28px 28px 30px;
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 14px;
}

.hero-kicker svg {
  color: #f2b569;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 750;
  letter-spacing: 0.01em;
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 14px;
  line-height: 1.65;
  max-width: 46ch;
}

.hero-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.hero-actions .btn {
  border: 0;
}

.btn-on-dark {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  backdrop-filter: blur(4px);
}

.btn-on-dark:hover {
  background: rgba(255, 255, 255, 0.24);
}

.btn-on-dark.accent {
  background: var(--primary);
}

.hero-side {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 26px 28px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-side .label {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.66);
}

.next-birthday-person {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 12px;
}

.next-birthday-person .name {
  font-size: 18px;
  font-weight: 700;
}

.next-birthday-person .date {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.64);
  margin-top: 2px;
}

.countdown-big {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.countdown-big .num {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  color: #f5c375;
}

.countdown-big .unit {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.stat {
  padding: 16px 18px;
}

.stat .stat-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  margin-bottom: 12px;
}

.stat .stat-icon svg {
  font-size: 18px;
}

.stat .num {
  font-size: 24px;
  font-weight: 750;
  line-height: 1;
}

.stat .label {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.tint-coral {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.tint-teal {
  background: var(--accent-soft);
  color: var(--accent);
}

.tint-gold {
  background: var(--gold-soft);
  color: #9a6c17;
}

.tint-slate {
  background: #ebe9e4;
  color: #5b564c;
}

/* Avatar */
.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

/* Birthday rows on home */
.bday-list {
  display: grid;
  gap: 10px;
}

.bday-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
}

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

.bday-row .info .name {
  font-weight: 650;
  font-size: 14.5px;
}

.bday-row .info .meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.count-chip {
  flex: none;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  background: var(--gold-soft);
  color: #8a5f12;
}

.count-chip.today {
  background: var(--primary);
  color: #fff;
}

.count-chip.soon {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Two-column dashboard layout */
.home-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.home-grid .section-title {
  margin-top: 0;
}

/* Media preview strip */
.media-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.media-strip .thumb {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #eceae4;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.media-strip .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Gallery */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.drop-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  background: var(--surface);
  margin-bottom: 18px;
}

.drop-hint.is-visible {
  display: flex;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.media-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #eceae4;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
}

.media-card img,
.media-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.media-card:hover img,
.media-card:hover video {
  transform: scale(1.04);
}

.media-card .type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(20, 18, 15, 0.55);
  color: #fff;
  backdrop-filter: blur(3px);
}

.media-card .type-badge svg {
  font-size: 14px;
}

.media-card .meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 10px 9px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 11.5px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.media-card:hover .meta {
  opacity: 1;
}

/* Empty states */
.empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--muted);
}

.empty .empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}

.empty .empty-icon svg {
  font-size: 26px;
}

.empty h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 16px;
}

.empty p {
  margin: 0 0 18px;
  font-size: 13.5px;
}

/* Birthday page */
.birthday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.birthday-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

.birthday-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--avatar-color, var(--primary));
}

.birthday-card .top {
  display: flex;
  align-items: center;
  gap: 13px;
}

.birthday-card .identity {
  min-width: 0;
  flex: 1;
}

.birthday-card .identity .name {
  font-size: 16px;
  font-weight: 700;
}

.birthday-card .identity .rel {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.birthday-card .actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.birthday-card:hover .actions {
  opacity: 1;
}

.birthday-card .count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.birthday-card .count-row .big {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.birthday-card .count-row .big small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.birthday-card .count-row .when {
  text-align: right;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* Games */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.game-card {
  position: relative;
  padding: 0;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.game-card .game-cover {
  height: 118px;
  display: grid;
  place-items: center;
  font-size: 46px;
  color: #fff;
}

.game-card .game-body {
  padding: 15px 16px 17px;
}

.game-card h3 {
  margin: 0 0 5px;
  font-size: 16px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.cover-2048 {
  background: linear-gradient(135deg, #e6b46a, #d98b3f);
}

.cover-memory {
  background: linear-gradient(135deg, #5bb8a9, #1f7a72);
}

.cover-snake {
  background: linear-gradient(135deg, #8fbf6a, #4f8b3f);
}

.cover-ttt {
  background: linear-gradient(135deg, #d979a0, #b34a76);
}

/* Game frame */
.game-frame {
  animation: fade-in 0.25s ease;
}

.game-frame .back-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.game-frame .back-row h2 {
  margin: 0;
  font-size: 19px;
}

.game-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 22px;
  align-items: start;
}

.game-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.game-info {
  display: grid;
  gap: 12px;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.score-card .score-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--gold-soft);
  color: #9a6c17;
}

.score-card .v {
  margin-left: auto;
  font-size: 18px;
  font-weight: 750;
}

.hint-box {
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* 2048 */
.board-2048 {
  position: relative;
  width: min(100%, 420px);
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: #b6aa99;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  touch-action: none;
}

.tile-2048 {
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: clamp(18px, 6vw, 34px);
  background: rgba(238, 228, 218, 0.35);
  color: #776e65;
  transition: transform 0.08s ease;
}

.tile-2048.pop {
  animation: pop 0.18s ease;
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.tile-2048[data-v="2"] { background: #eee4da; }
.tile-2048[data-v="4"] { background: #ede0c8; }
.tile-2048[data-v="8"] { background: #f2b179; color: #fff; }
.tile-2048[data-v="16"] { background: #f59563; color: #fff; }
.tile-2048[data-v="32"] { background: #f67c5f; color: #fff; }
.tile-2048[data-v="64"] { background: #f65e3b; color: #fff; }
.tile-2048[data-v="128"] { background: #edcf72; color: #fff; font-size: clamp(15px, 5vw, 26px); }
.tile-2048[data-v="256"] { background: #edcc61; color: #fff; font-size: clamp(15px, 5vw, 26px); }
.tile-2048[data-v="512"] { background: #edc850; color: #fff; font-size: clamp(15px, 5vw, 26px); }
.tile-2048[data-v="1024"] { background: #edc53f; color: #fff; font-size: clamp(12px, 4.5vw, 22px); }
.tile-2048[data-v="2048"] { background: #edc22e; color: #fff; font-size: clamp(12px, 4.5vw, 22px); }
.tile-2048[data-v="4096"] { background: #3c3a32; color: #fff; font-size: clamp(12px, 4.5vw, 22px); }

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(246, 245, 241, 0.86);
  backdrop-filter: blur(2px);
  z-index: 2;
}

.game-overlay .box {
  text-align: center;
  padding: 24px;
}

.game-overlay h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.game-overlay p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

/* Memory */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.memory-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: clamp(22px, 8vw, 34px);
  transition: transform 0.3s ease, background 0.25s ease;
  transform-style: preserve-3d;
}

.memory-card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  backface-visibility: hidden;
}

.memory-card .back-face {
  background: var(--primary);
}

.memory-card .back-face svg {
  font-size: 22px;
}

.memory-card .front-face {
  background: var(--surface);
  transform: rotateY(180deg);
}

.memory-card.flipped {
  transform: rotateY(180deg);
}

.memory-card.matched {
  background: var(--accent-soft);
  cursor: default;
}

/* Snake */
.snake-wrap {
  max-width: 420px;
  margin: 0 auto;
}

.snake-canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: var(--radius);
  background: #20302b;
}

/* Tic-tac-toe */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
}

.ttt-cell {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: clamp(34px, 11vw, 54px);
  font-weight: 750;
  color: var(--ink);
  transition: background 0.15s ease, transform 0.1s ease;
}

.ttt-cell:hover:not(:disabled) {
  background: var(--surface);
}

.ttt-cell:active:not(:disabled) {
  transform: scale(0.96);
}

.ttt-cell.win {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 27, 22, 0.44);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease;
}

.modal {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px 20px 22px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--c);
  transition: transform 0.12s ease;
}

.swatch.is-active {
  border-color: var(--ink);
  transform: scale(1.12);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(18, 16, 13, 0.92);
  animation: fade-in 0.18s ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-stage {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
}

.lightbox-stage img,
.lightbox-stage video {
  max-width: 100%;
  max-height: 86vh;
  border-radius: 6px;
  display: block;
  box-shadow: var(--shadow-lg);
}

.lightbox-close,
.lightbox-delete {
  position: absolute;
  top: 20px;
  border: 0;
  border-radius: 999px;
  height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
}

.lightbox-close {
  right: 20px;
  width: 40px;
  padding: 0;
  justify-content: center;
}

.lightbox-close svg {
  font-size: 20px;
}

.lightbox-delete {
  left: 20px;
  background: rgba(196, 59, 52, 0.85);
}

/* Toast */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 999px;
  background: #2c2923;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.22s ease;
}

.toast svg {
  color: #7fd8c6;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Bottom nav (mobile) */
.bottom-nav {
  display: none;
}

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }

  .bottom-nav .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    font-size: 11px;
    border-radius: 10px;
  }

  .bottom-nav .nav-item svg {
    font-size: 20px;
  }

  .bottom-nav .nav-item.is-active {
    background: transparent;
    color: var(--primary-deep);
  }

  .view {
    padding: 22px 16px calc(86px + env(safe-area-inset-bottom));
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head h1 {
    font-size: 23px;
  }

  .head-actions {
    width: 100%;
  }

  .head-actions .btn {
    flex: 1;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-side {
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 20px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .game-panel {
    grid-template-columns: 1fr;
  }

  .game-info {
    order: -1;
    grid-template-columns: repeat(2, 1fr);
  }

  .hint-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 460px) {
  .media-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .media-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .birthday-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
