:root {
  --color-accent: #f59e0b;
  --color-alert: #ef4444;
  --color-dice-text: #1c1917;
  --color-dice-background: #f5f0e6;
  --experience-accent: #f59e0b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: #1c1917;
  color: #f5f5f4;
  font-family: Arial, Helvetica, sans-serif;
}

#experience {
  min-height: 100dvh;
}

.boggle {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.boggle-bar {
  align-items: center;
  border-bottom: 1px solid rgba(245, 245, 244, 0.28);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 1rem;
}

.boggle-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.08rem;
  margin: 0;
}

.boggle-timer {
  flex: 1;
  font-size: 1.4rem;
  margin: 0;
  text-align: center;
}

.boggle-timer.is-over {
  color: var(--color-alert);
}

.boggle-timer.is-warn {
  color: #fbbf24;
}

.boggle-actions {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.boggle-length select {
  appearance: none;
  background: #292524;
  border: 1px solid rgba(245, 245, 244, 0.35);
  border-radius: 0.5rem;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0.45rem 0.7rem;
}

.boggle-btn {
  align-items: center;
  background: transparent;
  border: 1px solid rgba(245, 245, 244, 0.4);
  border-radius: 0.55rem;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  height: 2.6rem;
  justify-content: center;
  padding: 0;
  width: 2.6rem;
}

.boggle-btn svg {
  height: 1.35rem;
  width: 1.35rem;
}

.boggle-btn:hover,
.boggle-btn:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent);
  outline: none;
}

.boggle-btn.primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #1c1917;
}

.boggle-btn.primary:hover,
.boggle-btn.primary:focus-visible {
  box-shadow: 0 0 0.8rem rgba(245, 158, 11, 0.45);
  color: #1c1917;
}

.boggle-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.boggle-stage {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  padding: 1rem 1rem 5.5rem;
  position: relative;
}

.boggle-board {
  aspect-ratio: 1;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
  margin: 0;
  max-height: min(72dvh, 36rem);
  max-width: min(92vw, 36rem);
  padding: 0;
  transform: rotate(var(--board-rot, 0deg));
  transition: transform 0.35s ease;
  width: 100%;
}

.boggle-board.is-shaking {
  animation: shake-board 0.7s ease;
}

.die {
  align-items: center;
  aspect-ratio: 1;
  background: var(--color-dice-background);
  border-radius: 18%;
  box-shadow:
    inset 0 -0.18em 0.2em rgba(28, 25, 23, 0.18),
    0 0.18em 0.35em rgba(0, 0, 0, 0.35);
  color: var(--color-dice-text);
  display: flex;
  font-size: clamp(1.6rem, 8vw, 3.4rem);
  font-weight: 700;
  justify-content: center;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transform: rotate(calc(-1 * var(--board-rot, 0deg)));
}

.die.is-qu {
  font-size: clamp(1.2rem, 6vw, 2.5rem);
}

.boggle-overlay {
  align-items: center;
  background: rgba(28, 25, 23, 0.62);
  display: flex;
  inset: 0;
  justify-content: center;
  position: absolute;
}

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

.boggle-overlay p {
  color: #fff;
  font-size: clamp(2.4rem, 10vw, 5rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0;
  text-shadow: 0 0 1.2rem rgba(245, 158, 11, 0.55);
  text-transform: uppercase;
}

.boggle-overlay.is-over p {
  color: var(--color-alert);
  letter-spacing: 0.08em;
  text-shadow: none;
}

.zen-volume {
  bottom: 0.85rem;
  color: #f5f5f4;
  display: flex;
  gap: 0.4rem;
  left: 0.85rem;
  position: fixed;
  z-index: 2;
  filter:
    drop-shadow(0 1px 1px #000)
    drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.zen-sound,
.zen-full {
  background: none;
  border: 0;
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  display: grid;
  flex: none;
  height: 2.5rem;
  padding: 0;
  place-items: center;
  width: 2.5rem;
}

.zen-sound svg,
.zen-full svg {
  display: block;
  fill: none;
  height: 1.4rem;
  margin: 0;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  width: 1.4rem;
}

.zen-sound .icon-speaker {
  fill: currentColor;
  stroke: none;
}

.zen-sound .icon-waves {
  display: none;
}

.zen-sound .icon-mute {
  display: block;
}

.zen-sound.is-on .icon-waves {
  display: block;
}

.zen-sound.is-on .icon-mute {
  display: none;
}

.zen-full .icon-exit {
  display: none;
}

.zen-full.is-on .icon-enter {
  display: none;
}

.zen-full.is-on .icon-exit {
  display: block;
}

.zen-volume:not(.is-on) .zen-sound {
  animation: sound-hint 2.8s ease-in-out infinite;
}

.zen-volume-label {
  align-items: center;
  display: flex;
  margin: 0;
}

.zen-volume-label input[type="range"] {
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 1.35rem;
  margin: 0;
  width: 7.6rem;
}

.zen-volume-label input[type="range"]::-webkit-slider-runnable-track {
  background: rgba(245, 245, 244, 0.38);
  border-radius: 999px;
  height: 4px;
}

.zen-volume-label input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: #f59e0b;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(28, 25, 23, 0.55);
  height: 14px;
  margin-top: -5px;
  width: 14px;
}

.zen-volume-label input[type="range"]::-moz-range-track {
  background: rgba(245, 245, 244, 0.38);
  border-radius: 999px;
  height: 4px;
}

.zen-volume-label input[type="range"]::-moz-range-thumb {
  background: #f59e0b;
  border: 0;
  border-radius: 50%;
  height: 14px;
  width: 14px;
}

.zen-sound:focus-visible,
.zen-full:focus-visible,
.zen-volume-label input:focus-visible,
.boggle-length select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

@keyframes shake-board {
  0%,
  100% {
    transform: rotate(var(--board-rot, 0deg));
  }
  20% {
    transform: rotate(var(--board-rot, 0deg)) translate(-8px, 4px);
  }
  40% {
    transform: rotate(var(--board-rot, 0deg)) translate(7px, -3px);
  }
  60% {
    transform: rotate(var(--board-rot, 0deg)) translate(-4px, 2px);
  }
  80% {
    transform: rotate(var(--board-rot, 0deg)) translate(3px, -1px);
  }
}

@keyframes sound-hint {
  0%,
  100% {
    opacity: 0.58;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boggle-board,
  .boggle-board.is-shaking,
  .zen-volume:not(.is-on) .zen-sound {
    animation: none;
    transition: none;
  }
}
