/* Riddlio modal shell */
.modal {
  width: 100%;
  background: transparent;
  display: none;
  align-items: center;
  justify-content: center;
}

.riddle-modal-wrapper {
  display: flex;
}

.modal .modal-content {
  position: relative;
  width: min(650px, calc(100vw - 28px));
  min-height: 0;
  max-height: calc(100vh - var(--headerH) - var(--footerH) - 36px);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(143, 169, 227, 0.12);
}

#riddle-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: -4px;
}

.riddle-title-icon {
  width: 43px;
  height: 45px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #79bdff;
  font-size: 0;
  font-weight: 800;
  line-height: 1;
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 0, 95% 24%, 95% 76%, 50% 100%, 5% 76%, 5% 24%);
  background: rgba(106, 190, 255, 0.68);
  box-shadow: 0 0 14px rgba(63, 164, 255, 0.22), inset 0 0 16px rgba(143, 204, 255, 0.14);
}

.riddle-title-icon-fill {
  width: calc(100% - 3px);
  height: calc(100% - 3px);
  display: grid;
  place-items: center;
  clip-path: inherit;
  background: #071637;
  box-shadow: inset 0 0 16px rgba(143, 204, 255, 0.14);
}

.riddle-title-icon-fill img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
  opacity: 0.9;
  filter: drop-shadow(0 0 4px rgba(114, 190, 255, 0.28));
}

.riddle-title-copy {
  min-width: 0;
}

#modal-title-main {
  margin: 0;
  font-size: 20px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--riddlio-text);
  text-shadow: 0 0 18px rgba(129, 169, 255, 0.18);
}

#modal-title-meta {
  display: block;
  min-height: 19px;
  margin-top: 4px;
  color: #d7e6ff;
  font-size: 16px;
  line-height: 1.2;
}

#riddle-mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

#riddle-daily-info {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  margin: 0 auto;
}

.riddle-stat-pill-nohint::before {
  content: "";
  width: 1px;
  height: 18px;
  margin-right: 14px;
  background: rgba(143, 169, 227, 0.12);
}

.riddle-stat-pill-nohint {
  padding-left: 0;
  border-left: 0;
}

.riddle-stat-pill {
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--riddlio-text);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  line-height: 20px;
}

#riddle-daily-streak-label {
  min-width: 0;
}

.stat-label-text {
  white-space: nowrap;
}

.riddlio-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#riddle-daily-streak-value,
#riddle-nohint-streak-value {
  color: #fff;
}

.stat-icon {
  color: #4f9aff;
  transform: translateY(1px);
  filter: drop-shadow(0 0 7px rgba(79, 154, 255, 0.46));
}

.stat-icon-nohint {
  width: 19.5px;
  height: 19.5px;
  fill: currentColor;
  transform: translateY(2px);
}

.riddlio-stats-modal {
  position: fixed;
  inset: 0;
  z-index: 12050;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 3, 12, 0.58);
}

.riddlio-stats-modal[hidden] {
  display: none;
}

.riddlio-stats-panel {
  position: relative;
  width: min(420px, calc(100vw - 40px));
  padding: 20px;
  color: var(--riddlio-text);
  border: 1px solid rgba(116, 177, 235, 0.42);
  border-radius: 12px;
  background: #050d22;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.riddlio-stats-panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.riddlio-stats-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  color: var(--riddlio-text);
  border: 1px solid rgba(116, 177, 235, 0.34);
  border-radius: 8px;
  background: #071637;
}

.riddlio-stats-content {
  display: grid;
  gap: 14px;
}

.riddlio-stat-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.riddlio-stat-section-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  color: #d7e6ff;
  font-size: 14px;
  font-weight: 700;
}

.riddlio-stat-box {
  padding: 10px;
  border: 1px solid rgba(143, 169, 227, 0.16);
  border-radius: 8px;
  background: rgba(7, 16, 40, 0.72);
}

.riddlio-stat-box strong {
  display: block;
  margin-bottom: 4px;
  color: #d7e6ff;
  font-size: 12px;
  font-weight: 600;
}

/* Debug grid: activated by shared footer Toggle Grid */
body.debugHeaderGrid {
  --riddlio-grid-line: rgba(42, 94, 255, 0.95);
  --riddlio-grid-soft: rgba(42, 94, 255, 0.34);
  --riddlio-grid-fill: rgba(42, 94, 255, 0.08);
}

body.debugHeaderGrid .modal .modal-content,
body.debugHeaderGrid .modal-header,
body.debugHeaderGrid #riddle-title-row,
body.debugHeaderGrid #riddle-mode-toggle-row,
body.debugHeaderGrid #riddle-daily-info,
body.debugHeaderGrid .riddle-stat-pill {
  outline: 3px solid var(--riddlio-grid-line);
  outline-offset: 0;
}

body.debugHeaderGrid .modal .modal-content {
  isolation: isolate;
}

body.debugHeaderGrid .modal .modal-content::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  border: 3px solid var(--riddlio-grid-line);
  border-radius: 4px;
  background:
    linear-gradient(90deg, transparent calc(50% - 2px), var(--riddlio-grid-line) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)),
    linear-gradient(transparent calc(33.333% - 1px), var(--riddlio-grid-soft) calc(33.333% - 1px) calc(33.333% + 1px), transparent calc(33.333% + 1px)),
    linear-gradient(transparent calc(66.666% - 1px), var(--riddlio-grid-soft) calc(66.666% - 1px) calc(66.666% + 1px), transparent calc(66.666% + 1px));
}

body.debugHeaderGrid .modal-header,
body.debugHeaderGrid #riddle-daily-info {
  background-color: var(--riddlio-grid-fill);
}
