.kgh-control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: rgba(248, 249, 250, 0.82);
  border: 1px solid rgba(149, 146, 146, 0.32);
  border-radius: 10px;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,.7);
}

.kgh-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.kgh-stat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.kgh-stat:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  width: 1px;
  height: 24px;
  background: rgba(149, 146, 146, 0.36);
  transform: translateY(-50%);
}

.kgh-stat-icon { font-size: 18px; }
.kgh-stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}
.kgh-stat-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #2d2d2d;
  line-height: 1;
}
.kgh-highlight { color: #94b54f; }

.kgh-display-container { margin: 18px 0; }

.kgh-keys-bg,
.kgh-level-bg {
  position: relative;
  overflow: hidden;
  border: 1px solid #959292;
  border-radius: 8px;
  box-shadow:
    6px 6px 13px rgba(82, 87, 99, 0.20),
    -3px -3px 6px rgba(248, 246, 242, 0.75),
    inset 1px 1px 0 rgba(248, 246, 242, 0.42);
}

.kgh-keys-bg {
  min-height: 112px;
  background: linear-gradient(180deg, #fbef8d 0%, #ee130d 100%);
}

.kgh-level-bg {
  min-height: 260px;
  background:
    radial-gradient(circle at 22% 28%, rgba(190, 210, 118, 0.92), rgba(123, 181, 66, 0.9) 28%, rgba(55, 94, 46, 0.92) 64%, rgba(38, 38, 38, 0.96)),
    linear-gradient(145deg, #a8c45d, #708d3d);
}

.kgh-keys-bg::before,
.kgh-level-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(38,38,38,.12) 0, rgba(38,38,38,.12) 1px, transparent 1px, transparent 4px),
    repeating-linear-gradient(90deg, rgba(55,94,46,.14) 0, rgba(55,94,46,.14) 1px, transparent 1px, transparent 4px);
  background-size: 4px 4px;
  pointer-events: none;
}

.kgh-key-display {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 112px;
  padding: 10px;
}

.kgh-key-placeholder {
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,.82);
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}

.kgh-key-block {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 76px;
  padding: 0 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 64px;
  font-weight: 900;
  line-height: .85;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgba(0,0,0,.55);
  animation: kgh-pulse .45s ease-in-out;
}

.kgh-key-block::before {
  content: attr(data-key);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,.78);
  transform: translate(4px, 4px);
  z-index: -1;
}

@keyframes kgh-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.kgh-levels {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.kgh-level {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 232px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
}

.kgh-level:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(148,181,79,.3);
}

.kgh-level-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 178px;
}

.kgh-level-img {
  width: clamp(122px, 11vw, 168px);
  height: clamp(122px, 11vw, 168px);
  object-fit: contain;
  filter: brightness(.18) contrast(.55) grayscale(.85);
  transition: filter .35s ease, transform .35s ease;
}

.kgh-question {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(52px, 8vw, 118px);
  font-weight: 900;
  color: rgba(255,255,255,.62);
  text-shadow: 0 2px 4px rgba(0,0,0,.55);
  transition: opacity .35s ease, transform .35s ease;
}

.kgh-level-name {
  width: 100%;
  padding: 7px 8px;
  border-top: 2px solid #fbbf24;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,.92), rgba(0,0,0,.72));
  box-shadow: 0 4px 12px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.2);
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 900;
  color: #fef08a;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,1), 0 0 10px rgba(251,191,36,.8);
}

.kgh-result-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(160px, auto) 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(52, 211, 153, .36);
  border-radius: 12px;
  background:
    radial-gradient(circle at 12% 18%, rgba(110, 231, 183, .24), transparent 36%),
    linear-gradient(135deg, rgba(18, 37, 28, .96), rgba(9, 18, 13, .94));
  box-shadow: 0 12px 26px rgba(15, 23, 42, .18), inset 0 1px 0 rgba(255,255,255,.12);
}

.kgh-result-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.055) 0, rgba(255,255,255,.055) 1px, transparent 1px, transparent 8px);
  opacity: .45;
  pointer-events: none;
}

.kgh-result-main,
.kgh-result-meta {
  position: relative;
  z-index: 1;
}

.kgh-result-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kgh-result-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: rgba(209, 250, 229, .76);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.kgh-result-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: clamp(38px, 5vw, 66px);
  font-weight: 900;
  line-height: .9;
  color: #fef08a;
  text-shadow: 0 0 18px rgba(251, 191, 36, .45);
}

.kgh-result-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.kgh-result-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: #d1fae5;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}

.kgh-result-meta b {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.62);
  text-transform: uppercase;
}

.kgh-result-range {
  color: #fde68a !important;
  letter-spacing: .08em;
}

.kgh-level.kgh-unlocked .kgh-level-img {
  filter: brightness(1) saturate(1) grayscale(0);
  transform: scale(1.04);
}

.kgh-level.kgh-unlocked .kgh-question {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.33);
}

.kgh-level.kgh-unlocked .kgh-level-name {
  color: #6ee7b7;
  border-color: #34d399;
  text-shadow: 0 2px 4px rgba(0,0,0,1), 0 0 15px rgba(52,211,153,.9);
  box-shadow: 0 4px 12px rgba(0,0,0,.6), 0 0 20px rgba(52,211,153,.4), inset 0 1px 0 rgba(255,255,255,.2);
}

.kgh-keyboard-wrapper {
  margin: 22px 0 4px;
}

.kgh-keycap.is-pressed {
  outline: 2px solid rgba(238,19,13,.55);
}

[data-theme="dark"] .kgh-control-panel {
  background: #1e241e;
  border-color: #3a3e3a;
}
[data-theme="dark"] .kgh-stat-value { color: #8a9a6a; }
[data-theme="dark"] .kgh-highlight { color: #d0e8a0; }
[data-theme="dark"] .kgh-stat-label { color: #b9c0a0; }
[data-theme="dark"] .kgh-keys-bg,
[data-theme="dark"] .kgh-level-bg {
  border-color: #3a3e3a;
  box-shadow: 4px 4px 10px rgba(0,0,0,.35), inset 1px 1px 0 rgba(255,255,255,.04);
}
[data-theme="dark"] .kgh-result-card {
  border-color: rgba(208, 232, 160, .28);
  background:
    radial-gradient(circle at 12% 18%, rgba(208, 232, 160, .16), transparent 36%),
    linear-gradient(135deg, rgba(22, 28, 18, .98), rgba(8, 12, 8, .96));
}

@media (max-width: 900px) {
  .kgh-control-panel { align-items: stretch; flex-direction: column; }
  .kgh-stats { justify-content: center; }
  .kgh-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kgh-result-card { grid-template-columns: 1fr; }
  .kgh-result-meta { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .kgh-stats { flex-direction: column; align-items: stretch; gap: 10px; }
  .kgh-stat { justify-content: space-between; width: 100%; }
  .kgh-stat::after { display: none; }
  .kgh-key-block { min-width: 48px; min-height: 56px; font-size: 44px; }
  .kgh-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kgh-level { min-height: 178px; }
  .kgh-level-card { min-height: 126px; }
  .kgh-result-card { padding: 14px; }
  .kgh-result-meta span { width: 100%; justify-content: space-between; }
}
