* {
  box-sizing: border-box;
}

:root {
  --page-bg: #f6f2ea;
  --card-bg: #fffdf8;
  --ink: #243143;
  --muted: #6d7784;
  --line: #cbd5df;
  --forum-blue: #3f78a8;
  --forum-blue-dark: #2e5f88;
  --soft-blue: #eaf3fb;
  --button-shadow: 0 4px 0 rgba(31, 49, 69, 0.16);
  --radius: 18px;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(115, 166, 208, 0.12), transparent 30rem),
    var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
summary {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100% - 24px, 780px);
  margin: 0 auto;
  padding: 28px 0 42px;
}

.game-header {
  text-align: center;
  margin-bottom: 18px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border: 1px solid #9dbbd3;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--forum-blue-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.game-header h1 {
  margin: 10px 0 6px;
  font-size: clamp(26px, 5vw, 38px);
  line-height: 1.15;
}

.subtitle {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-item {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.94);
  text-align: center;
}

.status-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-item strong span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.machine-card,
.result-card,
.rules-card {
  border: 1px solid #b9c7d3;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 10px 30px rgba(40, 56, 76, 0.08);
}

.machine-card {
  overflow: hidden;
}

.machine-topbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #edf4fa;
  color: var(--forum-blue-dark);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.machine-light {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #74a5cb;
  box-shadow: 0 0 0 4px rgba(116, 165, 203, 0.16);
}

.state-badge {
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid #b9cbd9;
  border-radius: 999px;
  background: #fff;
  color: #607182;
  font-size: 11px;
  letter-spacing: 0;
}

.machine-window {
  position: relative;
  padding: 14px 14px 12px 34px;
  background: #e7edf2;
}

.reels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(5px, 1.4vw, 10px);
  width: 100%;
}

.reel {
  min-width: 0;
}

.reel-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 3;
  overflow: hidden;
  border: 2px solid #33485c;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.reel-track {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  will-change: transform;
}

.slot-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-bottom: 1px solid rgba(45, 64, 82, 0.42);
  background: #fff;
}

.slot-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.reel-viewport::before,
.reel-viewport::after {
  position: absolute;
  z-index: 3;
  left: 0;
  width: 100%;
  height: 10%;
  content: "";
  pointer-events: none;
}

.reel-viewport::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(26, 40, 54, 0.16), transparent);
}

.reel-viewport::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(26, 40, 54, 0.14), transparent);
}

.reel-viewport.settled {
  animation: reel-settle 180ms ease-out;
}

@keyframes reel-settle {
  0% { transform: translateY(-3px); }
  55% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

.line-tags {
  position: absolute;
  z-index: 5;
  top: 14px;
  bottom: 12px;
  left: 8px;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  width: 20px;
  pointer-events: none;
}

.line-tags span {
  display: grid;
  place-items: center;
  color: #5d6f7d;
  font-size: 11px;
  font-weight: 800;
}

.stop-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px 6px;
}

.stop-button,
.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.stop-button {
  border: 1px solid #71869a;
  background: #f5f8fa;
  color: #32475a;
  font-size: 14px;
  font-weight: 800;
}

.stop-button:not(:disabled):active,
.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: none;
}

.stop-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

.main-controls {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 10px;
  padding: 6px 14px 10px;
}

.primary-button {
  border: 1px solid #2a5d86;
  background: var(--forum-blue);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--button-shadow);
}

.secondary-button {
  border: 1px solid #8796a5;
  background: #fff;
  color: #31465a;
  font-weight: 800;
  box-shadow: var(--button-shadow);
}

.message-box {
  min-height: 44px;
  margin: 0;
  padding: 10px 16px 14px;
  color: #627080;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.result-card {
  margin-top: 14px;
  padding: 16px;
}

.result-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-heading h2 {
  margin: 0;
  font-size: 18px;
}

.result-badge {
  margin-left: auto;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.result-badge.neutral {
  background: #eef1f4;
  color: #697783;
}

.result-badge.win {
  background: #e5f5e7;
  color: #34703d;
}

.result-badge.lose {
  background: #f2f0ed;
  color: #786f65;
}

#resultSummary {
  margin: 10px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.result-lines {
  display: grid;
  gap: 8px;
}

.result-line-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #d5dce3;
  border-radius: 10px;
  background: #fbfcfd;
  font-size: 13px;
}

.result-line-item img {
  width: 42px;
  height: 42px;
  border: 1px solid #bdc8d1;
  border-radius: 8px;
  object-fit: cover;
}

.result-line-item strong {
  display: block;
  margin-bottom: 2px;
}

.result-line-item small {
  color: var(--muted);
}

.result-line-reward {
  font-weight: 900;
  white-space: nowrap;
}

.result-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #c7d0d8;
}

.result-total span {
  color: var(--muted);
}

.result-total strong {
  color: var(--forum-blue-dark);
  font-size: 20px;
}

.result-total strong span {
  color: inherit;
}

.rules-card {
  margin-top: 14px;
  overflow: hidden;
}

.rules-card summary {
  padding: 14px 16px;
  cursor: pointer;
  color: #33475b;
  font-weight: 900;
}

