/* =========================
   Hidden Cask – stats.css
========================= */

/* Prevent padding from making the stats panel wider than intended */
body.hc-stats-mode,
body.hc-stats-mode * {
  box-sizing: border-box;
}

html:has(body.hc-stats-mode),
body.hc-stats-mode {
  overflow-x: hidden;
}

/* Keep one source of truth for the stats background */
html:has(body.hc-stats-mode) {
  min-height: 100%;
  background: #120d0a !important;
}

body.hc-stats-mode {
  max-width: none !important;
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh;
  color: #1f2937;

  background-color: #120d0a !important;
  background-image:
    radial-gradient(circle at top center, rgba(255, 221, 170, 0.08), transparent 34%),
    linear-gradient(rgba(18, 13, 10, 0.34), rgba(18, 13, 10, 0.58)),
    url('/images/bg/hidden-cask-bg5.jpg') !important;
  background-size: cover, cover, cover !important;
  background-position: center top, center center, center center !important;
  background-repeat: no-repeat, no-repeat, no-repeat !important;
  background-attachment: fixed, fixed, fixed !important;
}

/* Remove whisky background + dark overlay from game.css */
body.hc-stats-mode::before,
body.hc-stats-mode::after {
  display: none !important;
  content: none !important;
}

/* Hide the normal game page */
body.hc-stats-mode header,
body.hc-stats-mode #intro,
body.hc-stats-mode #setup,
body.hc-stats-mode #roundSection,
body.hc-stats-mode #results,
body.hc-stats-mode footer {
  display: none !important;
}

/* Stats wrapper — transparent glass panel */
body.hc-stats-mode #hcStatsWrap {
  display: block !important;
  width: min(calc(100% - 72px), 1180px);
  max-width: 1180px;
  margin: 52px auto 86px;
  padding: 42px 22px 58px;
  position: relative;
  z-index: 20;
  box-sizing: border-box;

  background:
    linear-gradient(
      180deg,
      rgba(248, 246, 241, 0.28) 0%,
      rgba(245, 241, 235, 0.18) 48%,
      rgba(245, 241, 235, 0.10) 100%
    );

  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 34px;

  box-shadow:
    0 24px 72px rgba(0, 0, 0, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);

  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}

/* Very soft panel sheen */
body.hc-stats-mode #hcStatsWrap::before,
body.hc-stats-mode #hcStatsWrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: -1;
}

body.hc-stats-mode #hcStatsWrap::before {
  top: 0;
  height: 52px;
  border-radius: 34px 34px 0 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}

body.hc-stats-mode #hcStatsWrap::after {
  bottom: 0;
  height: 74px;
  border-radius: 0 0 34px 34px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
}

.hc-stats {
  color: #1f2937;
}

.hc-stats-body > * {
  margin-bottom: 28px;
}

.hc-stats-body > *:last-child {
  margin-bottom: 0;
}

/* =========================
   Header / Controls
========================= */

.hc-stats-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.hc-stats-title {
  margin: 0 0 8px;
  font-size: 2.1rem;
  line-height: 1.1;
  font-weight: 900;
  color: #fff;
  text-align: left;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
}

