:root {
  --bg-top: #0b132b;
  --bg-bottom: #111827;
  --panel: #1f2937;
  --panel-border: #334155;
  --text-main: #f8fafc;
  --text-soft: #cbd5e1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.game-page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 24px 18px 28px;
}

.home-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding-left: 10px;
  color: #f5f9ff;
  text-decoration: none;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  letter-spacing: 0.03em;
  font-weight: 700;
  line-height: 1;
}

.home-brand-text {
  margin-left: 0;
}

.home-brand-link:focus-visible {
  outline: 2px solid rgba(147, 197, 253, 0.8);
  outline-offset: 4px;
  border-radius: 8px;
}

.home-brand-icons {
  display: inline-flex;
  gap: 6px;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  line-height: 1;
  transform: translateY(1px);
}

.home-brand-icon.spade,
.home-brand-icon.club {
  color: #b08a48;
}

.home-brand-icon.heart,
.home-brand-icon.diamond {
  color: #ff1e1e;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.03em;
}

.hud {
  margin-top: 16px;
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.hud-left-group {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.hud-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
}

.hud-bonus-box {
  min-width: 194px;
  width: 194px;
  flex: 0 0 194px;
  height: 82px;
  padding: 8px 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
}

.hud-bonus-stack {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}

.hud-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  letter-spacing: 0.03em;
  text-align: center;
}

.hud-box {
  min-width: 140px;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 86%, white 14%);
  text-align: center;
}

.score-label {
  display: block;
  color: var(--text-soft);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-value {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.lives-box {
  display: grid;
  justify-items: center;
  text-align: center;
}

.lives-box .score-value {
  display: none;
}

.hearts-track {
  margin-top: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

.heart-unit {
  font-size: 1.14rem;
  line-height: 1;
  color: #ef4444;
  filter: drop-shadow(0 0 3px rgba(239, 68, 68, 0.45));
  transition: opacity 0.15s ease;
}

.heart-unit.losing {
  animation: heartBlinkTwice 0.48s ease-in-out 1;
}

.heart-unit.lost {
  opacity: 0.18;
  filter: none;
}

.settings-gear-btn {
  width: 34px;
  height: 34px;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 86%, white 14%);
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.settings-gear-btn:hover {
  background: color-mix(in srgb, var(--panel) 76%, white 24%);
}

@keyframes heartBlinkTwice {
  0% { opacity: 1; }
  12.5% { opacity: 0.1; }
  25% { opacity: 1; }
  37.5% { opacity: 0.1; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

.play-button {
  border: 1px solid #2563eb;
  background: #3b82f6;
  color: #eff6ff;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 18px 42px;
  cursor: pointer;
}

.play-button:hover {
  background: #2563eb;
}

.play-button-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
}

.board-wrap {
  margin-top: 14px;
}

.seo-content {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid #8ea0bb;
  border-radius: 14px;
  background: rgba(239, 246, 255, 0.96);
}

.seo-content h2,
.seo-content h3 {
  margin: 0;
  color: #0f172a;
}

.seo-content h2 {
  font-size: 1.35rem;
}

.seo-content h3 {
  margin-top: 12px;
  font-size: 1.04rem;
}

.seo-content p {
  margin: 6px 0 0;
  color: #0f172a;
  line-height: 1.45;
}

.cbd-explainer-figure {
  margin: 10px 0 4px;
  text-align: center;
}

.cbd-explainer-figure img {
  display: inline-block;
  width: min(100%, 960px);
  height: auto;
  border: 1px solid #8ea0bb;
  border-radius: 10px;
  background: #ffffff;
}

.game-board {
  width: 100%;
  min-height: 68vh;
  border: 2px solid #64748b;
  border-radius: 16px;
  padding: 14px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 30%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.05), transparent 34%),
    rgba(15, 23, 42, 0.8);
}

.game-board.life-loss-shake {
  animation: boardShake var(--shake-ms, 150ms) ease-in-out 1;
}

.game-board.life-loss-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: rgba(220, 38, 38, 0.36);
  opacity: 0;
  pointer-events: none;
  animation: lifeLossFlash 170ms ease-out 1 forwards;
}

@keyframes boardShake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 1px); }
  40% { transform: translate(4px, -1px); }
  60% { transform: translate(-3px, 1px); }
  80% { transform: translate(3px, -1px); }
  100% { transform: translate(0, 0); }
}