.rules-content {
  padding: 0 16px 16px;
  border-top: 1px solid #dbe1e6;
}

.rules-content ul {
  margin: 14px 0;
  padding-left: 20px;
  color: #5f6d79;
  font-size: 13px;
  line-height: 1.8;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #d5dde4;
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e1e6ea;
  text-align: center;
}

th {
  background: #f0f5f9;
  color: #40576b;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.probability-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef1f3;
}

.game-footer {
  padding: 18px 4px 0;
  color: #88929b;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 620px) {
  .game-shell {
    width: min(100% - 14px, 780px);
    padding-top: 14px;
  }

  .status-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .status-item {
    padding: 9px 7px;
  }

  .machine-window {
    padding: 8px 8px 8px 27px;
  }

  .line-tags {
    top: 8px;
    bottom: 8px;
    left: 4px;
    width: 18px;
  }

  .stop-controls {
    gap: 5px;
    padding: 9px 8px 5px;
  }

  .stop-button {
    min-height: 46px;
    padding: 6px 3px;
    font-size: 12px;
  }

  .main-controls {
    gap: 7px;
    padding: 5px 8px 8px;
  }

  .result-card {
    padding: 13px;
  }
}

@media (max-width: 390px) {
  .game-header h1 {
    font-size: 25px;
  }

  .subtitle {
    font-size: 12px;
  }

  .reels {
    gap: 4px;
  }

  .reel-viewport {
    border-width: 1px;
    border-radius: 7px;
  }

  .stop-button {
    font-size: 11px;
  }

  .main-controls {
    grid-template-columns: 1fr;
  }
}

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

/* =========================================================
   v1.0.4 中奖特效
   ========================================================= */

.machine-window {
  --win-glow: rgba(234, 179, 52, 0.72);
  --win-edge: rgba(193, 135, 20, 0.95);
  isolation: isolate;
}

.machine-window.win-grade-5 {
  --win-glow: rgba(222, 181, 87, 0.42);
  --win-edge: rgba(181, 139, 51, 0.78);
}

.machine-window.win-grade-4 {
  --win-glow: rgba(231, 178, 54, 0.52);
  --win-edge: rgba(193, 133, 22, 0.86);
}

.machine-window.win-grade-3 {
  --win-glow: rgba(239, 177, 41, 0.64);
  --win-edge: rgba(202, 129, 16, 0.94);
}

.machine-window.win-grade-2,
.machine-window.win-grade-1 {
  --win-glow: rgba(250, 189, 35, 0.82);
  --win-edge: rgba(214, 137, 8, 1);
}

.win-fx-layer {
  position: absolute;
  z-index: 12;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.win-fx-layer.flash-medium::before,
.win-fx-layer.flash-strong::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0;
  pointer-events: none;
}

.win-fx-layer.flash-medium::before {
  background: radial-gradient(circle at 50% 50%, rgba(255, 232, 153, 0.34), transparent 62%);
  animation: win-screen-flash 760ms ease-out 1;
}

.win-fx-layer.flash-strong::before {
  background: radial-gradient(circle at 50% 50%, rgba(255, 235, 152, 0.52), transparent 68%);
  animation: win-screen-flash 760ms ease-out 2;
}

.win-row-band {
  position: absolute;
  border-top: 2px solid var(--win-edge);
  border-bottom: 2px solid var(--win-edge);
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 232, 154, 0.16) 12%,
    rgba(255, 229, 138, 0.32) 50%,
    rgba(255, 232, 154, 0.16) 88%,
    transparent
  );
  box-shadow: 0 0 18px var(--win-glow), inset 0 0 14px rgba(255, 244, 195, 0.22);
  opacity: 0;
  animation: win-row-band 1280ms ease-in-out 1 forwards;
}

.slot-cell.win-cell {
  z-index: 4;
  outline: 2px solid var(--win-edge);
  outline-offset: -3px;
  animation: win-cell-pulse 620ms ease-in-out 2;
}

.slot-cell.win-cell img {
  animation: win-image-pop 620ms ease-in-out 2;
}

.win-banner {
  position: absolute;
  z-index: 18;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 10px 18px;
  border: 1px solid rgba(171, 119, 15, 0.72);
  border-radius: 999px;
  background: rgba(255, 249, 226, 0.95);
  box-shadow: 0 8px 26px rgba(116, 79, 7, 0.18), 0 0 24px rgba(240, 181, 38, 0.36);
  color: #805813;
  font-size: clamp(18px, 4vw, 29px);
  font-weight: 950;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.72);
}

.win-banner.show {
  animation: win-banner-pop 1260ms cubic-bezier(.2,.88,.27,1.15) 1 forwards;
}

.win-banner.grade-1 {
  padding: 12px 22px;
  border-width: 2px;
  font-size: clamp(21px, 4.6vw, 34px);
}

