/* Base styles and reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 20px;
}

.container {
  max-width: 500px;
  width: 100%;
}

h1 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.8rem;
  color: #e94560;
}

/* Card component */
.card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #e94560;
}

.card-description {
  font-size: 0.95rem;
  color: #ccc;
  margin-bottom: 20px;
  line-height: 1.5;
}

.card-link {
  display: inline-block;
  width: 100%;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  background: linear-gradient(135deg, #e94560 0%, #0f3460 100%);
  color: white;
  text-decoration: none;
  text-align: center;
}

.card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(233, 69, 96, 0.4);
}

/* Status indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #666;
  transition: background 0.3s, box-shadow 0.3s;
}

.status-dot.connected {
  background: #4ade80;
  box-shadow: 0 0 12px #4ade80;
}

.status-dot.connecting {
  background: #fbbf24;
  box-shadow: 0 0 12px #fbbf24;
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.status-text {
  font-size: 1rem;
  color: #ccc;
}

/* Buttons */
#connectBtn {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  background: linear-gradient(135deg, #e94560 0%, #0f3460 100%);
  color: white;
}

#connectBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(233, 69, 96, 0.4);
}

#connectBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#disconnectBtn {
  width: 100%;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid #e94560;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  background: transparent;
  color: #e94560;
  margin-top: 10px;
}

#disconnectBtn:hover {
  background: rgba(233, 69, 96, 0.2);
}

/* Browser warning */
.browser-warning {
  background: rgba(251, 191, 36, 0.2);
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: none;
}

/* Settings section */
.settings-section {
  margin-bottom: 20px;
  display: none;
}

.settings-section.visible {
  display: block;
}

/* Cards visibility control */
.settings-card {
  display: none;
}

.connection-status-card {
  display: none;
}

.settings-label {
  font-size: 0.9rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-control input[type="number"] {
  flex: 1;
  padding: 12px;
  font-size: 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  outline: none;
  transition: border-color 0.3s;
}

.settings-control input[type="number"]:focus {
  border-color: #e94560;
}

.settings-control button {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  background: #e94560;
  color: white;
}

.settings-control button:hover {
  background: #d13a52;
  transform: translateY(-1px);
}

.settings-control button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.current-max {
  font-size: 0.9rem;
  color: #aaa;
}

/* Dice buttons grid */
.dice-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 10px;
}

.dice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.dice-btn:hover {
  background: rgba(233, 69, 96, 0.2);
  border-color: #e94560;
  transform: translateY(-2px);
}

.dice-btn.active {
  background: rgba(233, 69, 96, 0.3);
  border-color: #e94560;
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
}

.dice-btn img {
  width: 40px;
  height: 40px;
  filter: brightness(0) invert(1);
  opacity: 0.8;
  transition: opacity 0.3s;
}

.dice-btn:hover img,
.dice-btn.active img {
  opacity: 1;
}

.dice-btn span {
  font-size: 0.85rem;
  letter-spacing: 1px;
}

/* Dice display */
.dice-display {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 20px;
}

.dice-number {
  font-size: 6rem;
  font-weight: 700;
  color: #4ade80;
  text-shadow: 0 0 30px rgba(74, 222, 128, 0.5);
  margin-bottom: 10px;
  transition: all 0.3s;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dice-number.rolling {
  animation: shake 0.5s infinite;
  color: #fbbf24;
  text-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  25% {
    transform: translateX(-5px) rotate(-2deg);
  }

  75% {
    transform: translateX(5px) rotate(2deg);
  }
}

.dice-label {
  font-size: 1rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* History section */
.history-section {
  margin-top: 20px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-header h3 {
  font-size: 0.9rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.clear-history-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #e94560;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  background: transparent;
  color: #e94560;
}

.clear-history-btn:hover {
  background: rgba(233, 69, 96, 0.2);
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 12px;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

.history-entry:last-child {
  border-bottom: none;
}

.history-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: #4ade80;
  min-width: 40px;
}

.history-dice {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e94560;
  background: rgba(233, 69, 96, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.history-time {
  color: #888;
  font-size: 0.85rem;
  margin-left: auto;
}

.history-empty {
  text-align: center;
  color: #666;
  padding: 20px;
  font-size: 0.9rem;
}

/* Message container (sensor monitor) */
.message-container {
  margin-top: 20px;
}

.message-container h3 {
  font-size: 0.9rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.current-status {
  font-size: 1.5rem;
  font-weight: 600;
  color: #4ade80;
  padding: 20px;
  background: rgba(74, 222, 128, 0.1);
  border-radius: 12px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.current-status.roll {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  animation: shake 0.5s;
}

/* Message log */
.message-log {
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 12px;
}

.message-log::-webkit-scrollbar {
  width: 6px;
}

.message-log::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.message-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.log-entry {
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 10px;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: #888;
  flex-shrink: 0;
}

.log-message {
  color: #fff;
}

.error {
  color: #f87171 !important;
}

/* Footer */
footer {
  margin-top: 30px;
  text-align: center;
  color: #666;
  font-size: 0.8rem;
}