@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Comfortaa:wght@400;700&family=Roboto:wght@300;500&display=swap');

/* ===== BASE & SPACE BACKGROUND ===== */
body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: #0f0;
  font-family: 'Roboto', sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  padding: 20px 0 60px;
}

.stars {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(2px 2px at 20px 30px, white, transparent),
              radial-gradient(2px 2px at 60px 70px, white, transparent),
              radial-gradient(1px 1px at 50px 50px, white, transparent),
              radial-gradient(1px 1px at 130px 80px, white, transparent),
              radial-gradient(2px 2px at 90px 10px, white, transparent);
  background-size: 200px 200px;
  animation: twinkle 8s infinite;
  opacity: 0.7;
  z-index: -2;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.nebula {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, rgba(255,69,0,0.3) 0%, transparent 70%),
              radial-gradient(ellipse at 80% 20%, rgba(0,255,0,0.2) 0%, transparent 50%);
  opacity: 0.5;
  z-index: -1;
}

.background-towel {
  position: fixed;
  bottom: 0; right: 0;
  width: 300px; height: 300px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23ffd700"/><path d="M0 0h100v20H0z" fill="%23ff6347"/><path d="M0 80h100v20H0z" fill="%23ff6347"/><circle cx="20" cy="40" r="8" fill="%2347a0ff"/><circle cx="50" cy="30" r="10" fill="%23ff47a0"/><circle cx="80" cy="50" r="7" fill="%23a0ff47"/></svg>') center/contain no-repeat;
  opacity: 0;
  transition: opacity 2s ease;
  pointer-events: none;
  z-index: 0;
}

.background-towel.show {
  opacity: 0.3;
}

