@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

:root {
  --color-bg: #f8fafc;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-border: #cbd5e1;
  --color-success: #C1E59F;
  --color-fail: #FF937E;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  width: 100%;
  min-height: 100%;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: 'Nunito', 'Roboto', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  text-align: center;
  font-weight: 800;
  font-size: 2.5rem;
  margin-top: 1em;
  letter-spacing: -0.02em;
}

#start-infos {
  position: absolute;
  margin-top: 3em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75em;
}

#start-infos>h3 {
  text-align: center;
  margin: 0 0 0.5em 0;
  color: var(--color-text-secondary);
  font-weight: 600;
}

input,
select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75em 1em;
  height: auto;
  width: 18em;
  border: 1px solid var(--color-border);
  border-radius: 0.5em;
  background-color: white;
  color: var(--color-text-primary);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

select {
  width: 7em;
}

input:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#start-button {
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 0.75em 2em;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 0.5em;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5em;
  width: 100%;
}

#start-button:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

#start-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px -1px rgba(59, 130, 246, 0.3);
}

#lives {
  display: flex;
  justify-content: center;
  gap: 0.5em;
  margin-top: 3em;
}

.life {
  font-size: 1.5rem;
  transition: transform 0.2s;
}

#digits-container {
  position: relative;
  width: 80%;
  height: 4em;
  margin: 8em auto;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 30%, black 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 30%, black 100%);
  z-index: -1;
}

#digits {
  position: absolute;
  right: 50%;
  font-size: xx-large;
  white-space: nowrap;
  margin: 0;
}

table {
  left: 50%;
  position: relative;
  transform: translateX(-50%);
  width: fit-content;
  background-color: white;
  border-collapse: collapse;
  border-radius: 0.75em;
  box-shadow: var(--shadow-md);
}

th,
td {
  text-align: left;
  padding: 0.6em 1em;
  white-space: nowrap;
}


th {
  background-color: #f1f5f9;
  color: var(--color-text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e2e8f0;
}

td {
  border-bottom: 1px solid #f1f5f9;
  color: var(--color-text-primary);
  font-weight: 500;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

td:nth-child(1),
td:nth-child(3),
td:nth-child(4) {
  width: 4em;
}

div#end-window {
  position: fixed;
  background-color: #ffffff;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04), 0 0 0 100vw rgba(0, 0, 0, 0.4);
  border-radius: 1.25em;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 2.5em 3em;
  z-index: 1000;
  min-width: 320px;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

#end-window h3 {
  text-align: center;
  margin: 0 0 1.5em 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text-primary);
}

h4 {
  margin: 0 0 0.25em 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.main {
  width: fit-content;
  margin: 0 auto;
}

#end-window p,
.cumulative p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

#end-infos-grid {
  display: grid;
  grid-template-areas:
    "name name digits"
    "rank time digits";
  gap: 1em;
  margin: 0 auto 2em auto;
}

.cumulative {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: center;
  justify-self: center;
  width: fit-content;
}

.individual {
  display: flex;
  gap: 1em;
  margin-top: 3em;
  margin-bottom: 3em;
  flex-wrap: wrap;
  justify-content: center;
}

.name-card {
  grid-area: name;
}

.rank-card {
  grid-area: rank;
}

.digits-card {
  grid-area: digits;
}

.time-card {
  grid-area: time;
}

.end-info,
.statistic {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.75em;
  padding: 1em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.2s ease;
}

.end-info:hover,
.statistic:hover {
  transform: translateY(-2px);
  border-color: #94a3b8;
}



.digits-card {
  align-items: center;
  background-color: #eff6ff;
  border-color: #bfdbfe;
}

.digits-card h4 {
  color: var(--color-primary);
}

#end-rank::after {
  content: ".";
}

#end-window #end-digits {
  font-size: 3rem;
  color: #1d4ed8;
  line-height: 1;
  margin-top: 0.1em;
}

.next-digit-info {
  text-align: center;
  font-weight: 500 !important;
  color: var(--color-text-secondary) !important;
  font-size: 0.95rem !important;
  margin-bottom: 2em !important;
  background: #f1f5f9;
  padding: 0.75em;
  border-radius: 0.5em;
}

.next-digit-info span {
  font-weight: 800;
  color: #ef4444;
}

.close-btn {
  background: none;
  position: absolute;
  right: 1.25em;
  top: 1.25em;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  padding: 0.25em;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background-color: #f1f5f9;
  color: #ef4444;
}

.primary-btn {
  display: block;
  width: 100%;
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 0.8em 1.5em;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 0.5em;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

.primary-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px -1px rgba(59, 130, 246, 0.3);
}

.flex-row>h3 {
  margin: 1em 0;
}

.flex-row {
  display: flex;
  justify-content: space-between;
}

.flex-row>.primary-btn {
  width: fit-content;
  padding: 0.4em 1em;
  font-size: 0.9rem;
  height: fit-content;
  margin: 1em 0;
}

#home-btn,
#logout-btn {
  width: fit-content;
  height: fit-content;
  position: fixed;
  top: 1em;
  z-index: 2;
}

#home-btn {
  left: 1em;
}

#logout-btn {
  right: 1em;
}

#home-btn>.primary-btn,
#logout-btn>.primary-btn {
  padding: 0.5em;
  margin: 0;
  display: flex;
  align-items: center;
}

.primary-btn:disabled {
  background-color: var(--color-text-muted) !important;
  box-shadow: none !important;
  cursor: default !important;
}

.primary-btn:disabled:hover,
.primary-btn:disabled:active {
  background-color: var(--color-text-muted) !important;
  transform: none !important;
  box-shadow: none !important;
}

#login-btn,
.btn-leaderboard,
#login-button {
  width: fit-content;
}

#login-login {
  gap: 1em;
}

#login {
  width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  position: absolute;
}

#login>div {
  display: flex;
  width: fit-content;
  flex-direction: column;
  align-items: center;
}

@media (max-width: 768px) {
  :root {
    font-size: small;
  }

  th,
  td {
    text-align: center;
    padding: 0.6em 0.2em;
  }

  td:last-child {
    text-align: left;
  }

}