/* Логотип */
.logo-container {
  flex: 1 1 55%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 0;
  z-index: 10;
}

.logo {
  width: 50px;
  height: 50px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
  display: block;
  /* Добавляем стили для корректного отображения SVG */
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.logo:hover {
  transform: scale(1.1) rotate(5deg);
}

.logo-emoji {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
  animation: logoFloat 3s ease-in-out infinite;
}

.logo-emoji:hover {
  transform: scale(1.1) rotate(5deg);
}

.logo-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 2rem;
  font-weight: bold;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.app-header {
  width: min(100%, 720px);
  margin-bottom: 1.5rem;
  padding: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid rgba(144, 202, 249, 0.24);
  border-radius: 18px;
  background: rgba(17, 23, 34, 0.82);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.interface-controls { display: flex; align-items: center; gap: 0.5rem; }
.language-select--native { display: none; }
.language-menu { position: relative; }
.language-menu__trigger, .theme-toggle { min-height: 44px; border: 1px solid rgba(144, 202, 249, 0.28); border-radius: 12px; background: rgba(17, 23, 34, 0.92); color: var(--text-color); font: inherit; font-weight: 700; cursor: pointer; }
.language-menu__trigger { min-width: 140px; padding: 0.35rem 0.65rem 0.35rem 0.35rem; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.5rem; text-align: left; }
.language-menu__flag { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border: 1px solid rgba(144, 202, 249, 0.24); border-radius: 8px; color: #90caf9; font-size: 0.65rem; letter-spacing: 0.04em; }
.language-menu__chevron { width: 1rem; height: 1rem; transform: rotate(180deg); transform-origin: center; transition: transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.language-menu__trigger[aria-expanded='true'] .language-menu__chevron { transform: rotate(0deg); }
.language-menu__panel { position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 30; width: min(210px, calc(100vw - 1rem)); padding: 0.4rem; display: grid; gap: 0.2rem; border: 1px solid rgba(144, 202, 249, 0.24); border-radius: 14px; background: #111722; box-shadow: 0 20px 44px rgba(0, 0, 0, 0.4); }
.language-menu__panel[hidden] { display: none; }
.language-menu__option { min-height: 44px; padding: 0.4rem; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.5rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #e7edf7; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.language-menu__option:hover, .language-menu__option:focus-visible, .language-menu__option[aria-checked='true'] { border-color: rgba(144, 202, 249, 0.3); background: rgba(144, 202, 249, 0.1); }
.language-menu__check { opacity: 0; }
.language-menu__option[aria-checked='true'] .language-menu__check { opacity: 1; }
.theme-toggle { width: 44px; padding: 0.6rem; }
.theme-toggle svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 520px) {
  .app-header { width: 100%; gap: 0.5rem; }
  .logo-container { gap: 0.5rem; }
  .logo { width: 36px; }
  .logo-title { font-size: 1.2rem; }
  .language-menu__trigger { min-width: 54px; width: 54px; grid-template-columns: 1fr auto; padding: 0.3rem; }
  .language-menu__label { display: none; }
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* CSS переменные для тем */
:root {
  --bg-color: #080b12;
  --surface-color: rgba(17, 23, 34, 0.82);
  --surface-strong: #111722;
  --dice-bg: linear-gradient(145deg, #ffffff, #dce8f5);
  --dot-color: #7c3aed;
  --text-color: #e7edf7;
  --muted-color: #a9b7ca;
  --border-color: rgba(144, 202, 249, 0.28);
  --accent-color: #73e8f2;
  --accent-secondary: #c6a0ff;
  --shadow-color: rgba(0, 0, 0, 0.36);
}

body.light-theme {
  --bg-color: #eef4fb;
  --surface-color: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --dice-bg: linear-gradient(145deg, #ffffff, #edf3fa);
  --dot-color: #6d28d9;
  --text-color: #172033;
  --muted-color: #59677b;
  --border-color: rgba(52, 107, 158, 0.22);
  --accent-color: #087f8c;
  --accent-secondary: #7047b9;
  --shadow-color: rgba(40, 70, 105, 0.18);
}

/* Основные стили */
body {
  background:
    radial-gradient(circle at 12% 8%, rgba(115, 232, 242, 0.14), transparent 30rem),
    radial-gradient(circle at 88% 84%, rgba(198, 160, 255, 0.14), transparent 32rem),
    var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.dice-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  min-height: 124px;
  margin: clamp(1.25rem, 5vw, 2.25rem) 0;
  align-items: center;
}

.dice {
  width: clamp(78px, 22vw, 104px);
  height: clamp(78px, 22vw, 104px);
  background: var(--dice-bg);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  box-shadow:
    0 18px 34px var(--shadow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -3px 7px rgba(49, 73, 102, 0.12);
  padding: 12px;
  transform: translateZ(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dice:hover {
  transform: translateY(-3px) rotate(1deg);
  box-shadow:
    0 23px 42px var(--shadow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.dice.rolling {
  animation: shake 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0) rotate(-15deg);
  }
  20%,
  80% {
    transform: translate3d(2px, 0, 0) rotate(10deg);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0) rotate(-25deg);
  }
  40%,
  60% {
    transform: translate3d(4px, 0, 0) rotate(25deg);
  }
}

.dot {
  fill: var(--dot-color);
}

.controls {
  width: min(100%, 600px);
  padding: clamp(0.75rem, 3vw, 1rem);
  display: grid;
  gap: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--surface-color);
  box-shadow: 0 18px 42px var(--shadow-color);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.controls__primary {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(180px, 1.2fr);
  gap: 0.75rem;
}

.controls__actions {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 0.55rem;
}

.controls .form-select,
.roll,
.motion-toggle {
  min-height: 48px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  font: inherit;
  font-weight: 750;
}

.controls .form-select {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 2.5rem 0.7rem 0.9rem;
  appearance: none;
  color: var(--text-color);
  background-color: var(--surface-strong);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M10.583 6 7.997 8.587 5.41 6a.665.665 0 0 0-.94.94L7.53 10a.665.665 0 0 0 .94 0l3.06-3.06a.665.665 0 0 0-.947-.94Z' fill='%2390caf9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.controls .form-select option {
  color: var(--text-color);
  background: var(--surface-strong);
}

.roll {
  padding: 0.7rem 1rem;
  color: #0b1020;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
  box-shadow: 0 10px 24px rgba(115, 232, 242, 0.16);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.roll:hover {
  transform: translateY(-2px);
  filter: saturate(1.08) brightness(1.04);
  box-shadow: 0 14px 30px rgba(115, 232, 242, 0.23);
}

.roll:active {
  transform: translateY(0) scale(0.98);
}

.motion-control {
  position: relative;
  display: grid;
  place-items: center;
}

.motion-toggle {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  background: var(--surface-strong);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.motion-toggle svg {
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.motion-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--accent-color);
}

.motion-toggle.is-active {
  color: #091312;
  border-color: rgba(93, 230, 190, 0.72);
  background: linear-gradient(135deg, #7ff2d0, #73e8f2);
  box-shadow: 0 8px 22px rgba(93, 230, 190, 0.18);
}

.motion-status {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.65rem);
  z-index: 20;
  width: min(230px, calc(100vw - 1.5rem));
  padding: 0.65rem 0.75rem;
  margin: 0;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--muted-color);
  box-shadow: 0 12px 30px var(--shadow-color);
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 160ms ease, transform 160ms ease;
}

.motion-status::after {
  position: absolute;
  right: 0.9rem;
  top: 100%;
  width: 0.65rem;
  height: 0.65rem;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-strong);
  content: '';
  transform: translateY(-50%) rotate(45deg);
}

.motion-status.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.motion-status[data-state='active'],
.motion-status[data-state='detected'] {
  color: var(--accent-color);
}

.motion-status[data-state='denied'],
.motion-status[data-state='unsupported'],
.motion-status[data-state='secure'],
.motion-status[data-state='error'] {
  color: #ff9f9f;
}

/* Логотип для светлой темы */
body.light-theme .logo-title {
  background: linear-gradient(45deg, #e74c3c, #27ae60, #3498db, #f39c12, #9b59b6);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.light-theme .app-header,
body.light-theme .language-menu__trigger,
body.light-theme .theme-toggle {
  background: rgba(255, 255, 255, 0.88);
}

body.light-theme .language-menu__panel {
  background: #ffffff;
  box-shadow: 0 20px 44px rgba(40, 70, 105, 0.2);
}

body.light-theme .language-menu__option {
  color: var(--text-color);
}

/* d9911 dark UI baseline: local, dependency-free, and motion-aware. */
html {
  background-color: var(--bg-color);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  background-color: var(--bg-color);
  accent-color: #90caf9;
}

body.light-theme {
  color-scheme: light;
}

::selection {
  background: rgba(144, 202, 249, 0.28);
  color: #ffffff;
}

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid #90caf9;
  outline-offset: 3px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #90caf9 #111722;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: #111722;
}

*::-webkit-scrollbar-thumb {
  min-width: 36px;
  min-height: 36px;
  border: 2px solid #111722;
  border-radius: 999px;
  background: linear-gradient(180deg, #90caf9, #ce93d8);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #73e8f2, #c6a0ff);
  background-clip: padding-box;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.game {
  width: min(100% - 1.5rem, 920px);
  margin-inline: auto;
  padding-block: clamp(1.25rem, 4vw, 3rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.controls .language-select { min-width: 74px; }

.app-footer {
  display: flex;
  justify-content: space-between;
  width: min(100%, 560px);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  gap: 1rem;
  color: var(--text-color);
}

.app-footer a { color: #90caf9; font-weight: 700; }

#themeToggle {
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

@media (max-width: 576px) {
  .logo-container {
    gap: 8px;
    margin-bottom: 0;
  }

  .logo-title {
    font-size: clamp(1.5rem, 8vw, 2rem);
  }

  .controls {
    width: min(100%, 360px);
  }

  .controls__primary {
    grid-template-columns: 1fr;
  }

  .dice-container {
    gap: 12px;
  }

}

@media (max-width: 340px) {
  .game {
    width: calc(100% - 0.75rem);
    padding-block: 0.65rem;
  }

  .app-header {
    padding: 0.4rem;
    border-radius: 14px;
  }

  .logo {
    width: 28px;
  }

  .logo-title {
    font-size: 1rem;
  }

  .language-menu__trigger {
    width: 48px;
    min-width: 48px;
  }

  .theme-toggle {
    width: 42px;
    min-width: 42px;
  }

  .controls {
    padding: 0.65rem;
    border-radius: 16px;
  }

  .dice-container {
    gap: 8px;
    min-height: 104px;
  }

  .app-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
