:root {
  --bg: #fff9f0;
  --card: #ffefe5;
  --primary: #e86f6f;
  --primary-dark: #c75555;
  --success: #a3d0b2;
  --warn: #f7d96b;
  --text: #5e3a3a;
  --subtext: #a58e8e;
  --border: #e1cfc3;
}

* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

body {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.pixel-noise {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(#e1cfc355 1px, transparent 1px);
  background-size: 8px 8px;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  padding-bottom: 100px;
  font-size: 16px;
}

.pixel-card {
  background: var(--card);
  border: 2px solid var(--border);
  outline: 1px solid #fff;
  outline-offset: -4px;
  padding: 22px;
  box-shadow: 4px 4px 0 #dcb9b0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 20px;
}

.brand p {
  margin: 8px 0 0;
  color: var(--subtext);
  font-size: 14px;
}

.logo {
  font-size: 32px;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-name {
  font-size: 14px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-btn {
  font-size: 10px;
  padding: 8px 14px;
}

.hero {
  margin-top: 16px;
  text-align: center;
}

.hero h2 {
  margin: 0 0 12px;
  font-size: 28px;
}

.hero p {
  margin: 0 0 12px;
  color: var(--subtext);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.ghost-btn {
  display: inline-block;
  text-decoration: none;
  background: #fff;
  color: var(--primary);
  box-shadow: 3px 3px 0 var(--border);
}

.ghost-btn:hover {
  filter: none;
  background: #fff6f2;
}

.pixel-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--primary-dark);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.pixel-btn:hover {
  filter: brightness(0.9);
  transform: translateY(-1px);
}

.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--primary-dark);
}

.pixel-btn.warning {
  background: #d59f31;
  box-shadow: 3px 3px 0 #996c17;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.big-number {
  margin: 0 0 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 22px;
}

.section {
  display: none;
  margin-top: 16px;
  gap: 12px;
}

.section.active {
  display: grid;
}

.todo-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.pixel-input {
  flex: 1;
  border: 2px solid var(--border);
  padding: 8px;
  background: #fff;
  color: var(--text);
}

.pixel-input:focus {
  outline: none;
  border-color: var(--primary);
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px dashed #d9b9af;
}

.todo-item.done span {
  text-decoration: line-through;
  color: var(--subtext);
}

.checkin-card {
  text-align: center;
}

.big-btn {
  width: 220px;
  height: 56px;
  font-size: 13px;
}

.reward-toast {
  margin-top: 10px;
  min-height: 20px;
  color: #4f8d66;
  font-weight: bold;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.day-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid #d5bfb4;
  background: #fff;
}

.day-cell.checked {
  background: var(--success);
}

.day-cell.missed {
  background: #ccc;
}

.day-cell.makeup {
  background: var(--warn);
}

.legend {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid #bca9a0;
}

.dot.checked { background: var(--success); }
.dot.missed { background: #ccc; }
.dot.makeup { background: var(--warn); }
.dot.pending { background: #fff; }

.shop-list {
  display: grid;
  gap: 10px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px dashed #dbbab0;
  padding: 10px;
  background: #fff6f2;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hint {
  color: var(--subtext);
}

.public-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: min(1200px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 12px;
}

.nav-btn {
  border: 2px solid #d8bfb4;
  background: #fff;
  color: var(--text);
  padding: 8px 4px;
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", sans-serif;
  font-size: 12px;
  text-align: center;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.nav-link:hover {
  background: #fff6f2;
}

.music-credit {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--subtext);
}

.music-credit a {
  color: var(--primary);
}

.float-icons {
  position: fixed;
  right: 16px;
  bottom: 96px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.float-icon {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  background: var(--card);
  box-shadow: 3px 3px 0 #dcb9b0;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.1s steps(2);
}

.float-icon:hover {
  transform: translateY(-2px);
}

.float-icon:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #dcb9b0;
}

.float-icon.playing {
  background: #ffe1de;
  border-color: var(--primary);
}

@keyframes pixel-bounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-4px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-2px); }
}

@keyframes pixel-spin {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(8deg); }
}

@keyframes pixel-sway {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

@keyframes pixel-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.anim-bounce { animation: pixel-bounce 2s steps(4) infinite; }
.anim-spin { animation: pixel-spin 1.5s steps(4) infinite; }
.anim-sway { animation: pixel-sway 2.5s steps(4) infinite; }
.anim-pulse { animation: pixel-pulse 1.8s steps(4) infinite; }

/* 登录弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(94, 58, 58, 0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(440px, 96vw);
  padding: 28px;
}

.modal-card h3 {
  margin: 0 0 16px;
  font-size: 20px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--subtext);
}

.login-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.login-tab {
  border: 2px solid var(--border);
  background: #fff;
  padding: 10px 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.login-tab.active {
  background: #ffe1de;
  border-color: var(--primary);
}

.login-panel {
  display: none;
}

.login-panel.active {
  display: grid;
  gap: 12px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.oauth-hint {
  margin: 0;
  font-size: 13px;
  color: var(--subtext);
  text-align: center;
}

.oauth-btn {
  width: 100%;
  padding: 14px;
  font-size: 12px;
}

.wechat-btn {
  background: #07c160;
  box-shadow: 3px 3px 0 #059a4c;
}

.qq-btn {
  background: #12b7f5;
  box-shadow: 3px 3px 0 #0d8fbf;
}

.big-login-btn {
  width: 100%;
  padding: 14px;
}

.login-msg {
  margin: 12px 0 0;
  min-height: 20px;
  font-size: 13px;
  color: var(--primary);
  text-align: center;
}

/* 小游戏 */
.game-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.game-desc {
  margin: 0 0 12px;
  color: var(--subtext);
  font-size: 14px;
}

.game-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  font-size: 15px;
}

.catch-area {
  position: relative;
  height: 200px;
  background: #fff;
  border: 2px dashed var(--border);
  margin-bottom: 12px;
  overflow: hidden;
}

.candy-fall {
  position: absolute;
  top: -40px;
  font-size: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  animation: candy-drop 1.8s linear forwards;
  padding: 0;
}

@keyframes candy-drop {
  to { top: 100%; transform: rotate(360deg); }
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.memory-card {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 24px;
  cursor: pointer;
}

.memory-card.open {
  background: #ffe1de;
  border-color: var(--primary);
}

.wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 12px 0;
}

.lucky-wheel {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 4px solid var(--primary);
  background: conic-gradient(
    #ffe1de 0deg 45deg,
    #fff9f0 45deg 90deg,
    #ffe1de 90deg 135deg,
    #fff9f0 135deg 180deg,
    #ffe1de 180deg 225deg,
    #fff9f0 225deg 270deg,
    #ffe1de 270deg 315deg,
    #fff9f0 315deg 360deg
  );
  position: relative;
  transition: transform 3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-slice {
  position: absolute;
  font-size: 11px;
  font-family: "Press Start 2P", monospace;
  transform: rotate(calc(var(--i) * 45deg + 22deg)) translateY(-55px);
}

.wheel-result {
  text-align: center;
  font-size: 15px;
  color: #4f8d66;
  min-height: 22px;
}

.nav-btn.active {
  background: #ffe1de;
  border-color: var(--primary);
}

@media (max-width: 960px) {
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .panel-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .brand h1 {
    font-size: 14px;
  }

  .hero h2 {
    font-size: 20px;
  }

  .bottom-nav {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 8px;
  }

  .nav-btn {
    font-size: 10px;
    padding: 6px 2px;
  }

  .float-icons {
    right: 10px;
    bottom: 150px;
  }

  .float-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
