:root {
  --bg-color: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --bar-bg: rgba(59, 130, 246, 0.8);
  --bar-highlight: rgba(96, 165, 250, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
  color: var(--text-main);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 600px;
  min-height: 100dvh;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: space-evenly;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
}

.icon-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-icon {
  padding: 0.25rem;
  opacity: 0.6;
}

.info-icon:hover {
  transform: scale(1.1);
  opacity: 1;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(to right, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
  padding: 0.25rem;
  display: flex;
}

.icon-btn:hover {
  color: var(--text-main);
  transform: rotate(-30deg);
}

/* Glassmorphic Panels */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Tracker Section */
.tracker-section {
  padding: 0.5rem;
}

.tracker-window {
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  width: 100%;
  height: 50px;
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tracker-window::-webkit-scrollbar {
  display: none;
}

.history-track {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  height: 100%;
  padding: 0 40px;
  cursor: grab;
}

.history-track:active {
  cursor: grabbing;
}

.roll-bubble {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.6;
  transform: scale(0.8);
  transition: all 0.4s ease;
}

.roll-bubble.latest {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-color: transparent;
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.roll-bubble.new-entry {
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.5) translateX(-20px); }
  100% { opacity: 1; transform: scale(1.1) translateX(0); }
}

/* Graph Section */
.graph-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.graph {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  flex-grow: 1;
  min-height: 100px;
  height: auto;
  gap: 2px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

.bar-wrapper {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  flex-grow: 1;
  position: relative;
}

.bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bar-bg);
  border-radius: 4px;
  height: 0%;
  min-height: 4px;
  transition: height 0.5s cubic-bezier(0.25, 1, 0.5, 1), background 0.3s;
}

.bar.highlight {
  background: var(--bar-highlight);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

.bar-val {
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  opacity: 0.4;
  transition: opacity 0.3s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.bar-col:hover .bar-val,
.bar.highlight .bar-val {
  opacity: 1;
}

.bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Keypad Section */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px; /* Tighter gap */
}

.key-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-radius: 12px;
  padding: 0.6rem 0; /* Reduced height */
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:hover, .key-btn:focus {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.key-btn:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.15);
}

/* Version text */
.version {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 0;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-color);
  border: 1px solid var(--panel-border);
  padding: 1.5rem;
  border-radius: 16px;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(0) scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.hidden .modal-content {
  transform: translateY(20px) scale(0.95);
}

.modal-content h2 {
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1.2rem;
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.4;
  font-size: 0.9rem;
}

.modal-content a {
  color: var(--accent);
  text-decoration: none;
}

.modal-content a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: var(--danger-hover);
}

/* Desktop styles to restore comfortable sizing */
@media (min-width: 768px) {
  body {
    align-items: center;
  }
  .app-container {
    justify-content: center;
    padding: 2rem;
    gap: 1.5rem;
  }
  h1 {
    font-size: 1.8rem;
  }
  .panel {
    padding: 1.5rem;
  }
  .tracker-section {
    padding: 1rem;
  }
  .tracker-window {
    height: 60px;
  }
  .roll-bubble {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  .graph {
    min-height: 180px;
    height: auto;
    gap: 4px;
  }
  .keypad {
    gap: 12px;
  }
  .key-btn {
    padding: 1rem 0;
    font-size: 1.5rem;
  }
  .version {
    padding-top: 1rem;
  }
}
