/* ==========================================================================
   像素狗狗 · 吃饭喝水记录
   风格参考 Minecraft：硬边立体边框、像素质感、等宽字体
   ========================================================================== */

:root {
  --sky-top: #6fa8ff;
  --sky-bottom: #cfe6ff;
  --grass: #6aa84f;
  --grass-dark: #4e7c33;
  --dirt: #8b5a2b;
  --dirt-dark: #63401c;
  --wood: #a0713f;
  --wood-dark: #5d3d1c;

  --gui: #c6c6c6;
  --gui-light: #ffffff;
  --gui-dark: #565656;
  --gui-darker: #373737;
  --slot: #8b8b8b;

  --text: #2b2b2b;
  --text-light: #f4f4f4;
  --red: #c0392b;
  --red-light: #e0574a;
  --blue: #3f7cb9;
  --blue-light: #6aa8e0;
  --green: #5f8f36;
  --green-light: #8fc45e;
  --gold: #f5c542;

  --px: 4px;                /* 统一的像素厚度 */
  --font: "Courier New", Consolas, "Lucida Console", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 62%, #a8d8a0 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------ 背景装饰 */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.sun {
  position: absolute; top: 26px; right: 48px;
  width: 56px; height: 56px;
  background: #ffe680;
  box-shadow: 0 0 0 8px rgba(255, 230, 128, .35);
}

.cloud {
  position: absolute;
  width: 96px; height: 28px;
  background: #ffffff;
  opacity: .92;
  box-shadow:
    24px -20px 0 0 #ffffff,
    48px 0 0 0 #ffffff,
    -20px 8px 0 0 #ffffff;
}
.cloud--1 { top: 60px; left: -140px; animation: drift 62s linear infinite; }
.cloud--2 { top: 150px; left: -220px; transform: scale(.8); animation: drift 88s linear infinite 6s; }
.cloud--3 { top: 230px; left: -180px; transform: scale(1.15); animation: drift 74s linear infinite 18s; }
.cloud--4 { top: 330px; left: -160px; transform: scale(.65); animation: drift 104s linear infinite 30s; }

@keyframes drift {
  from { transform: translateX(0) scale(var(--s, 1)); }
  to   { transform: translateX(calc(100vw + 320px)) scale(var(--s, 1)); }
}

.ground {
  position: fixed; left: 0; right: 0; bottom: 0; height: 72px; z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, var(--grass) 0 12px, var(--grass-dark) 12px 20px, var(--dirt) 20px 100%);
  background-color: var(--dirt);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, .25);
}
.ground::after {
  content: ""; position: absolute; inset: 20px 0 0 0;
  background-image:
    repeating-linear-gradient(90deg, rgba(0,0,0,.10) 0 8px, transparent 8px 16px),
    repeating-linear-gradient(0deg, rgba(0,0,0,.10) 0 8px, transparent 8px 16px);
}

/* ------------------------------------------------------------ 布局 */
.app {
  position: relative; z-index: 1;
  max-width: 940px;
  margin: 0 auto;
  padding: 22px 16px 120px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* 关键：允许轨道收缩，避免窄屏横向溢出 */
  gap: 16px;
}
.app > * { min-width: 0; }

/* ------------------------------------------------------------ 面板 */
.mc-panel {
  background: var(--gui);
  border: var(--px) solid;
  border-color: var(--gui-light) var(--gui-dark) var(--gui-dark) var(--gui-light);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .22);
  padding: 14px;
}

.mc-panel.panel--wood {
  background: var(--wood);
  border-color: #d8b183 var(--wood-dark) var(--wood-dark) #d8b183;
  background-image:
    repeating-linear-gradient(90deg, rgba(0,0,0,.10) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.06) 0 10px, transparent 10px 20px);
}