@keyframes lifeLossFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.board-column {
  min-height: calc(68vh - 32px);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 8px;
  position: relative;
  overflow: hidden;
  background: transparent;
}

.column-label {
  display: block;
  color: transparent;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2px;
  pointer-events: none;
  user-select: none;
}

.active-card {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(150px, 34%);
  aspect-ratio: 63 / 88;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: #111827;
  box-shadow: 0 8px 16px rgba(2, 6, 23, 0.45);
  transform: translateX(-50%);
  cursor: pointer;
  user-select: none;
  z-index: 2;
}

.card-part {
  position: absolute;
  line-height: 1;
  font-weight: 900;
}

.card-rank-top {
  top: 10px;
  left: 10px;
  font-size: 2.1rem;
}

.card-suit-top {
  top: 14px;
  left: 38px;
  font-size: 2rem;
}

.active-card.rank-10 .card-suit-top {
  left: 52px;
}

.card-suit-center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 4.6rem;
}

.card-suit-bottom {
  bottom: 14px;
  left: 12px;
  font-size: 2rem;
}

.active-card.rank-10 .card-suit-bottom {
  left: 26px;
}

.card-rank-bottom {
  right: 10px;
  bottom: 8px;
  font-size: 2.1rem;
}

.suit-red {
  color: #dc2626;
}

.suit-black {
  color: #111827;
}

.burst-piece {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(248, 250, 252, 0.95);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.3);
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  z-index: 4;
}

.burst-piece.big-suit {
  min-width: 52px;
  min-height: 52px;
  font-size: 2.25rem;
}

.burst-piece.small-part {
  font-size: 1.5rem;
}

.burst-piece.clutch-flash {
  animation: clutchFlashPulse 1s ease-in-out 1;
}

.preview-piece {
  pointer-events: none;
  opacity: 0.64;
  filter: saturate(0.9);
  will-change: transform;
  z-index: 1;
}

@keyframes clutchFlashPulse {
  0% { box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
  20% { box-shadow: 0 0 22px rgba(250, 204, 21, 0.95); }
  50% { box-shadow: 0 0 12px rgba(250, 204, 21, 0.72); }
  80% { box-shadow: 0 0 18px rgba(250, 204, 21, 0.9); }
  100% { box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
}

.clutch-toast {
  position: absolute;
  padding: 4px 8px;
  border: 1px solid #ca8a04;
  border-radius: 8px;
  background: rgba(254, 249, 195, 0.96);
  color: #854d0e;
  font-size: 1.16rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 8;
  animation: clutchToastFade 1s ease-out 1 forwards;
}

@keyframes clutchToastFade {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -14px); }
}

.bonus-float {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border: 2px solid #15803d;
  border-radius: 10px;
  background: rgba(220, 252, 231, 0.96);
  color: #14532d;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(21, 128, 61, 0.24);
  z-index: 7;
  pointer-events: none;
  opacity: 0;
}

.bonus-float.show {
  opacity: 1;
}

.speed-bonus-float {
  position: absolute;
  left: 50%;
  top: 29%;
  transform: translate(-50%, -50%);
  min-width: 210px;
  padding: 10px 14px;
  border: 2px solid #2563eb;
  border-radius: 10px;
  background: rgba(239, 246, 255, 0.98);
  color: #0f172a;
  text-align: center;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.26);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
}

.speed-bonus-float.show {
  opacity: 1;
}