/* ===== HEADER ===== */
header {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.lang-switch {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 1rem;
}

.lang-switch a {
  color: #ff4500;
  text-decoration: none;
  padding: 8px 15px;
  border: 2px solid #ff4500;
  border-radius: 30px;
  transition: all 0.3s;
  background: rgba(0,0,0,0.7);
  box-shadow: 0 0 15px rgba(255,69,0,0.5);
}

.lang-switch a:hover {
  background: #ff4500;
  color: #000;
  box-shadow: 0 0 25px rgba(255,69,0,0.8);
}

h1 {
  font-family: 'Orbitron', cursive;
  font-size: 5rem;
  margin: 0;
  color: #ff4500;
  text-shadow: 0 0 30px #ff4500, 0 0 60px #ff4500;
  animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { text-shadow: 0 0 30px #ff4500, 0 0 60px #ff4500; }
  50% { text-shadow: 0 0 40px #ff4500, 0 0 80px #ff4500, 0 0 100px #ff4500; }
}

p.intro {
  font-size: 1.3rem;
  line-height: 1.8;
  margin: 2rem auto;
  color: #0f0;
}

.ps {
  font-style: italic;
  color: #ffd700;
  font-size: 1.5rem;
  margin: 1.5rem 0;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
}

/* ===== DICE 3D ===== */
.dice-container {
  display: flex;
  gap: 80px;
  margin: 3rem 0;
  perspective: 1500px;
  justify-content: center;
  min-height: 200px;
  align-items: center;
}

.die-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  animation: float 6s ease-in-out infinite;
}

.die-wrapper:nth-child(2) {
  animation-delay: -3s;
}

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

.die {
  width: 140px;
  height: 140px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.face {
  position: absolute;
  width: 140px;
  height: 140px;
  background: linear-gradient(145deg, #ffffff, #d5d5d5);
  border-radius: 20px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.15),
              0 0 20px rgba(0, 255, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

/* Position each face of the cube */
.face.front  { transform: rotateY(0deg) translateZ(70px); }
.face.back   { transform: rotateY(180deg) translateZ(70px); }
.face.right  { transform: rotateY(90deg) translateZ(70px); }
.face.left   { transform: rotateY(-90deg) translateZ(70px); }
.face.top    { transform: rotateX(90deg) translateZ(70px); }
.face.bottom { transform: rotateX(-90deg) translateZ(70px); }

/* Dots on each face */
.face .dot {
  width: 20px;
  height: 20px;
  background: #000;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
              0 0 8px rgba(0, 255, 0, 0.3);
  position: absolute;
}

/* Face 1 (front) - one dot in center */
.face.front .dot:nth-child(1) {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Face 2 (back) - two dots diagonal */
.face.back .dot:nth-child(1) {
  left: 25%;
  top: 25%;
}
.face.back .dot:nth-child(2) {
  right: 25%;
  bottom: 25%;
}

/* Face 3 (right) - three dots diagonal */
.face.right .dot:nth-child(1) {
  left: 25%;
  top: 25%;
}
.face.right .dot:nth-child(2) {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.face.right .dot:nth-child(3) {
  right: 25%;
  bottom: 25%;
}

/* Face 4 (left) - four dots in corners */
.face.left .dot:nth-child(1) {
  left: 25%;
  top: 25%;
}
.face.left .dot:nth-child(2) {
  right: 25%;
  top: 25%;
}
.face.left .dot:nth-child(3) {
  left: 25%;
  bottom: 25%;
}
.face.left .dot:nth-child(4) {
  right: 25%;
  bottom: 25%;
}

/* Face 5 (top) - five dots */
.face.top .dot:nth-child(1) {
  left: 25%;
  top: 25%;
}
.face.top .dot:nth-child(2) {
  right: 25%;
  top: 25%;
}
.face.top .dot:nth-child(3) {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.face.top .dot:nth-child(4) {
  left: 25%;
  bottom: 25%;
}
.face.top .dot:nth-child(5) {
  right: 25%;
  bottom: 25%;
}

/* Face 6 (bottom) - six dots */
.face.bottom .dot:nth-child(1) {
  left: 25%;
  top: 25%;
}
.face.bottom .dot:nth-child(2) {
  right: 25%;
  top: 25%;
}
.face.bottom .dot:nth-child(3) {
  left: 25%;
  top: 50%;
  transform: translateY(-50%);
}
.face.bottom .dot:nth-child(4) {
  right: 25%;
  top: 50%;
  transform: translateY(-50%);
}
.face.bottom .dot:nth-child(5) {
  left: 25%;
  bottom: 25%;
}
.face.bottom .dot:nth-child(6) {
  right: 25%;
  bottom: 25%;
}

/* Bounce animation for dice landing */
@keyframes bounce {
  0% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-30px);
  }
  50% {
    transform: translateY(0);
  }
  65% {
    transform: translateY(-15px);
  }
  80% {
    transform: translateY(0);
  }
  90% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

/* ===== ROLL BUTTON ===== */
button#roll {
  background: #ff4500;
  color: white;
  border: none;
  padding: 1.2rem 3.5rem;
  font-size: 1.8rem;
  font-family: 'Orbitron', sans-serif;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(255,69,0,0.6);
  transition: all 0.3s;
  margin: 0 auto;
  display: block;
}

button#roll:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 50px rgba(255,69,0,0.9);
}

button#roll:active {
  transform: translateY(2px);
}

button#roll[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

/* ===== RESULT ===== */
.result {
  margin: 3rem auto;
  min-height: 120px;
  max-width: 900px;
  padding: 2rem;
  font-size: 1.5rem;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease;
  background: rgba(0,255,0,0.1);
  border: 2px solid #0f0;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 30px rgba(0,255,0,0.3);
  line-height: 1.7;
}

.result.show {
  opacity: 1;
  transform: translateY(0);
}

.result.jackpot {
  animation: pulse 2s infinite;
  color: #ffd700;
  border-color: #ffd700;
  text-shadow: 0 0 20px gold;
  box-shadow: 0 0 50px rgba(255,215,0,0.6);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== CUMULATIVE RESULTS ===== */
.cumulative-results-section {
  width: min(900px, 95vw);
  margin: 2rem auto;
  background: rgba(0,255,0,0.05);
  border: 2px solid #0f0;
  border-radius: 20px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 30px rgba(0,255,0,0.2);
}

.cumulative-results-section h2 {
  font-family: 'Orbitron', cursive;
  color: #0f0;
  margin: 0 0 1.5rem;
  font-size: 2rem;
  text-align: center;
  text-shadow: 0 0 15px rgba(0,255,0,0.6);
}

.cumulative-list {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 5px;
}

.cumulative-list::-webkit-scrollbar {
  width: 8px;
}

.cumulative-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
}

.cumulative-list::-webkit-scrollbar-thumb {
  background: rgba(0,255,0,0.5);
  border-radius: 10px;
}

.cumulative-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0,255,0,0.8);
}

.cumulative-item {
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(0,255,0,0.05);
  border-left: 3px solid #0f0;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.cumulative-item:hover {
  background: rgba(0,255,0,0.15);
  transform: translateX(5px);
  box-shadow: 0 0 15px rgba(0,255,0,0.3);
}

.cumulative-item .roll-key {
  color: #ff4500;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 5px;
  text-shadow: 0 0 10px rgba(255,69,0,0.5);
}

.cumulative-item .roll-text {
  color: #0f0;
  font-size: 1rem;
  line-height: 1.4;
  margin-bottom: 5px;
}

.cumulative-item .roll-time {
  color: #ffd700;
  font-size: 0.9rem;
}

.empty-state {
  color: #0f0;
  text-align: center;
  font-style: italic;
  padding: 2rem;
  opacity: 0.6;
}

/* ===== ACTION BUTTONS ===== */
.actions-row {
  margin: 2rem auto;
  text-align: center;
}

button.action-btn,
button.reset {
  padding: 1rem 2.5rem;
  font-size: 1.3rem;
  font-family: 'Orbitron', cursive;
  background: #0f0;
  color: #000;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0,255,0,0.5);
  transition: all 0.3s;
}

button.action-btn:hover,
button.reset:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 35px rgba(0,255,0,0.8);
}

/* ===== GUIDE DEVICE (style film 2005) ===== */
.guide-device {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95vw;
  max-width: 1200px;
  max-height: 90vh;
  z-index: 100;
  animation: deviceOpen 1.2s ease-out;
  border: 18px solid #ff4500;
  border-radius: 50px;
  box-shadow: 0 0 80px rgba(255, 69, 0, 0.9), 
              inset 0 0 40px rgba(255, 69, 0, 0.3),
              0 0 120px rgba(255, 69, 0, 0.6);
  background: #000;
  overflow: hidden;
  display: none;
}

.guide-device:not([hidden]) {
  display: block;
}

.device-screen {
  width: 100%;
  max-height: calc(90vh - 36px);
  background: #000;
  color: #0f0;
  padding: 1.5rem 2.5rem 2rem 2.5rem;
  overflow-y: auto;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  position: relative;
  word-wrap: break-word;
  box-sizing: border-box;
}

.device-screen::-webkit-scrollbar {
  width: 10px;
}

.device-screen::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
}

