body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  /* -khtml-user-select: none; <-- Eliminado (obsoleto) */
}

* {
  touch-action: pan-y !important;
  box-sizing: border-box;
}

.navbar {
  background-color: #1f1f1f;
  color: #ffffff;
  padding: 0.5rem;
  /* text-align: top; <-- Eliminado (inválido) */
  font-size: 1.2rem;
  border-bottom: 2px solid #333;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

.main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
}

.main-columns {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
}

.checkbox-wrapper {
  margin-bottom: 10px;
}

input[type="checkbox"] {
  -ms-transform: scale(1.5);
  -moz-transform: scale(1.5);
  -webkit-transform: scale(1.5);
  -o-transform: scale(1.5);
  transform: scale(1.5);
  padding: 10px;
}

.checkboxtext {
  margin-left: 5px;
  display: inline;
}

.sidebar {
  width: 26%; /* Se mantiene tu ancho de 26% */
  border-right: 2px solid #333;
  padding: 1rem;
  box-sizing: border-box;
  background-color: #1a1a1a;
  display: flex;
  flex-direction: column;
}

.filter-input {
  width: 100%;
  padding: 0.5rem;
  box-sizing: border-box;
  background-color: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
}

.obl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.obl-grid::-webkit-scrollbar {
  display: none;
}
.case {
  border: 3px solid #666;
  font-weight: bold;
  min-width: 140px;
  height: 45px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #262626;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.case {
  border: 3px solid #666;
  font-weight: bold;
  min-width: 140px;
  height: 45px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #262626;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.hidden {
  display: none !important;
}

.case:hover {
  background-color: #333;
}

.case.checked {
  border-color: #a5f2f8;
  background-color: #32374a;
}

.case.checked:hover {
  border-color: #a5f2f8;
  background-color: #3f4764;
}

.content {
  flex: 1;
  padding: 0;
  background-color: #181818;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
}

.content-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
}

.filter-input:focus,
.case:focus {
  outline: none;
  box-shadow: 0 0 0 2px #a5f2f8;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0.5rem 0;
}

button {
  background-color: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.5rem;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

button:hover {
  background-color: #3a3a3a;
  border-color: #a5f2f8;
}

.top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  padding-bottom: 20px;
  border-bottom: 2px solid #333;
  flex-shrink: 0;
  background-color: #181818;
}

.bar-btn {
  background-color: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.bar-btn:hover {
  background-color: #3a3a3a;
  border-color: #a5f2f8;
}

.bar-scramble {
  text-align: center;
  flex: 1;
  font-size: 1.6rem;
  font-weight: bold;
  color: #e0e0e0;
  cursor: text;
  user-select: text;
}

.timer-box {
  flex: 2.5; /* Se mantiene tu proporción de 2.5 */
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
  border-right: 2px solid #333;
  padding: 1rem;
  box-sizing: border-box;
}

.timer-display {
  font-size: 3.5rem;
  font-weight: bold;
  text-align: center;
  margin: 0;
}

.bottom-info {
  text-align: center;
  font-size: 1rem;
  margin-top: auto;
  color: #aaa;
}

#timer {
  font-size: 8em;
  color: white;
}

#timer.red {
  color: #ff4d4d;
}

#timer.green {
  color: #4dff4d;
}

.popup {
  background-color: #00000000;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -1;

  display: flex;
  align-items: center;
  justify-content: center;
}

.popup.open {
  background-color: rgb(0, 0, 0, 0.9);
  z-index: 999;
}

.popup-inner {
  background-color: #2d2a2a;
  width: 50%;
  height: 80%;
  opacity: 1;
  display: flex;
  flex-flow: column;
}

.scram-bar,
.list-bar {
  flex: 0 1 auto;
  padding: 20px;
  display: flex;
  font-size: 25px;
  justify-content: space-between;
  transition: all 0.2s ease-in-out;
}

.cross {
  padding: 5px;
  transition: all 0.2s ease-in-out;
}

.cross:hover {
  background-color: rgb(255, 255, 255, 0.13);
}

.oblname {
  flex: 0 1 auto;
  font-size: 40px;
  width: 100%;
  text-align: center;
}

#canvas-wrapper {
  width: 100%;
  flex: 1 1 auto;
}

.display-scram {
  user-select: text;
}

.list-menu {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: scroll;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-top: #555 solid;
  border-bottom: #555 solid;
}

.list-item {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  padding: 10px 20px;
  font-size: 1.5rem;
}

.list-item:hover {
  background-color: rgb(255, 255, 255, 0.13);
}