.speed-bonus-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.speed-bonus-value {
  display: block;
  margin-top: 4px;
  font-size: 1.28rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.speed-bonus-float.blitz {
  border-color: #ca8a04;
  background: rgba(254, 249, 195, 0.98);
  color: #854d0e;
  box-shadow:
    0 0 10px rgba(250, 204, 21, 0.7),
    0 10px 22px rgba(15, 23, 42, 0.22);
}

.hud-bonus-stack .bonus-float,
.hud-bonus-stack .speed-bonus-float {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  min-width: 0;
  margin: 0;
  display: none;
  opacity: 1;
}

.hud-bonus-stack .bonus-float {
  padding: 6px 10px;
  font-size: 0.95rem;
}

.hud-bonus-stack .speed-bonus-float {
  padding: 6px 10px;
}

.hud-bonus-stack .speed-bonus-value {
  margin-top: 1px;
  font-size: 0.98rem;
}

.hud-bonus-stack .bonus-float.show,
.hud-bonus-stack .speed-bonus-float.show {
  display: block;
}

.game-over-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 92%);
  border: 2px solid #334155;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.98);
  color: #0f172a;
  padding: 16px 18px;
  z-index: 9;
  text-align: center;
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.38);
}

.game-over-card h2 {
  margin: 0 0 10px;
}

.game-over-card p {
  margin: 6px 0;
}

.play-again-button {
  margin-top: 12px;
  border: 1px solid #991b1b;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 800;
  padding: 10px 18px;
  cursor: pointer;
}

.play-again-button:hover {
  background: #b91c1c;
}

.game-over-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid #334155;
  background: #e2e8f0;
  color: #0f172a;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 5px 8px;
  cursor: pointer;
}

.game-over-close:hover {
  background: #cbd5e1;
}

.hidden {
  display: none !important;
}

.site-footer {
  width: min(1100px, 100%);
  margin: 18px auto 0;
  padding: 12px 18px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.footer-right {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.footer-game-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
}

.footer-help-button {
  border: 2px solid #0b3b88;
  border-radius: 12px;
  padding: 8px 14px;
  background: #2f6fed;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.footer-help-button:hover {
  background: #1f58c5;
}

.footer-game-button {
  border: 2px solid #0b3b88;
  background: #e5efff;
  color: #0f172a;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.footer-game-button:hover {
  background: #d5e5ff;
}

.report-bug-btn {
  border-color: #b45309;
  background: #8a4b08;
  color: #fff7ed;
  cursor: pointer;
}

.report-bug-btn:hover {
  background: #a16207;
}

.bug-report-modal-panel {
  width: min(680px, 96vw);
  max-height: min(88vh, 760px);
  overflow: auto;
}

.bug-report-form {
  display: grid;
  gap: 8px;
}

.bug-form-label {
  font-weight: 800;
  color: #0f172a;
  margin-top: 2px;
}

.bug-report-form input,
.bug-report-form select,
.bug-report-form textarea {
  width: 100%;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff;
  color: #0f172a;
}

.bug-report-form textarea {
  resize: vertical;
  min-height: 82px;
}

.bug-report-status {
  margin: 4px 0 0;
  font-weight: 800;
}

.bug-report-status.ok {
  color: #166534;
}

.bug-report-status.error {
  color: #991b1b;
}

.bug-form-actions {
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
}

.bug-submit-btn {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
}

.footer-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-meta {
  margin: 0;
  color: #94a3b8;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
}

.cbd-help-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(15, 23, 42, 0.48);
  display: grid;
  place-items: center;
  padding: 16px;
}

.cbd-help-panel {
  width: min(560px, 96vw);
  max-height: min(88vh, 760px);
  overflow: auto;
  position: relative;
  border-radius: 14px;
  border: 2px solid #0b3b88;
  background: rgba(239, 246, 255, 0.99);
  color: #0f172a;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.38);
  padding: 20px 16px 16px;
  display: grid;
  gap: 10px;
}

.cbd-help-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 66px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 2px solid #0b3b88;
  background: #e5efff;
  color: #0f172a;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cbd-help-panel h2 {
  margin: 0;
  padding-right: 78px;
  color: #0b3b88;
  font-size: 1.25rem;
}

.cbd-help-panel p {
  margin: 0;
  line-height: 1.45;
  color: #1f2f45;
}

