* {
  box-sizing: border-box;
}

:root {
  color-scheme: light dark;
  --bg: #f4f8f4;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #b7e4c7;
  --primary-dark: #8fd3aa;
  --primary-text: #14532d;
  --success: #2e7d32;
  --danger: #455a64;
  --border: #d1d5db;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  --key-bg: #ffffff;
  --key-text: #111111;
  --key-border: #d1d5db;
  --key-tested-bg: #d1d5db;
  --key-tested-border: #6b7280;
  --key-tested-text: #111111;
  --title-color: #1f2937;
  --hint-color: #6b7280;
  --version-color: #1f2937;
}

html[data-theme="dark"],
body[data-theme="dark"],
html.theme-dark,
body.theme-dark {
  --bg: #0f1720;
  --panel: #16202b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #345f43;
  --primary-dark: #4f8f63;
  --primary-text: #eafff0;
  --success: #7ddc8a;
  --danger: #f87171;
  --border: #2b3947;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  --key-bg: #d1d5db;
  --key-text: #000000;
  --key-border: #9ca3af;
  --key-tested-bg: #6b7280;
  --key-tested-border: #374151;
  --key-tested-text: #111111;
  --title-color: #ffffff;
  --hint-color: #ffffff;
  --version-color: #ffffff;
  --hangman-stroke: #ffffff;
  --theme-toggle-size: 24px;
  --theme-toggle-icon-size: 12px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  padding: 12px;
  transition: background-color 180ms ease, color 180ms ease;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.app-header,
.controls,
.hint-card,
.hangman-card,
.word-card,
.status-card,
.keyboard-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.app-header {
  position: relative;
  text-align: center;
  padding: 14px 16px 10px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.25rem);
  padding-right: 56px;
  color: var(--title-color);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.controls {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  min-height: 48px;
  border: 1px solid #96c7a8;
  border-radius: 14px;
  padding: 0 16px;
  background: #c9ebd4;
  color: #184d2e;
  font-weight: 700;
  cursor: pointer;
}

.action-btn--ghost {
  background: #dff2e6;
  color: #184d2e;
  border: 1px solid #96c7a8;
}

html[data-theme="dark"] .action-btn--ghost,
body[data-theme="dark"] .action-btn--ghost,
html.theme-dark .action-btn--ghost,
body.theme-dark .action-btn--ghost {
  background: #1f2e24;
  color: var(--primary-text);
  border-color: #4f8f63;
}

.theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: var(--theme-toggle-size);
  height: var(--theme-toggle-size);
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, #111827 0 50%, #f8fafc 50% 100%);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  z-index: 2;
  color: #111827;
}

.theme-toggle__icon {
  width: var(--theme-toggle-icon-size);
  height: var(--theme-toggle-icon-size);
  display: block;
}

html[data-theme="dark"] .theme-toggle,
body[data-theme="dark"] .theme-toggle,
html.theme-dark .theme-toggle,
body.theme-dark .theme-toggle {
  background: linear-gradient(90deg, #f8fafc 0 50%, #111827 50% 100%);
  color: #f8fafc;
  border-color: #f8fafc;
  transform: scale(0.85);
}

html[data-theme="dark"] .theme-toggle__icon,
body[data-theme="dark"] .theme-toggle__icon,
html.theme-dark .theme-toggle__icon,
body.theme-dark .theme-toggle__icon {
  color: #f8fafc;
}


.hint-card,
.status-card,
.word-card,
.hangman-card,
.keyboard-card {
  padding: 14px;
}

.hint-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hint-text {
  margin-top: 6px;
  font-size: clamp(1.05rem, 3.6vw, 1.35rem);
  font-weight: 700;
  word-break: break-word;
  color: var(--hint-color);
}

.hint-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.hint-german {
  margin-top: 8px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.hint-german.is-blurred {
  filter: blur(5px);
}

.hint-german.is-revealed {
  filter: none;
  color: var(--text);
}

.hangman-card {
  display: flex;
  justify-content: center;
  align-items: center;
}

#hangman-svg {
  width: 100%;
  max-width: 360px;
  height: auto;
}

html[data-theme="dark"] #hangman-svg *,
body[data-theme="dark"] #hangman-svg *,
html.theme-dark #hangman-svg *,
body.theme-dark #hangman-svg * {
  stroke: #ffffff !important;
  fill: none !important;
}

#hangman-svg path,
#hangman-svg circle {
  stroke: var(--hangman-stroke);
  stroke-width: 5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hangman-base path {
  stroke: var(--hangman-stroke);
}

.hangman-part {
  opacity: 0;
  transition: opacity 180ms ease;
}

.hangman-part.is-visible {
  opacity: 1;
}

.word-display {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: clamp(1.4rem, 6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.word-char {
  min-width: 1ch;
  padding: 2px 1px;
}

.word-char.is-hidden {
  color: var(--muted);
}

.word-char.is-revealed {
  color: var(--text);
}

.word-char.is-special {
  color: var(--text);
}

.word-display.is-won {
  color: var(--success);
}

.word-display.is-lost {
  color: var(--primary-dark);
}

.status-text {
  text-align: center;
  font-weight: 700;
  color: var(--text);
  min-height: 1.2em;
}

.keyboard {
  display: grid;
  gap: 8px;
}

.keyboard-row {
  display: grid;
  gap: 8px;
}

.keyboard-row--main {
  grid-template-columns: repeat(13, minmax(0, 1fr));
}

.keyboard-row--special {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.key {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--key-border);
  background: var(--key-bg);
  color: var(--key-text);
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}


.key:active {
  transform: scale(0.98);
}

.key.is-tested {
  border-width: 2px;
  background: var(--key-tested-bg);
  border-color: var(--key-tested-border);
  color: var(--key-tested-text);
}

.key.is-correct {
  background: var(--key-tested-bg);
  border-color: var(--key-tested-border);
  color: var(--key-tested-text);
}

.key.is-wrong {
  background: var(--key-tested-bg);
  border-color: var(--key-tested-border);
  color: var(--key-tested-text);
}

.key.is-disabled,
.key[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  font-size: 0.92rem;
  color: var(--muted);
  flex-wrap: nowrap;
  white-space: nowrap;
}

.app-credit {
  text-align: right;
  margin-left: auto;
  flex: 0 0 auto;
}

.app-footer > :first-child {
  font-weight: 700;
  flex: 0 0 auto;
}

.app-footer a {
  color: inherit;
}

.app-version {
  font-weight: 700;
  color: var(--version-color);
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) {
  body {
    padding: 20px;
  }

  .app-shell {
    gap: 14px;
  }

  .keyboard-row--main {
    grid-template-columns: repeat(13, minmax(0, 1fr));
  }

  .keyboard-row--special {
    max-width: 520px;
    margin: 0 auto;
  }
}