.win-reward-float {
  position: absolute;
  z-index: 16;
  min-width: 56px;
  padding: 5px 10px;
  border: 1px solid rgba(177, 124, 16, 0.6);
  border-radius: 999px;
  background: rgba(255, 251, 234, 0.95);
  box-shadow: 0 5px 16px rgba(108, 73, 5, 0.16);
  color: #8b5d0c;
  font-size: clamp(15px, 3vw, 22px);
  font-weight: 950;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -30%) scale(0.85);
  animation: win-reward-rise 1180ms ease-out forwards;
}

.win-particle {
  position: absolute;
  z-index: 14;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--particle-scale, 1));
  animation: win-particle-burst 1120ms cubic-bezier(.13,.67,.2,1) var(--particle-delay, 0ms) 1 forwards;
}

.win-particle.star {
  width: 18px;
  height: 18px;
  color: #d89511;
  font-size: 18px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 226, 118, 0.9);
}

.win-particle.coin {
  width: 11px;
  height: 11px;
  border: 2px solid #c98a0d;
  border-radius: 50%;
  background: #ffe08a;
  box-shadow: inset 0 0 0 2px rgba(255, 249, 215, 0.65), 0 0 7px rgba(232, 170, 25, 0.42);
}

.result-card.win-result-pop {
  animation: result-card-pop 640ms ease-out 1;
}

.machine-card.jackpot-flash {
  animation: jackpot-card-flash 720ms ease-in-out 2;
}

@keyframes win-cell-pulse {
  0%, 100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
  45% {
    box-shadow: inset 0 0 20px 4px var(--win-glow), 0 0 16px 3px var(--win-glow);
  }
}

@keyframes win-image-pop {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.065); }
}

@keyframes win-row-band {
  0% { opacity: 0; transform: scaleX(0.84); }
  18% { opacity: 1; transform: scaleX(1); }
  62% { opacity: 0.92; }
  100% { opacity: 0; transform: scaleX(1.02); }
}

@keyframes win-banner-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  30% { transform: translate(-50%, -50%) scale(0.98); }
  64% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -63%) scale(0.98); }
}

@keyframes win-reward-rise {
  0% { opacity: 0; transform: translate(-50%, -15%) scale(0.82); }
  18% { opacity: 1; transform: translate(-50%, -35%) scale(1.08); }
  50% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.94); }
}

@keyframes win-particle-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  12% { opacity: 1; }
  72% { opacity: 0.95; }
  100% {
    opacity: 0;
    transform: translate(
      calc(-50% + var(--particle-x)),
      calc(-50% + var(--particle-y))
    ) scale(var(--particle-scale, 1)) rotate(var(--particle-rotate, 160deg));
  }
}

@keyframes win-screen-flash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes result-card-pop {
  0% { transform: translateY(2px); box-shadow: 0 10px 30px rgba(40, 56, 76, 0.08); }
  42% { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(176, 126, 22, 0.19); }
  100% { transform: translateY(0); box-shadow: 0 10px 30px rgba(40, 56, 76, 0.08); }
}

@keyframes jackpot-card-flash {
  0%, 100% { box-shadow: 0 10px 30px rgba(40, 56, 76, 0.08); }
  50% { box-shadow: 0 10px 34px rgba(200, 144, 25, 0.34), 0 0 0 2px rgba(237, 183, 52, 0.22); }
}

@media (max-width: 620px) {
  .win-banner {
    padding: 8px 13px;
  }

  .win-particle.star {
    width: 15px;
    height: 15px;
    font-size: 15px;
    line-height: 15px;
  }

  .win-particle.coin {
    width: 9px;
    height: 9px;
  }
}

/* ===== v1.0.6 layout overrides ===== */
.game-header.simple-title {
  margin: 8px 0 18px;
  text-align: center;
}

.game-header.simple-title h1 {
  margin: 0;
  color: #000;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.main-controls.single-control {
  grid-template-columns: 1fr;
}

.main-action-button {
  width: 100%;
}

@media (max-width: 620px) {
  .game-header.simple-title {
    margin: 6px 0 14px;
  }

  .game-header.simple-title h1 {
    font-size: 28px;
  }
}


/* v1.0.8：累计奖励与历史中奖记录 */
.current-win-item strong {
  font-size: 15px;
}

.win-history-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #d9e0e6;
}

.win-history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.win-history-heading strong {
  color: var(--ink);
  font-size: 14px;
}

.win-history-heading span {
  color: var(--muted);
  font-size: 12px;
}

.win-history-list {
  display: grid;
  gap: 8px;
}

.win-history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #dde3e8;
  border-radius: 10px;
  background: #fbfcfd;
}

.win-history-item img {
  width: 40px;
  height: 40px;
  border: 1px solid #c3cdd5;
  border-radius: 8px;
  object-fit: cover;
}

.win-history-body {
  min-width: 0;
}

.win-history-body strong,
.win-history-body small,
.win-history-body time {
  display: block;
}

.win-history-body strong {
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
}

.win-history-body small {
  color: var(--muted);
  font-size: 12px;
}

.win-history-body time {
  margin-top: 3px;
  color: #929ba4;
  font-size: 10px;
}

.win-history-reward {
  color: var(--forum-blue-dark);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.win-history-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed #d4dce3;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 620px) {
  .win-history-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
  }

  .win-history-item img {
    width: 36px;
    height: 36px;
  }
}