.hc-stats-sub {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(18, 13, 10, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.hc-stats-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.hc-stat-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.hc-stat-select select {
  min-width: 170px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  font-size: 0.95rem;
  color: #1f2937;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
}

.hc-stats-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5e3c, #a76b3c);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(139, 94, 60, 0.22);
  transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}

.hc-stats-back:hover {
  background: linear-gradient(135deg, #734b2f, #965f36);
  box-shadow: 0 12px 26px rgba(139, 94, 60, 0.28);
}

.hc-stats-back:active {
  transform: translateY(1px);
}

/* =========================
   KPI Cards
   Desktop deliberately uses 4 + 4
========================= */

.hc-stat-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 34px;
}

.hc-stat-card {
  min-width: 0;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: 20px;
  padding: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 12px 28px rgba(0, 0, 0, 0.07);
}

.hc-stat-k {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 8px;
  font-weight: 600;
  line-height: 1.25;
}

.hc-stat-v {
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
  line-height: 1;
}

.hc-stat-sub {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #6b7280;
}

/* =========================
   Section titles
========================= */

.hc-stat-section-title {
  margin: 56px auto 22px;
  text-align: center;
  width: fit-content;
  max-width: min(100%, 720px);
  padding: 14px 24px;
  border-radius: 22px;

  background:
    linear-gradient(
      135deg,
      rgba(18, 13, 10, 0.72),
      rgba(80, 52, 32, 0.62)
    );

  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.hc-stat-section-title h2 {
  margin: 0 0 5px;
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  line-height: 1.15;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

.hc-stat-section-title p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
}

/* =========================
   Layout grids
========================= */

.hc-stat-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* =========================
   Blocks / Tables
========================= */

.hc-stat-block {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(232, 223, 211, 0.95);
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 12px 30px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.hc-stat-block-title {
  padding: 18px 20px 14px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #1f2937;
  border-bottom: 1px solid #eee6dc;
  background: rgba(255, 255, 255, 0.42);
}

.hc-stat-table-wrap {
  overflow-x: auto;
}

.hc-stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: #fff;
  box-shadow: none;
  margin-bottom: 0;
}

.hc-stat-table th,
.hc-stat-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}

.hc-stat-table th {
  background: #f3f1ed;
  font-size: 0.82rem;
  font-weight: 700;
  color: #5f6675;
}

.hc-stat-table td {
  color: #1f2937;
}

.hc-stat-empty {
  text-align: center;
  color: #7a7f8c;
  padding: 34px 22px !important;
  font-style: italic;
}

.hc-stat-empty-box {
  padding: 28px;
  text-align: center;
  font-style: italic;
  color: #4b5563;
}

/* =========================
   Awards
========================= */

.hc-awards-block {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hc-awards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 18px;
  flex: 1;
}

.hc-award {
  background: linear-gradient(135deg, rgba(255, 250, 240, 0.96), rgba(250, 247, 243, 0.94));
  border: 1px solid #eadfce;
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.hc-award-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
  padding: 6px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8b5e3c, #b8793d);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.1;
  box-shadow: 0 4px 10px rgba(139, 94, 60, 0.22);
}

.hc-award-name {
  margin-top: 12px;
  font-size: 1.16rem;
  font-weight: 900;
  color: #1f2937;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.hc-award-sub {
  margin-top: 8px;
  font-size: 0.86rem;
  color: #6b7280;
  line-height: 1.35;
}

/* Legacy class support in case older markup is cached */
.hc-award-k {
  font-size: 0.9rem;
  font-weight: 700;
  color: #7a5a36;
  margin-bottom: 8px;
  line-height: 1.25;
}

.hc-award-v {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1f2937;
  margin-bottom: 6px;
  line-height: 1.2;
}

/* Awards when placed inside a right-hand / half-width column */
.hc-stat-grid-2 .hc-awards-block {
  min-height: 100%;
}

.hc-stat-grid-2 .hc-awards-grid {
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
  align-content: stretch;
}

.hc-stat-grid-2 .hc-award {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 126px;
  padding: 16px 18px;
}

.hc-stat-grid-2 .hc-award-name {
  width: 100%;
  font-size: 1.16rem;
}

.hc-stat-grid-2 .hc-award-sub {
  font-size: 0.84rem;
}

/* =========================
   Loading / Error
========================= */

.hc-stat-loading,
.hc-stat-error {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 24px;
  color: #374151;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.hc-stat-error {
  background: #fff5f5;
  border-color: #f3b7b7;
  color: #7f1d1d;
  font-weight: 700;
}

.hc-stat-error code {
  background: rgba(127, 29, 29, 0.08);
  padding: 2px 5px;
  border-radius: 5px;
}

/* =========================
   Rich Bottle Leaderboards
   Required for ui-stats.js richBottleList()
========================= */

.hc-rich-bottle-block {
  margin-bottom: 28px;
}

.hc-rich-bottle-list {
  display: grid;
  gap: 0;
}

.hc-rich-bottle-row {
  display: grid;
  grid-template-columns: 44px 82px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #f0ebe4;
  background: rgba(255, 255, 255, 0.88);
  transition: background 0.15s ease, transform 0.12s ease;
}

.hc-rich-bottle-row:last-child {
  border-bottom: 0;
}

/* Keep visual affordance soft; rows should not look like external links */
.hc-rich-bottle-row.is-clickable {
  cursor: pointer;
}

.hc-rich-bottle-row.is-clickable:hover {
  background: #fff8ec;
  transform: translateY(-1px);
}

.hc-rich-bottle-row:visited,
.hc-rich-bottle-row:hover,
.hc-rich-bottle-row:active {
  color: inherit;
  text-decoration: none;
}

.hc-rich-bottle-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #8b5e3c;
  color: #fff;
  font-weight: 900;
  line-height: 1;
}

.hc-rich-bottle-img-wrap {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: #f5f1eb;
  border: 1px solid #eadfce;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hc-rich-bottle-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
  padding: 6px;
}

.hc-rich-bottle-main {
  min-width: 0;
}

.hc-rich-bottle-name {
  font-size: 1.08rem;
  font-weight: 900;
  color: #1f2937;
  line-height: 1.2;
}

.hc-rich-bottle-meta {
  margin-top: 3px;
  color: #6b7280;
  font-size: 0.9rem;
}

