:root {
  --bg-top: #040611;
  --bg-bottom: #0a1230;
  --ui-bg: rgba(7, 12, 26, 0.74);
  --ui-border: rgba(146, 182, 255, 0.35);
  --text: #eaf2ff;
  --card-bg-panel: #e7edf6;
  --card-text: #0f172a;
  --card-line: #c9d5e6;

  --bg-dark: #072a15;
  --bg-table: #1c5230;
  --brand: #4f7bff;
  --brand-hover: #eab308;
  --text-light: #f8fafc;
  --suit-black: #1e293b;
  --suit-red: #dc2626;
  --card-bg: #ffffff;
  --card-border: #cbd5e1;
  --card-radius: 8px;
  --font-ui: "Noto Sans TC", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, var(--bg-bottom), var(--bg-top));
  color: var(--text);
  font-family: var(--font-ui);
}

.page-wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(8, 10, 23, 0.92);
  border-bottom: 1px solid rgba(126, 153, 255, 0.24);
  backdrop-filter: blur(8px);
}

.top-strip-inner {
  overflow-x: auto;
}

.top-bar {
  padding: 0.35rem 0;
  display: flex;
  align-items: center;
  min-height: 58px;
  width: max-content;
}

.icon-button {
  width: auto;
  height: auto;
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  transition: filter 0.2s, transform 0.2s;
}

.icon-button img {
  width: clamp(168px, 26vw, 280px);
  height: auto;
  pointer-events: none;
}

.icon-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.game-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  padding: 1.2rem 0 2rem;
}

.game-stage,
.game-info {
  grid-column: 1;
}

.game-panel {
  background: var(--card-bg-panel);
  border: 1px solid var(--card-line);
  border-radius: 8px;
  color: var(--card-text);
  padding: 1rem 1.05rem;
  box-shadow: 0 10px 24px rgba(9, 20, 36, 0.08);
}

.game-info h2 {
  margin: 0 0 0.5rem;
}

.game-info p {
  margin: 0.35rem 0;
  line-height: 1.6;
}

.game-info h3 {
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(13, 24, 51, 0.82);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.05);
}

.hud-controls {
  display: flex;
  gap: 0.5rem;
}

.hud-controls button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.hud-controls button:hover:not(:disabled) {
  background: var(--brand);
  color: var(--bg-dark);
  border-color: var(--brand);
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.4);
}

.hud-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hud-stats {
  display: flex;
  gap: 1.5rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  font-size: 1.1rem;
}

.hud-stats span {
  color: var(--brand);
  margin-left: 0.2rem;
}

/* BOARD */
.game-viewport {
  width: 100%;
  max-width: 1200px;
  height: 1000px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(146, 182, 255, 0.45);
  background: var(--bg-table);
  background-image:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.3) 100%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.02) 0, rgba(0, 0, 0, 0.02) 2px, transparent 2px, transparent 8px);
  user-select: none;
  touch-action: none;
}

.board {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* SLOTS */
.slot {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: var(--card-radius);
  background: rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  transition: all 0.2s;
}

.slot.highlight {
  background: rgba(234, 179, 8, 0.2);
  border-color: var(--brand);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.5);
}

.slot-stock::after {
  content: "↺";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.2);
  font-weight: 300;
}

.slot-foundation::after {
  content: "A";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.12);
  font-weight: 800;
}

/* CARDS */
.card {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--card-border);
  box-sizing: border-box;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  overflow: hidden;
  padding: 0;
}

.card:not(.face-up) {
  background: #2563eb;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%);
  background-position: 10px 0, 10px 0, 0 0, 0 0;
  background-size: 20px 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.card:not(.face-up) * {
  display: none;
}

.card.dragging {
  transition: none !important;
  cursor: grabbing;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--card-border);
}

.card.hint-anim {
  animation: pulse-hint 1s infinite alternate;
}

@keyframes pulse-hint {
  from {
    box-shadow: 0 0 0px 4px var(--brand);
    z-index: 50;
  }

  to {
    box-shadow: 0 0 15px 8px var(--brand);
    z-index: 50;
  }
}

.card.selected {
  box-shadow: 0 0 0 4px var(--brand), 0 4px 8px rgba(0, 0, 0, 0.3);
  z-index: 40;
}

/* 左上角：點數 + 花色同一排 */
.card-top {
  position: absolute;
  top: 0.22em;
  left: 0.24em;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.08em;
  padding: 0.02em 0.14em 0.04em;
  min-width: 0;
  line-height: 1;
  font-weight: 800;
  font-size: 0.96em;
  z-index: 3;
  pointer-events: none;
  text-align: left;
  border-radius: 0.22em;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.card-top .rank {
  display: block;
  font-size: 1em;
  line-height: 1;
  letter-spacing: -0.02em;
}

.card-top .suit {
  display: block;
  font-size: 0.9em;
  line-height: 1;
  transform: translateY(0.01em);
}

/* 中間大花色 */
.card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.7em;
  font-weight: 700;
  opacity: 0.32;
  z-index: 1;
  pointer-events: none;
  transform: translateY(0.02em);
}

.card-bottom {
  display: none;
}

.card .rank,
.card .suit {
  pointer-events: none;
}

.color-black {
  color: var(--suit-black);
}

.color-red {
  color: var(--suit-red);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .hide-mobile {
    display: none;
  }

  .hud {
    padding: 0.4rem 0.6rem;
  }

  .hud-stats {
    gap: 0.8rem;
    font-size: 0.95rem;
  }

  .hud-controls button {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
  }

  .solitaire-app {
    padding: 0.3rem 0.5rem;
  }

  .icon-button img {
    width: clamp(100px, 20vw, 150px);
  }

  .card-top {
    top: 0.18em;
    left: 0.18em;
    font-size: 0.9em;
    gap: 0.06em;
    padding: 0.02em 0.12em 0.03em;
  }

  .card-center {
    font-size: 2.35em;
    opacity: 0.3;
  }
}

/* 遊戲結束區塊 */
.win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 500;
  backdrop-filter: blur(4px);
  text-align: center;
}

.win-overlay h2 {
  font-size: 2.5rem;
  color: #ffd700;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.win-overlay p {
  font-size: 1.5rem;
  margin-bottom: 2rem;
}

.win-overlay button {
  padding: 1rem 2rem;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  background: var(--brand);
  border: none;
  border-radius: 8px;
  color: #000;
  transition: transform 0.2s, box-shadow 0.2s;
}

.win-overlay button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--brand);
}

.site-footer {
  border-top: 1px solid rgba(177, 198, 233, 0.28);
  padding: 1rem 0 1.5rem;
  color: #d5e2ff;
}

/* Fullscreen Hint & Layout Overrides */
.fs-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 1.4rem 3rem;
  border-radius: 60px;
  font-size: 1.5rem;
  font-weight: 700;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  letter-spacing: 1px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.fs-hint.show {
  opacity: 1;
  visibility: visible;
}

:fullscreen .top-strip,
:fullscreen .site-header,
:fullscreen .site-footer,
:fullscreen .game-info {
  display: none !important;
}

:fullscreen .game-page {
  padding: 0 !important;
  margin: 0 !important;
}

:fullscreen .game-stage {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
  border: none;
}

:fullscreen .game-viewport {
  height: calc(100vh - 80px); /* 扣掉 HUD 大約高度 */
}