.list-item.highlighted {
  border: 3px solid #a5f2f8 !important;
}

.list-item.selected {
  text-decoration: underline;
}

.list-btn {
  font-size: 18px;
  border-width: 2px;
  margin: 5px;
  width: 100px;
}

.list-btn.right {
  margin-left: auto;
}

.list-item:nth-child(even) {
  background-color: #2d2a2a;
  border: 3px solid #2d2a2a;
}

.list-item:nth-child(odd) {
  background-color: #343131;
  border: 3px solid #343131;
}

.sublist-name {
  background-color: #222222;
  padding: 10px 20px;
  font-weight: bold;
  text-align: center;
}

.list-buttons {
  background-color: #222222;
  padding: 10px;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.times-list-container {
  flex: 1; /* Se mantiene tu proporción */
  display: flex;
  flex-direction: column;
  border-top: none;
  margin-top: 0;
  padding: 1rem;
  padding-left: 0.5rem;
  box-sizing: border-box;
}

.times-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem 0.5rem 0.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  flex-shrink: 0;
  padding: 0.5rem;
}

.times-list-header a {
  color: #a5f2f8;
  text-decoration: none;
  font-size: 0.9rem;
}
.times-list-header a:hover {
  text-decoration: underline;
}

.times-list-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #444 #1a1a1a;
}
.times-list-content::-webkit-scrollbar {
  width: 8px;
}
.times-list-content::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.time-entry {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid #333;
  font-size: 0.9rem;
}

.time-entry-header {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1rem;
}

.time-entry-casename {
  color: #e0e0e0;
}

.time-entry-best {
  color: #a5f2f8;
}

.time-entry-alltimes {
  font-size: 0.9rem;
  color: #aaa;
  padding-top: 4px;
  word-wrap: break-word;
  line-height: 1.4;
}

.time-entry-alltimes .time-best {
  color: #ffd700;
  font-weight: bold;
}
.time-entry-alltimes .time-worst {
  color: #ff4d4d;
  font-weight: bold;
}

/* --- ESTILOS PARA EL NUEVO FEATURE DE BEST/WORST CASE --- */

.summary-stats-container {
  padding: 8px 12px;
  /* Crea una separación visual */
  border-bottom: 2px solid #333;
  background-color: #202020; /* Un fondo sutil */
  flex-shrink: 0; /* Evita que se encoja */
}

.summary-stat {
  font-size: 0.9rem;
  color: #ccc;
  padding: 2px 0;

  /* Asegura que el texto no se desborde */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-stat strong {
  /* El nombre del caso */
  color: #fff;
  margin-left: 4px;
}

/* Colorea los textos "Best" y "Worst" */
#best-case-stat {
  color: #ffd700;
}
#worst-case-stat {
  color: #ff4d4d;
}

/* --- RESPONSIVE DESIGN --- */
@media screen and (max-width: 900px) {
  /* 1. Define las clases de helper que usa el JS */
  .hidden-mobile {
    display: none !important;
    width: 0;
    margin: 0;
    padding: 0;
  }

  .full-width-mobile {
    width: 100% !important; /* Sobreescribe el width: 26% */
    height: 100%; /* Ocupa toda la altura */
    border-right: none;
  }

  /* 2. Permite que el .main-columns se desborde, para que el toggle funcione */
  .main-columns {
    overflow-x: hidden; /* Evita scroll horizontal */
  }

  /* 3. Ajusta el .sidebar (que ahora será .full-width-mobile) */
  .sidebar {
    width: 100%; /* Por defecto, ocupa todo el ancho */
  }

  .obl-grid {
    /* La cuadrícula de casos ahora usa auto-fit en móvil */
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .selection-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columnas para botones */
  }

  /* 4. Apila el timer y la lista de solves en el .content */
  .content {
    padding: 1rem; /* Añade padding de vuelta en móvil */
    overflow-y: auto; /* Permite scroll del contenido si es necesario */
  }

  .content-body {
    flex-direction: column;
  }

  .timer-box {
    border-right: none;
    min-height: 200px;
    padding: 0.5rem;
    flex: 1;
  }

  #timer {
    font-size: 7em;
  }

  .times-list-container {
    border-top: 2px solid #333;
    padding-left: 1rem;
    padding-top: 0.5rem;
    flex: 1;
    min-height: 250px;
    padding-top: 0;
    padding-bottom: 1;
  }
}

@media screen and (max-width: 600px) {
  .selection-grid,
  .full-width-mobile .selection-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 290px) {
  .selection-grid,
  .full-width-mobile .selection-grid {
    grid-template-columns: repeat(1, 1fr);
  }
}