.hc-rich-bottle-stats {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hc-rich-bottle-stats span {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f1ed;
  color: #5f5146;
  font-size: 0.78rem;
  font-weight: 800;
}

button.hc-rich-bottle-row {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  font: inherit;
  text-align: left;
}

/* Make the full-width winner leaderboard feel more premium */
.hc-rich-bottle-block .hc-stat-block-title {
  font-size: 1.3rem;
}

/* Two-column rich lists should stay balanced */
.hc-stat-grid-2 .hc-rich-bottle-row {
  grid-template-columns: 38px 70px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 16px;
}

.hc-stat-grid-2 > .hc-stat-block {
  height: 100%;
}

.hc-stat-grid-2 .hc-rich-bottle-img-wrap {
  width: 62px;
  height: 62px;
}

.hc-stat-grid-2 .hc-rich-bottle-img {
  max-width: 62px;
  max-height: 62px;
}

.hc-stat-grid-2 .hc-rich-bottle-name {
  font-size: 1rem;
}

/* =========================
   Modal support
========================= */

body.hc-stats-mode .modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.hc-stats-mode .modal {
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  position: relative;
}

body.hc-stats-mode .modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #050505;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  z-index: 2;
}

body.hc-stats-mode .modal-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 26px;
  padding: 36px 32px;
}

body.hc-stats-mode .modal-left {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

body.hc-stats-mode .modal-left img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border: 1px solid #eee6dc;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

body.hc-stats-mode .modal-title {
  margin: 0 0 10px;
  font-size: 1.3rem;
  line-height: 1.2;
  color: #1f2937;
}

body.hc-stats-mode .kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  margin: 7px 0;
  color: #4b5563;
}

body.hc-stats-mode .kv span {
  color: #6b7280;
}

body.hc-stats-mode .kv b {
  color: #1f2937;
}

body.hc-stats-mode .desc {
  color: #1f2937;
  line-height: 1.45;
}

body.hc-stats-mode .noimg {
  width: 220px;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f1eb;
  border: 1px solid #eadfce;
  border-radius: 12px;
  font-size: 42px;
}

/* =========================
   Responsive
========================= */

@media (max-width: 1100px) {
  .hc-stat-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hc-awards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .hc-stat-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hc-stat-grid-2 .hc-award {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 800px) {
  body.hc-stats-mode {
    background-attachment: scroll !important;
  }

  body.hc-stats-mode #hcStatsWrap {
    width: min(calc(100% - 24px), 1180px);
    margin: 16px auto 32px;
    padding: 24px 14px 40px;
    border-radius: 22px;
  }

  .hc-stat-grid-2 {
    grid-template-columns: 1fr;
  }

  .hc-stats-title {
    font-size: 1.95rem;
  }

  .hc-stats-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hc-stats-controls {
    align-items: stretch;
  }

  .hc-stat-select select,
  .hc-stats-back {
    width: 100%;
  }

  body.hc-stats-mode .modal-body {
    grid-template-columns: 1fr;
  }

  body.hc-stats-mode .modal-left img {
    max-height: 280px;
  }
}

@media (max-width: 700px) {
  .hc-rich-bottle-row,
  .hc-stat-grid-2 .hc-rich-bottle-row {
    grid-template-columns: 36px 58px minmax(0, 1fr);
    gap: 10px;
    padding: 14px;
  }

  .hc-rich-bottle-img-wrap,
  .hc-stat-grid-2 .hc-rich-bottle-img-wrap {
    width: 54px;
    height: 54px;
  }

  .hc-rich-bottle-img,
  .hc-stat-grid-2 .hc-rich-bottle-img {
    max-width: 54px;
    max-height: 54px;
  }

  .hc-rich-bottle-name,
  .hc-stat-grid-2 .hc-rich-bottle-name {
    font-size: 0.98rem;
  }

  .hc-rich-bottle-stats {
    gap: 6px;
  }

  .hc-rich-bottle-stats span {
    font-size: 0.74rem;
  }
}

@media (max-width: 520px) {
  body.hc-stats-mode #hcStatsWrap {
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .hc-stat-cards {
    grid-template-columns: 1fr;
  }

  .hc-stat-v {
    font-size: 1.7rem;
  }

  .hc-stats-title {
    font-size: 1.75rem;
  }

  .hc-stat-section-title {
    margin-top: 42px;
  }

  .hc-awards-grid,
  .hc-stat-grid-2 .hc-awards-grid {
    padding: 14px;
  }

  .hc-award,
  .hc-stat-grid-2 .hc-award {
    padding: 14px;
  }

  body.hc-stats-mode .modal-overlay {
    padding: 12px;
  }

  body.hc-stats-mode .modal-body {
    padding: 28px 20px 22px;
  }

  body.hc-stats-mode .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}