.panel__title {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--text);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, .8);
}
.panel--wood .panel__title { color: #fff8ec; text-shadow: 2px 2px 0 var(--wood-dark); }

/* ------------------------------------------------------------ 顶部狗狗栏 */
.header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.dog-box {
  position: relative;
  width: 96px; height: 96px;
  background: #6f9ad6;
  border: var(--px) solid;
  border-color: var(--gui-dark) var(--gui-light) var(--gui-light) var(--gui-dark);
  display: grid; place-items: center;
  cursor: pointer;
  transition: filter .12s linear, transform .06s linear;
}
.dog-box:hover { filter: brightness(1.14); }
.dog-box:active { transform: translateY(2px); }
.dog-box:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
/* 右下角小徽章，提示「可以点」 */
.dog-box::after {
  content: "🎨";
  position: absolute; right: -9px; bottom: -9px;
  font-size: 16px; line-height: 1;
  padding: 3px 4px;
  background: var(--gui-darker);
  border: 2px solid var(--gui-light);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .3);
}
.dog-sprite svg { width: 80px; height: 80px; display: block; animation: bob 2.6s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

.header__text { min-width: 0; }

.dog-name {
  font-family: var(--font);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 var(--wood-dark);
  background: transparent;
  border: none;
  border-bottom: 3px dashed rgba(255, 255, 255, .5);
  padding: 2px 0;
  width: 100%;
  max-width: 260px;
}
.dog-name:focus { outline: none; border-bottom-color: var(--gold); }

.header__date { margin: 6px 0 2px; color: #fff8ec; font-size: 13px; }
.header__hint  { margin: 0; color: #ffeccc; font-size: 13px; }

.header__clock { text-align: right; }
.clock__time {
  display: block; font-size: 26px; font-weight: 700; color: #fff;
  text-shadow: 2px 2px 0 var(--wood-dark);
  font-variant-numeric: tabular-nums;
}
.clock__label { font-size: 11px; color: #ffeccc; letter-spacing: 2px; }

/* ------------------------------------------------------------ 提醒条 */
.alert-bar {
  background: var(--red);
  color: #fff;
  border: var(--px) solid;
  border-color: var(--red-light) #7d1f16 #7d1f16 var(--red-light);
  padding: 10px 14px;
  font-weight: 700;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
  animation: pulse 1.6s ease-in-out infinite;
}
.alert-bar--water { background: var(--blue); border-color: var(--blue-light) #1d3f63 #1d3f63 var(--blue-light); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .72; }
}

/* ------------------------------------------------------------ 数据卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 16px;
}
.stat { min-width: 0; }

.stat__title {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1px;
  color: #3d3d3d;
  display: flex; align-items: center; gap: 6px;
}
.stat__big {
  margin: 0;
  font-size: 22px; font-weight: 700;
  line-height: 1.25;
  color: #1f1f1f;
  text-shadow: 1px 1px 0 #fff;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat__suffix { font-size: 14px; color: #4a4a4a; }
.stat__big.is-warn { color: var(--red); }
.stat__sub { margin: 4px 0 0; font-size: 12px; color: #4a4a4a; }
.stat__foot { margin: 6px 0 0; font-size: 11px; color: #4a4a4a; min-height: 16px; }

/* 进度条：凹陷像素槽 */
.bar {
  margin-top: 10px;
  height: 16px;
  background: var(--slot);
  border: 3px solid;
  border-color: var(--gui-dark) #e8e8e8 #e8e8e8 var(--gui-dark);
  overflow: hidden;
}
.bar__fill {
  display: block; height: 100%; width: 0%;
  background: var(--green);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18);
  transition: width .35s steps(8, end);
}
.bar--food  .bar__fill { background: var(--green); }
.bar--water .bar__fill { background: var(--blue); }
.bar.is-over .bar__fill { background: var(--red); }

/* ------------------------------------------------------------ 按钮 */
.mc-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
  background: #7a7a7a;
  border: var(--px) solid;
  border-color: #b5b5b5 #2f2f2f #2f2f2f #b5b5b5;
  padding: 11px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: filter .12s linear, transform .06s linear;
}
.mc-btn:hover { filter: brightness(1.16); }
.mc-btn:active { transform: translateY(2px); border-color: #2f2f2f #b5b5b5 #b5b5b5 #2f2f2f; }
.mc-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.mc-btn--small { font-size: 12px; padding: 7px 11px; letter-spacing: .5px; }
.mc-btn--ghost { background: #8b8b8b; }
.mc-btn--food  { background: var(--green); border-color: var(--green-light) #2c4a17 #2c4a17 var(--green-light); }
.mc-btn--water { background: var(--blue);  border-color: var(--blue-light)  #1d3f63 #1d3f63 var(--blue-light); }
.mc-btn--danger{ background: #9c3b32; border-color: #cf6a5f #5c1e17 #5c1e17 #cf6a5f; }

/* ------------------------------------------------------------ 记录区 */
.record__time {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px;
  background: #b4b4b4;
  border: 3px solid;
  border-color: var(--gui-dark) #e8e8e8 #e8e8e8 var(--gui-dark);
}
.record__time label { font-size: 13px; font-weight: 700; }
.record__timehint { font-size: 12px; color: #4a4a4a; }

.record__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.record__block {
  background: #b8b8b8;
  border: 3px solid;
  border-color: #e8e8e8 var(--gui-dark) var(--gui-dark) #e8e8e8;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.record__head { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 1px; }

.record__foot { margin-top: 12px; display: flex; justify-content: flex-end; }

/* 快捷数量 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 10px;
  background: #9a9a9a;
  color: #fff;
  border: 3px solid;
  border-color: #d0d0d0 #4a4a4a #4a4a4a #d0d0d0;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .4);
}
.chip:hover { filter: brightness(1.14); }
.chip.is-active { background: var(--green); border-color: var(--green-light) #2c4a17 #2c4a17 var(--green-light); }

/* 输入框：凹陷像素槽 */
.amount { display: flex; align-items: stretch; gap: 0; }
.amount input,
.record__time input,
.settings input {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: #e9e9e9;
  border: 3px solid;
  border-color: var(--gui-dark) #ffffff #ffffff var(--gui-dark);
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
.amount input { flex: 1 1 auto; width: auto; min-width: 80px; }
.record__time input { flex: 1 1 140px; width: auto; }
.amount input:focus, .record__time input:focus, .settings input:focus {
  outline: none; background: #fffbe8;
}
.amount__unit {
  display: grid; place-items: center;
  padding: 0 10px;
  background: #9a9a9a; color: #fff;
  border: 3px solid; border-left: none;
  border-color: var(--gui-dark) #ffffff #ffffff var(--gui-dark);
  font-size: 13px;
}

/* ------------------------------------------------------------ 记录列表 */
.log__count { font-size: 12px; color: #4a4a4a; font-weight: 400; }

.log__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.log__row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #b8b8b8;
  border: 3px solid;
  border-color: #e8e8e8 var(--gui-dark) var(--gui-dark) #e8e8e8;
}
.log__row--water { background: #a8c4dc; }
.log__icon { display: grid; place-items: center; }
.log__icon svg { width: 30px; height: 30px; }
.log__time { font-weight: 700; font-variant-numeric: tabular-nums; }
.log__meta { font-size: 12px; color: #3d3d3d; }
.log__amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log__del {
  font-family: var(--font);
  font-size: 12px; line-height: 1;
  padding: 6px 8px;
  background: #9c3b32; color: #fff;
  border: 3px solid; border-color: #cf6a5f #5c1e17 #5c1e17 #cf6a5f;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}
.log__del:hover { filter: brightness(1.15); }

.log__empty { margin: 4px 0 0; color: #4a4a4a; font-size: 13px; }

.log__more { margin-top: 12px; }

.log__day { margin-top: 14px; }
.log__daytitle {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 1px;
  color: #2f2f2f;
  border-bottom: 3px dashed #9a9a9a;
  padding-bottom: 6px;
}
.log__daysum { font-size: 11px; color: #4a4a4a; font-weight: 400; }

/* ------------------------------------------------------------ 设置 */
.settings__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 12px;
}
.settings label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; min-width: 0; }
.settings__foot { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ 狗狗造型 */
.skins__hint { margin: 10px 0 0; font-size: 12px; color: #4a4a4a; }

.skin-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.skin-option {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .45);
  background: #9a9a9a;
  border: 3px solid;
  border-color: #d0d0d0 #4a4a4a #4a4a4a #d0d0d0;
  padding: 6px 8px 5px;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 62px;
}
.skin-option svg { width: 34px; height: 34px; display: block; }
.skin-option:hover { filter: brightness(1.14); }
.skin-option.is-active {
  background: var(--green);
  border-color: var(--green-light) #2c4a17 #2c4a17 var(--green-light);
}
.skin-option.is-active::after { content: "✔"; font-size: 10px; }

/* ------------------------------------------------------------ 达成庆祝 */
.fx-layer {
  position: fixed; inset: 0; z-index: 60;
  overflow: hidden; pointer-events: none;
}
.particle {
  position: absolute;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .25);
  animation-name: rise;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}
@keyframes rise {
  from { transform: translateY(0) scale(1); opacity: 1; }
  70%  { opacity: 1; }
  to   { transform: translateY(-46vh) scale(.6); opacity: 0; }
}

.celebrate {
  position: fixed; left: 50%; top: 11%; z-index: 61;
  transform: translateX(-50%) scale(.82);
  background: #2f2f2f;
  color: #fff;
  border: 5px solid;
  border-color: var(--gold) #8a6a1a #8a6a1a var(--gold);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35);
  padding: 14px 24px;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
  max-width: min(92vw, 520px);
  opacity: 0;
  transition: opacity .22s linear, transform .26s steps(5, end);
}
.celebrate.is-show { opacity: 1; transform: translateX(-50%) scale(1); }
.celebrate__big { display: block; font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.celebrate__sub { display: block; margin-top: 7px; font-size: 12px; color: #ffe9a8; }

/* 达成时狗狗原地雀跃（覆盖默认的呼吸浮动） */
.dog-sprite.is-happy svg { animation: happy .42s steps(2, end) 4; }
@keyframes happy {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-13px); }
}

/* ------------------------------------------------------------ 其它 */
.app-footer { text-align: center; font-size: 12px; color: #2f4a63; }
.app-footer p { margin: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.sprite svg { display: block; image-rendering: pixelated; }
.sprite--sm svg { width: 20px; height: 20px; }
.sprite--md svg { width: 30px; height: 30px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(140%);
  background: var(--gui-darker); color: #fff;
  border: var(--px) solid; border-color: #6f6f6f #000 #000 #6f6f6f;
  padding: 10px 18px;
  font-weight: 700;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
  transition: transform .22s steps(6, end), opacity .22s linear;
  opacity: 0; visibility: hidden;
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.is-show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .app { padding: 14px 10px 110px; gap: 12px; }
  .record__grid { grid-template-columns: 1fr; }
  .header { grid-template-columns: auto 1fr; gap: 12px; }
  .header__clock { grid-column: 1 / -1; text-align: left; }
  .dog-box { width: 78px; height: 78px; }
  .dog-sprite svg { width: 64px; height: 64px; }
  .dog-name { font-size: 20px; }
  .clock__time { font-size: 22px; }
  .stat__big { font-size: 20px; }
  .mc-btn { padding: 12px 14px; }
  .log__row { grid-template-columns: 36px minmax(0, 1fr) auto auto; gap: 8px; }
  .log__icon svg { width: 26px; height: 26px; }
  .skin-option { min-width: 54px; padding: 5px 6px 4px; }
  .skin-option svg { width: 30px; height: 30px; }
  .celebrate { top: 7%; padding: 12px 16px; }
  .celebrate__big { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .dog-sprite svg, .alert-bar { animation: none; }
  .bar__fill { transition: none; }
  .particle { animation: none; opacity: 0; }
  .dog-sprite.is-happy svg { animation: none; }
  .celebrate { transition: none; }
}

/* ------------------------------------------------------------ 同步面板 */
.sync-panel {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #9ba9ff #3d2e5c #3d2e5c #9ba9ff;
}

.sync-panel .panel__title {
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .3);
}

.sync-content {
  display: grid;
  gap: 12px;
}

.sync-input-group {
  display: flex;
  gap: 8px;
}

.sync-input {
  flex: 1;
  padding: 10px 12px;
  border: 3px solid;
  border-color: #3d2e5c #9ba9ff #9ba9ff #3d2e5c;
  background: rgba(255, 255, 255, .95);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
}

.sync-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--gold);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, .25);
  border: 2px solid rgba(255, 255, 255, .3);
  font-size: 13px;
  color: #ffeccc;
}

.sync-dot {
  width: 10px;
  height: 10px;
  background: #9a9a9a;
  border: 2px solid #6a6a6a;
}

.sync-dot.is-online {
  background: var(--green-light);
  border-color: var(--green);
  box-shadow: 0 0 8px var(--green-light);
}

.sync-text {
  font-weight: 700;
  letter-spacing: .5px;
}

.sync-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .sync-input-group { flex-direction: column; }
  .sync-actions { flex-direction: column; }
  .sync-actions .mc-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sync-dot { box-shadow: none; }
}
