/* ============================================================
 * 小鱼の生日大富翁 —— 样式（可爱糖果风）
 * 设计语言：大圆角 / 糖果渐变 / 白描边 / 柔光投影 / 轻微弹跳
 * ============================================================ */

:root {
  --ink: #6b4a5a;
  --ink-soft: #a98a9b;
  --paper: #fffdfb;
  --cream: #fff6fa;

  --pink: #ff8fc0;
  --pink-deep: #ff5fa2;
  --pink-pale: #ffe3f0;

  --peach: #ffb98a;
  --mint: #93e7c4;
  --sky: #a5dcff;
  --lemon: #ffe58a;
  --lilac: #c9b6ff;

  --r-lg: 26px;
  --r-md: 20px;

  --soft: 0 10px 24px rgba(255, 130, 180, 0.22);
  --soft-sm: 0 5px 12px rgba(255, 130, 180, 0.2);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 8% 2%, rgba(255, 214, 234, 0.95) 0 130px, transparent 130px),
    radial-gradient(circle at 96% 8%, rgba(255, 236, 190, 0.75) 0 110px, transparent 110px),
    radial-gradient(circle at 92% 94%, rgba(190, 234, 255, 0.7) 0 150px, transparent 150px),
    radial-gradient(circle at 4% 88%, rgba(214, 244, 228, 0.8) 0 120px, transparent 120px),
    linear-gradient(180deg, #fff9fc 0%, #fff3f8 55%, #fdf4ff 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

#app {
  min-height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------------- 顶部状态 ---------------- */

.hud {
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 8px 6px 9px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #ffffff 0%, #fff6fb 100%);
  border: 2px solid #fff;
  box-shadow: var(--soft-sm);
  transform: rotate(-0.8deg);
}

.stat:nth-child(1) { background: linear-gradient(180deg, #fff 0%, #ffeaf4 100%); }
.stat:nth-child(2) { background: linear-gradient(180deg, #fff 0%, #eef8ff 100%); transform: rotate(0.6deg); }
.stat:nth-child(3) { background: linear-gradient(180deg, #fff 0%, #fff6e0 100%); transform: rotate(-0.4deg); }

.stat .k {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.stat strong {
  display: inline-block;
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: #5a3b4b;
}

.stat strong.low { color: var(--pink-deep); }

.stat strong.bump { animation: bump 0.45s cubic-bezier(0.34, 1.7, 0.5, 1); }

@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.26); color: var(--pink-deep); }
  100% { transform: scale(1); }
}

.help-btn {
  width: 46px;
  flex: 0 0 46px;
  border: 2px solid #fff;
  border-radius: 16px;
  background: linear-gradient(180deg, #e3d7ff, #c9b6ff);
  box-shadow: var(--soft-sm);
  color: #fff;
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
  transform: rotate(2.5deg);
  transition: transform 0.14s cubic-bezier(0.34, 1.6, 0.6, 1);
}

.help-btn:active { transform: rotate(2.5deg) scale(0.93); }

/* ---------------- 棋盘 ---------------- */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.board {
  position: relative;
  width: min(100%, calc((100dvh - 300px) * 1.4133));
  aspect-ratio: 1491 / 1055;
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow:
    0 0 0 4px #fff,
    0 16px 34px rgba(255, 130, 180, 0.26),
    0 4px 10px rgba(255, 130, 180, 0.16);
  transform: rotate(-0.5deg);
}

.board-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--r-lg);
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------------- 格子 ---------------- */

.tile {
  position: absolute;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  font-family: inherit;
}

.tile .glow {
  position: absolute;
  inset: 6%;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.tile:hover .glow,
.tile:focus-visible .glow {
  opacity: 1;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 3px rgba(255, 143, 192, 0.95), 0 0 18px rgba(255, 143, 192, 0.55);
}

.tile.active .glow { opacity: 0; }

.tile.flash .glow { animation: flash 0.45s ease; }

@keyframes flash {
  0%, 100% { opacity: 0; }
  40% { opacity: 1; background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 3px #fff, 0 0 20px rgba(255, 143, 192, 0.8); }
}

/* 对齐检查：按 G */
.board.show-grid .tile {
  outline: 2px dashed rgba(255, 95, 162, 0.75);
  outline-offset: -2px;
}

.board.show-grid .tile .glow {
  opacity: 1;
  background: rgba(255, 143, 192, 0.18);
  box-shadow: none;
  animation: none;
}

/* 选目标格（飞行卡） */
.board.picking .tile { cursor: crosshair; outline: 2px dashed var(--sky); outline-offset: -2px; }

.board.picking .tile:hover .glow {
  opacity: 1;
  background: rgba(165, 220, 255, 0.3);
  box-shadow: inset 0 0 0 3px var(--sky), 0 0 18px rgba(165, 220, 255, 0.8);
}

/* 棋子 */
.token {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 12;
  pointer-events: none;
  transition: left 0.18s cubic-bezier(0.34, 1.4, 0.64, 1), top 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
  filter:
    drop-shadow(0 0 2.5px #fff)
    drop-shadow(0 3px 4px rgba(190, 90, 130, 0.4));
}

.token svg {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
  animation: fishBob 2.2s ease-in-out infinite;
}

@keyframes fishBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4%) rotate(2deg); }
}

/* ---------------- 浮动提示 ---------------- */

.toast {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12.5px;
  font-weight: 900;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(255, 130, 180, 0.35);
  pointer-events: none;
  z-index: 20;
  animation: rise 1.05s ease forwards;
  white-space: nowrap;
}

.toast-pos  { color: #2aa96b; }
.toast-neg  { color: var(--pink-deep); }
.toast-gold { color: #d99400; }
.toast-info { color: #8a6ad6; }

@keyframes rise {
  0%   { opacity: 0; transform: translate(-50%, -20%) scale(0.85); }
  18%  { opacity: 1; transform: translate(-50%, -62%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.95); }
}

/* ---------------- 底部操作 ---------------- */

.dock {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 2px;
}

.status {
  align-self: center;
  max-width: 100%;
  padding: 4px 14px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  box-shadow: var(--soft-sm);
}

.items {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 470px;
  margin: 0 auto;
}

.items-empty {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.chip {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  border: 2px solid #fff;
  background: #fff;
  box-shadow: var(--soft-sm);
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.14s cubic-bezier(0.34, 1.6, 0.6, 1);
}

.chip:active { transform: scale(0.9); }

.chip.passive { background: var(--pink-pale); }

.chip sup {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--pink-deep);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 12px;
  text-align: center;
  padding: 0 3px;
}

.roll-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 470px;
  margin: 0 auto;
}

.dice {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  font-size: 30px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fff2f8);
  border: 2px solid #fff;
  box-shadow: var(--soft-sm);
  color: #6a4a5c;
  transform: rotate(-3deg);
}

.dice.rolling { animation: shake 0.16s linear infinite; }
.dice.pop { animation: pop 0.3s cubic-bezier(0.34, 1.7, 0.5, 1); }

@keyframes shake {
  0%, 100% { transform: rotate(-9deg); }
  50% { transform: rotate(9deg); }
}

@keyframes pop {
  0% { transform: rotate(-3deg) scale(0.7); }
  60% { transform: rotate(2deg) scale(1.18); }
  100% { transform: rotate(-3deg) scale(1); }
}

/* 开发者模式 */
.dice.dev {
  cursor: pointer;
  border: 2px dashed var(--pink);
}

.dice.dev::after {
  content: attr(data-dev);
  position: absolute;
  top: -9px;
  right: -9px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--pink-deep);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  box-shadow: var(--soft-sm);
}

.roll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 58px;
  border: 2px solid #fff;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffa6cf 0%, #ff6fb0 100%);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(255, 95, 162, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -3px 0 rgba(200, 50, 110, 0.18);
  transition: transform 0.12s cubic-bezier(0.34, 1.6, 0.6, 1), box-shadow 0.2s, filter 0.2s;
}

.roll small {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.92;
  letter-spacing: 0.04em;
}

.roll:active:not(:disabled) {
  transform: translateY(3px) scale(0.99);
  box-shadow: 0 3px 8px rgba(255, 95, 162, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.roll:disabled {
  filter: grayscale(0.4) brightness(1.03);
  opacity: 0.75;
  cursor: default;
  box-shadow: 0 4px 10px rgba(255, 130, 180, 0.2);
}

.roll.pulse { animation: breathe 2.2s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.022); }
}

/* ---------------- 弹窗 ---------------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(110, 70, 95, 0.3);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.mask.in { opacity: 1; }
.mask.out { opacity: 0; }

.sheet {
  width: 100%;
  max-width: 360px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 22px 20px 18px;
  border-radius: 28px;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #ffffff 0%, #fffafd 100%);
  box-shadow:
    0 22px 50px rgba(150, 80, 120, 0.28),
    0 0 0 1px rgba(255, 190, 215, 0.6);
  transform: translateY(16px) scale(0.94);
  transition: transform 0.24s cubic-bezier(0.34, 1.5, 0.64, 1);
  text-align: center;
}

.mask.in .sheet { transform: translateY(0) scale(1); }

.sheet-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 6px rgba(255, 130, 180, 0.35));
}

.sheet-title {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #5a3b4b;
}

.sheet-body {
  font-size: 14.5px;
  line-height: 1.7;
  color: #7a5a6b;
  font-weight: 600;
}

.sheet-body b {
  color: var(--pink-deep);
  font-weight: 900;
  padding: 0 2px;
}

.muted {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
}

.sheet-input {
  width: 100%;
  margin-top: 12px;
  padding: 11px 15px;
  border-radius: 16px;
  border: 2.5px solid #ffe0ee;
  background: #fffafd;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sheet-input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 143, 192, 0.2);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.sheet-actions.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 9px;
}

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 9px 12px;
  border: 2px solid #fff;
  border-radius: 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: #fff;
  color: #6b4a5a;
  box-shadow: var(--soft-sm);
  transition: transform 0.12s cubic-bezier(0.34, 1.6, 0.6, 1), box-shadow 0.15s, filter 0.15s;
}

.btn small {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.8;
}

.btn:active { transform: scale(0.96); }

.btn.primary {
  background: linear-gradient(180deg, #ffa6cf 0%, #ff6fb0 100%);
  color: #fff;
  box-shadow:
    0 8px 18px rgba(255, 95, 162, 0.38),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
}

.btn.danger {
  background: linear-gradient(180deg, #ffc49a 0%, #ff9f6b 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 150, 100, 0.34), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.btn.soft {
  background: linear-gradient(180deg, #ffffff, #ffeef7);
  color: #b3457a;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-soft);
  font-weight: 800;
  min-height: 40px;
}

.btn.ghost:active { transform: none; opacity: 0.7; }

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

/* 刮刮卡 */
.scratch-back {
  margin: 10px auto 12px;
  width: 160px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 2.5px dashed #ffb8d6;
  background: repeating-linear-gradient(45deg, #fff7fb, #fff7fb 9px, #ffe9f3 9px, #ffe9f3 18px);
  color: #ff7fb2;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

.card-text {
  margin: 8px 0 10px;
  padding: 13px 15px;
  border-radius: 18px;
  background: #fff4fa;
  border: 1.5px solid #ffe0ee;
  font-size: 15px;
  line-height: 1.75;
  color: #7a4258;
  font-weight: 800;
  text-align: left;
}

.card-pts {
  font-size: 21px;
  font-weight: 900;
  color: var(--pink-deep);
}

/* 结算 */
.result-banner {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.result-banner.win {
  color: #b3457a;
  background: linear-gradient(120deg, #ffe6f2, #fff4d8);
  box-shadow: inset 0 0 0 2px #ffd0e2;
}

.result-banner.lose {
  color: #7a5f70;
  background: linear-gradient(120deg, #f4ecfa, #fdf1f6);
  box-shadow: inset 0 0 0 2px #eadcf3;
}

.result-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 6px;
}

.result-rank .big {
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(140deg, #ffb36b, #ff5fa2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 4px rgba(255, 120, 170, 0.3));
}

.result-rank .rank-title {
  font-size: 15px;
  font-weight: 900;
  color: #b3457a;
}

.result-score {
  font-size: 34px;
  font-weight: 900;
  color: var(--pink-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.result-score small {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  margin-left: 4px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 14px 0;
}

.result-grid > div {
  background: linear-gradient(180deg, #fff, #fff5fa);
  border-radius: 16px;
  padding: 8px 2px;
  box-shadow: inset 0 0 0 1.5px #ffe3f0;
}

.result-grid b {
  display: block;
  font-size: 16px;
  font-weight: 900;
  color: #d1407a;
}

.result-grid span {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
}

.result-quotes {
  text-align: left;
  margin-top: 6px;
}

.result-quotes h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-soft);
}

.result-quotes ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.75;
  font-weight: 600;
  color: #7a5a6b;
  max-height: 120px;
  overflow-y: auto;
}

.rules {
  margin: 0;
  padding-left: 18px;
  text-align: left;
  font-size: 13px;
  line-height: 1.95;
  font-weight: 600;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 640px) {
  #app { padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); }
  .board {
    width: min(100%, calc((100dvh - 272px) * 1.4133));
  }
  .stat strong { font-size: 16px; }
  .help-btn { width: 42px; flex-basis: 42px; font-size: 17px; }
  .dice { width: 50px; height: 50px; flex-basis: 50px; font-size: 26px; }
  .roll { min-height: 50px; font-size: 16px; }
  .sheet { max-width: 100%; padding: 18px 16px 14px; }
}

@media (max-height: 720px) and (max-width: 640px) {
  .board { width: min(100%, calc((100dvh - 258px) * 1.4133)); }
  .status { font-size: 10.5px; }
}

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