.device-screen::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 0, 0.5);
  border-radius: 10px;
  border: 2px solid #000;
}

.device-screen::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 0, 0.8);
}

/* Scan lines rétro terminal */
.device-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 255, 0, 0.03),
    rgba(0, 255, 0, 0.03) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  animation: scan 8s linear infinite;
  z-index: 1;
}

.device-screen > * {
  position: relative;
  z-index: 2;
}

.dont-panic-header {
  font-size: 4rem;
  text-align: center;
  color: #0f0;
  text-shadow: 0 0 25px #0f0, 0 0 50px #0f0;
  margin: 1rem 0 2rem;
  font-weight: bold;
  letter-spacing: 0.3rem;
  font-family: 'Orbitron', cursive;
  animation: textGlow 3s ease-in-out infinite;
}

@keyframes textGlow {
  0%, 100% { text-shadow: 0 0 25px #0f0, 0 0 50px #0f0; }
  50% { text-shadow: 0 0 35px #0f0, 0 0 70px #0f0, 0 0 100px #0f0; }
}

.device-screen h2 {
  text-align: center;
  color: #ff4500;
  text-shadow: 0 0 20px #ff4500;
  margin-bottom: 2rem;
  font-size: 1.8rem;
  font-family: 'Orbitron', cursive;
}

.device-screen .history {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}

.device-screen .history li {
  color: #0f0;
  border-bottom: 1px dashed rgba(0, 255, 0, 0.4);
  padding: 1rem 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.device-screen .history li:last-child {
  border-bottom: none;
}

.device-screen .entry-key {
  color: #ff4500;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 69, 0, 0.8);
}

.device-screen .entry-text {
  color: #0f0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  min-width: 0;
  max-width: 100%;
}

.device-screen .entry-time {
  color: #ffd700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.device-screen .notes {
  margin-top: 2rem;
  display: grid;
  gap: 15px;
}

.device-screen .notes label {
  color: #0f0;
  font-size: 1rem;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.device-screen .notes textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #0f0;
  color: #0f0;
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
  min-height: 120px;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.device-screen button.reset {
  margin: 2rem auto 1rem;
  display: block;
  background: #ff4500;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 69, 0, 0.6);
  padding: 1rem 3rem;
  font-size: 1.2rem;
}

.device-screen button.reset:hover {
  box-shadow: 0 0 35px rgba(255, 69, 0, 0.9);
  transform: translateY(-3px);
}

.close-device {
  position: absolute;
  top: 15px;
  right: 25px;
  background: none;
  border: none;
  color: #ff4500;
  font-size: 3rem;
  cursor: pointer;
  z-index: 10;
  text-shadow: 0 0 15px rgba(255, 69, 0, 0.8);
  transition: all 0.3s;
  line-height: 1;
  padding: 0;
  width: 40px;
  height: 40px;
}

.close-device:hover {
  color: #fff;
  text-shadow: 0 0 25px #ff4500, 0 0 50px #ff4500;
  transform: rotate(90deg);
}

@keyframes deviceOpen {
  0% {
    transform: translate(-50%, -50%) scale(0.1);
    opacity: 0;
    box-shadow: 0 0 0 rgba(255, 69, 0, 0);
  }
  70% {
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes scan {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 100%;
  }
}

/* Towel jackpot enhancement */
body.jackpot .background-towel {
  opacity: 0.8;
  animation: towelPulse 3s infinite;
}

@keyframes towelPulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  h1 { font-size: 3.5rem; }
  
  .dice-container { gap: 40px; margin: 2rem 0; }
  .die { width: 100px; height: 100px; }
  .face { width: 100px; height: 100px; }
  .dot { width: 16px; height: 16px; }
  
  button#roll {
    padding: 1rem 2.5rem;
    font-size: 1.5rem;
  }
  
  .result {
    font-size: 1.2rem;
    padding: 1.5rem;
  }
  
  .cumulative-results-section {
    padding: 1rem;
  }
  
  .cumulative-results-section h2 {
    font-size: 1.5rem;
  }
  
  .cumulative-list {
    max-height: 300px;
  }
  
  .floating-guide {
    width: 90vw;
    height: 70vh;
    left: 5vw;
    transform: none;
  }
  
  .book-screen {
    top: 20%;
    left: 15%;
    right: 15%;
    bottom: 20%;
    padding: 10px;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 2.5rem; }
  
  .intro { font-size: 1.1rem; }
  .ps { font-size: 1.2rem; }
  
  .dice-container { gap: 25px; }
  .die { width: 80px; height: 80px; }
  .face { width: 80px; height: 80px; }
  
  button#roll {
    padding: 0.8rem 2rem;
    font-size: 1.3rem;
  }
}
