:root {
  --dice-size: 100px;
  --dice-depth: 50px;
  --dice-radius: 16px;
  --primary: #f6c34f;
  --primary-hover: #e6b343;
  --text: #333;
  --muted: #888;
  --border: #eee;
  --panel-bg: #ffffff;
  --panel-border: #eee;
}



.dice-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 60px);
  padding: 20px;
  width: 100%;
}

.dice-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 2rem 0;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}


.dice-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3rem;
  padding: 2rem;
  perspective: 1200px;
  min-height: 240px;
  align-items: center;
}

.dice-wrapper {
  width: var(--dice-size);
  height: var(--dice-size);
  perspective: 1000px;
  position: relative;
}

.dice {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
  transition: transform 1.0s cubic-bezier(0.35, 0.17, 0.3, 0.99);
  cursor: pointer;
  will-change: transform;
}

.dice-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: var(--dice-radius);
  padding: 0;
  display: flex;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  backface-visibility: hidden;
}


.dice-wrapper::after {
  content: '';
  position: absolute;
  left: 10%;
  bottom: -10px;
  width: 80%;
  height: 10px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.15) 0%, transparent 70%);
  filter: blur(4px);
  z-index: -1;
}


.dot {
  width: 20px;
  height: 20px;
  background: var(--text);
  border-radius: 50%;
  position: absolute;
}


.d-1 .dot {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}


.d-2 .dot:nth-child(1) {
  top: 25%;
  left: 25%;
}

.d-2 .dot:nth-child(2) {
  bottom: 25%;
  right: 25%;
}


.d-3 .dot:nth-child(1) {
  top: 20%;
  left: 25%;
}

.d-3 .dot:nth-child(2) {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.d-3 .dot:nth-child(3) {
  bottom: 20%;
  right: 25%;
}


.d-4 .dot:nth-child(1) {
  top: 25%;
  left: 25%;
}

.d-4 .dot:nth-child(2) {
  top: 25%;
  right: 25%;
}

.d-4 .dot:nth-child(3) {
  bottom: 25%;
  left: 25%;
}

.d-4 .dot:nth-child(4) {
  bottom: 25%;
  right: 25%;
}


.d-5 .dot:nth-child(1) {
  top: 20%;
  left: 25%;
}

.d-5 .dot:nth-child(2) {
  top: 20%;
  right: 25%;
}

.d-5 .dot:nth-child(3) {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.d-5 .dot:nth-child(4) {
  bottom: 20%;
  left: 25%;
}

.d-5 .dot:nth-child(5) {
  bottom: 20%;
  right: 25%;
}


.d-6 .dot:nth-child(1) {
  top: 15%;
  left: 25%;
}

.d-6 .dot:nth-child(2) {
  top: 15%;
  right: 25%;
}

.d-6 .dot:nth-child(3) {
  top: 42%;
  left: 25%;
}

.d-6 .dot:nth-child(4) {
  top: 42%;
  right: 25%;
}

.d-6 .dot:nth-child(5) {
  bottom: 10%;
  left: 25%;
}

.d-6 .dot:nth-child(6) {
  bottom: 10%;
  right: 25%;
}


.face-1 {
  transform: rotateY(0deg) translateZ(var(--dice-depth));
}

.face-6 {
  transform: rotateY(180deg) translateZ(var(--dice-depth));
}

.face-2 {
  transform: rotateY(90deg) translateZ(var(--dice-depth));
}

.face-5 {
  transform: rotateY(-90deg) translateZ(var(--dice-depth));
}

.face-3 {
  transform: rotateX(90deg) translateZ(var(--dice-depth));
}

.face-4 {
  transform: rotateX(-90deg) translateZ(var(--dice-depth));
}


@keyframes diceRollPro {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  80% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }

  95% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(-5deg);
  }

  100% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }
}

.dice.rolling {
  animation: diceRollPro 2.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}


.dice-face {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.4s ease;
}


.dice.rolling .dice-face {
  opacity: 1;
}


.dice:not(.rolling) .dice-face:not(.face-1) {
  opacity: 0;
}


.dice.rolling.end-roll {
  animation: diceRollPro 2.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards,
    diceSettle 0.4s ease-out forwards;
}

@keyframes diceSettle {
  0% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }

  50% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(3deg);
  }

  100% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }
}


.dice.rolling.end-roll .dice-face:not(.face-1) {
  opacity: 0;
  transition: opacity 0.4s ease 0.4s;
}


@keyframes diceSettle {
  0% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }

  50% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(3deg);
  }

  100% {
    transform: rotateX(var(--final-x)) rotateY(var(--final-y)) rotateZ(0deg);
  }
}


.dice.rolling.end-roll .dice-face:not(.face-1) {
  opacity: 0;
  transition: opacity 0.4s ease 0.4s;
}



.stats-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stat-item {
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: #595959;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  display: block;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.3s ease;
}

.stat-value.updated {
  transform: scale(1.15);
  color: var(--primary);
}


.control-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.9rem;
  color: #595959;
  font-weight: 500;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #f5f5f5;
  padding: 6px;
  border-radius: 12px;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:hover:not(:disabled) {
  background: rgba(246, 195, 79, 0.2);
  color: var(--text);
}

.stepper-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.control-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  min-width: 2rem;
  text-align: center;
}


.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.roll-btn {
  flex: 1;
  padding: 1rem 2rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #FFD966, #FF7A45);
  border: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(246, 195, 79, 0.3);
}

.roll-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.roll-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: #e0e0e0;
  color: var(--muted);
}

.reset-btn {
  flex: 0 0 auto;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #eee;
  color: #666;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-btn:hover {
  background: #eeeeee;
  color: var(--text);
  border-color: #ddd;
}


.shortcut-btn-group {
  display: inline-flex;
  gap: 6px;
  margin-top: 1rem;
}

.sc-btn {
  background-color: #ffffff;
  color: #555555;
  border: 1px solid #eee;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  font-weight: normal;
}

.sc-btn:hover {
  background-color: #f8fafc;
  border-color: #ddd;
  color: #555;
}

.sc-btn.active {
  background-color: #ffffff;
  color: #555555;
  border: 2px solid #FF7A45;
  font-weight: 700;
}


.history-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.history-title {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  display: block;
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-item {
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  opacity: 0;
  animation: fadeInUp 0.3s ease forwards;
}

.history-item span {
  color: var(--primary);
  font-weight: 600;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


@media (min-width: 640px) {
  .stats-panel {
    grid-template-columns: repeat(4, 1fr);
  }

}


@media (max-width: 480px) {
  :root {
    --dice-size: 85px;
    --dice-depth: 42px;
    --dice-radius: 14px;
  }

  .dot {
    width: 18px;
    height: 18px;
  }

  .dice-container {
    padding: 0rem;
  }


  .stats-panel,
  .control-panel {
    padding: 1.2rem;
  }


  .roll-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #FFD966, #FF7A45);

  }

  .reset-btn {
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
  }

  .sc-btn {
    padding: 6px 10px;
    font-size: 13px;
  }


  .shortcut-btn-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 1rem;
    margin-left: 0;
  }


  .sc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
