.de-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 12px 28px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.de-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.de-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
}

.de-stat {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  box-shadow: 0 5px 14px rgba(33, 43, 40, 0.07);
}

.de-stat span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.de-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--cg-ink);
  font-size: 17px;
  line-height: 1.1;
}

.de-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.de-icon-button,
.de-share,
.de-key,
.de-close {
  min-height: 44px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.de-icon-button {
  display: inline-grid;
  width: 44px;
  place-items: center;
  padding: 0;
  font-size: 18px;
}

.de-icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.de-share {
  padding: 0 13px;
}

.de-share:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.de-icon-button:hover,
.de-share:not(:disabled):hover,
.de-key:hover,
.de-close:hover {
  transform: translateY(-1px);
  border-color: var(--cg-teal);
  box-shadow: 0 7px 16px rgba(33, 43, 40, 0.1);
}

.de-icon-button:focus-visible,
.de-share:focus-visible,
.de-key:focus-visible,
.de-close:focus-visible {
  outline: 3px solid rgba(18, 122, 137, 0.28);
  outline-offset: 2px;
}

.de-status {
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--cg-muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.de-board {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 504px;
  margin: 0 auto 16px;
}

.de-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.de-tile {
  display: grid;
  aspect-ratio: 1;
  min-height: 38px;
  place-items: center;
  border: 2px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font-size: clamp(20px, 7vw, 34px);
  font-weight: 900;
  line-height: 1;
  transform-style: preserve-3d;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.de-filled {
  border-color: #bfc8c0;
  transform: scale(1.02);
}

.de-correct {
  border-color: var(--cg-green);
  background: var(--cg-green);
  color: #fff;
}

.de-present {
  border-color: var(--cg-amber);
  background: var(--cg-amber);
  color: #fff;
}

.de-absent {
  border-color: #aab3ae;
  background: #aab3ae;
  color: #fff;
}

.de-keypad {
  display: grid;
  gap: 7px;
  margin: 0 auto 14px;
}

.de-key-row {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 5px;
}

.de-key {
  min-width: 0;
  padding: 0 6px;
  background: #eef1ed;
  font-size: 16px;
}

.de-key-wide {
  grid-column: span 2;
  font-size: 14px;
}

.de-key-correct {
  border-color: var(--cg-green);
  background: var(--cg-green);
  color: #fff;
}

.de-key-present {
  border-color: var(--cg-amber);
  background: var(--cg-amber);
  color: #fff;
}

.de-key-absent {
  border-color: #9fa9a4;
  background: #9fa9a4;
  color: #fff;
}

.de-result {
  padding: 12px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  box-shadow: var(--cg-shadow);
}

.de-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.de-result-head strong {
  font-size: 18px;
}

.de-result-head span {
  color: var(--cg-muted);
  font-weight: 900;
}

.de-dist {
  display: grid;
  gap: 5px;
}

.de-dist-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  color: var(--cg-muted);
  font-size: 12px;
  font-weight: 800;
}

.de-dist-row div {
  height: 18px;
  border-radius: 5px;
  background: #edf0ec;
  overflow: hidden;
}

.de-dist-row b {
  display: block;
  min-width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--cg-teal);
}

.de-dist-row strong {
  color: var(--cg-ink);
  text-align: right;
}

.de-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 37, 40, 0.44);
}

.de-overlay[hidden] {
  display: none;
}

.de-dialog {
  position: relative;
  width: min(100%, 460px);
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: var(--cg-shadow);
}

.de-dialog h2 {
  margin: 0 44px 10px 0;
  font-size: 24px;
}

.de-dialog p {
  margin: 8px 0;
  color: var(--cg-muted);
  line-height: 1.45;
}

.de-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.de-rule-grid {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  margin-top: 14px;
  color: var(--cg-ink);
  font-weight: 700;
}

.de-swatch {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.de-shake {
  animation: de-shake 380ms ease;
}

.de-flip {
  animation: de-flip 560ms ease both;
}

@keyframes de-shake {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes de-flip {
  0% {
    transform: rotateX(0deg);
  }
  48% {
    transform: rotateX(88deg);
  }
  52% {
    transform: rotateX(92deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

@media (max-width: 520px) {
  .de-shell {
    padding-right: 8px;
    padding-left: 8px;
  }

  .de-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .de-actions {
    justify-content: flex-end;
  }

  .de-tile {
    border-radius: 6px;
    font-size: clamp(18px, 8vw, 28px);
  }

  .de-key {
    padding: 0 4px;
    font-size: 15px;
  }

  .de-key-row {
    gap: 1px;
  }

  .de-key-wide {
    font-size: 13px;
  }
}
