:root {
  --bg: #1e1e1e;
  --text: #cfd8dc;
  --accent: #4caf50;
  --danger: #f44336;
  --warn: #ff9800;
  --font: 'Courier New', monospace;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Make desktop version display at phone screen size */
@media screen and (min-width: 768px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    min-height: 100vh;
  }
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #111;
  font-size: 1rem;
}

#progress-bar {
  height: 6px;
  background-color: var(--accent);
  width: 100%;
  transition: width 1s linear;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  position: relative;
}

.card {
  background: #2c2c2c;
  padding: 1rem;
  border: 1px solid #555;
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: transform 0.3s ease;
  position: relative;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 4rem; /* Increased to make room for fixed buttons */
}

.mini-card {
  background: #333;
  padding: 0.5rem;
  border: 1px dashed #555;
  border-radius: 6px;
  font-size: 0.85rem;
  opacity: 0.6;
  position: relative;
  cursor: pointer;
}

.mini-card.new-pr {
  animation: newPrAnimation 0.8s ease;
  border: 1px solid #4caf50;
}

@keyframes newPrAnimation {
  0% { transform: scale(0.8); opacity: 0; background-color: #4caf50; }
  50% { transform: scale(1.1); opacity: 1; background-color: #4caf50; }
  100% { transform: scale(1); opacity: 0.6; background-color: #333; }
}

.mini-card .timer-bar, .card .timer-bar {
  height: 4px;
  background: var(--danger);
  position: absolute;
  bottom: 0;
  left: 0;
  border-radius: 0 0 0 6px;
  transition: width 0.9s linear;
}

@keyframes deplete {
  from { width: 100%; }
  to { width: 0%; }
}

.exploding {
  animation: explode 0.4s ease forwards;
}

@keyframes explode {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.pressure {
  animation: pressurePulse 0.5s ease-in-out infinite;
}

@keyframes pressurePulse {
  0% { box-shadow: 0 0 0px #ff000050; }
  50% { box-shadow: 0 0 12px #ff0000aa; }
  100% { box-shadow: 0 0 0px #ff000050; }
}

.commit {
  margin: 0.5rem 0;
  font-style: italic;
  color: #aaa;
}

.files {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
}

/* Adjust fixed elements for desktop phone-sized view */
@media screen and (min-width: 768px) {
  .actions {
    width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}

button {
  flex: 1;
  padding: 1rem;
  font-size: 1.8rem;
  font-family: var(--font);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.merge { background-color: var(--accent); color: #fff; }
.request { background-color: var(--warn); color: #000; }
.close { background-color: var(--danger); color: #fff; }

.animate-correct { animation: pulse-green 0.6s ease; }
.animate-wrong { animation: pulse-red 0.6s ease; }

@keyframes pulse-green {
  0% { background-color: #2e7d32; }
  100% { background-color: var(--bg); }
}

@keyframes pulse-red {
  0% { background-color: #c62828; }
  100% { background-color: var(--bg); }
}

@keyframes error-highlight-wrong {
  0% { box-shadow: 0 0 0 2px var(--danger); background-color: rgba(244, 67, 54, 0.1); }
  50% { box-shadow: 0 0 0 4px var(--danger); background-color: rgba(244, 67, 54, 0.2); }
  100% { box-shadow: 0 0 0 2px var(--danger); background-color: rgba(244, 67, 54, 0.1); }
}

.error-element-wrong {
  animation: error-highlight-wrong 0.6s ease infinite;
}
@keyframes error-highlight-good {
  0% { box-shadow: 0 0 0 2px var(--accent); background-color: rgba(54, 244, 54, 0.1); }
  50% { box-shadow: 0 0 0 4px var(--accent); background-color: rgba(54, 244, 54, 0.2); }
  100% { box-shadow: 0 0 0 2px var(--accent); background-color: rgba(54, 244, 54, 0.1); }
}

.error-element-good {
  animation: error-highlight-good 0.6s ease infinite;
}

#start-screen, #end-screen, #tutorial-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  z-index: 1000;
}

#start-screen button, #end-screen button, #tutorial-screen button {
  margin-top: 1rem;
  background: var(--accent);
  color: white;
  font-size: 1.2rem;
}

.tutorial-content {
  max-width: 800px;
  max-height: 70vh;
  overflow-y: auto;
  margin: 1rem 0;
  padding: 1rem;
  background: #2c2c2c;
  border-radius: 8px;
  border: 1px solid #555;
  text-align: left;
}

.tutorial-step {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed #555;
}

.tutorial-step:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.tutorial-step h3 {
  color: var(--accent);
  margin-top: 0;
}

.tutorial-step ul {
  padding-left: 1.5rem;
}

.tutorial-step li {
  margin-bottom: 0.5rem;
}

.badges {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.badge {
  background: #444;
  border: 1px solid #777;
  border-radius: 12px;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

.mistakes {
  margin-top: 1rem;
  text-align: left;
  max-width: 600px;
}

.shop {
  margin-top: 2rem;
  text-align: center;
}

.shop button {
  background: #555;
  margin: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: white;
  font-size: 1rem;
}

/* Reputation changes table styles */
.reputation-changes {
  margin-top: 1.5rem;
  text-align: left;
  max-width: 600px;
}

.reputation-changes table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: #2c2c2c;
  border-radius: 8px;
  overflow: hidden;
}

.reputation-changes th,
.reputation-changes td {
  padding: 0.6rem;
  text-align: left;
  border-bottom: 1px solid #444;
}

.reputation-changes th {
  background: #333;
  font-weight: bold;
}

.reputation-changes tr:last-child td {
  border-bottom: none;
}

.reputation-changes .positive {
  color: var(--accent);
  font-weight: bold;
}

.reputation-changes .negative {
  color: var(--danger);
  font-weight: bold;
}

/* You are fired animation */
@keyframes youAreFired {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  75% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.fired-message {
  position: absolute;
  top: 25%;
  left: 25%;
  transform: translate(-50%, -50%);
  background-color: var(--danger);
  color: white;
  font-size: 2.5rem;
  font-weight: bold;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
  z-index: 1001;
  text-align: center;
  animation: youAreFired 0.8s ease forwards;
}

.fired-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