.cbd-help-play-button {
  display: block;
  margin: 10px auto 0;
  border: 2px solid #0b3b88;
  background: #2f6fed;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0.05em;
  font-size: 0.96rem;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.cbd-help-play-button:hover {
  background: #1f58c5;
}

.cbd-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 5001;
  background: rgba(15, 23, 42, 0.48);
  display: grid;
  place-items: center;
  padding: 16px;
}

.cbd-settings-panel {
  width: min(420px, 94vw);
  position: relative;
  border-radius: 14px;
  border: 2px solid #0b3b88;
  background: rgba(239, 246, 255, 0.99);
  color: #0f172a;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.38);
  padding: 18px 14px 14px;
}

.cbd-settings-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 66px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 2px solid #0b3b88;
  background: #e5efff;
  color: #0f172a;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cbd-settings-panel h2 {
  margin: 2px 0 12px;
  color: #0b3b88;
  font-size: 1.2rem;
}

.cbd-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  background: #f8fbff;
}

.cbd-settings-label {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #0f172a;
}

.cbd-settings-toggle {
  min-width: 78px;
  border: 2px solid #0b3b88;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
  background: #dcfce7;
  color: #166534;
}

.cbd-settings-toggle.off {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 640px) {
  .game-page {
    padding: 18px 12px 20px;
  }

  .home-brand-link {
    width: 100%;
    margin-left: 0;
    padding-left: 8px;
    padding-right: 170px;
    justify-content: flex-start;
    font-size: clamp(1.1rem, 4.8vw, 1.5rem);
  }

  .home-brand-icons {
    gap: 4px;
    font-size: clamp(1.05rem, 4.8vw, 1.35rem);
  }

  .hud {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    margin-top: 12px;
  }

  .hud-title {
    position: absolute;
    right: 8px;
    top: -36px;
    margin: 0;
    font-size: clamp(0.95rem, 4.2vw, 1.15rem);
    text-align: right;
    line-height: 1;
    white-space: nowrap;
  }

  .hud-left-group {
    gap: 6px;
  }

  .hud-right-group {
    gap: 6px;
  }

  .hud-bonus-stack {
    gap: 3px;
  }

  .hud-left-group .hud-box {
    min-width: 106px;
    padding: 8px 10px;
    border-radius: 10px;
    height: 74px;
    min-height: 74px;
    max-height: 74px;
  }

  .hud-left-group .score-label {
    font-size: 0.72rem;
  }

  .hud-left-group .score-value {
    margin-top: 2px;
    font-size: 1.65rem;
  }

  .hud-right-group .hud-box {
    min-width: 106px;
    padding: 8px 10px;
    border-radius: 10px;
    height: 74px;
    min-height: 74px;
    max-height: 74px;
  }

  .hud-bonus-box {
    min-width: 106px;
    width: auto;
    flex: 0 1 auto;
    height: 74px;
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .lives-box {
    min-width: 106px;
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .hud-bonus-stack .bonus-float {
    padding: 4px 6px;
    font-size: 0.74rem;
  }

  .hud-bonus-stack .speed-bonus-float {
    padding: 4px 6px;
  }

  .hud-bonus-stack .speed-bonus-title {
    font-size: 0.62rem;
  }

.hud-bonus-stack .speed-bonus-value {
  margin-top: 1px;
  font-size: 0.76rem;
}

  .settings-gear-btn {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .game-board {
    min-height: 60vh;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-column {
    min-height: calc(30vh - 18px);
  }

  .play-button {
    padding: 10px 18px;
    font-size: 0.95rem;
  }

  .active-card {
    width: min(128px, 42%);
  }

  .site-footer {
    padding: 10px 12px 16px;
  }

  .footer-game-button {
    font-size: 0.9rem;
    padding: 9px 14px;
  }

  .footer-help-button {
    font-size: 0.88rem;
    padding: 8px 12px;
  }

  .cbd-help-panel {
    padding: 18px 12px 12px;
  }

  .cbd-help-panel h2 {
    font-size: 1.12rem;
  }

  .cbd-help-panel p {
    font-size: 0.92rem;
  }

  .cbd-settings-panel {
    padding: 16px 12px 12px;
  }

  .cbd-settings-panel h2 {
    font-size: 1.12rem;
  }
}

